FlyFar

Keylogger/assets

Oct 25th, 2021 (edited)
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.72 KB | None | 0 0
  1. keymap = open("keymaps.txt", "r")
  2. keymap_linelist=keymap.readlines()
  3. keymap.close()
  4.  
  5.  
  6. keylogger = open("logger.txt", "r")
  7. keylogger_linelist=keylogger.readlines()
  8. keylogger.close()
  9.  
  10.  
  11.  
  12.  
  13. kmlist={}
  14.  
  15.  
  16. # This loop to generate the list of keymaps
  17.    
  18.  
  19. for i in keymap_linelist:
  20.     i=i.split()
  21.     l=len(i)
  22.     if(l==4):
  23.         kmlist[i[1]]=i[3]
  24.     elif(l==5):
  25.         kmlist[i[2]]=i[4]
  26.     else:
  27.         continue
  28.  
  29. #kmlist dict generated with keycode:key
  30.  
  31. klist=kmlist.keys()
  32.  
  33. #print klist
  34.  
  35. kllist=[]
  36. st=0
  37. for j in keylogger_linelist:
  38.     j=j.split()
  39.  
  40.     l=len(j)
  41.  
  42.  
  43.     if l==3:
  44.                 if j[1]=='14'and len(kllist)!=0:
  45.                     kllist.pop()
  46.  
  47.  
  48.         elif j[2]=='release':
  49.                         if j[1]=='42' and st==1:
  50.                 kllist.append(j[1])
  51.                                 st = 0
  52.                 kllist.append('<released>')
  53.  
  54.             else:
  55.                 continue
  56.         else:
  57.                         if j[1]=='42' and st==1:
  58.                             continue
  59.            
  60.             elif j[1]=='42'and st==0:  
  61.                 kllist.append(j[1])
  62.                             kllist.append('<pressed>')
  63.                             st=1
  64.                        
  65.                         elif j[1]!='42':
  66.                 kllist.append(j[1])
  67.                        
  68.                         else:
  69.                             continue
  70.  
  71.  
  72. #kllist is generated with codes of input from logger.txt
  73.  
  74.  
  75. #print kllist
  76.  
  77.  
  78.  
  79. #Now to decode the keycodes using kmlist dict and writing them in log file
  80.  
  81. output=open("output.log","w")
  82.  
  83. for x in kllist:
  84.     for y in klist:
  85.         if x==y:
  86.             output.write(kmlist[y])
  87.    
  88.  
  89.     if x=='<pressed>':
  90.         output.write('<pressed>')
  91.     elif x=='<released>':
  92.         output.write('<released>')
  93.  
  94.     #output.write("\n")
  95.            
  96.  
  97. output.close()
  98.  
  99.  
  100.  
  101. #end of program
  102.  
Add Comment
Please, Sign In to add comment