使用netcat(瑞士军刀)进行文件传输
nc(netcat)被誉为网络工具中的“瑞士军刀”,体积虽小但功能强大,nc最简单的功能是端口扫描,这里我主要笔记一下它作为文件传输的妙用。
首先看一下帮助信息。
$nc-h OpenBSDnetcat(Debianpatchlevel1.105-7ubuntu1) Thisisncfromthenetcat-openbsdpackage.Analternativencisavailable inthenetcat-traditionalpackage. usage:nc[-46bCDdhjklnrStUuvZz][-Ilength][-iinterval][-Olength] [-Pproxy_username][-psource_port][-qseconds][-ssource] [-Ttoskeyword][-Vrtable][-wtimeout][-Xproxy_protocol] [-xproxy_address[:port]][destination][port] CommandSummary: -4UseIPv4 -6UseIPv6 -bAllowbroadcast -CSendCRLFasline-ending -DEnablethedebugsocketoption -dDetachfromstdin -hThishelptext -IlengthTCPreceivebufferlength -isecsDelayintervalforlinessent,portsscanned -jUsejumboframe -kKeepinboundsocketsopenformultipleconnects -lListenmode,forinboundconnects -nSuppressname/portresolutions -OlengthTCPsendbufferlength -PproxyuserUsernameforproxyauthentication -pportSpecifylocalportforremoteconnects -qsecsquitafterEOFonstdinanddelayofsecs -rRandomizeremoteports -SEnabletheTCPMD5signatureoption -saddrLocalsourceaddress -TtoskeywordSetIPTypeofService -tAnswerTELNETnegotiation -UUseUNIXdomainsocket -uUDPmode -VrtableSpecifyalternateroutingtable -vVerbose -wsecsTimeoutforconnectsandfinalnetreads -XprotoProxyprotocol:"4","5"(SOCKS)or"connect" -xaddr[:port]Specifyproxyaddressandport -ZDCCPmode -zZero-I/Omode[usedforscanning] Portnumberscanbeindividualorranges:lo-hi[inclusive]
端口扫描:
$nc-z-v-n127.0.0.120-100 ... Connectionto127.0.0.180port[tcp/*]succeeded! ...
简单文件传输:
客户端:
$nc-l192.168.1.111234>passwd.txt&
服务端:
$nc192.168.1.111234</etc/passwd
也可以是
cat/etc/passwd|nc192.168.1.111234
服务端ip是192.169.1.11,端口是1234
如此,当两台linux机器需要简单传输文件时,再好不过了~