Payment Systems Tools – Netcat

Netcat is described as the Swiss Army Knife for TCP/IP. I use it in two different ways:

1) Build a small server that dumps the contents it receives to a file. (Helpful for reverse engineering and debugging purposes)

$ nc -l -p 10000 > out.txt

This will set netcat to listen on port 10000 and redirect the output to the file out.txt

For Instance, I configured a client program that sends messages to a server and connected to my localhost:10000 instead:

$hd out.txt

00000000 00 4d 30 31 30 30 70 2000 00 00 c0 00 00 31 36  |.M0100p ……16|

00000010 34 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 |4111111111111111|

00000020 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 31 |0000000000000001|

00000030 30 30 31 32 33 34 35 36 31 32 33 34 35 36 30 31 |0012345612345601|

00000040 31 32 33 34 35 36 30 31 30 31 30 31 30 31 20      |12345601010101 |

This shows me that there is a 2 byte header (00 4d) of 77 bytes in front of this ISO8583 0100 (30 31 30 30) message.

2) Use it as a client to send message dumps. (Helpful for a quick and dirty method to send data over TCP/IP)

$ cat out.txt | nc localhost 10000

This will send the contents of out.txt and ‘pipe’ it to netcat that will attempt to connect to localhost on port 10000 and send the contents of out.txt.

2 Comments

  1. Perl with the IO::Socket module is another very handy tool. It allows you to do other tasks on the data, like verifying the length header, or calculating/verifying the LRC/CRC if one exists in the message.

Leave a Comment.