Ever need a quick and dirty way of getting packet payloads out of one connection and into another? We all know how great netcat and hping are, if only there was some way to unify the two into one glorious (maybe more quick and dirty than glorious, but that’s cool too) packet replay thingummyjig. Well, check out nc2bin below.
#!/usr/bin/perl
#
# Netcat ascii dump to payload converter by Steve of SnakeOil Labs
#
# First get a netcat dump with:
# nc -l -p 137 -u -o netcatdump
# Edit the dump so you only have the hex section, nc2bin only looks at that.
#
# usage: cat netcatdump | nc2bin.pl > ncdump.bin
# then: hping2 -2 -s 137 -p 137
# -d `ls -l ncdump.bin | cut -c41-43`
#
while (
$whoop = substr($_, 11, 48);
@me = split(" ", $whoop);
foreach $gibor(@me){
$baltac = hex($gibor);
print (chr($baltac));
}
}