how can I run the Thales "NC" diagnostic host command from linux / cygwin console -
i run thales nc (perform diagnostics) host command directly linux / cygwin console.
how can done?
assuming have xxd , nc (netcat) installed, can peform following:
$ echo '0006303030304e43' | xxd -r -p | nc localhost 9998 !0000nd007b44ac1ddee2a94b0007-e000
the command 0006303030304e43 broken down follows:
- 0006 = command length in hex (i.e. length of 0000nc)
- 30303030 = 4 byte header 0000 in hex
- 4e43 = 2 byte command nc in hex
!0000nd007b44ac1ddee2a94b0007-e000 - response hsm.
if don't have xxd, can use perl:
echo '0006303030304e43' | perl -e 'print pack "h*", <stdin>' | nc localhost 9998
update 1: simpler solution:
echo -ne '\x00\x06\x30\x30\x30\x30\x4e\x43' | nc localhost 9998
update 2: pure perl solution:
perl -e 'use io::socket::inet; $sock = new io::socket::inet(peeraddr=>"localhost:9998") or die; $sock->send(pack "h*","0006303030304e43"); $sock->recv($data, 1024); print $data;'
(just copy , paste bash prompt)
Comments
Post a Comment