Ubuntu netcat

From richud.com
Jump to navigation Jump to search

Netcat / nc

Fantastic little program!

network dump of a partition

e.g.

#TARGET
#netcat listens on port 7000, any data it receives is gunzipped and piped to dd which writes it to partition, in this case partition 4
nc -l -p 7000 | gzip -dfc | dd of=/dev/sda4
#SOURCE
#dd reads in the test.raw raw image from current path, gzips it up and pipes it to netcat which connects to IP 192.168.2.56 on port 7000
dd if=test.raw | gzip -cf | nc 192.168.2.56 7000 -q 10

network dump qcow2 image to hdd

Dump a qemu .qcow2 VM over network to another pc. Mount the qcow2 image with nbd and dump as a block device via dd. Very fast!

Source

sudo -i
qemu-nbd -c /dev/nbd0 kodi.qcow2
dd if=/dev/nbd0 | gzip -cf | nc 192.168.0.8 7000 -q 10

Target

sudo -i
nc -l -p 7000 | gzip -dfc | dd of=/dev/sda