01_安恒渗透攻击红队百科全书总结上
文档很全面,但是很模糊,所以整理补充了一下,用于违法与本人无关
第一章 信息搜集 主机发现/Google Hacking
1.1 主机发现
1.1.1 Nmap
1.1.1.1 Nmap 安装和帮助手册
Nmap官网:https://nmap.org/
namp安装:
-
Mac os: brew install nmap -
Centos: yum install nmap -
Ubuntu: apt-get install nmap
手册:https://nmap.org/man/zh/index.html

0pen 表示端口处于开放状态
Closed 表示端口处于关闭状态
Filterd 表示端口处于过滤无法收到返回的probe状态
UnFilterd 表示端口收到返回的probe,但是无法确认
Opend/UnFilterd表示端口处于开放或者是过滤状态
Closed/UnFilterd 表示端口处于关闭或者未过滤状态

1.1.1.2 nmap探测扫描方式
1.1.1.2.1 TCP -sT
root@attack:~# nmap -sT 192.168.2.254
Starting Nmap 7.95 ( https://nmap.org ) at 2025-06-29 21:33 CST
Nmap scan report for 192.168.2.254
Host is up (0.0044s latency).
Not shown: 998 filtered tcp ports (no-response)
PORT STATE SERVICE
80/tcp open http
1900/tcp open upnp
MAC Address: 94:D9:B3:D9:8B:98 (TP-Link Technologies)
1.1.1.2.2 SYN -sS
1.1.1.2.3 ACK -sA
1.1.1.2.4 UDP -sU
1.1.1.2.5 RPC -sR
1.1.1.2.6 ICMP -sP
1.1.1.2.7 端口扫描 -sn
1.1.1.3 常见方案扫描方法
1.1.1.3.1 综合扫描(10000端口+系统+版本+回显):nmap -T4 -A -v <目标>

root@attack:~# nmap -T4 -A -v 192.168.2.254
Starting Nmap 7.95 ( https://nmap.org ) at 2025-06-29 21:34 CST
Nmap scan report for 192.168.2.254
Host is up (0.0028s latency).
Not shown: 998 filtered tcp ports (no-response)
PORT STATE SERVICE VERSION
80/tcp open http
|_http-title: TL-WR886N
| fingerprint-strings:
| FourOhFourRequest:
| HTTP/1.0 302 Moved Temporarily
| Content-Type: text/plain;charset=UTF-8
| Content-Length: 0
| Connection: close
| Location: http://tplogin.cn:80
| Cache-control: no-cache
| GenericLines, Help:
| HTTP/1.1 400 Bad Request
| Content-Type: text/html;charset=UTF-8
| Content-Length: 0
| Connection: close
| Cache-control: no-cache
| GetRequest:
| HTTP/1.0 200 OK
| Content-Type: text/html;charset=UTF-8
| Content-Length: 820
| Connection: close
| Cache-control: no-cache
1.1.1.3.2 版本探测:nmap -sV <目标>
root@attack:~# nmap -sV 192.168.226.1
Starting Nmap 7.95 ( https://nmap.org ) at 2025-06-29 21:48 CST
Nmap scan report for 192.168.226.1
Host is up (0.00018s latency).
Not shown: 994 closed tcp ports (reset)
PORT STATE SERVICE VERSION
135/tcp open msrpc Microsoft Windows RPC
139/tcp open netbios-ssn Microsoft Windows netbios-ssn
903/tcp open ssl/vmware-auth VMware Authentication Daemon 1.10 (Uses VNC, SOAP)
1024/tcp open msrpc Microsoft Windows RPC
1025/tcp open msrpc Microsoft Windows RPC
6000/tcp open X11?
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port6000-TCP:V=7.95%I=7%D=6/29%Time=6861443D%P=x86_64-pc-linux-gnu%r(X1
SF:1Probe,48,"\0@\x0b\0\0\0\x10\0Authorization\x20required,\x20but\x20no\x
SF:20authorization\x20protocol\x20specified\n");
MAC Address: 00:50:56:C0:00:08 (VMware)
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 55.83 seconds
1.1.1.3.4 操作系统识别:nmap -O <目标>
root@attack:~# nmap -O 192.168.226.1
Starting Nmap 7.95 ( https://nmap.org ) at 2025-06-29 21:47 CST
Nmap scan report for 192.168.226.1
Host is up (0.00022s latency).
Not shown: 994 closed tcp ports (reset)
PORT STATE SERVICE
135/tcp open msrpc
139/tcp open netbios-ssn
903/tcp open iss-console-mgr
1024/tcp open kdm
1025/tcp open NFS-or-IIS
6000/tcp open X11
MAC Address: 00:50:56:C0:00:08 (VMware)
Device type: general purpose
Running: Microsoft Windows 10
OS CPE: cpe:/o:microsoft:windows_10
OS details: Microsoft Windows 10 1909 - 20H2
Network Distance: 1 hop
OS detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 3.07 seconds
1.1.1.3.5 不使用ICMP探测将主机视为联机状态 :nmap -Pn <目标>
root@attack:~# nmap -Pn 192.168.226.1
Starting Nmap 7.95 ( https://nmap.org ) at 2025-06-29 21:45 CST
Nmap scan report for 192.168.226.1
Host is up (0.00028s latency).
Not shown: 994 closed tcp ports (reset)
PORT STATE SERVICE
135/tcp open msrpc
139/tcp open netbios-ssn
903/tcp open iss-console-mgr
1024/tcp open kdm
1025/tcp open NFS-or-IIS
6000/tcp open X11
MAC Address: 00:50:56:C0:00:08 (VMware)
1.1.1.4 其他技巧
--host-timeout 18000ms(主机超时)
--scan-delay 1000ms(报文间隔)
-S <源地址>定义扫描源地址,为了不被发现
1.1.1.5 示例
nmap-V -iR 100000 -P0 -p 80
随机选择100000台主机扫描是否运行Web 服务器(80端口)。
-P0和-Pn绕过主机存活检测(Ping扫描)的关键参数,适用于目标主机禁用 ICMP 响应或防火墙过滤 Ping 请求的场景。
其核心作用是强制 Nmap 跳过传统的存活检测,直接进行端口扫描,从而穿透部分安全防护机制
host -1 company.com |cut -d -f 4 |nmap -v iL -
进行DNS 区域传输,以发现company.com 中的主机,然后将IP地址提供给Nmap。
1.1.1.6 输出
-
-oN 普通文本格式
-
-oX XML格式
-
-oG Grep友好格式
Grep 输出参考: http://www.unspecific.com
nmap -0 -oG - 10.1.1.100
nmap -oG - -SP 10.1.1.172/29
1.1.2 masscan工具使用
1.1.2.1 项目信息
GitHub主页:https://github.com/robertdavidgraham/masscan
1.1.2.2 安装三部曲
安装依赖:
sudo apt-get install git gcc make libpcap-dev
克隆项目:
git clone https://github.com/robertdavidgraham/masscan
编译安装:
cd masscan && make
新版本kali自带
root@attack:~# which masscan
/usr/bin/masscan

1.1.2.3 高级配置
• --adapter-ip 设置扫描源IP(像隐身斗篷)
• --adapter-port 设置扫描源端口(像小邮差)
• --adapter-mac 伪装MAC地址(像变色龙)
• --router-mac 指定网关MAC(像GPS导航)
1.1.2.4 文件操作
--excludefile 黑名单文件(禁止扫描名单)
--includefile 白名单文件(VIP扫描名单)
1.1.2.5 性能调节
--wait 10 发送包后的冷却时间(默认10秒)
(突然发现)作者名字Robert David Graham里有三个名字呢,像童话故事里的三兄弟~ 需要我演示具体使用示例吗
1.1.3 nbtscan
在 Kali Linux中 已 经 安 装 :
root@attack:~# whereis nbtscan
nbtscan: /usr/bin/nbtscan /usr/share/man/man1/nbtscan.1.gz

1.1.3.1 nbtscan 扫描整个C段
root@attack:~# nbtscan -r 192.168.226.0/24
Doing NBT name scan for addresses from 192.168.226.0/24
IP address NetBIOS Name Server User MAC address
------------------------------------------------------------------------------
192.168.226.1 laowang <unknown> 00:50:56:c0:00:08
192.168.226.240 <unknown> <unknown>
192.168.226.255 Sendto failed: Permission denied
1.1.3.2 nbtscan 扫描一个范围
root@attack:~# nbtscan 192.168.226.1-137
Doing NBT name scan for addresses from 192.168.226.1-137
IP address NetBIOS Name Server User MAC address
------------------------------------------------------------------------------
192.168.226.1 laowang <unknown> 00:50:56:c0:00:08
1.1.3.3 nbtscan 分割显示结果
root@attack:~# nbtscan -v -s : 192.168.226.0/24
192.168.226.1:laowang :00U
192.168.226.1:WORKGROUP :00G
192.168.226.1:MAC:00:50:56:c0:00:08
192.168.226.255 Sendto failed: Permission denied
1.1.3.2 高级用法
root@attack:~# nbtscan -v -s ' ' 192.168.226.1
192.168.226.1 laowang 00U
192.168.226.1 WORKGROUP 00G
192.168.226.1 MAC 00:50:56:c0:00:08
-v(verbose 模式) #显示目标主机的完整 NetBIOS 名称表,包括所有注册的 NetBIOS 名称(如计算机名、域名、用户名等)及其类型标识符
-s ' '(空格分隔符)#取消默认的列标题和表格格式,用空格分隔字段,便于脚本
nbtscan -v -s ' ' 192.168.117.130 | awk '{print $1, $2}' | uniq
root@attack:~# nbtscan -v -s ' ' 192.168.226.1 | awk '{print $1}' |uniq
192.168.226.1
1.1.4 hping3
hping3是一个命令行下使用的TCP/IP数据包组装/分析工具,通常用于安全测试和网络探测。
基本语法:
hping3 [参数] [目标地址]
常用参数:
-c --count 发送数据包的次数
-i --interval 发送间隔(秒)(或使用微秒,例如 -i u1000 表示1000微秒,即1毫秒)
--fast 等同于 -i u10000 (每秒10个包)
--faster 等同于 -i u1000 (每秒100个包)
--flood 洪水模式(尽可能快地发送,不显示回复)
-p --port 目标端口(默认为0,即端口扫描)
-S --syn 发送SYN数据包(TCP连接的第一个包)
-A --ack 发送ACK数据包
-U --urg 发送URG数据包
-F --fin 发送FIN数据包
-R --rst 发送RST数据包
-P --push 发送PUSH数据包
--icmp 发送ICMP报文(默认是TCP,除非指定UDP或ICMP)
--udp 使用UDP
-a --spoof 伪造源地址(用于隐藏自身)
-t --ttl 设置TTL值
-V --verbose 详细模式
-d --data 数据包大小(单位字节)
--file 发送文件内容(如--file filename)
--sign 添加数字签名
--help 帮助
1.1.4.1 Ping 测试(ICMP 模式)
hping3 -1 -c 5 192.168.1.1 # -1 表示 ICMP 模
1.1.4.2 TCP SYN 端口扫描
hping3 -S -p 80 192.168.1.1 # -S 发送 SYN 包,
1.1.4.3 UDP 数据包测试
hping3 -2 -p 53 192.168.1.1 # -2 表示 UDP 模式
1.1.4.4 洪水攻击测试(压力测试)
hping3 -S --flood -p 80 192.168.1.1 # --flood 极速发送请求(谨慎使用!)
1.1.4.5 伪造源 IP 地址(隐蔽扫描)
hping3 -S -p 80 -a 伪造的IP 目标IP # -a 伪造源 IP(例:-a 10.0.0.1)
1.1.4.6 携带自定义数据
hping3 -p 80 -E data.txt 192.168.1.1 # -E 从文件读取数据作为载荷
hping3 -p 80 -d 100 --data "ABC" 192.168.1.1 # -d 载荷大小(字节),--data 直接指定内容
1.1.4.7 设置 TTL 和分片
hping3 -S -p 80 -t 64 192.168.1.1 # -t 设置 TTL
hping3 -S -p 80 -f 192.168.1.1 # -f 设置分片标志
1.1.4.8 高级扫描组合
# 发送 ACK 包探测防火墙规则
hping3 -A -p 80 192.168.1.1
# 发送 FIN 包绕过无状态防火墙
hping3 -F -p 80 192.168.1.1
| 参数 | 作用 |
|---|---|
| -S | 发送 TCP SYN 包 |
| -A | 发送 TCP ACK 包 |
| -F | 发送 TCP FIN 包 |
| -1 | ICMP 模式 |
| -2 | UDP 模式 |
| -p | 目标端口号 |
| -c | 发送包数量(如 -c 100) |
| --flood | 极速模式(无间隔发送) |
| --rand-source | 随机伪造源 IP |
| -a | 手动伪造源 IP |
| -d | 载荷大小(字节) |
| -i | 发包间隔(如 -i u100 = 100微秒) |
| --ttl | 设置 TTL 值 |
| -V | 显示详细输出 |
1.2 关联信息生成
1.2.1 关联信息生成
目标:赫尔巴斯亚基国
• 🍊 饮食特征:酷爱橙子
• 🕌 宗教特征:伊斯兰教信仰
• 🌐 网络特征:IPv4开放段
• 💾 社交数据:公开数据库
(小贴士:这些信息就像拼图碎片,能组合出目标画像呢)
1.2.2 字典生成工具
pydictor - 强大的社会工程学字典生成器
安装命令:
git clone https://github.com/LandGrey/pydictor
1.2.2.1 打开字典生成程序
快速使用:https://github.com/LandGrey/pydictor/blob/master/docs/doc/usage.md
python pydictor.py --sedb

1.2.2.2 设置参数
set cname bank
set birth 19970512
run

1.2.2.3 生成字典

1.2.2.4 合并去重
python pydictor.py -tool uniqbiner /my/all/dict/
1.2.2.5 多字典文件组合工具
python pydictor.py -tool hybrider heads.txt some_others.txt tails.txt
1.3 开放漏洞情报
1.3.1 开放漏洞情报
常用网站:
• CVE - https://cve.mitre.org
• Exploit-DB - https://www.exploit-db.com
• CX Security - https://cxsecurity.com
• CNVD - https://www.cnvd.org.cn
• securitytracker - https://securitytracker.com
1.3.2 Search Exploit-DB

1.3.3 例子
1.3.3.1 搜索windows提权漏洞
searchsploit -t windows local

1.3.3.2 搜索Apache 漏洞

1.4 开源情报信息搜集(OSINT)
1.4.1 开源情报信息搜集
搜索引擎语法
百度
谷歌
必应
在线接口
http://ce.baidu.com/index/getRelatedSites?site_address=baidu.com
http://www.webscan.cc/
http://sbd.ximcx.cn/
https://censys.io/certificates?q=.example.com
https://crt.sh/?q=%25.example.com
https://github.com/c0ny1/WorkScripts/tree/master/get-subdomain-from-baidu
https://dnsdumpster.com/
https://www.threatcrowd.org/searchApi/v2/domain/report/?domain=baidu.com
https://findsubdomains.com/
https://dnslytics.com/search?q=www.baidu.com
https://pentest-tools.com/information-gathering/find-subdomains-of-domain
https://viewdns.info/
https://www.ipneighbour.com/#/lookup/114.114.114.114
https://securitytrails.com/list/apex_domain/baidu.com
https://url.fht.im/
http://api.hackertarget.com/hostsearch/?q=baidu.com
http://www.yunsee.cn/finger.html
相关工具
https://github.com/rshipp/awesome-malware-analysis/blob/master/恶意软件分析大合集.md#域名分析
1.4.2 企业信息查询
| 标签 | 名称 | 地址 |
|---|---|---|
| 企业信息 | 天眼查 | https://www.tianyancha.com/ |
| 企业信息 | 小蓝本 | https://www.xiaolanben.com/ |
| 企业信息 | 爱企查 | https://aiqicha.baidu.com/ |
| 企业信息 | 企查查 | https://www.qcc.com/ |
| 企业信息 | 国外企查 | https://opencorporates.com/ |
| 企业信息 | 启信宝 | https://www.qixin.com/ |
| 备案信息 | 备案信息查询 | http://www.beianx.cn/ |
1.4.3 域名与网络资产探测
| 分类 | 名称 | 地址 |
|---|---|---|
| 备案信息 | 备案管理系统 | https://beian.miit.gov.cn/ |
| 公众号信息 | 搜狗微信搜索 | https://weixin.sogou.com/ |
| 注册域名 | 域名注册查询 | https://buy.cloud.tencent.com/domain |
| IP 反查 | IP 反查域名(微步) | https://x.threatbook.cn/ |
| IP 反查 | IP 反查域名(BugScaner) | https://dns.bugscaner.com/ |
| DNS 救援 | dnsdumpster | https://dnsdumpster.com/ |
| 证书查询 | Certificate Search | https://crt.sh/ |
| 网络空间 | FOFA | https://fofa.info/ |
| 网络空间 | 全球鹰(360) | https://hunter.qianxin.com/ |
| 网络空间 | 360 Quake | https://quake.360.cn/quake/ |
| 威胁情报 | 微步在线情报社区 | https://x.threatbook.cn/ |
| 威胁情报 | 奇安信威胁情报中心 | https://ti.qianxin.com/ |
| 威胁情报 | 360威胁情报中心 | https://ti.360.cn/#/homepage |
| 枚举解析 | 在线域名查询 | http://tools.bugscaner.com/subdomain/ |
| 枚举解析 | DNSGrep 子域名查询 | https://www.dnsgrep.cn/subdomain |
| 工具 | OneForAll(GitHub) | https://github.com/shmilylty/OneForAll |
1.4.4 指纹识别与网络空间测绘
| 标签 | 名称 | 地址 |
|---|---|---|
| 指纹识别 | ||
| 指纹识别 | 在线CMS指纹识别 | http://whatweb.bugscaner.com/look/ |
| 指纹识别 | Wappalyzer | https://github.com/AliasIO/Wappalyzer |
| 指纹识别 | TideFinger 蹄沙 | http://finger.tidesec.net/ |
| 指纹识别 | 云悉指纹 | https://www.yunsee.cn/ |
| 指纹识别 | WhatWeb | https://github.com/urbanadventurer/WhatWeb |
| 指纹识别 | 数字观星 Finger-P | https://fp.shuziguanxing.com/#/ |
| 网络空间 | ||
| 网络空间 | 钟馗之眼(ZoomEye) | https://www.zoomeye.org/ |
| 网络空间 | 零零信安(0.zone) | https://0.zone/ |
| 网络空间 | Shodan | https://www.shodan.io/ |
| 网络空间 | Censys | https://censys.io/ |
| 网络空间 | ONYPHE | https://www.onyphe.io/ |
| 网络空间 | FullHunt | https://fullhunt.io/ |
| 网络空间 | Soall Search Engine | https://soall.org/ |
| 网络空间 | Netlas | https://app.netlas.io/responses/ |
| 网络空间 | Leakix | https://leakix.net/ |
| 网络空间 | DorkSearch | https://dorksearch.com/ |
1.4.5 威胁情报平台
| 标签 | 名称 | 地址 |
|---|---|---|
| 威胁情报 | VirusTotal | https://www.virustotal.com/gui/ |
| 威胁情报 | VenusEye威胁情报中心 | https://www.venuseye.com.cn/ |
| 威胁情报 | 微步在线威胁情报云 | https://x.threatbook.cn/ |
| 威胁情报 | IBM X-Force Exchange | https://exchange.xforce.ibmcloud.com/ |
| 威胁情报 | 天际友爱安全智解平台 | https://www.sina.com.cn |
| 威胁情报 | 华为安全中心平台 | https://isecurity.huawei.com/sec |
| 威胁情报 | 安恒威胁情报中心 | https://tib.dbappsecurity.com.cn/ |
| 威胁情报 | AlienVault OTX | https://otx.alienvault.com/ |
| 威胁情报 | 深信服安全中心 | https://sec.sangfor.com.cn/ |
| 威胁情报 | 丁信威胁分析工具箱 | https://dingba.top/ |
| 威胁情报 | 听风者情报源 start.me | https://start.me/p/X20Apn |
| 威胁情报 | GreyNoise Visualizer | https://viz.greynoise.i0/ |
| 威胁情报 | URLhaus 数据库 | https://urlhaus.abuse.ch/browse/ |
| 威胁情报 | Pithus | https://beta.pithus.org/ |
1.4.2 DNS历史解析记录
1.4.2.1 nslookup
域名和IP地址的解析
root@attack:~# nslookup www.xiaomi.com
Server: 180.76.76.76
Address: 180.76.76.76#53
Non-authoritative answer:
Name: www.xiaomi.com
Address: 111.13.141.98
Name: www.xiaomi.com
Address: 39.156.150.102
www.xiaomi.com canonical name = matrix-pub-c3-c4.alb.xiaomi.com.
1.4.2.2 dig
dig(Domain Information Groper)以输出详尽、可定制性强著称,适合深度排查DNS问题,支持几乎所有DNS记录类型(A、AAAA、MX、NS、TXT等)。
root@attack:~# dig www.baidu.com
; <<>> DiG 9.20.9-1-Debian <<>> www.baidu.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20319
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.baidu.com. IN A
;; ANSWER SECTION:
www.baidu.com. 126 IN A 36.152.44.93
www.baidu.com. 126 IN A 36.152.44.132
;; Query time: 36 msec
;; SERVER: 180.76.76.76#53(180.76.76.76) (UDP)
;; WHEN: Sun Jun 29 19:38:11 CST 2025
;; MSG SIZE rcvd: 63
1.4.4.3 host
host输出精简,侧重快速获取关键信息,易于集成到自动化脚本中
root@attack:~# host -a www.baidu.com
Trying "www.baidu.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31427
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.baidu.com. IN ANY
;; ANSWER SECTION:
www.baidu.com. 1045 IN CNAME www.a.shifen.com.
Received 58 bytes from 180.76.76.76#53 in 83 ms
1.5 Github Hacking
1.5.1 GitHub搜索功能说明
您可以在所有公共GitHub存储库中搜索以下类型的信息,以及您有权访问的所有私有GitHub存储库:
Repositories
Topics
Issues and pull requests
Code
Commits
Users
Wikis
参考:
Searching for repositories
Searching topics
Searching code
Searching commits
Searching issues and pull requesls
Searching users
Searching wikis
Searching in forks
您可以使用搜索页面或高级搜索页面搜索GitHub。
您可以使用 >, >= ,<,和 <= 搜索是大于,大于或等于,小于和小于或等于另一个值的值。
1.5.2 搜索仓库
核心搜索语法规则
- 比较运算符
| 语法 | 说明 | 示例 | 含义 |
|---|---|---|---|
| > n | 大于 | cats stars:>1000 | 匹配 stars >1000 的 "cats" 仓库 |
| >= n | 大于等于 | cats topics:>=5 | 匹配标签数 ≥5 的 "cats" 仓库 |
| < n | 小于 | cats size:<10000 | 匹配文件大小 <10KB 的 "cats" 仓库 |
| <= n | 小于等于 | cats stars:<=50 | 匹配 stars ≤50 的 "cats" 仓库 |
- 区间范围查询
| 语法 | 说明 | 示例 | 含义 |
|---|---|---|---|
| n..* | ≥ n(无上限) | cats stars:10..* | 匹配 stars ≥10 的 "cats" 仓库 |
| *..n | ≤ n(无下限) | cats stars:*..10 | 匹配 stars ≤10 的 "cats" 仓库 |
| n1..n2 | n1 到 n2 之间(开区间) | cats stars:10..50 | 匹配 10 < stars < 50 的 "cats" 仓库 |
注意:
10..50表示 大于 10 且小于 50(不包含边界值),实际使用时需根据平台特性确认是否开闭区间。
使用场景与技巧
组合查询
# 搜索标签≥5 + 文件<10KB + stars在50~100之间的仓库
keyword topics:>=5 size:<10000 stars:50..100
空值匹配(图片未展示但常见用法)
# 匹配无 license 声明的仓库
license:none
时间范围搜索(扩展用法)
# 匹配2023年更新的仓库
pushed:2023-01-01..2023-12-31
重要注意事项
字段名称一致性
-
图片中的
stars/topics/size需替换为平台实际字段(如 GitHub 用stars,GitLab 用star_count)
开闭区间争议
对于 10..50 是否包含 10 和 50:
1. GitHub 实际为 闭区间(含边界值)
2. 图片描述为开区间(>10 & <50),建议通过平台验证
语法冲突处理
# 查询带空格的字符串需加引号
"machine learning" stars:>500
1.5.2.1 搜索代码
GitHub 搜索核心限制规则
只能搜索小于384 KB的文件。
只能搜索少于500.000个文件的存储库。
登录的用户可以搜索所有公共存储库。
除 filename 搜索外,搜索源代码时必须至少包含一个搜索词。例如,搜中索 language:javascript 无效,而是这样:amazing language:javascript 。
搜索结果最多可以显示来自同一文件的两个片段,但文件中可能会有更多结果。
您不能将以下通配符用作搜索查询的一部分:.,:;/\""=*!?#$&+^|~<>(){}[]。搜索将忽略这些符号。
| 限制类型 | 具体规则 | 示例说明 |
|---|---|---|
| 文件大小限制 | 仅支持搜索小于 384KB 的文件 | 超限文件无法出现在搜索结果中 |
| 仓库规模限制 | 仅支持文件总数少于 500,000 个的仓库 | 大型/超大型仓库可能被排除 |
| 用户权限要求 | 登录用户可搜索所有公共仓库;匿名用户功能受限 | 未登录时无法完整使用搜索功能 |
| 搜索词强制要求 | 除 filename 外,源代码搜索必须包含至少一个关键词 | ✘ 无效搜索:language:javascript |
| 搜索结果显示上限 | 同一文件最多显示 2个结果片段 | 实际可能存在更多匹配结果(需下载文件查看) |
| 禁用符号列表 | 以下符号会被忽略: | `. , : ; / \ ' = * ! ? # $ & + ^ |
1.1.5.2 日期条件
cats pushed:<2012-07-05 搜索在2012年07月05日前push代码,且cats作为关键字
cats pushed:2016-04-30..2016-07-04日期区间
cats created:>=2017-04-01 创建时间
1.5.2.3 逻辑运算
AND、OR、NOT
1.5.2.4 排除运算
cats pushed:<2012-07-05 -language:java
搜索在2012年07月05日前push代码,且cats作为关键字,排除 java 语言仓库。
1.5.2.5 包含搜索
cats in:file 搜索路径中包含cats的代码cats in:path
cats in:path,file 搜索路径、文件中包含cats的代码
console path:app/public language:javascript 搜索关键字console,且语言为javascript,在app/public下的代码
1.5.2.6 主体搜索
user:USERNAME 用户名搜索
org:ORGNAME 组织搜索
repO:USERNAME/REPOSITORY指定仓库搜索
1.5.2.7 文件大小
size:>1000 搜索大小大于1KB的文件
1.5.2.8 扩展名
extension:EXTENSION 指定扩展名搜索
例如:extension:`properties jdbc
1.5.2.9 自动化工具
GitMiner是一个Python脚本工具(源自项目UnkL4b/GitMiner),用于批量搜索GitHub代码库并提取特定内容。

命令行参数分解
| 参数 | 含义 | 示例值解析 | 作用说明 |
|---|---|---|---|
| -c cookie.txt | 指定认证文件 | cookie.txt 是一个文本文件,包含GitHub API的访问令牌(Token) | 用于绕过API限制,确保高效、大流量搜索GitHub。cookie.txt中应存储有效的GitHub Token(从GitHub账户生成)。 |
| -q 'extension:properties jdbc' | 定义搜索查询 | 'extension:properties jdbc' | 搜索.properties文件中包含"jdbc"关键词的代码。Properties文件常见于Java应用,存储配置如数据库连接字符串(易暴露密码)。 |
| -r 'password(.*)' | 设置正则表达式匹配规则 | 'password(.*)' | 使用正则表达式匹配文本中的"password"关键词及后续任意字符(如password=12345),提取可能存在的密码值。(.*)表示捕获所有后续内容。 |
| -m passwords | 指定输出模式 | passwords | 结果输出为密码列表(可能是提取的值),便于保存或分析。工具还可能支持其他模式如-m emails用于提取邮箱。 |

完整命令示例解释:
#下载GitMiner:
git clone https://github.com/UnkL4b/GitMiner.git
#安装依赖:
运行 pip install -r requirements.txt
#查询
python3 gitminer-v2.0.py -c cookie.txt -q 'extension:properties jdbc' -r 'password(.*)' -m passwords
-
作用:运行GitMiner脚本,使用cookie.txt中的认证信息,搜索GitHub上所有.properties文件中含有"jdbc"的代码,然后通过正则表达式提取"password"关键词后的内容(如数据库密码),并将结果输出为密码列表。
-
输出预期:工具会生成一个文件或终端输出,列出所有匹配到的密码值。例如,如果某个文件中有
jdbc.password=secret123,则输出secret123。
安全审计目的:此操作用于识别公开代码库中的敏感信息泄露(常见于开发人员错误地将配置文件提交到GitHub)。Properties文件中常包含数据库密码、API密钥等,暴露后可能导致数据泄露。例如:
-
示例场景:扫描可发现
jdbc:mysql://user:password@localhost/db格式的连接字符串。
1.6 Google Hacking
intitle: "index of /"
intitle index of/ mp3
intitle index of/ mp4
intitle index of/msvcr100.dll
intitle index of/ password
intitle index of / software
intitle index of / admin
intitle index of / pdf
intitle index of / bitcoin /
intitle index of /inurl passport
intitle index of / passport

1.6.1 通配符
通配符使用规则详解
表格分为四列:通配符(符号)、语义(含义)、说明(使用规则)和示例(具体用法)。以下是每个通配符的完整解析:
| 通配符 | 语义 | 说明 | 示例及解释 |
|---|---|---|---|
| + | 包含关键词 | + 前面必须有一个空格;用于强制要求结果中包含指定关键词。 | admin +login |
| - | 排除关键词 | - 前面必须有一个空格;用于从结果中排除指定关键词。 | mysql -csdn |
| ~ | 同义词匹配 | ~ 前面必须有一个空格;用于搜索与关键词同义或相近的词(说明中提及 - 前需空格,但语义对应 ~,建议规则为 ~ 前需空格)。 | mysql-csdn (可能为笔误,实际应为 mysql ~csdn) |
| \* | 模糊查询 | * 可代替任意字符或字符序列;用于部分匹配或通配符搜索。 | mysql** |
| ''' | 强调(精确匹配) | 无特殊说明(标记为 -),但示例使用双引号,实际等同于引号包裹关键词,强调完全一致匹配。 | "mysql" |
通配符总结速查表
| 符号 | 目的 | 规则 | 示例 |
|---|---|---|---|
| + | 强制包含 | 符号前加空格 | topic +security |
| - | 排除 | 符号前加空格 | python -tutorial |
| ~ | 同义词 | 符号前加空格 | ~cloud -aws(匹配“cloud”及同义词) |
| * | 模糊匹配 | 无空格要求 | data*(匹配“database”“dataset”) |
| " "(推荐) | 精确短语 | 包裹关键词 | "error code" |
提示:此语法广泛适用于 GitHub 搜索、代码审计工具或数据库查询(如 SQL)。掌握后,搜索精度可提升 50% 以上。如需工具支持,可参考搜索引擎的官方文档(如 GitHub 搜索语法)。
1.6.2 谷歌语法
| 语法指令 | 功能描述 | 使用示例 | 适用场景 |
|---|---|---|---|
| site: | 限定搜索结果在指定网站/域名内 | 碳中和政策 site:gov.cn | 查政府文件、权威机构数据 |
| inurl: | 搜索 URL 含关键词的页面 | inurl:admin login | |
| intext: | 在网页正文中搜索关键词 | intext:"免费PDF资源" | |
| filetype: | 限定文件类型(PDF/DOC/XLS等) | 用户体验报告 filetype:pdf | 找行业白皮书、学术文献 |
| intitle: | 在网页标题中搜索关键词 | intitle:2024人工智能趋势 | |
| link: | 查找指向指定域名的外链 | link:tsinghua.edu.cn | 分析网站影响力(仅Google支持) |
| info: | 查看站点基本信息(收录/缓存) | info:github.com | 快速了解网站索引状态 |
| cache: | 查看Google 缓存的页面副本 | cache:example.com | |
| "关键词" | 精确匹配词组(防拆分) | "机器学习入门指南" | 避免搜索结果语义发散 |
| A -B | 排除特定关键词 | 神雕侠侣 -电视剧 | 过滤干扰信息(如排除影视结果) |
| A OR B | 搜索包含A或B的结果 | (元宇宙 OR 虚拟现实) 教育 | 扩大检索范围 |
| related: | 查找相似网站 | related:coursera.org | 发现同类资源平台 |
谷歌黑客数据库:https://www.exploit-db.com/google-hacking-database
1.6.3 例子
1.6.3.1 inurl:/admin intext: 后台管理系统
site:"some-keywords.com" intitle: login intext: intext:管理|后台|登陆|用户名|密码|验证码|系统账号|manage|admin|login|system

1.6.3.2 搜索目录功能是否开启
site:"some-keywords.com" intext: index of /|../ |Parent Directory

1.7 Git-all-secret
1.7.1 Git-all-secret功能描述
项目地址:https://github.com/anshumanbh/git-all-secrets
git-all-secrets 是一个用于捕获所有 Git 秘密的工具,它利用多个开源 Git 搜索工具来扫描多个仓库。该工具可以帮助用户发现潜在的敏感信息,如 API 密钥、密码等,从而提高代码安全性。
- 克隆多个某组织的 public/private 有仓库并扫描;
- 克隆多个某组织用户的 public/private 仓库并扫描;
- 克隆一个某组织的 public/private 仓库并扫描;
- 克隆一个某用户的 public/private 仓库并扫描;
- 克隆一个某用户的 public/secret gist(代码片段管理服务)并扫描;
- 申克隆一个某组织团队的仓库并扫描;
- 克降和扫描Github企业仓库还有gists;
1.7.2 扫描过程需要借助的开源工具
-
truffleHog-扫描高熵值字符串和用户提供的正则表达式;
-
repo-supervisor 扫描在js和json文件中的高熵值字符串;
所有工具中的输出文件最终会合并为一个输出文件。
1.7.3 新手入门
运行Git-all-secrets最简便的方法是使用Docker,作者也强烈推荐安装Docker。
获取Docker: apt install docker docker-compose
- 运行 docker run --rm -it abhartiya/tools gitallsecrets --help 了解不同标志
- 运行 docker run -it abhartiya/tools gitallsecrets -token=<> -org=<> 扫描组织。
- 运行 docker run -it abhartiya/tools gitallsecrets -token=<>*-org=<>-toolName=<> 选择特定工具,toolName=thog or repo-supervisor
- 运行docker run -it abhartiyatools gitallsecrets -token=<> -org=<> -toolName=thogthogEntropy truffleHog的默认正则和高熵设置
- 当容器完成运行,输入dockerps-a返回容器ID
- 获得容器ID以后,输入dockercp:/rootresults.txt来获取结果文件。
1.7.4 标志/选项
- token= Github访问令牌。如果未授权请求Github API会被限速。
- -org=组织扫描。它会扫描组织中的所有公共仓库,以及用户的gists。如果你使用的是该组织用户的token,它还会克隆并扫描该用户的所有私密gists,以及所有该用户有权限访问的私有仓库。
- -user=用户扫描。它会扫描当前用户的所有仓库和gists,扫描私有仓库请使用scanPrivateReposOnly标志,以及SSHkey。
- -repoURL= httpsURL 仓库扫描。它只会扫描当前仓库。如果你希望扫描私有仓库,请提供SSH URL和SSHkey,以及scanPrivateReposOnly标志。
- -gistURL= httpsURL Gist扫描。它只会扫描Gist。如果你知道私密gist的htpsURL,它也能够访问。
- -output= 输出结果文件,默认是result.txt。
- -cloneForks= 这是一个布尔标志。默认设置为0,不克隆forks,如果设置为1,它就会克隆forks.-orgOnly= 这也是一个布尔标志。默认设置为0。如果只扫描组织仓库而不扫描用户的仓库,请将它设置为1。
- -toolName=这是规范扫描工具的标志。默认它使用all,thog和repo-supervisor。-scanPrivateReposOnly=这是规范是否扫描用户私有仓库的标志。它只能工作在user、repoURL、org标志。
- -enterpriseURL=企业GithubURL的标志,如果你希望扫描企业仓库,就选这个。
- -threads=默认线程10。
- -thogEntropy=开启高熵提取,默认是false。设置为true会有大量的垃圾信息,在比较大的目标上,不建议开启。如果设置为false,则意味着truffeHog只会提取基于rules.json文件中的正则结果。
- -blacklist= 不需要扫描的仓库名称,以逗号分隔。
1.7.5 注意事项
- Token选项不能为空。
- Org user repoURL gistURL 不能都设置为空,至少需要提供一个选项。如果你提供了多个选项,他的顺序是org>user>repoURL>gistURL。如果你只需要运行在特定用户上,那就不需要提供org选项。
- 当定义scanPrivateReposOnly标志时:
1.必须将包含SSH-key的卷载入到Docker容器中,使用-v选项。
2.它应该在扫描私有仓库时使用,使用SSH ur,而不是https url。
3.确保使用了私有仓库/gist的用户token,否则会报错。
4.如果你想在没有手动干扰的情况下运行,请不要设置SSH key的密钥密码。 - 当定义teamName标志的时候,提供一个团队成员用户的token非常重要,否则可能会出现意外结果。
- 当定义enterpriseURL标志的时候,即使你提供了https URL,它也始终会考虑ssh key。所有企业克隆/扫描都是通过ssh url,而不是https url。
综上,请确保使用了SSHkey,并且没有设置密钥密码。
1.7.6 扫描私有仓库
扫描私有仓库的最安全方法是使用 SSH URL 进行克隆。为此,需要放置一个已添加到 Github 用户的适当 SSH 密钥。Github 提供了有关配置帐户的有用文档。确保此密钥上没有设置任何密码。获得 SSH 密钥后,只需通过卷将其挂载到 Docker 容器即可。只需键入以下命令即可:
docker run -it -v ~/.ssh/id_rsa_personal:/root/.ssh/id_rsa abhartiya/tools_gitallsecrets -token=<> -user=<> -scanPrivateReposOnly
或
docker run -it -v ~/.ssh/id_rsa_personal:/root/.ssh/id_rsa abhartiya/tools_gitallsecrets -token=<> -repoURL=<> -scanPrivateReposOnly
在这里,我将存储在本地的个人 SSH 密钥映射到容器内部,以便 git-all-secrets 尝试通过克隆存储库,并使用存储在容器内部的 SSH 密钥。这样,您就不会真正在容器内存储任何敏感的东西。您只是使用本地计算机中的文件。容器销毁后,它将无法再访问此密钥。id_rsa_personal``/root/.ssh/id_rsa``ssh``/root/.ssh/id_rsa
1.7.8 扫描组织团队
Github API 限制了报告私有仓库的情况。如果尝试扫描用户不是管理员的 Organization,则可能需要提供向用户提供仓库访问权限的团队。为此,请将 flag 与 flag 一起使用。示例如下:teamName``org
docker run --it -v ~/.ssh/id_rsa_personal:/root/.ssh/id_rsa abhartiya/tools_gitallsecrets -token=<> -org=<> -teamName <>
1.7.9 扫描企业 Github
git-all-secrets 现在也支持扫描 Github Enterprise。如果你有自己的 Github Enterprise,托管在 VPN 或其他后面,请确保你已连接到 VPN 或有权访问 Github Enterprise 存储库的正确网络上。这是扫描 Github Enterprise 存储库所需的内容。以下是一些示例:enterpriseURL
示例 1:
docker run -it -v ~/.ssh/id_rsa_gitenterprise:/root/.ssh/id_rsa -token <token> -enterpriseURL https://github.<org>.com/api/v3 -repoURL https://github.<org>.com/<user>/<repo>.git
在这里,我现在将我的 github 企业 SSH 密钥挂载到容器上,然后是我的个人访问令牌、请求将发送到的企业 URL 以及我要扫描的存储库。
示例 2:
docker run -it -v ~/.ssh/id_rsa_gitenterprise:/root/.ssh/id_rsa -token <token> -enterpriseURL https://github.<org>.com/api/v3 -repoURL https://github.<org>.com/<user>/<repo>.git -toolName thog -thogEntropy
在上图中,我现在只是使用 Entropy 设置对存储库运行 truffleHog。
示例 3:
docker run -it -v ~/.ssh/id_rsa_gitenterprise:/root/.ssh/id_rsa -token <token> -enterpriseURL https://github.<org>.com/api/v3 -user <username> -scanPrivateReposOnly
在上面,我只扫描了该用户的私有存储库,该用户的令牌随所有工具(repo-supevisor 和 thog)一起提供,但没有 truffleHog 的熵设置。
1.7.10 特征
- 您可以在文件中添加自己的正则表达式,并在执行时使用参数 .
rules.json``docker run``-v $(pwd)/rules.json:/root/truffleHog/rules.json - 该工具将查找一些默认正则表达式。如果需要,它也可以用于高熵字符串。所有这些都是通过 truffleHog 工具实现的。
- 它可以通过 repo-supervisor 工具在 .js 和 .json 文件中查找高熵字符串。
- 它扫描用户的 gists,而大多数工具则不会。
- 如果有一个好的新工具,它可以毫不费力地集成到其中。
git-all-secrets - 它专为与其他工具和框架集成而构建。它采用一些输入参数并生成结果的输出文件。非常简单!
- 它还支持扫描 Github Enterprise orgs/users/repos/gist。
- 大多数工具都是用于扫描单个存储库的。如果你想在多个存储库上循环它,你必须在 shell 脚本或类似的东西中编写自己的 for 循环。git-all-secrets 可以帮助您一次性扫描多个存储库。
- 您现在可以将两个工具的输出合并到一个 json 文件中,然后可以在其他自动化类型的工具/框架中使用
1.8 Git 仓库还原
1.9 Mailsniper.psl获取Outlook所有联系人
1.9.1 条件
掌握其中一个用户邮箱的账号密码,并且可以登录outlookoutlook地址可以是官方的也可以是目标自己搭建的,并无影响。
1.9.2 目的
获取目标邮箱里的所有联系人,方便后续爆破弱口令等等。
1.9.3 利用
1.9.3.1 命令
将尝试Outlook Web Access(OWA)和Exchange Web服务(EWS)的方法。此命令可用于从Exchange收集电子邮件列表:
Get-GlobalAddressList -ExchHostname outlook地址 -UserName 域名\域用户名 -Password i
1.9.3.2 目标outlook搭建在自己服务器上
此处使用klion的域环境模拟
在mailsniper.ps1最后一行加入以下代码,也可以通过传参的形式调用。
Get-GlobalAddressList -ExchHostname owa2010cn-god.god.org -UserName god\webadmir
尝试使用我们传递的账号密码去登录目标的outook,成功登录后会把邮件里的联系人都获取下来,并输出保存到文件里
1.9.3.3 目标outlook在office365
一样的道理,只不过把ExchHostname只向outlook.ofice365.com即可,username使用完整的邮箱,而不仅仅是用户名。
Get-GlobalAddressList -ExchHostname outlook,office365.com -UserName 用户名@邮箱后台
1.9.3.4 参考链接:
https://www.blackhillsinfosec.com/abusing-exchange-mailbox-permissions-mailsniperl
https://www.cnblogs.com/backlion/p/6812690.html
1.9.3.5 工具地址:
https://github.com/dafthack/mailsniper
1.10 内网渗透之信息收集
1.9.1 windows 工作组
1.9.1.1 检查当前shell权限
whoami /user && whoami /priv
C:\Users\laowang>whoami /user && whoami /priv
USER INFORMATION
----------------
User Name SID
========= ===========================================
laowang\laowang S-1-5-21-244998269-60732380-2226631807-1001
PRIVILEGES INFORMATION
----------------------
Privilege Name Description State
============================= ==================================== ========
SeShutdownPrivilege Shut down the system Enabled
SeChangeNotifyPrivilege Bypass traverse checking Enabled
SeUndockPrivilege Remove computer from docking station Disabled
SeIncreaseWorkingSetPrivilege Increase a process working set Disabled
SeTimeZonePrivilege Change the time zone Disabled
1.9.1.2 查看系统信息
systeminfo
C:\Users\laowang>systeminfo
Host Name: laowang
OS Name: Microsoft Windows 10 Pro N
OS Version: 10.0.19045 N/A Build 19045
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Workstation
OS Build Type: Multiprocessor Free
Registered Owner: laowang
Registered Organization:
Product ID: 00331-60000-00000-AA596
Original Install Date: 5/16/2023, 2:09:08 PM
System Boot Time: 7/1/2024, 3:29:54 PM
System Manufacturer: Dell Inc.
System Model: XPS 8950
System Type: x64-based PC
Processor(s): 1 Processor(s) Installed.
[01]: Intel64 Family 6 Model 151 Stepping 2 GenuineIntel ~2100 Mhz
BIOS Version: Dell Inc. 1.9.0, 11/15/2022
Windows Directory: C:\Windows
System Directory: C:\Windows\system32
Boot Device: \Device\HarddiskVolume1
System Locale: zh-cn;Chinese (China)
Input Locale: zh-cn;Chinese (China)
Time Zone: (UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi
Total Physical Memory: 16,107 MB
Available Physical Memory: 4,130 MB
Virtual Memory: Max Size: 24,992 MB
1.9.1.3 tcp/udp 网络连接状态信息
查看主机的TCP连接状态:netstat -ano -p tcp
C:\Users\laowang>netstat -ano -p tcp
Active Connections
Proto Local Address Foreign Address State PID
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 1216
TCP 0.0.0.0:903 0.0.0.0:0 LISTENING 4084
TCP 0.0.0.0:913 0.0.0.0:0 LISTENING 4084
TCP 0.0.0.0:1024 0.0.0.0:0 LISTENING 3624
TCP 0.0.0.0:1025 0.0.0.0:0 LISTENING 968
TCP 0.0.0.0:5040 0.0.0.0:0 LISTENING 7452
TCP 0.0.0.0:5244 0.0.0.0:0 LISTENING 14004
TCP 0.0.0.0:49664 0.0.0.0:0 LISTENING 960
TCP 0.0.0.0:49665 0.0.0.0:0 LISTENING 588
TCP 0.0.0.0:49666 0.0.0.0:0 LISTENING 1700
TCP 0.0.0.0:49667 0.0.0.0:0 LISTENING 1712
TCP 0.0.0.0:49668 0.0.0.0:0 LISTENING 3496
TCP 127.0.0.1:1028 127.0.0.1:1029 ESTABLISHED 1164
TCP 127.0.0.1:1029 127.0.0.1:1028 ESTABLISHED 1164
TCP 127.0.0.1:3602 127.0.0.1:5244 TIME_WAIT 0
TCP 127.0.0.1:5475 127.0.0.1:5476 ESTABLISHED 4084
TCP 127.0.0.1:5476 127.0.0.1:5475 ESTABLISHED 4084
TCP 127.0.0.1:8475 0.0.0.0:0 LISTENING 2908
1.9.1.4 主机名
hostname
C:\Users\laowang>hostname
laowang
1.9.1.5 查看当前操作系统
wmic OS get Caption,CSDVersion,OSArchitecture,Version
C:\Users\laowang>wmic OS get Caption,CSDVersion,OSArchitecture,Version
Caption CSDVersion OSArchitecture Version
Microsoft Windows 10 Pro N 64-bit 10.0.19045
1.9.1.6 查杀毒软件
WMIC /Node:localhost /Namespace:\\root\Securitycenter2 Path AntiVirusProduct Get displayName,productState /Format:List
C:\Users\pz>WMIC /Node:localhost /Namespace:\\root\Securitycenter2 Path AntiVirusProduct Get displayName,productState /Format:List
displayName=Kaspersky
productState=270336
displayName=Windows Defender
productState=401664
displayName=卡巴斯基免费版
productState=266240
1.9.1.7 查看当前安装的程序
wmic product get name,version
C:\Users\pz>wmic product get name,version
Name Version
Python 3.11.0 Standard Library (64-bit) 3.11.150.0
Python 3.11.0 Core Interpreter (64-bit) 3.11.150.0
Python 3.11.0 Utility Scripts (64-bit) 3.11.150.0
Oh My Posh 26.6.1
Python 3.11.0 Tcl/Tk Support (64-bit) 3.11.150.0
MountPluginSetup 1.0.0
Python 3.11.0 Documentation (64-bit) 3.11.150.0
VanDyke Software SecureCRT 8.0 8.0.1
Python 3.11.0 Test Suite (64-bit) 3.11.150.0
Python 3.11.0 pip Bootstrap (64-bit) 3.11.150.0
Python 3.11.0 Add to Path (64-bit) 3.11.150.0
Python 3.11.0 Executables (64-bit) 3.11.150.0
Python 3.11.0 Development Libraries (64-bit) 3.11.150.0
Microsoft Visual C++ 2022 X64 Minimum Runtime - 14.32.31332 14.32.31332
MSI Development Tools 10.1.17763.132
1.9.1.8 查看在线用户
`C:\Users\laowang>quser
USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME
laowang console 1 Active none 7/1/2025 3:30 PM`
1.9.1.9 查看网络配置
有Primary Dns Sufix 就说明是域内,空的则当前机器应该在工作组
C:\Users\pz>ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . . . . : laowang
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
Wireless LAN adapter Wi-Fi 2:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Killer(R) Wi-Fi 6E AX1675x 160MHz Wireless Network Adapter (210NGW)
Physical Address. . . . . . . . . : 8C-17-59-2C-B5-73
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IPv4 Address. . . . . . . . . . . : 192.168.2.106(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Tuesday, July 1, 2025 3:30:08 PM
Lease Expires . . . . . . . . . . : Tuesday, July 1, 2025 9:52:30 PM
Default Gateway . . . . . . . . . : 192.168.2.254
DHCP Server . . . . . . . . . . . : 192.168.2.254
DNS Servers . . . . . . . . . . . : 180.76.76.76
223.5.5.5
NetBIOS over Tcpip. . . . . . . . : Enabled
1.9.1.9 查看进程
tasklist /v
C:\Users\pz>tasklist /v
Image Name PID Session Name Session# Mem Usage Status User Name CPU Time Window Title
========================= ======== ================ =========== ============ =============== ================================================== ============ ========================================================================
System Idle Process 0 Services 0 8 K Unknown NT AUTHORITY\SYSTEM 75:32:55 N/A
System 4 Services 0 7,064 K Unknown N/A 0:05:28 N/A
Registry 196 Services 0 23,160 K Unknown N/A 0:00:00 N/A
smss.exe 580 Services 0 328 K Unknown N/A 0:00:00 N/A
csrss.exe 860 Services 0 2,264 K Unknown N/A 0:00:01 N/A
wininit.exe 588 Services 0 624 K Unknown N/A 0:00:00 N/A
csrss.exe 784 Console 1 3,056 K Running N/A 0:02:41 N/A
services.exe 968 Services 0 6,628 K Unknown N/A 0:00:05 N/A
lsass.exe 960 Services 0 13,052 K Unknown N/A 0:00:02 N/A
1.9.1.10 查看当前登录域
net config workstation
C:\Users\pz>net config workstation
Computer name \\PZ
Full Computer name pz
User name pz
Workstation active on
NetBT_Tcpip_{7E880711-85AC-4035-AFF4-4E55B496FDB1} (005056C00001)
Software version Windows 10 Pro N
Workstation domain WORKGROUP
Logon domain PZ
COM Open Timeout (sec) 0
COM Send Count (byte) 32
COM Send Timeout (msec) 250
The command completed successfully.
1.9.1.11 远程桌面连接历史记录
cmdkey /list
C:\Users\pz>cmdkey /list
Currently stored credentials:
Target: Domain:target=192.168.226.128
Type: Domain Password
User: pz
Target: Domain:target=192.168.2.105
Type: Domain Password
User: pz
Target: LegacyGeneric:target=com.logi.ghub/shared
Type: Generic
User: shared
1.9.1.12 查看本机上的用户帐号列表
net user
C:\Users\pz>net user
User accounts for \\PZ
-------------------------------------------------------------------------------
Administrator DefaultAccount Guest
pz WDAGUtilityAccount
The command completed successfully.
1.9.1.13 查看本机用户的信息
net user /domain显示所在域的用户名单
net user 域用户 /domain 获取某个域用户的详细信息
net user /domain XXX12345678 修改域用户密码,需要域管理员权限
1.9.2 Windows 域
返回所有信任192.168.52.2返回域控和其相应的IP地址
nltest /domain_trusts /all_trusts /v /server:192.168.52.2
nltest /dsgetdc:hack /server:192.168.52.2
net group "domain admins" /domain 获取域管理员列表
net group "domain controllers" /domain 查看域控制器(如果有多台)
net group "domain computers"/domain 查看域机器
net group /domain 查询域里面的工作组
net localgroup administrators 本机管理员[通常含有域用户]
net localgroup administratorsdomain 登录本机的域管理员
net localgroup administrators workgroup\user001 /add 域用户添加到本机
Net view 查看同一域内机器列表
net view \lip 查看某IP共享
Net view GHQ 查看GHQ计算机的共享资源列表。
net view /domain 查看内网存在多少个域
Net view /domain:XYZ 查看xYZ域中的机器列表。
net accounts /domain # 查询域用户密码过期等信息
1.9.3 Linux
1.9.3.1 查看当前权限
1.9.3.2 查看网卡配置
1.9.3.3 查看端口状态
1.9.3.4 查看进程状态
1.9.3.5 查找某个文件
1.9.3.6 查看系统版本
1.9.3.7 查看系统用户
1.11 后渗透信息收集之Wmic命令的一些使用方法
1.11.1 前言
wmic和cmd一样在所有的windows版本中都存在,同时wmic有很多cmd下不方便使用的部分,今天给大家介绍一些在后渗透过程中非常适用的使用wmic进行信息收集的命令。
1.11.2 关于wmic
WMI命令行(WMIC)实用程序为WMI提供了命令行界面。WMIC与现有的Shell和实用程序命令兼容。在WMIC出现之前,如果要管理WMI系统,必须使用一些专门的WMI应用,例如SMS,或者使用WMI的脚本编程API,或者使用象CIM Studio之类的工具。如果不熟悉C++之类的编程语言或VBScript之类的脚本语言,或者不掌握WMI名称空间的基本知识,要用WMI管理系统是很困难的。WMIC改变了这种情况。
1.11.3 wmic的简单使用
首先在cmd命令行输入wmic进入交互式页面,这里说一下在powershell也可以和cmd命令行一样的操作
1.11.3.1 wmic /?
通过 wmic /? 可快速扩展 WMIC 操作能力,尤其适用于批处理脚本编写或远程管理场景。
/NAMESPACE 操作使用的名称空间路径
/ROLE 包含角色定义的角色路径
/NODE 操作中使用的服务器
/IMPLEVEL 模拟级别
/AUTHLEVEL 身份验证级别
/LOCALE 操作中使用的语言标识
/PRIVILEGES 启用或禁用所有权限
/TRACE 将调试信息输出到错误文件
/RECORD 将所有输入命令和输出写入日志
/INTERACTIVE 设置或重置交互模式
/FAILFAST 设置或重置 FailFast 模式
/USER 会话期间使用的用户
/PASSWORD 登录会话的密码
/OUTPUT 输出重定向的模式
/APPEND 输出重定向的追加模式
/AGGREGATE 设置或重置聚合模式
/AUTHORITY 连接的 <授权类型>
/?[:<BRIEF|FULL>] 用法信息
1.11.3.2 process /?
process /? 进程管理的帮助

1.11.3.3 wmic process get /?
wmic process get /? 属性获取操作帮助

根据自己实际的需要去对相关的信息进行读取
1.11.4 以进程为例展现wmic的使用
这里的靶机使用的是一台win7 x86的虚拟机 这里以査看进程为例:
wmic process get caption,executablepath,processid #获取系统当前正在运行的进程、进程
下面以进程管理为例,详细展示 wmic 命令的使用方法和实际应用场景。我将从基础查询到高级操作逐步演示:
一、基础进程查询
1. 查看所有进程(核心字段)
wmic process get ProcessId, Name, ExecutablePath, CommandLine
输出示例:
CommandLine ExecutablePath Name ProcessId
C:\Windows\System32\svchost.exe svchost 1196
"C:\Program Files\Google\Chrome\Application\chrome.exe" chrome.exe 5432
2. 过滤特定进程
wmic process where "name='chrome.exe'" get ProcessId, CommandLine, WorkingSetSize
输出示例:
CommandLine WorkingSetSize ProcessId
"C:\Program Files\Google\Chrome\Application\chrome.exe" 34276352 5432
二、进程资源监控
1. 查看内存占用前10的进程
wmic process get Name,WorkingSetSize,ProcessId /every:1 | sort /+60 /r | head -10
输出示例:
Name ProcessId WorkingSetSize
chrome.exe 5432 34276352
mysqld.exe 2314 28521472
explorer.exe 1024 12582912
2. 实时监控CPU占用率
wmic path Win32_PerfFormattedData_PerfProc_Process get Name,PercentProcessorTime /every:5
每5秒刷新:
Name PercentProcessorTime
chrome.exe 15
System 8
Idle 75
三、进程操作管理
1. 结束指定进程(强制终止)
wmic process where "ProcessId=5432" delete
2. 启动新进程(带参数)
wmic process call create "notepad.exe c:\temp\log.txt"
成功返回:
__PARAMETERS:
Instance of __PARAMETERS
{
ProcessId = 8765;
ReturnValue = 0;
};
四、高级进程分析
1. 查看进程启动时间和运行时长
wmic process get Name, CreationDate, KernelModeTime, UserModeTime
输出示例:
Name CreationDate KernelModeTime UserModeTime
chrome.exe 20240515103635.111111+480 1562500 4375000
- 运行时长:(1562500 + 4375000)/10000000 = 0.59375秒(100纳秒单位)
2. 查找可疑进程(DLL注入检测)
wmic process where "ExecutablePath not like '%\\Program Files%' and ExecutablePath not like '%\\Windows%'" get Name,ExecutablePath,ProcessId
五、实用组合技巧
1. 导出所有进程信息到CSV
wmic /output:processes.csv process get ProcessId,Name,CommandLine,ParentProcessId,ThreadCount /format:csv
2. 建立进程树关系
# PowerShell + WMIC组合
wmic process get ProcessId,ParentProcessId,Name /format:list |
ForEach-Object {
$data = $_ -split '\r?\n' | Where-Object { $_ }
$p = [ordered]@{}
$data | ForEach-Object {
$key,$value = $_ -split '=',2
$p[$key] = $value
}
[pscustomobject]$p
} | Sort-Object ProcessId
3. 检测隐藏进程(通过PPID)
wmic process where "ParentProcessId != 4 and ParentProcessId not in (select ProcessId from Win32_Process)" get ProcessId,Name,ParentProcessId
六、注意事项
-
管理员权限:所有写操作需要管理员权限CMD
-
进程保护:系统进程(如csrss.exe)删除会蓝屏
时间格式
:
- CreationDate:
YYYYMMDDHHmmss.ffffff+时区 - Kernel/UserModeTime: 100纳秒单位
替代方案
:生产环境推荐使用PowerShell:
Get-Process | Select-Object Id, Name, CPU, WorkingSet
企业级应用场景:
- 批量服务器进程监控脚本
- 病毒/挖矿程序自动清除工具
- 应用健康状态巡检系统
- 资源泄漏定位分析
1.11.5 关于powershell的Get-Wmi 对象
Get-Wmi是获取Windows Management Instrumentation(WM!)类的实例或有关可用类的信息。
我们需要首先知道自己的windows计算机支持那些可用的WMI类。
Get-Wmiobject -list 自己的windows计算机支持那些可用的WMI类

1.11.5.1 示例
Get-WmiObject和wmic相比,可以说是一个升级版,Get-Wmi0bject可以指定一个参数进行使用(Parameters) 例如在本地计算机上获取进程,也可以指定相应的参数进行一个查询它的一个过程.
Get-Wmiobject -Class win32_process |more 在本地计算机上获取进程

具体的参数以及命令在官方文档中进行查询https://docs.microsoft.com/zh-cn/powershell/module/Microsoft.PowerShell.ManagementGet-WmiObject?view=powershell5.1#parameters
1.12 内网横向常见端口
1.12.1 port 445
SMB(Server Message Block) Windows协议族,主要功能为文件打印共享服务,简单来讲就是共享文件夹。
该端口也是近年来内网横向扩展中比较火的端口,大名鼎鼎的永恒之蓝漏洞就是利用该端口,操作为扫描其是否存在MS17-010漏洞。正常情况下,其命令主要是建立IPC服务()
1.12.1.1 空会话
net use 192.168.1.2
1.12.1.2 远程本地认证
net use 192.168.1.2 /user:a\username password
注****:a/username 中 a为工作组情况下的机器命名,可以为任意字符,例如workgroup/username
1.12.1.3 域test.local 远程认证
net use \192.168.1.2 /user:test\username password
1.12.2 Port 137、138、139
NetBios端口,137、138为UDP端口,主要用于内网传输文件,而NetBios/SMB服务的获取主要是通过139端口的。
1.12.3 Port 135
该端口主要使用DCOM和RPC(Remote Procedure Call)服务,我们利用这个端口主要做WMl(Windows Management Instrumentation)管理工具的远程操作。
-
使用时需要开启wmic服务
-
几乎所有的命令都是管理员权限
-
如果出现"Invalid Global Switch",需要使用双引号把该加的地方都加上
-
远程系统的本地安全策略的“网络访问: 本地帐户的共享和安全模式"应设为“经典-本地用户以自己的身份验证”
-
防火墙最好是关闭状态
wmic /node:192.168,1.2 /user:domain\username /password:123456 process call creat
同时,wmic还有很多版本 类似于 python版本、Powershell版本和exe版本等等
该端口还可以验证是否开启 Exchange Server
1.12.4 Port 53
该端口为DNS服务端口,只要提供域名解析服务使用,该端口在渗透过程中可以寻找一下DNS域传送漏洞,在内网中可以使用DNS协议进行通信传输,隐蔽性更加好.
1.12.5 port 389
用于LADP(轻量级目录访问协议),属于TCP/IP协议,在域过程中一般出现在域控上出现该端口,进行权限认证服务,如果拥有对该域的用户,且担心net或者其他爆破方法不可行的情况,可以尝试使用LADP端口进行爆破。
工具可以使用类似于hydra等开源项目
1.12.6 port 80
该端口主要开启Kerberos服务,属于TCP/IP协议,主要任务是监听KDC的票据请求,该协议在渗透过程中可以进行黄金票据和白银票据的伪造,以横向扩展某些服务。
1.12.7 port 5985
该端口主要介绍WinRM服务,WinRM是Windows对WS-Management的实现,WinRM允许远程用户使用工具和脚本对Windows服务器进行管理并获取数据。并且WinRM服务自Windows Vista开始成为Windows的默认组件。
条件:
-
Windows Vista上必须手动启动,而Windows Server 2008 中服务是默认开启的。
-
服务在后台开启,但是端口还没有开启监听,所以需要开启端口
-
使用 winrm quickconfig 对WinRM进行配置,开启HTTP和HTTPSS监听,且需要开启防火墙

浙公网安备 33010602011771号