Nmap Development mailing list archives

Re: netcat missing example (is this even possible?)


From: David Fifield <david () bamsoftware com>
Date: Tue, 1 Jun 2010 17:43:18 -0600

On Wed, Jun 02, 2010 at 03:42:53AM +1000, David Burrows wrote:
Hello again!

Sorry to reply to my own post so soon, but it appears that I have found a
solution that could save someone the trouble of what I just went though.

(on server)
socat /dev/urandom TCP4-LISTEN:9999
(on client - substitute localhost for the servers ip if not localhost)
socat TCP4:localhost:9999 PTY,link=/dev/newrandom,raw,echo=0

The server socat command can be substituted with: ncat -l -k 9999 -c 'cat
/dev/urandom'
I'm not sure if there would be a netcat equivalent of the client connection.
Now you can "dd bs=nnn count=1 /dev/newrandom of=/dev/null" and cat, etc all
works as expected with the newly cloned device.

Ncat doesn't have code to create a pty. You could probably do it with a
fifo:

$ ncat -l -k 9999 --sh-exec "cat /dev/urandom"
$ mkfifo /dev/newrandom
$ ncat localhost 9999 > /dev/newrandom

If you're replacing socat with Ncat on the server, you're doing it the
right way. This is the wrong way:

$ ncat -l -k 9999 < /dev/urandom

The reason that's wrong is that Ncat will accept multiple client
connections, and each one of them will receive the same random bytes.
There's some discussion about this in
http://nmap.org/ncat/guide/ncat-simple-services.html in the chargen
example.

David Fifield
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


Current thread: