-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfake_process.py
More file actions
73 lines (59 loc) · 2.07 KB
/
Copy pathfake_process.py
File metadata and controls
73 lines (59 loc) · 2.07 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
import subprocess
import random
import time
class FakeSubprocess(object):
def selector(self, subprocess):
func_name = subprocess
func = getattr(self, func_name, lambda: 'Invalid')
return func()
def ls(self):
print("\n")
print("ls")
return subprocess.run('ls')
def ping(self):
print("ping")
subprocess.run(['ping', "8.8.8.8"])
def nbtstat(self):
print("nbtstat")
result = subprocess.run('nbtstat -c', stdout=subprocess.PIPE).stdout.decode('utf-8')
self.slow_output(result)
def netstat(self):
print("netstat")
result = subprocess.run('netstat', stdout=subprocess.PIPE).stdout.decode('utf-8')
self.slow_output(result)
def processes(self):
print("processes")
subprocess.run('ps -a')
def tasklist(self):
print("tasklist")
result = subprocess.run('tasklist', stdout=subprocess.PIPE).stdout.decode('utf-8')
self.slow_output(result)
def route(self):
print("route")
result = subprocess.run('route PRINT', stdout=subprocess.PIPE).stdout.decode('utf-8')
self.slow_output(result)
def system_info(self):
print("system info")
result = subprocess.run('systeminfo', stdout=subprocess.PIPE).stdout.decode('utf-8')
self.slow_output(result)
def tracert(self):
print("tracert")
subprocess.run('tracert 8.8.8.8')
def nslookup(self):
print("nslookup")
subprocess.run('nslookup www.google.com')
def ipconfig(self):
print("ipconfig")
result = subprocess.run('ipconfig', stdout=subprocess.PIPE).stdout.decode('utf-8')
self.slow_output(result)
def slow_output(self, result):
data_line = []
for i in result:
data_line.append(i)
if i == '\n':
joined = ''.join(data_line)
print(joined[:-2])
data_line = []
rando_sleepo = random.randint(1, 10)
rando_sleepo /= 50
time.sleep(rando_sleepo)