Question

I would like to run the Thales NC (Perform Diagnostics) host command directly from a linux / cygwin console.

How can this be done?

Was it helpful?

Solution

Assuming you have xxd and nc (netcat) installed, you can peform the following:

$ echo '0006303030304e43' | xxd -r -p | nc localhost 9998
!0000ND007B44AC1DDEE2A94B0007-E000

The command 0006303030304e43 is broken down as follows:

  • 0006 = the command length in hex (i.e. length of 0000NC)
  • 30303030 = the 4 byte header 0000 in hex
  • 4e43 = the 2 byte command NC in hex

!0000ND007B44AC1DDEE2A94B0007-E000 - this is the response from the HSM.


If you don't have xxd, you can use Perl:

echo '0006303030304e43' | perl -e 'print pack "H*", <STDIN>' | nc localhost 9998

UPDATE 1: An even simpler solution:

echo -ne '\x00\x06\x30\x30\x30\x30\x4e\x43' | nc localhost 9998

UPDATE 2: A pure perl solution:

perl -e 'use IO::Socket::INET; 
my $sock = new IO::Socket::INET(PeerAddr=>"localhost:9998") or die; 
$sock->send(pack "H*","0006303030304e43"); 
$sock->recv($data, 1024); print $data;'

(just copy and paste into your bash prompt)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top