-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathporta_ptyspawn.py
More file actions
111 lines (87 loc) · 2.7 KB
/
Copy pathporta_ptyspawn.py
File metadata and controls
111 lines (87 loc) · 2.7 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
110
111
#! /usr/bin/python3
import os
import sys
import platform
import pty
import time
# """ Python3 script to detect the local operating system (OS)
# and processor architecture (ARCH),
# then spawn an appropriate shell
# on the system ... """
def get_platform() -> str:
"""Finds the Operating System platform/family:
e.g: 'win32' | 'darwin' | 'linux' | [...]
Returns system platform found, as a String."""
platform_found = False
# platform eg.: 'darwin' | 'win32' | 'linux' | 'aix' | ...
try:
OS_PLATFORM = sys.platform
print(f"[+] Operating System identified as: *** {OS_PLATFORM} ***")
platform_found = True
except os.error as e:
print("[-] There was a problem identifying this systems OS-Platform: ", e)
def get_arch() -> str:
"""Finds the Processor Architecture of the systems OS.
e.g: 'x86' | 'x86-64' | 'arm64' | [...]
Returns Architecture found, as a String"""
arch_found = False
# architecture eg.: 'x86' | 'x86-64' | 'arm64' | 'arm32'
try:
OS_ARCH = os.uname().machine
print(f"[+] Processor Architecture identified as: *** {OS_ARCH} ***")
arch_found = True
except os.error as e:
print(
"[-] There was a problem identifying this systems Processor-Architecture:",
e,
)
def char_timer(s: int) -> int:
"""Takes one int: Number of Seconds - as Argument.
Returns one int: Number of chars printed."""
end = s + 1
num = 0
# start charTimer printing ...
for i in range(end):
if i == 0:
print("# ", end="")
time.sleep(2)
num += 2
elif i == s:
print(".")
time.sleep(1)
break
else:
print(".", end="")
time.sleep(1)
num += 1
# Return number of chars printed...
return num
def main():
OS_PLATFORM = get_platform()
OS_ARCH = get_arch()
if OS_PLATFORM and OS_ARCH:
print(
"""
***************************************
*** Script executed successfully! ***
***************************************
"""
)
time.sleep(1.4)
print("[+] Found system platform (OS)")
time.sleep(0.7)
print("[+] Found processor architecture (SysArch)")
time.sleep(0.7)
print("[+] *** Now spawning Shell ***\n")
time.sleep(2)
# start char timer
char_timer(7)
# case clauses OR if-elif-else clauses:
# to determine specific OS/Arch Combination
# and spawn an appropriate shell ...
# cases:
# ...
# to be continued ... (18.9.2021 - 8:15am)
def main():
if __name__ == "__main__":
main()