Skip to content

Commit 07dc845

Browse files
committed
Release 1.0.1
1 parent ad166b5 commit 07dc845

39 files changed

Lines changed: 6284 additions & 1777 deletions

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
.DS_Store
2-
.vscode
2+
.vscode/
33
__pycache__/
44
*.pyc
55
build/
66
dist/
77
*.egg-info/
8-
test_inputs/
8+
ffuf/
9+
katana/
10+
urls.txt
911
Development/
1012
tests/
1113
test_inputs/
12-

AD/DBeaverdecrypt.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,37 @@
1717
[186, 187, 74, 159, 119, 74, 184, 83, 201, 108, 45, 101, 61, 254, 84, 74]
1818
)
1919

20+
RED = "\033[31m"
21+
BLUE = "\033[34m"
22+
RESET = "\033[0m"
23+
24+
25+
def create_argument_parser(*args, **kwargs):
26+
try:
27+
return argparse.ArgumentParser(*args, color=False, **kwargs)
28+
except TypeError:
29+
return argparse.ArgumentParser(*args, **kwargs)
30+
31+
32+
def print_banner():
33+
lines = [
34+
f"{RED} ____ ____ ____ _ {RESET}",
35+
f"{BLUE}| _ \\| __ ) ___ __ ___ _____ _ __ | _ \\ ___ ___ _ __ _ _ _ __| |_ {RESET}",
36+
f"{RED}| | | | _ \\ / _ \\/ _` \\ \\ / / _ \\ '__| | | | |/ _ \\/ __| '__| | | | '_ \\ __|{RESET}",
37+
f"{BLUE}| |_| | |_) | __/ (_| |\\ V / __/ | | |_| | __/ (__| | | |_| | |_) | |_ {RESET}",
38+
f"{RED}|____/|____/ \\___|\\__,_| \\_/ \\___|_| |____/ \\___|\\___|_| \\__, | .__/ \\__|{RESET}",
39+
f"{BLUE} |___/|_| {RESET}",
40+
]
41+
for line in lines:
42+
print(line)
43+
44+
print(
45+
"\nDecrypt saved DBeaver credentials from credentials-config.json.\n"
46+
)
47+
2048

2149
def parse_args(argv=None):
22-
parser = argparse.ArgumentParser(
50+
parser = create_argument_parser(
2351
description="Decrypt DBeaver credentials-config.json."
2452
)
2553
parser.add_argument(
@@ -115,7 +143,7 @@ def main(argv=None):
115143
print(f"Error: {exc}", file=sys.stderr)
116144
return 1
117145

118-
print(filepath)
146+
print_banner()
119147
print(format_output(plaintext))
120148
return 0
121149

AD/DomainSid-Hex.py

100755100644
Lines changed: 166 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,80 +2,192 @@
22
"""
33
SID Converter Script
44
5-
This script converts a Domain SID from its standard string format to a hexadecimal representation.
6-
7-
Usage:
8-
python3 ScriptName.py -s S-1-5-21-1154311717-913441446-2400334863-1114
5+
This script converts a Domain SID from its standard string format to a
6+
hexadecimal representation.
97
"""
108

11-
import sys
129
import argparse
13-
from struct import pack
14-
from typing import Any
10+
import shutil
11+
import subprocess
12+
import sys
1513

1614

17-
def convert_sid_to_hex(sid: str) -> str:
18-
"""
19-
Convert a SID string to its hexadecimal representation.
20-
"""
21-
items = sid.split('-')
22-
if len(items) < 4 or items[0] != "S":
23-
raise ValueError("Invalid SID format. It should start with 'S' and contain at least 4 parts.")
24-
15+
GREEN = "\033[1;92m"
16+
MAX_IDENTIFIER_AUTHORITY = (1 << 48) - 1
17+
MAX_SUB_AUTHORITY = (1 << 32) - 1
18+
RESET = "\033[0m"
19+
20+
21+
def create_argument_parser(*args, **kwargs):
2522
try:
26-
revision = pack('B', int(items[1]))
27-
dash_number = pack('B', len(items) - 3)
28-
identifier_authority = b'\x00\x00' + pack('>L', int(items[2]))
29-
except Exception as e:
30-
raise ValueError("Error processing SID components. Please check the input format.") from e
23+
return argparse.ArgumentParser(*args, color=False, **kwargs)
24+
except TypeError:
25+
return argparse.ArgumentParser(*args, **kwargs)
26+
3127

32-
sub_authority = b''
28+
def parse_int_in_range(value: str, label: str, minimum: int, maximum: int) -> int:
3329
try:
34-
for i in range(len(items) - 3):
35-
sub_authority += pack('<L', int(items[i + 3]))
36-
except Exception as e:
37-
raise ValueError("Error processing sub-authority values.") from e
30+
parsed = int(value, 10)
31+
except ValueError as exc:
32+
raise ValueError(f"Invalid {label}: {value}") from exc
33+
34+
if not (minimum <= parsed <= maximum):
35+
raise ValueError(
36+
f"{label.capitalize()} out of range: {value} "
37+
f"(expected {minimum}..{maximum})"
38+
)
39+
40+
return parsed
3841

39-
hex_sid = revision + dash_number + identifier_authority + sub_authority
40-
return '0x' + ''.join('{:02X}'.format(b) for b in hex_sid)
4142

43+
def parse_sid_components(sid: str):
44+
items = sid.strip().split("-")
45+
if len(items) < 4 or items[0] != "S":
46+
raise ValueError(
47+
"Invalid SID format. It should start with 'S-' and contain at least 4 parts."
48+
)
4249

43-
def parse_arguments() -> argparse.Namespace:
44-
"""
45-
Parse command line arguments.
46-
"""
47-
parser = argparse.ArgumentParser(
48-
description="Convert SID from string format to hexadecimal."
50+
revision = parse_int_in_range(items[1], "revision", 0, 255)
51+
identifier_authority = parse_int_in_range(
52+
items[2],
53+
"identifier authority",
54+
0,
55+
MAX_IDENTIFIER_AUTHORITY,
56+
)
57+
58+
sub_authorities = []
59+
for raw_value in items[3:]:
60+
sub_authorities.append(
61+
parse_int_in_range(
62+
raw_value,
63+
"sub-authority",
64+
0,
65+
MAX_SUB_AUTHORITY,
66+
)
67+
)
68+
69+
if len(sub_authorities) > 255:
70+
raise ValueError("SID contains too many sub-authorities.")
71+
72+
return revision, identifier_authority, sub_authorities
73+
74+
75+
def convert_sid_to_hex(sid: str) -> str:
76+
revision, identifier_authority, sub_authorities = parse_sid_components(sid)
77+
78+
sid_bytes = bytearray()
79+
sid_bytes.append(revision)
80+
sid_bytes.append(len(sub_authorities))
81+
sid_bytes.extend(identifier_authority.to_bytes(6, byteorder="big"))
82+
83+
for sub_authority in sub_authorities:
84+
sid_bytes.extend(sub_authority.to_bytes(4, byteorder="little"))
85+
86+
return "0x" + sid_bytes.hex().upper()
87+
88+
89+
def build_parser() -> argparse.ArgumentParser:
90+
parser = create_argument_parser(
91+
description="Convert SID from string format to hexadecimal.",
92+
add_help=False,
4993
)
5094
parser.add_argument(
51-
"-s", "--sid",
95+
"-s",
96+
"--sid",
5297
type=str,
53-
help="Domain SID in standard format (e.g. S-1-5-21-1154311717-913441446-2400334863-1114)"
98+
help=(
99+
"Domain SID in standard format "
100+
"(e.g. S-1-5-21-1154311717-913441446-2400334863-1114)"
101+
),
54102
)
55-
if len(sys.argv) == 1:
56-
parser.print_help()
57-
sys.exit(1)
58-
59-
return parser.parse_args()
103+
parser.add_argument(
104+
"-h",
105+
"--help",
106+
action="store_true",
107+
help="Show this help message and exit.",
108+
)
109+
return parser
110+
111+
112+
def clipboard_commands() -> list[list[str]]:
113+
commands = []
114+
candidates = [
115+
["pbcopy"],
116+
["wl-copy"],
117+
["xclip", "-selection", "clipboard"],
118+
["xsel", "--clipboard", "--input"],
119+
["clip.exe"],
120+
["clip"],
121+
[
122+
"powershell.exe",
123+
"-NoProfile",
124+
"-Command",
125+
"Set-Clipboard -Value ([Console]::In.ReadToEnd())",
126+
],
127+
]
128+
for command in candidates:
129+
if shutil.which(command[0]):
130+
commands.append(command)
131+
return commands
132+
133+
134+
def copy_to_clipboard(text: str) -> bool:
135+
for command in clipboard_commands():
136+
try:
137+
completed = subprocess.run(
138+
command,
139+
input=text,
140+
text=True,
141+
capture_output=True,
142+
check=False,
143+
)
144+
except OSError:
145+
continue
146+
if completed.returncode == 0:
147+
return True
148+
return False
60149

61150

62-
def main() -> None:
63-
"""
64-
Main function that handles argument parsing, SID conversion, and result output.
65-
"""
66-
args: argparse.Namespace = parse_arguments()
151+
def print_green_status(message: str) -> None:
152+
print(f"{GREEN}{message}{RESET}", file=sys.stderr, flush=True)
153+
154+
155+
def main(argv=None) -> int:
156+
argv_list = list(sys.argv[1:] if argv is None else argv)
157+
parser = build_parser()
158+
159+
if not argv_list:
160+
parser.print_help(sys.stderr)
161+
return 1
162+
163+
args = parser.parse_args(argv_list)
164+
165+
if args.help:
166+
parser.print_help()
167+
return 0
67168
if not args.sid:
68-
print("Error: The SID argument is required.")
69-
sys.exit(1)
70-
sid: str = args.sid
71-
print(f"[+] SID: {sid}")
169+
print("Error: The SID argument is required.", file=sys.stderr)
170+
return 1
171+
72172
try:
73-
result: str = convert_sid_to_hex(sid)
74-
print(f"[+] Result: {result}")
173+
result = convert_sid_to_hex(args.sid)
75174
except ValueError as err:
76-
print(f"Error: {err}")
77-
sys.exit(1)
175+
print(f"Error: {err}", file=sys.stderr)
176+
return 1
177+
178+
if copy_to_clipboard(result):
179+
print_green_status("Result copied to clipboard.")
180+
else:
181+
print(
182+
"Warning: clipboard tool not found or copy failed; result printed to stdout.",
183+
file=sys.stderr,
184+
flush=True,
185+
)
186+
187+
print(f"[+] SID: {args.sid}")
188+
print(f"[+] Result: {result}")
189+
return 0
78190

79191

80192
if __name__ == "__main__":
81-
main()
193+
raise SystemExit(main())

0 commit comments

Comments
 (0)