#!/usr/bin/perl
#s0t4ipv6@shellcode.com.ar

$version="0001";
$tab=5;

if($ARGV[0] eq "-h"||!defined($ARGV[0]))
{
    print "./string v".$version." coded by s0t4ipv6\n";
    print "use: string [-h] | <file objdump>\n";
    exit(0);
}

if (!defined($ARGV[0])) { exit(0); }

$fileobj=$ARGV[0];

open(ABRIR,"< $fileobj") ;

while (<ABRIR>) { 
	chomp; 
	@address=split(":",$_); 
	
	foreach $opcode ($address[1]) {
		$opcode=~ s/\t//g;
		@all=split(/ /,$opcode);
		print "\"";
		$activate=$count=0;
		foreach $opc (@all) {

			if ( length($opc) != 0 ) {

				if ( length($opc) < 3 ) {
					print "\\x".$opc;
					$count++;
					} else { $activate++ }

				if ( $activate == 1 && length($opc) >2 ) {
					print "\"";
					if ( $count > 2 && $count < 5) { $count--; }
					if ( $count > 4 && $count < 8) { $count-=2; }
					print "\t"x($tab-$count);
					print "\/\/ ".$opc;
					if (length($opc) >2 && length($opc) < 5) { print "\t" }
					}
				if ( $activate > 1  ) { print "\t".$opc; }
				}	

			} 
			print "\n";
		}
	}

close (ABRIR);

