Netcat can also be used to transfer files, both text and binary, from one computer to another. To send a file from Computer 2 to Computer 1, try the following:
Computer 1: Set up Netcat to listen to and accept the connection and to redirect any input into a file.
root@bt:~# nc -lvp 4444 > output.txt
listening on [any] 4444 …
Computer 2: Connect to the listening Netcat on computer 1 (port 4444) and send the file:
C:\>echo “Hi! This is a text file!” > test.txt
C:\>type test.txt
“Hi! This is a text file!”
C:\>nc -vv 192.168.8.74 4444 < test.txt
192.168.8.74: inverse host lookup failed: h_errno 11004: NO_DATA
(UNKNOWN) [192.168.8.74] 4444 (?) open
Because Netcat doesn’t give any indication of file transfer progress, wait for a few seconds and then
press Ctrl+C to exit Netcat.
On Computer 1 you should see:
root@bt:~# nc -lvp 4444 > output.txt
listening on [any] 4444 …
192.168.9.158: inverse host lookup failed: Unknown server error : Connection timed out
connect to [192.168.8.74] from (UNKNOWN) [192.168.9.158] 1027
^C root@bt:~#
Now check that the file was transferred correctly:
Computer 1
root@bt:~# file output.txt
output.txt: ASCII text, with CRLF line terminators
root@bt:~# cat output.txt
“Hi! This is a text file!”
root@bt:~#
0 comments:
Post a Comment