文章目录
- [一、Linux Enumeration](#一、Linux Enumeration)
-
- [1.1 系统------/etc/*-release、hostname...](#1.1 系统——/etc/*-release、hostname...)
- [1.2 用户------who、whoami、w、id](#1.2 用户——who、whoami、w、id)
- [1.3 网络------DNS、netstat、lsof...](#1.3 网络——DNS、netstat、lsof...)
- [1.4 运行的服务](#1.4 运行的服务)
- [二、Windows Enumeration](#二、Windows Enumeration)
-
- [2.1 系统](#2.1 系统)
- [2.2 用户](#2.2 用户)
- [2.3 网络](#2.3 网络)
- [三、DNS、SMB and SNMP](#三、DNS、SMB and SNMP)
-
- [3.1 DNS](#3.1 DNS)
- [3.2 SMB](#3.2 SMB)
- [3.3 SNMP](#3.3 SNMP)
- 四、更多的windows工具
本节的前提是:在目标系统上拥有管理员或root权限,为下一步内网横向做信息收集。
一、Linux Enumeration
将从以下四类对linux进行信息收集:系统、用户、网络、正在运行的服务。
1.1 系统------/etc/*-release、hostname...
可以使用以下命令查看系统版本:
bash
# 查看linux版本
ls /etc/*-release
cat /etc/os-release
该系统版本为Ubuntu 20.04.6 LTS

bash
# 查看系统名字
hostname
系统名为ip-10-10-115-52

bash
# 用户、组、密码相关文件
cat /etc/passwd
cat /etc/group
cat /etc/shadow # 需要root权限
# 邮件相关文件
ls -lh /var/mail/
## -h:显示文件大小,以K、M等为单位
# 查看系统已安装应用(ubuntu、kali)
ls -lh /usr/bin/
ls -lh /sbin/
## RPM-based Linux system
rpm -qa
## Debian-based Linux syste
dpkg -l
1.2 用户------who、whoami、w、id
who
显示当前登录到系统的用户信息:
bash
user@TryHackMe$ who
# <username> <teminal> <time>(IP)
root tty1 2022-05-18 13:24
jane pts/0 2022-05-19 07:17 (10.20.30.105)
peter pts/1 2022-05-19 07:13 (10.20.30.113)
bash
# 显示当前用户
whoami
# 不仅显示当前登录系统的用户,还能知道用户在干什么
w

bash
# 显示用户的用户ID(UID)、组ID(GID)以及所属的用户组信息
# 在启用了SELinux 的系统中,id 命令还会显示用户的SELinux上下文信息
id
uid=1003(jane) gid=1003(jane) groups=1003(jane) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
bash
# 显示系统用户的登录历史记录以及系统的启动和关机记录
# 主要读取/var/log/wtmp文件
user@TryHackMe$ last
jane pts/0 10.20.30.105 Thu May 19 07:17 still logged in
peter pts/1 10.20.30.113 Thu May 19 07:13 still logged in
michael pts/0 10.20.30.1 Thu May 19 05:12 - 05:17 (00:04)
randa pts/1 10.20.30.107 Wed May 18 14:18 - 07:08 (16:49)
root tty1 Wed May 18 13:24 still logged in
1.3 网络------DNS、netstat、lsof...
DNS
配置文件:/etc/resolv.conf
,保存DNS服务器地址。
bash
user@TryHackMe$ cat /etc/resolv.conf
# Generated by NetworkManager
search localdomain thm
nameserver 10.20.30.2
netstat
命令:
bash
-a show both listening and non-listening sockets
-l show only listening sockets
-n show numeric output instead of resolving the IP address and port number
-t TCP
-u UDP
-x UNIX
-p Show the PID and name of the program to which the socket belongs
bash
# 查看所有处于监听状态的TCP端口
netstat -plt
# 查看所有处于监听或连接状态的TCP or UDP端口
netstat -atupn
lsof
代表"List Open Files
"(列出打开的文件),可以使用如下命令显示因特网和网络连接:
bash
# 显示因特网和网络连接
sudo lsof -i
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
chronyd 640 chrony 5u IPv4 16945 0t0 UDP localhost:323
chronyd 640 chrony 6u IPv6 16946 0t0 UDP localhost:323
sshd 978 root 3u IPv4 20035 0t0 TCP *:ssh (LISTEN)
sshd 978 root 4u IPv6 20058 0t0 TCP *:ssh (LISTEN)
master 1141 root 13u IPv4 20665 0t0 TCP localhost:smtp (LISTEN)
master 1141 root 14u IPv6 20666 0t0 TCP localhost:smtp (LISTEN)
dhclient 5638 root 6u IPv4 47458 0t0 UDP *:bootpc
sshd 5693 peter 3u IPv4 47594 0t0 TCP rpm-red-enum.thm:ssh->10.20.30.113:38822 (ESTABLISHED)
[...]
可以看到,peter
用户已经通过SSH
端口连接到服务器rpm-red-enum.th
。
要获取完整的匹配程序列表,你需要以
root
用户身份运行lsof
。
bash
# 将输出内容限定为与端口25相关的部分
sudo lsof -i :25
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
master 1141 root 13u IPv4 20665 0t0 TCP localhost:smtp (LISTEN)
master 1141 root 14u IPv6 20666 0t0 TCP localhost:smtp (LISTEN)
1.4 运行的服务
使用ps
命令来查看正在运行的服务,如:
bash
# -e:查看所有正在运行进程
ps -e
# -l使用长格式,-f使用完整格式
ps -el
ps -ef
也可以使用BSD
语法来获得类似的输出并查看所有进程:
bash
# 查看所有进行,ax为必须的参数
ps ax
ps aux
使用树的形式查看所有进程:
bash
ps axjf
ps axf

筛选特定关键字:
bash
ps -ef | grep peter

1、What is the name of the Linux distribution used in the VM?
Ubuntu
查看系统发行版本:
bash
ls /etc/*-release
cat /etc/os-release

2、What is its version number?
20.04.4
3、What is the name of the user who last logged in to the system?
randa
bash
# 越往上的记录越接近当前时间,显示的是最近登录的用户信息。
last

4、What is the highest listening TCP port number?
6667
bash
# -n:不要解析IP
netstat -pltn

5、What is the program name of the service listening on it?
bash
# 查看所有处于监听状态的TCP端口
sudo netstat -plnt
root
用户才能看到端口对应的服务。

6、There is a script running in the background. Its name starts with THM. What is the name of the script?
THM-24765.sh
bash
# 查看所有进程,并筛选包含THM关键字的进程信息
ps ax | grep THM

二、Windows Enumeration
2.1 系统
bash
# 查看系统相关信息,包括系统补丁
systeminfo

bash
# 查看已安装的补丁
wmic qfe get Caption,Description

bash
# 查看已安装且已运行的服务
net start

bash
# 查看已安装的应用程序
wmic product get name,version,vendor
Name Vendor Version
Microsoft Visual C++ 2019 X64 Minimum Runtime - 14.28.29910 Microsoft Corporation 14.28.29910
[...]
Microsoft Visual C++ 2019 X64 Additional Runtime - 14.28.29910 Microsoft Corporation 14.28.29910
2.2 用户
bash
# 查看当前用户身份
whoami
# 查看当前用户权限
whoami /priv

bash
# 查看当前用户属于哪个组
whoami /groups

bash
# 查看计算机中有哪些用户
net user

bash
# 列出系统中所有的本地组
## 非域控
net group
## 域控
net localgroup

powershell
# 查看本地administrator中的用户
net localgroup administrator

bash
# 查看密码策略
## 非域控
net accounts
## 域控
net accounts /domain

2.3 网络
bash
# 查看所有的网络信息
ipconfig /all
ipconfig
只会显示部分网络信息。

bash
netstat -abno
# -a:显示所有监听端口和活动连接
# -b:显示参与连接的可执行文件
# -n:避免解析IP地址和端口号
# -o:显示进程ID(PID)

bash
# 查看本地路由表
arp -a

1、What is the full OS Name?
2、What is the OS Version?
bash
# 查看系统相关信息,包括系统补丁
systeminfo

3、How many hotfixes are installed on this MS Windows Server?
减去第一行表头 31-1=30
bash
# 查看已安装的补丁
wmic qfe get Caption,Description | Measure-Object -Line

4、What is the lowest TCP port number listening on the system?
22
5、What is the name of the program listening on that port?
ssd.exe
bash
netstat -abno
# -a:显示所有监听端口和活动连接
# -b:显示参与连接的可执行文件
# -n:避免解析IP地址和端口号
# -o:显示进程ID(PID)

三、DNS、SMB and SNMP
3.1 DNS
DNS区域传输(DNS Zone Transfer)是一种用于在DNS服务器之间同步和更新DNS数据的过程。它通常用于将主DNS服务器(Primary DNS Server)上的 DNS 记录复制到辅助DNS服务器(Secondary DNS Server),以确保所有 DNS 服务器上的数据保持一致。
bash
# 辅助DNS服务器向主DNS服务器发送一个区域传输请求,请求特定区域的数据。
dig -t AXFR <DOMAIN_NAME> @<DNS_SERVER>
# -t AXFR:表示正在请求一个区域传输
# <DOMAIN_NAME>:域名
# <DNS_SERVER>:DNS服务器地址
3.2 SMB
服务器消息块(Server Message Block,SMB)是一种通信协议,它提供了对文件和打印机的共享访问。
bash
# 列出的共享文件夹及其相关信息
net share

C$
:共享名称,这是一个默认的隐藏共享文件夹,用于允许远程访问C盘的根目录。默认情况下,只有具有管理员权限的用户才能访问它。IPC$
:这是一个用于远程进程间通信(Inter-Process Communication)的特殊共享。它通常用于管理远程系统上的服务和任务,而不是用于文件共享。ADMIN$
:这是一个默认的隐藏共享文件夹,用于允许远程访问Windows系统目录。默认情况下,只有具有管理员权限的用户才能访问它。Internal
和Users
:自定义的共享文件夹,用于共享特定的目录,方便协作。
3.3 SNMP
简单网络管理协议(Simple Network Management Protocol,SNMP)是为了帮助收集网络上不同设备的信息而设计的,它能够告知你各种网络事件,从服务器磁盘故障到打印机缺墨。snmp
1、use dig to carry out a domain transfer. What is the flag that you get in the records?
bash
# DNS区域传输
dig -t AXFR redteam.thm @10.10.66.133

2、What is the name of the share available over SMB protocol and starts with THM?
bash
# 列出的共享文件夹及其相关信息,windows
net share

3、Knowing that the community string used by the SNMP service is public, use snmpcheck to collect information about the MS Windows Server of IP 10.10.66.133. What is the location specified?
bash
# snmp可以读取系统信息、网络接口、运行的服务等。
snmpcheck 10.10.223.16 -c public
# -c:指定SNMP的社区字符串(Community String)。社区字符串是SNMP协议中用于认证的简单密码,用于控制对 SNMP 代理的访问。
# public:这是 SNMP 的默认社区字符串,通常用于只读访问。
结果类似下面:

四、更多的windows工具
相关windows工具:
Sysinternals Suite
:一套由微软提供的强大工具集合,用于系统管理和故障排除。这些工具可以帮助用户深入了解系统运行状态、进程活动等信息。虽然这些工具非常实用,但它们需要单独下载和安装。Process Hacker
:一个开源的系统监视和分析工具,类似于Windows自带的任务管理器,但功能更强大。它可以提供更详细的过程信息、系统资源使用情况等。它也需要用户自行下载和安装。GhostPack Seatbelt
:GhostPack 是一组用于安全研究和渗透测试的工具,其中 Seatbelt 是一个用于收集系统信息和潜在安全问题的工具。它通常用于安全审计和漏洞发现,同样需要额外的下载和安装步骤。