Compare commits
No commits in common. "7f1d95183ed3efc4220416ff727fe2654f7764c4" and "304ea888ff84be7ad72a52558f39050543d848f3" have entirely different histories.
7f1d95183e
...
304ea888ff
@ -30,7 +30,7 @@ We use keylogger to get keyboard input on the client and simulate keystrokes on
|
|||||||
|
|
||||||
--- keylogger import string
|
--- keylogger import string
|
||||||
|
|
||||||
"github.com/EgosOwn/keylogger"
|
"github.com/MarinX/keylogger"
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
4
Makefile
4
Makefile
@ -19,7 +19,9 @@ build: tangle
|
|||||||
- cd smartkeyboard/client && go mod init keyboard.voidnet.tech
|
- cd smartkeyboard/client && go mod init keyboard.voidnet.tech
|
||||||
- cd smartkeyboard/client && go mod tidy
|
- cd smartkeyboard/client && go mod tidy
|
||||||
- cd smartkeyboard/client && go build -o ../../bin/keyboard-client
|
- cd smartkeyboard/client && go build -o ../../bin/keyboard-client
|
||||||
|
- cd smartkeyboard/tools/rawcapture && go mod init rawcapture.keyboard.voidnet.tech
|
||||||
|
- cd smartkeyboard/tools/rawcapture && go mod tidy
|
||||||
|
- cd smartkeyboard/tools/rawcapture && go build -o ../../../bin/rawcapture
|
||||||
|
|
||||||
|
|
||||||
test: tangle
|
test: tangle
|
||||||
|
@ -51,13 +51,6 @@ markdown book is actually the source code
|
|||||||
* Well defined [threat model](ThreatModel.md)
|
* Well defined [threat model](ThreatModel.md)
|
||||||
|
|
||||||
|
|
||||||
# Running
|
|
||||||
|
|
||||||
## Server
|
|
||||||
|
|
||||||
`sudo KEYBOARD_TCP_BIND_ADDRESS=0.0 KEYBOARD_TCP_BIND_PORT=8080 ./keyboard`
|
|
||||||
|
|
||||||
|
|
||||||
# Entrypoint
|
# Entrypoint
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
This tool captures keyboard input from /dev/input/eventX and pipes it to the fifo accordingly.
|
This tool captures keyboard input from /dev/input/eventX and pipes it to the fifo accordingly.
|
||||||
|
|
||||||
An escape sequence of QKEYBOARD (QWERTY) will exit the program, but this can be changed via a command line argument.
|
It is meant to be ran from it's own tty, and is not meant to be used with a graphical environment, although a full screen terminal emulator will work for most input.
|
||||||
|
|
||||||
|
An escape sequence of escape+f1 will exit the program, but this can be changed via a command line argument.
|
||||||
|
|
||||||
|
|
||||||
## Why
|
## Why
|
||||||
@ -13,249 +15,87 @@ Generally a user would be in this mode when not typing extensively.
|
|||||||
|
|
||||||
# Entrypoint
|
# Entrypoint
|
||||||
|
|
||||||
``` python
|
``` go
|
||||||
|
|
||||||
--- /tools/rawcapture/rawcapture.py
|
--- /tools/rawcapture/rawcapture.go
|
||||||
|
|
||||||
#!/usr/bin/python3
|
package main
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import evdev
|
|
||||||
import traceback
|
|
||||||
import queue
|
|
||||||
import threading
|
|
||||||
|
|
||||||
# Docs http://python-evdev.readthedocs.io/en/latest/tutorial.html
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
//"os/signal"
|
||||||
|
"github.com/MarinX/keylogger"
|
||||||
|
)
|
||||||
|
//ioutil.WriteFile(clientFifoInputFile, []byte(input), 0644)
|
||||||
|
|
||||||
device = ""
|
/*
|
||||||
|
func receive(signalCh chan os.Signal, doneCh chan struct{}) {
|
||||||
fifo = os.getenv("KEYBOARD_FIFO", "")
|
for {
|
||||||
if not fifo:
|
select {
|
||||||
print("KEYBOARD_FIFO not set, exiting.")
|
// Example. Process to receive a message
|
||||||
exit(0)
|
// case msg := <-receiveMessage():
|
||||||
|
case <-signalCh:
|
||||||
try:
|
pass
|
||||||
dev_path = sys.argv[1]
|
}
|
||||||
try:
|
}
|
||||||
device = evdev.InputDevice(dev_path)
|
|
||||||
except PermissionError:
|
|
||||||
print("Insufficent permission to read, run me as root!")
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
except IndexError:
|
|
||||||
foundDev = []
|
|
||||||
allDev = [evdev.InputDevice(dev) for dev in evdev.list_devices()]
|
|
||||||
if len(allDev) == 0:
|
|
||||||
print("No devices found, run me as root!")
|
|
||||||
exit(0)
|
|
||||||
print("Found the following USB input devices: ")
|
|
||||||
count = 0
|
|
||||||
for device in allDev:
|
|
||||||
if "usb" in device.phys:
|
|
||||||
count += 1
|
|
||||||
foundDev.append(device)
|
|
||||||
print(str(count) + ". " + device.name, device.fn)
|
|
||||||
|
|
||||||
print("Select a device (1 to %s)" % str(len(foundDev)), end=" ")
|
|
||||||
i = int(input())
|
|
||||||
i -= 1
|
|
||||||
device = foundDev[i]
|
|
||||||
|
|
||||||
print("Using device " + device.fn)
|
|
||||||
|
|
||||||
print("Grabbing device for exclusive access.")
|
|
||||||
device.grab()
|
|
||||||
print("Enter numbers, press enter (Ctrl-C to exit).")
|
|
||||||
|
|
||||||
write_queue = queue.Queue()
|
|
||||||
def write_loop():
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
data = write_queue.get()
|
|
||||||
with open(fifo, "w") as f:
|
|
||||||
f.write(data)
|
|
||||||
except Exception as e:
|
|
||||||
print("Error writing to fifo: " + str(e))
|
|
||||||
traceback.print_exc()
|
|
||||||
|
|
||||||
write_thread = threading.Thread(target=write_loop, daemon=True)
|
|
||||||
write_thread.start()
|
|
||||||
|
|
||||||
KEYMAP = {
|
|
||||||
1: "ESC",
|
|
||||||
2: "1",
|
|
||||||
3: "2",
|
|
||||||
4: "3",
|
|
||||||
5: "4",
|
|
||||||
6: "5",
|
|
||||||
7: "6",
|
|
||||||
8: "7",
|
|
||||||
9: "8",
|
|
||||||
10: "9",
|
|
||||||
11: "0",
|
|
||||||
12: "-",
|
|
||||||
13: "=",
|
|
||||||
14: "BS",
|
|
||||||
15: "TAB",
|
|
||||||
16: "Q",
|
|
||||||
17: "W",
|
|
||||||
18: "E",
|
|
||||||
19: "R",
|
|
||||||
20: "T",
|
|
||||||
21: "Y",
|
|
||||||
22: "U",
|
|
||||||
23: "I",
|
|
||||||
24: "O",
|
|
||||||
25: "P",
|
|
||||||
26: "[",
|
|
||||||
27: "]",
|
|
||||||
28: "ENTER",
|
|
||||||
29: "L_CTRL",
|
|
||||||
30: "A",
|
|
||||||
31: "S",
|
|
||||||
32: "D",
|
|
||||||
33: "F",
|
|
||||||
34: "G",
|
|
||||||
35: "H",
|
|
||||||
36: "J",
|
|
||||||
37: "K",
|
|
||||||
38: "L",
|
|
||||||
39: ";",
|
|
||||||
40: "'",
|
|
||||||
41: "`",
|
|
||||||
42: "L_SHIFT",
|
|
||||||
43: "\\",
|
|
||||||
44: "Z",
|
|
||||||
45: "X",
|
|
||||||
46: "C",
|
|
||||||
47: "V",
|
|
||||||
48: "B",
|
|
||||||
49: "N",
|
|
||||||
50: "M",
|
|
||||||
51: ",",
|
|
||||||
52: ".",
|
|
||||||
53: "/",
|
|
||||||
54: "R_SHIFT",
|
|
||||||
55: "*",
|
|
||||||
56: "L_ALT",
|
|
||||||
57: "SPACE",
|
|
||||||
58: "CAPS_LOCK",
|
|
||||||
59: "F1",
|
|
||||||
60: "F2",
|
|
||||||
61: "F3",
|
|
||||||
62: "F4",
|
|
||||||
63: "F5",
|
|
||||||
64: "F6",
|
|
||||||
65: "F7",
|
|
||||||
66: "F8",
|
|
||||||
67: "F9",
|
|
||||||
68: "F10",
|
|
||||||
69: "NUM_LOCK",
|
|
||||||
70: "SCROLL_LOCK",
|
|
||||||
71: "HOME",
|
|
||||||
72: "UP_8",
|
|
||||||
73: "PGUP_9",
|
|
||||||
74: "-",
|
|
||||||
75: "LEFT_4",
|
|
||||||
76: "5",
|
|
||||||
77: "RT_ARROW_6",
|
|
||||||
78: "+",
|
|
||||||
79: "END_1",
|
|
||||||
80: "DOWN",
|
|
||||||
81: "PGDN_3",
|
|
||||||
82: "INS",
|
|
||||||
83: "DEL",
|
|
||||||
84: "",
|
|
||||||
85: "",
|
|
||||||
86: "",
|
|
||||||
87: "F11",
|
|
||||||
88: "F12",
|
|
||||||
89: "",
|
|
||||||
90: "",
|
|
||||||
91: "",
|
|
||||||
92: "",
|
|
||||||
93: "",
|
|
||||||
94: "",
|
|
||||||
95: "",
|
|
||||||
96: "R_ENTER",
|
|
||||||
97: "R_CTRL",
|
|
||||||
98: "/",
|
|
||||||
99: "PRT_SCR",
|
|
||||||
100: "R_ALT",
|
|
||||||
101: "",
|
|
||||||
102: "HOME",
|
|
||||||
103: "UP",
|
|
||||||
104: "PGUP",
|
|
||||||
105: "LEFT",
|
|
||||||
106: "RIGHT",
|
|
||||||
107: "END",
|
|
||||||
108: "DOWN",
|
|
||||||
109: "PGDN",
|
|
||||||
110: "INSERT",
|
|
||||||
111: "DEL",
|
|
||||||
112: "",
|
|
||||||
113: "",
|
|
||||||
114: "",
|
|
||||||
115: "",
|
|
||||||
116: "",
|
|
||||||
117: "",
|
|
||||||
118: "",
|
|
||||||
119: "PAUSE",
|
|
||||||
120: "",
|
|
||||||
121: "",
|
|
||||||
122: "",
|
|
||||||
123: "",
|
|
||||||
124: "",
|
|
||||||
125: "SUPER"
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
key_str = ""
|
func main(){
|
||||||
log = []
|
@{get client fifo input file from environment}
|
||||||
quit_str = "QKEYBOARD"
|
if ! clientFifoInputFileEnvExists {
|
||||||
quit_list = []
|
os.Exit(1)
|
||||||
for c in quit_str:
|
}
|
||||||
for k, v in KEYMAP.items():
|
|
||||||
if v == c:
|
|
||||||
quit_list.append(k)
|
|
||||||
break
|
|
||||||
|
|
||||||
def quit_if_necessry(log):
|
/*
|
||||||
if len(log) > len(quit_list):
|
doneCh := make(chan struct{})
|
||||||
log.pop(0)
|
|
||||||
if log == quit_list:
|
|
||||||
print("Quitting...")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
try:
|
signalCh := make(chan os.Signal, 1)
|
||||||
for event in device.read_loop():
|
signal.Notify(signalCh, os.Interrupt)
|
||||||
|
|
||||||
if event.type == evdev.ecodes.EV_KEY:
|
go receive(signalCh, doneCh)
|
||||||
print(event)
|
*/
|
||||||
#e_code = event.code - 1
|
|
||||||
e_code = event.code
|
|
||||||
if e_code == 2:
|
|
||||||
break
|
|
||||||
try:
|
|
||||||
key_str = KEYMAP[e_code]
|
|
||||||
except KeyError:
|
|
||||||
print("Unknown key: " + str(e_code))
|
|
||||||
if event.value == 1:
|
|
||||||
key_str = "{KEYDWN}" + key_str
|
|
||||||
log.append(e_code)
|
|
||||||
quit_if_necessry(log)
|
|
||||||
elif event.value == 0:
|
|
||||||
key_str = "{KEYUP}" + key_str
|
|
||||||
else:
|
|
||||||
print("Unknown value: " + str(event.value))
|
|
||||||
continue
|
|
||||||
write_queue.put(key_str)
|
|
||||||
sys.stdout.flush()
|
|
||||||
|
|
||||||
except (KeyboardInterrupt, SystemExit, OSError):
|
keyboard := keylogger.FindKeyboardDevice()
|
||||||
print(traceback.format_exc())
|
if keyboard == "" {
|
||||||
device.ungrab()
|
os.Exit(1)
|
||||||
print("\rGoodbye!")
|
}
|
||||||
exit(0)
|
k, err := keylogger.New(keyboard)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("could not get keyboard")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
events := k.Read()
|
||||||
|
var key = ""
|
||||||
|
//byte keyByte = 0
|
||||||
|
|
||||||
|
// range of events
|
||||||
|
for e := range events {
|
||||||
|
switch e.Type {
|
||||||
|
// EvKey is used to describe state changes of keyboards, buttons, or other key-like devices.
|
||||||
|
// check the input_event.go for more events
|
||||||
|
case keylogger.EvKey:
|
||||||
|
key = e.KeyString()
|
||||||
|
if len(key) == 0{
|
||||||
|
fmt.Println(e.Code)
|
||||||
|
}
|
||||||
|
// if the state of key is pressed
|
||||||
|
if e.KeyPress() {
|
||||||
|
ioutil.WriteFile(clientFifoInputFile, []byte(fmt.Sprintf("{KEYDWN}%s", key)), 0644)
|
||||||
|
//fmt.Println(e.Code)
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the state of key is released
|
||||||
|
if e.KeyRelease() {
|
||||||
|
ioutil.WriteFile(clientFifoInputFile, []byte(fmt.Sprintf("{KEYUP}%s", key)), 0644)
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
---
|
---
|
||||||
```
|
```
|
@ -1,3 +0,0 @@
|
|||||||
# SmartKeyboardTUI
|
|
||||||
|
|
||||||
SmartKeyboardTUI is a terminal user interface for SmartKeyboard. It wraps the other tools in this repository.
|
|
Loading…
Reference in New Issue
Block a user