如何通过代理链使用 nmap?

信息安全 加密 Web应用程序 网络 地图 扫描
2021-08-21 07:39:15

我正在使用以下命令通过代理链运行 nmap:

proxychains nmap -v scanme.namp.org

这产生了一个错误:

root@kali:~# proxychains nmap -v scanme.nmap.org
ProxyChains-3.1 (http://proxychains.sf.net)

Starting Nmap 6.49BETA4 ( https://nmap.org ) at 2016-05-07 17:23 IST
|DNS-request| scanme.nmap.org 
|D-chain|-<>-127.0.0.1:9050-<>-127.0.0.1:9050-<--denied
|D-chain|-<>-127.0.0.1:9050-<><>-4.2.2.2:53-<><>-OK
|DNS-response| scanme.nmap.org is 45.33.32.156
45.33.32.156/0 looks like an IPv6 target specification -- you have to use the -6 option.
Read data files from: /usr/bin/../share/nmap
WARNING: No targets were specified, so 0 hosts scanned.
Nmap done: 0 IP addresses (0 hosts up) scanned in 0.94 seconds

然后我去了这个问题(在这里),我尝试了这个:

 to the solution was, that I disabled the DNS through socks:

in /etc/proxychains.conf file, just add a # before the line "proxy_dns"

但是当我通过代理链运行 nmap 时,nmap 扫描正在运行,但代理链代理不起作用,这给了我以下详细输出:

root@kali:~# proxychains nmap -v scanme.nmap.org
ProxyChains-3.1 (http://proxychains.sf.net)

Starting Nmap 6.49BETA4 ( https://nmap.org ) at 2016-05-07 17:26 IST
Initiating Ping Scan at 17:26
Scanning scanme.nmap.org (45.33.32.156) [4 ports]
Completed Ping Scan at 17:26, 0.20s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 17:26
Completed Parallel DNS resolution of 1 host. at 17:26, 0.00s elapsed
Initiating SYN Stealth Scan at 17:26
Scanning scanme.nmap.org (45.33.32.156) [1000 ports]
Discovered open port 22/tcp on 45.33.32.156
Discovered open port 80/tcp on 45.33.32.156
Increasing send delay for 45.33.32.156 from 0 to 5 due to 11 out of 31 dropped probes since last increase.
Increasing send delay for 45.33.32.156 from 5 to 10 due to 59 out of 196 dropped probes since last increase.
Increasing send delay for 45.33.32.156 from 10 to 20 due to max_successful_tryno increase to 4
Increasing send delay for 45.33.32.156 from 20 to 40 due to max_successful_tryno increase to 5
Increasing send delay for 45.33.32.156 from 40 to 80 due to 28 out of 92 dropped probes since last increase.
Increasing send delay for 45.33.32.156 from 80 to 160 due to max_successful_tryno increase to 6
Increasing send delay for 45.33.32.156 from 160 to 320 due to max_successful_tryno increase to 7
SYN Stealth Scan Timing: About 24.82% done; ETC: 17:28 (0:01:34 remaining)
Increasing send delay for 45.33.32.156 from 320 to 640 due to 11 out of 21 dropped probes since last increase.
Increasing send delay for 45.33.32.156 from 640 to 1000 due to max_successful_tryno increase to 8
SYN Stealth Scan Timing: About 24.66% done; ETC: 17:30 (0:03:06 remaining)
Discovered open port 31337/tcp on 45.33.32.156
Discovered open port 9929/tcp on 45.33.32.156
Completed SYN Stealth Scan at 17:28, 97.38s elapsed (1000 total ports)
Nmap scan report for scanme.nmap.org (45.33.32.156)
Host is up (0.23s latency).
Other addresses for scanme.nmap.org (not scanned): 2600:3c01::f03c:91ff:fe18:bb2f
Not shown: 992 closed ports
PORT      STATE    SERVICE
22/tcp    open     ssh
80/tcp    open     http
139/tcp   filtered netbios-ssn
445/tcp   filtered microsoft-ds
514/tcp   filtered shell
1434/tcp  filtered ms-sql-m
9929/tcp  open     nping-echo
31337/tcp open     Elite

Read data files from: /usr/bin/../share/nmap
Nmap done: 1 IP address (1 host up) scanned in 97.65 seconds
           Raw packets sent: 1477 (64.936KB) | Rcvd: 1457 (58.288KB)

从这里我们可以看到 nmap 工作正常,但我的问题是为什么 nmap 在命令执行后立即启动而不通过代理隧道自身?但是如果我运行这样的命令:

proxychains firefox www.google.com

我得到了以下详细的输出,它显示了代理的隧道。

root@kali:~# proxychains firefox www.duckduckgo.com
ProxyChains-3.1 (http://proxychains.sf.net)

(process:6159): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed
console.error: 
  [CustomizableUI]
  Custom widget with id loop-button does not return a valid node
console.error: 
  [CustomizableUI]
  Custom widget with id loop-button does not return a valid node
|D-chain|-<>-127.0.0.1:9050-<>-127.0.0.1:9050-<--denied
|D-chain|-<>-127.0.0.1:9050-<><>-46.51.216.186:80-<><>-OK
|D-chain|-<>-127.0.0.1:9050-<><>-46.51.216.186:443-<><>-OK
|D-chain|-<>-127.0.0.1:9050-<><>-52.19.3.28:443-<><>-OK
|D-chain|-<>-127.0.0.1:9050-<><>-117.18.237.29:80-<><>-OK
|D-chain|-<>-127.0.0.1:9050-<><>-74.125.130.91:443-<><>-OK
|D-chain|-<>-127.0.0.1:9050-<><>-216.58.199.174:80-<><>-OK
|D-chain|-<>-127.0.0.1:9050-<><>-74.125.130.102:443-<><>-OK
|D-chain|-<>-127.0.0.1:9050-<><>-46.51.216.186:443-<><>-OK
|D-chain|-<>-127.0.0.1:9050-<><>-46.51.216.186:443-<><>-OK
|D-chain|-<>-127.0.0.1:9050-<><>-46.51.216.186:443-<><>-OK
|D-chain|-<>-127.0.0.1:9050-<><>-46.51.216.186:443-<><>-OK
|D-chain|-<>-127.0.0.1:9050-<><>-46.51.216.186:443-<><>-OK
|D-chain|-<>-127.0.0.1:9050-<><>-54.251.178.52:443-<><>-OK
3个回答

nmap 对代理的支持非常有限。特别是您不能进行任何类型的 ICMP (ping) 或 UDP 扫描、SYN 隐身扫描、操作系统检测等。这意味着您使用的默认 nmap 命令将无法与代理一起使用,并且取决于实现将失败或将绕过代理。您必须将自己限制为仅通过代理支持的扫描类型,即简单的 TCP 连接。

有关这方面的更多详细信息,请参阅通过代理的 Nmap

您必须使用-sT选项——Connect()扫描技术。否则nmap将使用SYN方法,取消proxychains例如,这将是

proxychains nmap -sT -v scanme.namp.org

而且,顺便说一下,proxychains-ng似乎nmap比原始版本引起更多问题。

正如这篇文章Nmap through proxy中所建议的那样:

无法通过 ICMP ping 来查看主机是否处于活动状态,因为 ICMP 不是 TCP。因此,如果您的目标只能通过代理 (-Pn) 访问,您可能需要跳过主机发现步骤。由于(不支持的)SOCKS5 ICMP 不支持 ICMP,这在未来也不会改变。

您必须使用该-Pn选项让 nmap 与proxychains实用程序一起使用。所以命令是

proxychains nmap -sT -Pn -v www.example.com

在这里,-sT用于扫描 TCP 端口。而且您也不能使用该-O标志,因为无法使用 TCP 完成主机发现。

但最简单的方法和解决方法是编辑/etc/proxychains.conf文件。

我们只需要注释掉该proxy_dns行,一切都会完美运行。