Last active
October 3, 2022 20:12
-
-
Save james-see/dd6f14c8b5a023951794153cf2305bc4 to your computer and use it in GitHub Desktop.
using netcat effectively
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Netcat is a great tool to use to listen and forward ports as a simple proxy or routing of data. | |
Example: | |
Usb device connected and running on /dev/bus/usb/002/009 (revealed from lsusb -v command). | |
To get data from the device: | |
cat /dev/bus/usb/002/009/ | |
root@ubuntu-linux-20-04-desktop:/home/parallels# cat /dev/bus/usb/002/009 | hexdump | |
0000000 0112 0110 0000 0800 072f 2200 0216 0201 | |
0000010 0100 0209 005d 0101 8000 09c8 0004 0300 | |
0000020 000b 0000 2136 0100 0700 0002 0000 0fa0 | |
0000030 0000 0fa0 0000 0000 002a 9000 03d0 0000 | |
0000040 0100 0000 0000 0000 0000 0000 0040 0002 | |
0000050 010f 0000 0000 0000 0100 0507 0381 0008 | |
0000060 0732 0205 4002 0100 0507 0282 0040 0001 | |
000006f | |
To use netcat to pipe that data to a local port: | |
root@ubuntu-linux-20-04-desktop:/home/parallels# cat /dev/bus/usb/002/009 \ | |
| hexdump | nc -l localhost 8181 | |
In another terminal window, get the data (or from code you write to get it programmatically streaming in: | |
parallels@ubuntu-linux-20-04-desktop:~$ nc localhost 8181 | |
0000000 0112 0110 0000 0800 072f 2200 0216 0201 | |
0000010 0100 0209 005d 0101 8000 09c8 0004 0300 | |
0000020 000b 0000 2136 0100 0700 0002 0000 0fa0 | |
0000030 0000 0fa0 0000 0000 002a 9000 03d0 0000 | |
0000040 0100 0000 0000 0000 0000 0000 0040 0002 | |
0000050 010f 0000 0000 0000 0100 0507 0381 0008 | |
0000060 0732 0205 4002 0100 0507 0282 0040 0001 | |
000006f | |
As you can see, this is a powerful way to listen and get device data streaming in to evaluate anything plugged in virtually or physically to systems. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment