-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathezDistract.py
More file actions
109 lines (92 loc) · 3.06 KB
/
ezDistract.py
File metadata and controls
109 lines (92 loc) · 3.06 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
"""
Name: Omar Aljaloud
Email: oaa3024@rit.edu
Description: This is a Distraction tool that will be used to distract blue teamers from protecting their machines.
"""
import os
import keyboard
import string
import time
import sys
import argparse
import platform
# A list that contains all the keyboard characters
KEYS = list(string.printable)
def keyClear():
"""
This function will monitor the keys clicked in the keyboard and with each key clicked,
it will clear the terminal.
"""
global KEYS
while True:
# Read the keyboard clicks
key = keyboard.read_key()
if key == '1':
break
if key in KEYS:
# Clear the terminal
if platform.system().lower() == 'linux':
# Clear the terminal
os.system("clear")
if platform.system().lower() == 'windows':
os.system("cls")
time.sleep(1)
def keyAdd():
"""
This function will monitor the keys clicked in the keyboard and with each key clicked,
it will type the same key multiple times in the terminal.
"""
global KEYS
while True:
# Read the keyboard clicks
key = keyboard.read_key()
if key == '1':
break
if key in KEYS:
# Add the same litter in the terminal multiple times.
keyboard.write(key*2)
time.sleep(0.1)
def keyWrite():
"""
This function will monitor the keys clicked in the keyboard and with each key clicked,
it will write a short paragraph(maybe for now it will print O72_is_here) in the terminal.
"""
global KEYS
while True:
key = keyboard.read_key()
if key == '1':
break
if key in KEYS:
# Clear the terminal
os.system("echo O72_is_here")
time.sleep(1)
def arg_parser():
"""
This function gets the inputs from the user to use them in the tools
:return: the Namespace of the input arguments.
"""
parser = argparse.ArgumentParser(prog='ezDistract.py', usage='%(prog)s [options]')
options = parser.add_argument_group('Flag options', '')
options.add_argument('-c', '--clear', action='store_true', help='Clears the terminal as soon as the user click'
'any key in the keyboard')
options.add_argument('-a', '--add', action='store_true', help='Add the same key multiple times in the terminal')
options.add_argument('-w', '--write', action='store_true', help='Write sentences in terminal as soon as the user'
'click any key in the keyboard')
if len(sys.argv) != 2:
parser.print_help()
sys.exit(1)
args = parser.parse_args()
return args
def main():
"""
Read the flag that is given with the tool then it will call the right function.
"""
args = arg_parser()
if args.clear:
keyClear()
if args.add:
keyAdd()
if args.write:
keyWrite()
if __name__ == "__main__":
main()