iT邦幫忙

DAY 25
6

現代環境下的 Linux 裡的新工具系列 第 22

強大的 netcat 功能與相對應的工具

前篇的netcat的簡介是太不足以顯示其強大,今再來試試透過nc,windows與Linux的交互作用。

這邊舉的例子是很小的一些功能,而nc的功能強大到可以寫成專書:
Instant Netcat Starter

Netcat Power Tools

在此再試幾個有趣的功能:

即時通訊的功能
類似像即時通或msn之類的功能,
可以架像 Jabber,若要像IRC功能的server,就需要架 UnrealIRCd
但nc只要兩邊各下指令,就能夠進行對談的功能:
在 1.2.3.4 上當 server 開 port 3000 執行

$ nc -l -p 3000

在5.6.7.8 上執行

$ nc 1.2.3.4 3000

這樣兩邊就能有最簡易的即時的對談功能。

當簡單的web client
通常用 curl http://ifconfig.me/ip 能獲得自己 IP 的回應,而 nc 可這樣子執行:

$ nc ifconfig.me 80
GET /ip
1.2.3.4

可遠端控制windows的命令模式
在 windows 裡可裝 windows 版的 nc 並執行:

nc -Lp 3000 -vv -e cmd.exe

而從 Linux 端執行 nc windows_ip 3000 就能夠獲得 C:\> 的提示,然後遠端操作 windows 裡的命令模式的動作。

$ nc winxp 3000
Microsoft Windows XP [▒▒▒▒ 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\user\▒ୱ>cd ..
cd ..

C:\Documents and Settings\user>dir /w
dir /w
 ▒ϺаC ▒▒▒▒▒ϺШS▒▒▒ҡC
 ▒ϺаϧǸ▒:  2861-3C0B

 C:\Documents and Settings\user ▒▒▒ؿ▒

[.]                            [..]
[.asdm]                        [.juststyle]
[bluecoat]                     CPInfoLog.log
[Downloads]                    [dwhelper]
[Favorites]                    Foxit Reader SDK ActiveX.ini
ilomrc.log                     index.html
[My Documents]                 [ncftp]
PUTTY.RND                      SciTE.session
[temp]                         [Tracing]
[▒u▒}▒l▒v▒\▒]               [▒ୱ]
               6 ▒ɮ        298,840 ▒줸▒
              14 ▒ӥؿ▒   2,265,120,768 ▒줸▒եi▒

C:\Documents and Settings\user>

上面這個方法是windows端及Linux端都是public,windows當server,Linux就可以指定IP連過去。
如果windows端是內部虛擬IP,外面Linux是public IP,也有方法讓內部的windows的CMD被外部執行:
Linux 端當server執行:

# nc -lp 80

當然 80 port 需要root的身分才能打開執行,且port 80防火牆不會擋。
而在 windows 裡執行

nc 1.2.3.4 80 -e cmd.exe

然後Linux端這邊就會變成可執行遠端 windows 的命令列模式:

# nc -lp 80
Microsoft Windows XP [▒▒▒▒ 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\user>

實在是沒有想過,小小的nc的有這麼出人意料之外的功能。
通常要遠端連線,要裝teamviewer、VNC之類,雖然nc只能文字模式,卻也能快速有效穿透防牆進行遠端操作。


上一篇
TCP/IP 瑞士刀般的超強網路指令工具:netcat
下一篇
另個輕量快速的瀏覽器:Midori
系列文
現代環境下的 Linux 裡的新工具27
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 則留言

0

我要留言

立即登入留言