Syntax:
Server: netcat -l -p PORT
Client: netcat IP PORT
-l listening mode for server -p portnumber
—> To write output of incoming connections to file:
> netcat -l -p PORT > OUTFILE
—> To respawn netcat server, after connection has been closed: —> Attention: in order to get rid of process you have to kill -9 parent shell!
> while true; do netcat -l -p 3333; done
—> To transmit output of a commando to a server
> COMMAND | netcat IP PORT
—> If compiled with -DGAPING_SECURITY_HOLE the -e switch works: on new connection executable is called without parameters !
> netcate -l -p PORT -e EXECUTABLE
—> Send text to client
> echo MYTEXT | netcat -l -p PORT
----------------------------> Comunication with netcat:
SERVER:
> netcat -l -p 3333 Hallo Hi du Wie geht's! GUAAT.. punt! >
CLIENT:
arno@geaeini: arno> netcat localhost 3333 Hallo Hi du Wie geht's! GUAAT.. >
-----------------------------> Cmd-Line:
CLIENT:
> nc Cmd line: localhost 3333 Hi du Ei ! punt! >
SERVER:
> netcat -l -p 3333 Hi du Ei ! >
----------------------------> Puttin input in fifo and parsing output
> mkfifo fifi
SERVER:
> netcat -l -p 3333 > fifi &
CLIENT:
> netcat localhost 3333 line 1 line 2 line 3 line 4 line 5 line 6 punt! >
PARSER:
> X=0 > cat fifi | while read line; do echo $X: $line; let X=X+1; done 0: line 1 1: line 2 2: line 3 3: line 4 4: line 5 5: line 6
----------------------> Why does this not work?
CLIENT SENDING:
> netcat localhost 3333 line 1 > Line 4 received line 2 line 3 punt! >
PARSER:
> cat IN | while read line; do echo "> Line $X received" > OUT ; echo $line; let X=X+1; done line 1
SERVER:
> cat OUT | netcat -l -p 3333 > IN & [1] 13345 arno@geaeini: tmp>
documented on: 2003.12.10 Wed