nmap加载nse脚本在内网渗透中的使用-上

转载自:https://mp.weixin.qq.com/s/zEgHxJEOfaiYVZYmg7NnXA?

大多数情况下,大家都认为nmap只是一个扫描工具,而不把当成是一个渗透工具。nmap集成了大量优秀的nse脚本,可以帮助我们在一些比较严苛的环境下进行内网渗透,特别是当我们控制了一台低权限的*nix平台的机器,需要对域渗透。nmap提供了很多有效的脚本,不需要依赖其他第三方的工具,对内网机器进行渗透测试。在早期的linux发型版本中,大部分都默认安装了nmap。这里我总结一些常用的内网渗透脚本,希望对大家有所帮助。

 

友情提示:入侵有风险,扫描需谨慎

 

smb-enum-domains.nse 对域控制器进行信息收集扫描,可以获取主机信息,用户,密码策略可以用的用户等
nmap --script smb-enum-domains.nse -p445 <host>
sudo nmap -sU -sS --script smb-enum-domains.nse -p U:137,T:139 <host>
Script Output 

Host script results:
| smb-enum-domains:
|   WINDOWS2000
|     Groups: n/a
|     Users: Administrator, blah, Guest, testpass, ron, test, user
|     Creation time: 2009-10-17 12:45:47
|     Passwords: min length: n/a; min age: 5 days; max age: 100 days; history: 10 passwords
|     Properties: Complexity requirements exist
|     Account lockout: 5 attempts in 30 minutes will lock out the account for 30 minutes
|   Builtin
|     Groups: Administrators, Backup Operators, Guests, Power Users, Replicator, Users
|     Users: n/a
|     Creation time: 2009-10-17 12:45:46
|     Passwords: min length: n/a; min age: n/a days; max age: 42 days; history: n/a passwords
|_    Account lockout disabled


smb-enum-users.nse,在进行域渗透的时候,有了域内某台主机的权限,但是权限有限,不能获取更多的域用户信息的时候,可以借助这个脚本对域控制器进行扫描
nmap --script smb-enum-users.nse -p445 <host>
sudo nmap -sU -sS --script smb-enum-users.nse -p U:137,T:139 <host>
Script Output 

Host script results:
|  smb-enum-users:
|_ |_ Domain: RON-WIN2K-TEST; Users: Administrator, Guest, IUSR_RON-WIN2K-TEST, IWAM_RON-WIN2K-TEST, test1234, TsInternetUser

Host script results:
|  smb-enum-users:
|  |  RON-WIN2K-TEST\Administrator (RID: 500)
|  |  |  Description: Built-in account for administering the computer/domain
|  |  |_ Flags:       Password does not expire, Normal user account
|  |  RON-WIN2K-TEST\Guest (RID: 501)
|  |  |  Description: Built-in account for guest access to the computer/domain
|  |  |_ Flags:       Password not required, Password does not expire, Normal user account
|  |  RON-WIN2K-TEST\IUSR_RON-WIN2K-TEST (RID: 1001)
|  |  |  Full name:   Internet Guest Account
|  |  |  Description: Built-in account for anonymous access to Internet Information Services
|  |  |_ Flags:       Password not required, Password does not expire, Normal user account
|  |  RON-WIN2K-TEST\IWAM_RON-WIN2K-TEST (RID: 1002)
|  |  |  Full name:   Launch IIS Process Account
|  |  |  Description: Built-in account for Internet Information Services to start out of process applications
|  |  |_ Flags:       Password not required, Password does not expire, Normal user account
|  |  RON-WIN2K-TEST\test1234 (RID: 1005)
|  |  |_ Flags:       Normal user account
|  |  RON-WIN2K-TEST\TsInternetUser (RID: 1000)
|  |  |  Full name:   TsInternetUser
|  |  |  Description: This user account is used by Terminal Services.
|_ |_ |_ Flags:       Password not required, Password does not expire, Normal user account

smb-enum-shares.nse 遍历远程主机的共享目录
nmap --script smb-enum-shares.nse -p445 <host>
sudo nmap -sU -sS --script smb-enum-shares.nse -p U:137,T:139 <host>
Script Output 

Host script results:
| smb-enum-shares:
|  account_used: WORKGROUP\Administrator
|  ADMIN$
|    Type: STYPE_DISKTREE_HIDDEN
|    Comment: Remote Admin
|    Users: 0
|    Max Users: <unlimited>
|    Path: C:\WINNT
|    Anonymous access: <none>
|    Current user access: READ/WRITE
|  C$
|    Type: STYPE_DISKTREE_HIDDEN
|    Comment: Default share
|    Users: 0
|    Max Users: <unlimited>
|    Path: C:\
|    Anonymous access: <none>
|    Current user access: READ
|  IPC$
|    Type: STYPE_IPC_HIDDEN
|    Comment: Remote IPC
|    Users: 1
|    Max Users: <unlimited>
|    Path:
|    Anonymous access: READ
|_   Current user access: READ

smb-enum-processes.nse 通过smb对主机的系统进程进行遍历,通过这些信息,可以知道目标主机上运行软件信息,选择合适的漏洞或者规避防火墙以及杀毒软件。
nmap --script smb-enum-processes.nse -p445 <host>
sudo nmap -sU -sS --script smb-enum-processes.nse -p U:137,T:139 <host>

Script Output 

Host script results:
|  smb-enum-processes:
|_ |_ Idle, System, smss, csrss, winlogon, services, logon.scr, lsass, spoolsv, msdtc, VMwareService, svchost, alg, explorer, VMwareTray, VMwareUser, wmiprvse

--
Host script results:
|  smb-enum-processes:
|  `+-Idle
|   | `-System
|   |   `-smss
|   |     `+-csrss
|   |      `-winlogon
|   |        `+-services
|   |         | `+-spoolsv
|   |         |  +-msdtc
|   |         |  +-VMwareService
|   |         |  +-svchost
|   |         |  `-alg
|   |         +-logon.scr
|   |         `-lsass
|   +-explorer
|   | `+-VMwareTray
|   |  `-VMwareUser
|_  `-wmiprvse

--
Host script results:
|  smb-enum-processes:
|   PID  PPID  Priority Threads Handles
|  ----- ----- -------- ------- -------
|      0     0        0       1       0 `+-Idle
|      4     0        8      49     395  | `-System
|    252     4       11       3      19  |   `-smss
|    300   252       13      10     338  |     `+-csrss
|    324   252       13      18     513  |      `-winlogon
|    372   324        9      16     272  |        `+-services
|    872   372        8      12     121  |         | `+-spoolsv
|    896   372        8      13     151  |         |  +-msdtc
|   1172   372       13       3      53  |         |  +-VMwareService
|   1336   372        8      20     158  |         |  +-svchost
|   1476   372        8       6      90  |         |  `-alg
|    376   324        4       1      22  |         +-logon.scr
|    384   324        9      23     394  |         `-lsass
|   1720  1684        8       9     259  +-explorer
|   1796  1720        8       1      42  | `+-VMwareTray
|   1808  1720        8       1      44  |  `-VMwareUser
|_  1992   580        8       7     179  `-wmiprvse

smb-enum-sessions.nse 通过smb获取域内主机的用户登录session,查看当前是否有用户登录,对于我们抓取用户hash以及避免同时登陆被用户发现。
nmap --script smb-enum-sessions.nse -p445 <host>
sudo nmap -sU -sS --script smb-enum-sessions.nse -p U:137,T:139 <host>
Script Output 

Host script results:
|  smb-enum-sessions:
|  Users logged in:
|  |  TESTBOX\Administrator since 2008-10-21 08:17:14
|  |_ DOMAIN\rbowes since 2008-10-20 09:03:23
|  Active SMB Sessions:
|_ |_ ADMINISTRATOR is connected from 10.100.254.138 for [just logged in, it's probably you], idle for [not idle]

smb-os-discovery.nse 通过smb协议来收集目标主机的操作系统,计算机名,域名,全称域名,域林名称,NetBIOS机器名,NetBIOS域名,工作组,系统时间。
nmap --script smb-os-discovery.nse -p445 127.0.0.1
sudo nmap -sU -sS --script smb-os-discovery.nse -p U:137,T:139 127.0.0.1
Script Output 

Host script results:
| smb-os-discovery:
|   OS: Windows Server (R) 2008 Standard 6001 Service Pack 1 (Windows Server (R) 2008 Standard 6.0)
|   OS CPE: cpe:/o:microsoft:windows_2008::sp1
|   Computer name: Sql2008
|   NetBIOS computer name: SQL2008
|   Domain name: lab.test.local
|   Forest name: test.local
|   FQDN: Sql2008.lab.test.local
|   NetBIOS domain name: LAB
|_  System time: 2011-04-20T13:34:06-05:00

上一篇:php代码审计知识点总结


下一篇:16 SQL Mode