Implemented basic TUI

This commit is contained in:
Kevin F 2023-03-08 23:08:28 -06:00
parent 21c1d468a4
commit 0cb8c59882
4 changed files with 68 additions and 12 deletions

View File

@ -1,12 +1,12 @@
weave: weave:
srcweave --formatter srcweave-format --weave docs/ ReadMe.md Building.md Dependencies.md EnvironmentVariables.md LICENSE.md \ srcweave --formatter srcweave-format --weave docs/ ReadMe.md Building.md Dependencies.md EnvironmentVariables.md LICENSE.md \
security/Authentication.md security/ThreatModel.md Plumbing.md server/Server.md server/Streaming.md server/Sendkeys.md server/XdotoolCommands.md \ security/Authentication.md security/ThreatModel.md Plumbing.md server/Server.md server/Streaming.md server/Sendkeys.md server/XdotoolCommands.md \
Client.md tools/Tools.md tools/Editor.md tools/Input.md tools/RawCapture.md Client.md tools/Tools.md tools/Editor.md tools/Input.md tools/RawCapture.md tools/TUI.md
util/clean.py util/clean.py
tangle: tangle:
srcweave --formatter srcweave-format --tangle smartkeyboard/ ReadMe.md Plumbing.md security/Authentication.md EnvironmentVariables.md Dependencies.md \ srcweave --formatter srcweave-format --tangle smartkeyboard/ ReadMe.md Plumbing.md security/Authentication.md EnvironmentVariables.md Dependencies.md \
server/Server.md server/Streaming.md server/Sendkeys.md server/XdotoolCommands.md ThreatModel.md Client.md tools/Tools.md tools/Editor.md tools/Input.md \ server/Server.md server/Streaming.md server/Sendkeys.md server/XdotoolCommands.md security/ThreatModel.md Client.md tools/Tools.md tools/Editor.md tools/Input.md \
tools/RawCapture.md tools/RawCapture.md tools/TUI.md
clean: clean:
rm -rf docs rm -rf docs
find smartkeyboard/ -type f -not -name "*_test.go" -delete find smartkeyboard/ -type f -not -name "*_test.go" -delete
@ -20,6 +20,16 @@ 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 -tags osusergo,netgo -o ../../bin/keyboard-client - cd smartkeyboard/client && go build -tags osusergo,netgo -o ../../bin/keyboard-client
- cd smartkeyboard/tools/editor && go mod init keyboard.voidnet.tech
- cd smartkeyboard/tools/editor && go mod tidy
- cd smartkeyboard/tools/editor && go build -tags osusergo,netgo -o ../../../bin/keyboard-editor
- cd smartkeyboard/tools/input && go mod init keyboard.voidnet.tech
- cd smartkeyboard/tools/input && go mod tidy
- cd smartkeyboard/tools/input && go build -tags osusergo,netgo -o ../../../bin/keyboard-input
- cp smartkeyboard/tools/rawcapture/rawcapture.py bin/keyboard-rawcapture.py
- chmod +x bin/keyboard-rawcapture.py
- cp smartkeyboard/tools/tui/tui.py bin/tui.py
- chmod +x bin/tui.py
test: tangle test: tangle
-cd smartkeyboard && go mod init keyboard.voidnet.tech -cd smartkeyboard && go mod init keyboard.voidnet.tech

View File

@ -77,12 +77,6 @@ On first run it will output your authentication token. Store it in a safe place
It is highly recommended to use SSH forwarding (preferred) or a reverse https proxy to access the server. It is highly recommended to use SSH forwarding (preferred) or a reverse https proxy to access the server.
### SSH example
To connect with ssh, run this on the client:
`ssh -R 8080:localhost:8080 user@myserver`
### Socket file ### Socket file
@ -94,5 +88,16 @@ It is more secure and mildly more efficient to use a unix socket file. To do thi
From here you can use any program that can write to a FIFO to send keystrokes to the server. For example, you could use `cat` to send a file to the server, or `cowsay` to send a cow message to the server. From here you can use any program that can write to a FIFO to send keystrokes to the server. For example, you could use `cat` to send a file to the server, or `cowsay` to send a cow message to the server.
### SSH example
To connect with ssh, run this on the client:
`ssh -R 8080:localhost:8080 user@myserver`
You would then run the above keyboard-client command with `ws://localhost:8080/sendkeys` as the argument.
### Tools ### Tools
There are a few tools provided to help you get started. They are all in the `tools` directory.

View File

@ -19,8 +19,8 @@ import (
func main(){ func main(){
var input string var input string
@{get client input file from environment} @{get client fifo input file from environment}
if ! clientFifoInputFileExists { if ! clientFifoInputFileEnvExists {
os.Exit(1) os.Exit(1)
} }
for { for {

View File

@ -1,3 +1,44 @@
# SmartKeyboardTUI # SmartKeyboardTUI
SmartKeyboardTUI is a terminal user interface for SmartKeyboard. It wraps the other tools in this repository. SmartKeyboardTUI is a terminal user interface for SmartKeyboard. It wraps other commands and provides a way to quickly switch between them.
The commands it wraps are arbitrary and defined in commands.txt. The commands.txt file is a simple text file with one command per line. The first word of each line is the command name, and the rest of the line is the command to run. The command name is used to switch to that command. The command is run with the shell, so you can use pipes, redirection, etc.
``` python
--- /tools/tui/tui.py
#!/usr/bin/env python3
import os
import sys
import time
import subprocess
with open("commands.txt") as f:
commands = [line.strip().split(" ", 1) for line in f.readlines()]
output_file = os.getenv("KEYBOARD_FIFO", sys.stdout)
while True:
for c, cmd in enumerate(commands):
print(f"\r{c+1}: {cmd[0]} ")
print('\n\r', end='')
try:
inp = sys.stdin.read(1)
inp = int(inp)
except ValueError:
if inp == "q":
break
inp = 0
continue
if inp < 1 or inp > len(commands):
continue
cmd = commands[inp-1][1]
subprocess.run(cmd, shell=True, stdout=output_file)
print('\n\r')
---
```