Sunday, February 1, 2009

Helpful perl scripts for ASM/Shellcode

I've just knocked up some helpful perl scripts to convert objdump output to shellcode (shellcode.pl) and to convert ascii text to hex (ascii2hex).

shellcode.pl

#!/usr/bin/perl

while( <> )
{

my @input=split('\s');

foreach ( @input )
{
if ( $_ =~ /^[0-9abcdef]{2}$/ )
{
print "\\x" . $_ ;
}
}
}
print "\n";



usage: objdump -ds | shellcode.pl


ascii2hex.pl

#!/usr/bin/perl

while(<>)
{
chomp;
my @input=split(//);

foreach ( @input )
{
printf("%x ",ord($_));
}
}
print "\n";


usage: echo "This is a string" | ascii2hex.pl

No comments: