-
Notifications
You must be signed in to change notification settings - Fork 0
/
hackertyper.py
67 lines (55 loc) · 1.86 KB
/
hackertyper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import os
import random
from argparse import ArgumentParser
from pynput.keyboard import Listener, KeyCode, Key
from colorama import Fore, Style, init
init() # initialize colorama
parser = ArgumentParser()
parser.add_argument('-f', '--file', help='pick a specific file from the directory')
parser.add_argument('-c', '--color', help='choose the output color. Options:\
black, red, green, yellow, blue, magenta, cyan, white. (Not case sensitive)'
, default='green')
parser.add_argument('-s', '--speed', help='set the speed of the output(default is 4)', default=4, type=int)
parser.add_argument('--bright', help='make the output bright', action='store_true')
_progress = 0
def on_press(key):
global code, _progress, speed
if key == Key.esc:
return False # Stops the listener thread
if '\n' in code[_progress:_progress+speed]:
print(code[_progress:_progress + speed], end='', flush=True)
_progress += speed
while code[_progress:_progress+speed] == ' ':
print(code[_progress:_progress+speed], end='', flush=True)
_progress += speed
else:
print(code[_progress:_progress+speed], end='', flush=True)
_progress += speed
if __name__ == '__main__':
args = parser.parse_args()
speed = args.speed
color = args.color.upper()
if args.bright:
print(Style.BRIGHT, end='')
if args.file:
try:
with open(args.file, 'r') as file:
code = file.read()
except FileNotFoundError:
print(Fore.RED+f'File {args.file} is not found!'+Style.RESET_ALL)
exit()
else:
os.chdir('pwn3r-scripts')
file = random.choice(os.listdir(path='.'))
with open(file, 'r') as file:
code = file.read()
try:
exec(f'print(Fore.{color}, end="")')
except (AttributeError, SyntaxError):
parser.print_help()
exit()
listener = Listener(on_press=on_press, suppress=True) # threading.Thread instance
listener.start()
listener.join()
print(Style.RESET_ALL)
# THE END