- Inventory
- 0. 前置知识 Background
- 1. 信息收集 Reconnaissance
- 2. 漏洞挖掘 Vulnerabilities
- 3. 权限提升 Privilege Escalation
- 4. 后渗透期 Post Pentest
- 5. 对抗攻防 AWD
- 5. 社会工程 Social Engeering
- 6. 软件开发 Software Engeering
- Appendix. 链接
- Appendix. 靶场
- Appendix. 书籍
- Appendix. 学习资料
Red Team Kill Chain:
┌────────────────┐
│ │
│ Initial │
│ Recon │
│ │
└────────┬───────┘
│
│
┌────────▼───────┐
│ │
│ Initial │
│ Compromise │
│ │
└────────┬───────┘
│
│
┌────────▼───────┐
│ │
│ Establish │
│ Foothold │
│ │
└────────┬───────┘
│
│
┌────────▼───────┐ ┌────────────────┐
│ │ │ │
│ Escalte ◄──────┤ Maintain │
│ Privileges │ │ Presence │
│ │ │ │
└────────┬───────┘ └────────▲───────┘
│ │
│ │
┌────────▼───────┐ ┌────────┴───────┐
│ │ │ │
│ Internal │ │ Move │
│ Recon ├──────► Laterally │
│ │ │ │
└────────┬───────┘ └────────────────┘
│
│
┌────────▼───────┐
│ │
│ Complete │
│ Mission │
│ │
└────────────────┘
OS:
Integrated Pentest Environment:
- Exegol on macOS, 👉🏻GO
- Kali Linux VM, PD on macOS
- Kali Linux VM, OrbStack on macOS
- bash, 👉🏻GO
- zsh
- fish
- powershell
- HTML
- CSS
- JS
主流:
其他:
- Lua
- Perl
- Ruby
- SQL
- MySQL, 👉🏻Go
- MSSQL
- Oracle SQL
- NoSQL
- Redis
- MongoDB
- ElasticSearch
- HTTP
- HTTPS
- DHCP
- DNS
- SSH
- ARP
- SMB
- Socks5
- VPN
- FTP
- ...
- Assembly, 👉🏻Go
- Reverse Engineering, x86_64
- Basic: C/C++
- Windows Platform
- Linux PLatform
- Burp Suite Pro, 👉🏻Go
- arsenal
- Bug-bounty checklist
- goby
- LadonGo
subdomain top-domain-level signifies query
─── ─── ──
https://sub.domain.com/blog/article/search?param=1
────── ────── ─────────────────── ───────
scheme domain path or location parameter(s)
of contents
Generate word list:
# 扫描端口,然后探测版本(用默认的脚本)
nmap -n -v -Pn -sS -p- $IP --max-retries=0
nmap -n -v -sC -sV -p$PORTS $IP
#
nmap -sn $IP/24 # 寻找IP
nmap -sT --min-rate 10000 -p- $IP
nmap -sU --min-rate 10000 -p- $IP # TCP|UDP扫描全端口
nmap -sT -sV -sC -O -p$PORTS $IP # TCP使用默认脚本扫描全端口+版本+OS信息
nmap --script-vuln -p$PORTS $IP # 漏洞脚本扫描
# 一句话全模式扫描开放端口
nmap -A $IP -oA nmap/all -p`nmap -sS -sU -Pn -p- $IP --min-rate 10000 | grep '/tcp\|/udp' | awk -F '/' '{print $1}' | sort -u | tr '\n' ','`
- nmap
nmap -sn $IP/24
nmap -sU --min-rate 10000 -p- $IP
nmap -sT -sC -sV -O --min-rate 10000 -p- $IP
nmap --script=vuln -p$PORTS $IP
- ping 主机发现
ping -c 3 -W 1 $IP
for i in {1..254}; do ping -c 1 -W 1 $sub_IP.$i | grep from; done
- nc 端口扫描
nc.traditional -vv -z $IP 1-65535 2>&1 | grep -v refused
- /dev/tcp/xxx/nnn 端口扫描
IP=xxx.xxx.xxx.xxx
for i in {1..65535}
do
(echo < /dev/tcp/$IP/$i) &>/dev/null && printf "\n[+] Open port: %d\n" "$i" || printf "."
done
whatweb [opts] <urls>
dirb $IP $Wordlist
- dirsearch
- -t <thead>
- -r, brute-force recursively
- -i <code>, include status codes
- -x <codes>, exclude status codes
- -m <method>
- -d <data>
- -H <headers>
- --user-agent=<ua>
- --cookie=<ck>
dirsearch -u <target> -e <extensions> [options]
ffuf -fs 185 -c -w \$(fzf-wordlists) -H 'Host: FUZZ.org' -u "http://$TARGET/"
ffuf -w /usr/share/dirb/wordlists/common.txt -fc 403,404 -fs 185 -u "http://$TARGET/FUZZ" -p 1
- nmap
nmap -6 --min-rate 10000 -p- $IPv6
python IOXIDResolver.py -t $IP
snmpwalk -v2c -c public $IP
- 有web端:
- Windows大小写不敏感
- 工具识别
- 没有web:
- nmap -O
- TTL(不准确的方式):
1、WINDOWS NT/2000 TTL:128
2、WINDOWS 95/98 TTL:32
3、UNIX TTL:255
4、LINUX TTL:64
5、WIN7 TTL:64
- 特殊端口:22, 139, 445, 1433, 3389
数据库不同表示的结构也是不同、写法结构也不同,因此产生的漏洞也不一样。不同的数据库的攻击方式也不完全一样。
- default pair
- asp + access/mssql
- php + mysql
- aspx + mssql
- jsp + mysql/oracle
- python + mongodb
- common port
- SQL
- mysql, 3306
- sqlserver, 1433
- oracle, 1521
- postgresql, 5432
- NoSQL
- mongodb, 27017
- redis, 6379
- memcached, 11211
- SQL
- dig
- nslookup
- whois
dig axfr mydomain.local @IP_ADRESS
nslookup -type=any $DOMAIN_NAME
whois $DOMAIN_NAME
- theHaverster - OSINT
- subdomain
- name
theHarvester -d $DOMAIN_NAME -b google
CDN: Content Dilivery Network
- online ping
- no effect
- sqli
- xss
- bypass (maybe combined with se)
- 子域名查询:主站有CDN但是子站没有
- 邮件服务查询:邮件大部分是内部人员访问,量少无CDN
- 国外ping出IP地址:企业一般未在国外部署CDN
- 遗留文件、扫描全网:例如PHPInfo信息中会遗留出IP地址
- 特殊搜索引擎:fofa, shodan, zoomeye, censys, 谛听
- 工具:fackcdn, w8fuckcdn, zmap
- Usage
- 获取真实IP之后,更改本地Hosts文件绑定解析内容
WAF: Web Application Firewall
- objective
- 没有识别WAF直接扫描可能导致IP黑名单
- 识别完具体的WAF可以有针对性的bypass
- recognize WAF
- 目录结构
- 后台目录
- 模板目录
- 数据库目录
- 数据库配置文件
- 脚本类型
- asp
- php
- jsp
- java
- 应用分类
- 门户
- 电商
- 论坛
- 博客
- 其他补充
- 框架or非框架
- CMS识别
- 开源or闭源
- 源码获取
- gobuster
# fzf-wordlists
/usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt
# gobuster
gobuster vhost -u <http://example.com> -w /path/to/wordlist.txt --append-domain -t $THREAD_NUM
- 目录型站点(例如,www.xxx.com/bbs)
- 主站的漏洞
- 子站的漏洞
- 端口类站点,shodan扫描
- 子域名站点(子域名和域名可能不在一个服务器上)
- 类似域名站点(原有域名弃用,但是还能访问;二级or顶级域名更换,旧域名找到突破口)
- 社工方式找到相关域名信息
- 旁注,C段站点(在线工具:https://www.webscan.cc/)
- 旁注:同一个服务器上面存在多个站点、但是你要攻击的是A网站由于各种原因不能完成安全测试。就通过测试B网站进入服务器然后在攻击A网站最终实现目的。
- C段:不同的服务器上面存在不同的网站,通过扫描发现与你渗透测试的是同一个网段最终拿下服务器、然后通过内网渗透的方式拿下渗透服务器。
- 搭建软件特征站点
- 有的网站是借助于第三方的集成搭建工具实现例如:PHPstudy、宝塔等环境这样的集成环境搭建的危害就是泄露了详细的版本信息。
- phpstudy搭建了之后在默认的站点安装了phpmyadmin有的网站没有做安全性直接可以通过用户名:root密码:root 登录进入
- GitHub
- 搜集:子域名、DNS、备案、证书、全球节点请求CDN
- 搜索引擎:fofa, shodan, zoomeye
主流
- UGO
- SUID, SGID
- Capabilities
- AppArmor, Selinux
- ACL
其他
- Grsecurity
- Pax
- ExecShield
- ASLR
- TOMOYO Linux
- SMACK
- Yama
- CGroups
- Linux Namespaces
- StackGuard
- Proplice
- seccomp
- ptrace
- capsicum
- Mprotect
- chroot
- firejail
靠山吃山,靠水吃水
生产password密码 (qwe~qwe)
openssl passwd -1 -salt qwe qwe > hash.txt # generate a user line
echo 'qwe:$1$qwe$D95bkH3CwpH6ffYU7pu0m/:0:0:root:/root:/bin/bash' >> /etc/passwd # Append this line into passwd file
- 低权限可以修改可执行文件or脚本,再以高权限身份运行;
- 低权限的运维人员也会记录、输入备份程序,以备使用高权限的时候完成操作(用户行为);
- 在权限体系的上层捕捉、拦截、修改凭据信息or权限信息。
- 系统枚举
- 用户信息
- whoami
- id
- who
- w
- last
- 系统信息
- uname -a
- lsb_release -a
- cat /proc/version
- cat /etc/issue
- hostnamectl
- 用户信息
- 网络枚举
- ifconfig
- ip
- ip a
- ip route
- ip neigh
- netstat
- netstat -a
- netstat -at (-au)
- netstat -l
- netstat -s
- netstat -ano
- 权限枚举
- sudo -l
- getcap -r 2>/dev/null
- ls -liah
- history
- cat /etc/passwd
- cat /etc/crontab
- echo $PATH
- env
- 进程枚举
- ps -ef, ps aux
- ps axjf
- top -n 1
- find / -perm -u=s -type f 2>/dev/null
- which awk (perl, python, ruby, gcc, vi, vim, nmap, find, netcat, nc, wget, tftp, ftp, tmux, screen ...) 2>/dev/null
- cat /etc/fstab 磁盘挂载情况
工具列表
- https://github.com/carlospolop/PEASS-ng
- https://github.com/rebootuser/LinEnum
- https://github.com/diego-treitos/linux-smart-enumeration
- https://github.com/The-Z-Labs/linux-exploit-suggester
- https://github.com/sleventyeleven/linuxprivchecker
- https://github.com/pentestmonkey/unix-privesc-check
工具使用, 👉🏻GO
- Computer Science
- CSAPP
- Linux Basics for Hacker
- Computer Languages
- Python
- Fluent Python
- Go
- Black Hat Go
- Python
- Pentest
- Penetration Testing with Kali Linux
- Kali Linux Penetration Testing Bible
- Google Hacking
- OWASP权威指南
- Binary
- Intel® 64 and IA-32 Architectures Software Developer’s Manual
- The IDA Pro Book
- The Ghidra Book
- YouTube
- Adversary Emulation with Caldera | Red Team Series 1-13
- NTUSTISC - Penetration Test: 0x01, 0x02
- Beginner to Advanced Bug Bounty Hunting Course
- Bilibili
- Vulnerable Environments Practice
- Linux Privilege Escalation
- Article
- Course
- Workshop