Advertisement
Doddy

Hex Now 0.1

Mar 15th, 2013
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.65 KB | None | 0 0
  1. #!usr/bin/perl
  2. #HexNow 0.1
  3. #Coded By Doddy H
  4. #Script based in getbytes.py made by hecky neobits
  5. #Thanks to hecky neobits & explorer(perlenespanol)
  6.  
  7. use Getopt::Long;
  8. use File::Basename;
  9. use Cwd;
  10.  
  11. chdir( getcwd() );
  12.  
  13. GetOptions(
  14.     "hex=s"      => \$hex,
  15.     "each=s"     => \$hexeach,
  16.     "output=i"   => \$output,
  17.     "savefile=s" => \$savefile
  18. );
  19.  
  20. head();
  21.  
  22. if ($hex) {
  23.  
  24.     my $code_final;
  25.  
  26.     if ($hexeach) {
  27.  
  28.         my $st = unpack "H*", getcontent($hex);
  29.         my $reco;
  30.  
  31.         for ( my $num = 0 ; $num <= length($st) - 1 ; $num += $hexeach ) {
  32.             my $final = substr $st, $num, $hexeach;
  33.             $reco .= $final . "\n";
  34.         }
  35.  
  36.         $code_final = $reco;
  37.  
  38.     }
  39.     else {
  40.         $code_final = unpack "H*", getcontent($hex);
  41.     }
  42.  
  43.     if ( $output eq "1" ) {
  44.  
  45.         print "\n\n[+] Encoding ....\n";
  46.  
  47.         print "\n[Start]\n\n";
  48.         print $code_final;
  49.         print "\n\n[End]\n";
  50.  
  51.     }
  52.  
  53.     if ($savefile) {
  54.         savefile( $savefile, $code_final );
  55.         print "\n[+] Result generated in : $savefile\n";
  56.     }
  57.     else {
  58.         my $div = basename($hex);
  59.         if ( $div =~ /(.*)\.(.*)/ ) {
  60.             my $listo = $1 . "_hex.txt";
  61.             savefile( $listo, $code_final );
  62.             print "\n[+] Result generated in : $listo\n";
  63.         }
  64.     }
  65.  
  66.     copyright();
  67.  
  68. }
  69.  
  70. sub head {
  71.     print qq(
  72.  
  73.              _____
  74.       ,----/,--.   `.
  75.     /    '. `-'     \         Program Name : HexNow
  76.     | ____ \      '`|_        Version : 0.1
  77.     \'.--._/` _     \ '.       Author : Doddy H
  78.          /'-|/ \|`\|-`  \       Script based in getbytes.py made by hecky neobits  
  79.          /   /       \   |     Thanks to hecky neobits
  80.          |  ;    '`  |  .'
  81.          '. |;;      ;  /
  82.          \ \ ;     / ,'        Examples :
  83.            ;--,   .,--,
  84.         __||=|=|./|=|=||___   perl hexnow.pl -hex imagen.jpg
  85.           `'-'-'  `-'-'`      perl hexnow.pl -hex imagen.jpg -each 5
  86.      ______________________  perl hexnow.pl -hex imagen.jpg -output 1
  87.          /'/ /  \ \ \         perl hexnow.pl -hex imagen.jpg -savefile test.txt
  88.         / '.';  ; \ ' \
  89.        '-/   | ; | ; \-'
  90.          \_| |   | |_/        The End ?
  91.            `-'\_/`-'
  92.  
  93. );
  94. }
  95.  
  96. sub copyright {
  97.     print "\n(C) Doddy Hackman 2013\n";
  98.     exit(1);
  99. }
  100.  
  101. sub getcontent {
  102.  
  103.     open( FILE, $_[0] );
  104.     binmode(FILE);
  105.     my @lines = <FILE>;
  106.     close FILE;
  107.  
  108.     $code = join "", @lines;
  109.     return $code;
  110.  
  111. }
  112.  
  113. sub savefile {
  114.  
  115.     if ( -f $_[0] ) {
  116.         unlink( $_[0] );
  117.     }
  118.  
  119.     open( SAVE, ">>" . $_[0] );
  120.     print SAVE $_[1];
  121.     close SAVE;
  122. }
  123.  
  124. #The End ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement