-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.py
More file actions
505 lines (408 loc) · 17 KB
/
Copy pathcore.py
File metadata and controls
505 lines (408 loc) · 17 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
#!/usr/bin/env python3
"""
Krilin Core v0.3 - Unified Security Framework
Author: 0xbv1(0xb0rn3) | q4n0@proton.me | X/Discord: oxbv1 | IG: theehiv3
"""
import os
import subprocess
import sys
import shutil
import time
import re
from pathlib import Path
RED = '\033[91m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
BLUE = '\033[94m'
MAGENTA = '\033[95m'
CYAN = '\033[96m'
BOLD = '\033[1m'
NORMAL = '\033[0m'
KALI_REPO = "deb http://http.kali.org/kali kali-rolling main contrib non-free non-free-firmware"
LOG_FILE = "/var/log/krilin_operations.log"
KALI_CATEGORIES = {
"1": ("Information Gathering", ["nmap", "dnsrecon", "theharvester", "recon-ng", "maltego"]),
"2": ("Vulnerability Analysis", ["nikto", "sqlmap", "lynis", "openvas", "wapiti"]),
"3": ("Exploitation Tools", ["metasploit-framework", "exploitdb", "set", "beef-xss"]),
"4": ("Wireless Attacks", ["aircrack-ng", "reaver", "wifite", "kismet", "pixiewps"]),
"5": ("Web Application", ["burpsuite", "zaproxy", "wfuzz", "dirb", "gobuster"]),
"6": ("Password Attacks", ["hydra", "john", "hashcat", "crunch", "medusa"]),
"7": ("Individual Tools", []),
"8": ("All Kali Tools", [])
}
PARROT_EDITIONS = {
"1": ("Core Edition", ["bash", "wget", "gnupg", "parrot-core"]),
"2": ("Home Edition", ["parrot-interface-home", "parrot-desktop-mate", "parrot-wallpapers",
"firefox-esr", "parrot-firefox-profiles", "vscodium"]),
"3": ("Security Edition", ["parrot-interface-home", "parrot-desktop-mate", "parrot-tools-full",
"firefox-esr", "parrot-firefox-profiles", "vscodium"]),
"4": ("HTB Edition", ["parrot-interface-home", "parrot-desktop-mate", "parrot-tools-full",
"hackthebox-icon-theme", "win10-icon-theme", "firefox-esr", "vscodium"])
}
def log(msg):
timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
with open(LOG_FILE, "a") as f:
f.write(f"[{timestamp}] {msg}\n")
print(f"{CYAN}[*]{NORMAL} {msg}")
def log_ok(msg):
print(f"{GREEN}[+]{NORMAL} {msg}")
def log_warn(msg):
print(f"{YELLOW}[!]{NORMAL} {msg}")
def log_err(msg):
print(f"{RED}[-]{NORMAL} {msg}")
def run_cmd(cmd, silent=False, show_progress=False):
try:
if silent and not show_progress:
subprocess.run(cmd, shell=True, check=True,
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
elif show_progress:
process = subprocess.Popen(
cmd,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
bufsize=1
)
for line in process.stdout:
if any(keyword in line.lower() for keyword in ['unpacking', 'setting up', 'processing', 'installing']):
print(f"{CYAN} >{NORMAL} {line.strip()}")
process.wait()
if process.returncode != 0:
return False
else:
subprocess.run(cmd, shell=True, check=True)
return True
except subprocess.CalledProcessError:
return False
def check_root():
if os.geteuid() != 0:
log_err("Root access required")
sys.exit(1)
def is_docker():
return os.path.exists("/.dockerenv") or \
os.path.exists("/proc/1/cgroup") and \
"docker" in open("/proc/1/cgroup").read()
def fix_dpkg():
log("Fixing package system...")
lock_files = [
"/var/lib/apt/lists/lock",
"/var/cache/apt/archives/lock",
"/var/lib/dpkg/lock",
"/var/lib/dpkg/lock-frontend"
]
for lock in lock_files:
if os.path.exists(lock):
try:
os.remove(lock)
except:
pass
run_cmd("dpkg --configure -a", silent=True)
run_cmd("apt-get install -f -y", silent=True)
run_cmd("apt-get clean", silent=True)
run_cmd("apt-get update --fix-missing", silent=True)
def add_kali_repo():
log("Adding Kali repository...")
keyring_urls = [
"https://archive.kali.org/kali/pool/main/k/kali-archive-keyring/kali-archive-keyring_2025.1_all.deb",
"https://http.kali.org/kali/pool/main/k/kali-archive-keyring/kali-archive-keyring_2022.1_all.deb"
]
keyring_file = "/tmp/kali-keyring.deb"
for url in keyring_urls:
if run_cmd(f"wget -q -O {keyring_file} {url}", silent=True):
if run_cmd(f"dpkg -i {keyring_file}", silent=True):
os.remove(keyring_file)
break
with open("/etc/apt/sources.list.d/kali-temp.list", "w") as f:
f.write(f"{KALI_REPO}\n")
run_cmd("apt-get update", silent=True)
log_ok("Kali repository added")
def add_parrot_repo():
log("Adding Parrot repository...")
keyring_url = "https://deb.parrot.sh/parrot/pool/main/p/parrot-archive-keyring/parrot-archive-keyring_2024.12_all.deb"
keyring_file = "/tmp/parrot-keyring.deb"
if run_cmd(f"wget -q -O {keyring_file} {keyring_url}", silent=True):
run_cmd(f"apt install -y {keyring_file}", silent=True)
if os.path.exists(keyring_file):
os.remove(keyring_file)
parrot_list = """## Parrot Security Repositories - Managed by Krilin
deb https://deb.parrot.sh/parrot echo main contrib non-free non-free-firmware
deb https://deb.parrot.sh/direct/parrot echo-security main contrib non-free non-free-firmware
deb https://deb.parrot.sh/parrot echo-backports main contrib non-free non-free-firmware
"""
with open("/etc/apt/sources.list.d/parrot.list", "w") as f:
f.write(parrot_list)
sources_list = """# This file is empty, feel free to
# add here your custom APT repositories
# The default Parrot repositories
# are NOT here. If you want to
# edit them, take a look into
# /etc/apt/sources.list.d/parrot.list
"""
with open("/etc/apt/sources.list", "w") as f:
f.write(sources_list)
listchanges_conf = """[apt]
frontend=pager
which=news
email_address=root
email_format=text
confirm=false
headers=false
reverse=false
save_seen=/var/lib/apt/listchanges.db
"""
with open("/etc/apt/listchanges.conf", "w") as f:
f.write(listchanges_conf)
os_release = """PRETTY_NAME="Parrot Security 7.0 (echo)"
NAME="Parrot Security"
VERSION_ID="7.0"
VERSION="7.0 (echo)"
VERSION_CODENAME=echo
ID=debian
HOME_URL="https://www.parrotsec.org/"
SUPPORT_URL="https://www.parrotsec.org/community/"
BUG_REPORT_URL="https://gitlab.com/parrotsec/"
"""
with open("/etc/os-release", "w") as f:
f.write(os_release)
run_cmd("apt-get update", silent=True)
log_ok("Parrot repository configured")
def remove_repo(repo_type):
log(f"Removing {repo_type} repository...")
fix_dpkg()
if repo_type == "kali":
repo_file = "/etc/apt/sources.list.d/kali-temp.list"
elif repo_type == "parrot":
repo_file = "/etc/apt/sources.list.d/parrot.list"
else:
return
if os.path.exists(repo_file):
os.remove(repo_file)
run_cmd("apt-get update", silent=True)
log_ok("Repository removed")
def install_package(package, max_retries=3, show_progress=False):
for attempt in range(1, max_retries + 1):
result = subprocess.run(
["dpkg", "-l", package],
capture_output=True,
text=True
)
if f"ii {package}" in result.stdout:
if show_progress:
log_ok(f"{package} already installed")
return True
if show_progress:
log(f"Installing {package} (attempt {attempt}/{max_retries})...")
if run_cmd(f"apt-get install -y -qq --no-install-recommends {package}", silent=not show_progress, show_progress=show_progress):
if show_progress:
log_ok(f"{package} installed")
return True
if attempt < max_retries:
fix_dpkg()
time.sleep(2)
log_err(f"Failed to install {package}")
return False
def install_packages(packages, show_progress=False):
failed = []
success = []
total = len(packages)
for idx, pkg in enumerate(packages, 1):
if show_progress:
print(f"\n{BOLD}{CYAN}[{idx}/{total}]{NORMAL} Processing: {YELLOW}{pkg}{NORMAL}")
if install_package(pkg, show_progress=show_progress):
success.append(pkg)
else:
failed.append(pkg)
print(f"\n{BOLD}{BLUE}{'='*50}{NORMAL}")
if success:
log_ok(f"Installed: {len(success)} packages")
if failed:
log_warn(f"Failed: {len(failed)} packages")
for pkg in failed[:10]:
print(f" - {pkg}")
print(f"{BOLD}{BLUE}{'='*50}{NORMAL}\n")
def select_custom_tools():
print(f"{CYAN}Enter tool names separated by spaces:{NORMAL}")
print(f"{YELLOW}Example: nmap dirb nikto sqlmap metasploit-framework{NORMAL}")
tools = input(f"{GREEN}Tools: {NORMAL}").strip().split()
return tools if tools else []
def fetch_all_kali_tools():
fallback_tools = [
"nmap", "masscan", "dnsrecon", "theharvester", "nikto", "sqlmap",
"wpscan", "lynis", "openvas", "metasploit-framework", "exploitdb",
"set", "beef-xss", "aircrack-ng", "wifite", "reaver", "kismet",
"burpsuite", "zaproxy", "dirb", "gobuster", "ffuf", "hydra",
"john", "hashcat", "crunch", "medusa", "wireshark", "ettercap-text-only",
"responder", "mitmproxy", "bettercap", "autopsy", "binwalk",
"foremost", "volatility", "radare2", "gdb"
]
try:
add_kali_repo()
result = subprocess.run(
["apt-cache", "search", "kali-"],
stdout=subprocess.PIPE,
text=True,
check=False
)
if result.stdout:
tools = []
for line in result.stdout.split("\n"):
if line.strip():
pkg = line.split(" - ")[0].strip()
if pkg:
tools.append(pkg)
if tools:
return list(set(tools + fallback_tools))
except:
pass
return fallback_tools
def install_all_kali_tools():
print(f"\n{RED}{BOLD}{'='*60}{NORMAL}")
print(f"{RED}{BOLD} WARNING{NORMAL}")
print(f"{RED}{BOLD}{'='*60}{NORMAL}")
print(f"{YELLOW} * 10+ GB download size{NORMAL}")
print(f"{YELLOW} * Several hours installation time{NORMAL}")
print(f"{YELLOW} * May cause system conflicts{NORMAL}")
print(f"{RED}{BOLD}{'='*60}{NORMAL}\n")
confirm = input(f"{RED}Type 'I ACCEPT' to continue: {NORMAL}").strip()
if confirm != "I ACCEPT":
log_warn("Installation cancelled")
return
tools = fetch_all_kali_tools()
log(f"Found {len(tools)} tools")
try:
add_kali_repo()
fix_dpkg()
install_packages(tools)
finally:
remove_repo("kali")
def install_kali_tools(category, packages):
if category == "All Kali Tools":
install_all_kali_tools()
return
elif category == "Individual Tools":
packages = select_custom_tools()
if not packages:
return
log(f"Installing {category}...")
try:
add_kali_repo()
fix_dpkg()
install_packages(packages)
finally:
remove_repo("kali")
def install_parrot_edition(edition, packages):
log(f"Installing Parrot {edition}...")
if is_docker() and "Home" in edition:
log_warn("Desktop environment in Docker may have limited functionality")
try:
# Show initial progress
print(f"\n{BOLD}{CYAN}{'='*60}{NORMAL}")
print(f"{CYAN}Phase 1/4: Adding Parrot repositories...{NORMAL}")
print(f"{BOLD}{CYAN}{'='*60}{NORMAL}")
add_parrot_repo()
print(f"\n{BOLD}{CYAN}{'='*60}{NORMAL}")
print(f"{CYAN}Phase 2/4: Fixing package system...{NORMAL}")
print(f"{BOLD}{CYAN}{'='*60}{NORMAL}")
fix_dpkg()
print(f"\n{BOLD}{CYAN}{'='*60}{NORMAL}")
print(f"{CYAN}Phase 3/4: Updating system packages...{NORMAL}")
print(f"{BOLD}{CYAN}{'='*60}{NORMAL}")
print(f"{YELLOW}This may take several minutes...{NORMAL}\n")
run_cmd("apt-get update", silent=False, show_progress=True)
print(f"\n{YELLOW}Upgrading system packages...{NORMAL}\n")
run_cmd("apt-get upgrade -y", silent=False, show_progress=True)
if os.uname().machine == "aarch64":
run_cmd("apt-mark hold broadcom-sta-dkms", silent=True)
print(f"\n{BOLD}{CYAN}{'='*60}{NORMAL}")
print(f"{CYAN}Phase 4/4: Installing Parrot {edition} packages...{NORMAL}")
print(f"{BOLD}{CYAN}{'='*60}{NORMAL}")
print(f"{YELLOW}Total packages to install: {len(packages)}{NORMAL}")
print(f"{YELLOW}This will take significant time. Please be patient...{NORMAL}\n")
install_packages(packages, show_progress=True)
print(f"\n{BOLD}{GREEN}{'='*60}{NORMAL}")
log_ok(f"Parrot {edition} installation complete!")
print(f"{BOLD}{GREEN}{'='*60}{NORMAL}")
if "Home" in edition or "Security" in edition or "HTB" in edition:
log_warn("Reboot required for desktop environment")
finally:
pass
def display_main_menu():
print(f"\n{BOLD}{BLUE}╔{'═'*55}╗{NORMAL}")
print(f"{BOLD}{BLUE}║{CYAN} KRILIN SECURITY FRAMEWORK - MAIN MENU{BLUE} ║{NORMAL}")
print(f"{BOLD}{BLUE}╠{'═'*55}╣{NORMAL}")
print(f"{BOLD}{BLUE}║{YELLOW} [1] Kali Linux Tools{' '*33}{BLUE}║{NORMAL}")
print(f"{BOLD}{BLUE}║{YELLOW} [2] Parrot Security Conversion{' '*24}{BLUE}║{NORMAL}")
print(f"{BOLD}{BLUE}║{YELLOW} [0] Exit{' '*45}{BLUE}║{NORMAL}")
print(f"{BOLD}{BLUE}╚{'═'*55}╝{NORMAL}")
def display_kali_menu():
print(f"\n{BOLD}{BLUE}╔{'═'*55}╗{NORMAL}")
print(f"{BOLD}{BLUE}║{CYAN} KALI LINUX TOOLS INSTALLATION{BLUE} ║{NORMAL}")
print(f"{BOLD}{BLUE}╠{'═'*55}╣{NORMAL}")
for key, (category, _) in KALI_CATEGORIES.items():
icon = "[!]" if key == "8" else "[*]"
warning = f" {MAGENTA}(10+ GB){NORMAL}" if key == "8" else ""
padding = ' ' * (40 - len(category))
print(f"{BOLD}{BLUE}║{CYAN} [{key}] {icon} {category}{padding}{warning}{BLUE}║{NORMAL}")
print(f"{BOLD}{BLUE}║{YELLOW} [0] Back{' '*45}{BLUE}║{NORMAL}")
print(f"{BOLD}{BLUE}╚{'═'*55}╝{NORMAL}")
def display_parrot_menu():
print(f"\n{BOLD}{BLUE}╔{'═'*55}╗{NORMAL}")
print(f"{BOLD}{BLUE}║{CYAN} PARROT SECURITY CONVERSION{BLUE} ║{NORMAL}")
print(f"{BOLD}{BLUE}╠{'═'*55}╣{NORMAL}")
for key, (edition, _) in PARROT_EDITIONS.items():
icon = "[>]" if "Core" in edition else "[*]"
padding = ' ' * (42 - len(edition))
print(f"{BOLD}{BLUE}║{CYAN} [{key}] {icon} {edition}{padding}{BLUE}║{NORMAL}")
print(f"{BOLD}{BLUE}║{YELLOW} [0] Back{' '*45}{BLUE}║{NORMAL}")
print(f"{BOLD}{BLUE}╚{'═'*55}╝{NORMAL}")
def main():
check_root()
Path(LOG_FILE).touch(exist_ok=True)
log("Krilin Security Framework v0.3 started")
while True:
display_main_menu()
try:
choice = input(f"\n{GREEN}Select option: {NORMAL}").strip()
if choice == "0":
log("Session ended")
print(f"{BLUE}Stay tactical!{NORMAL}")
break
elif choice == "1":
while True:
display_kali_menu()
kali_choice = input(f"\n{GREEN}Select option: {NORMAL}").strip()
if kali_choice == "0":
break
elif kali_choice in KALI_CATEGORIES:
category, packages = KALI_CATEGORIES[kali_choice]
install_kali_tools(category, packages)
else:
log_err("Invalid option")
elif choice == "2":
while True:
display_parrot_menu()
parrot_choice = input(f"\n{GREEN}Select option: {NORMAL}").strip()
if parrot_choice == "0":
break
elif parrot_choice in PARROT_EDITIONS:
edition, packages = PARROT_EDITIONS[parrot_choice]
install_parrot_edition(edition, packages)
else:
log_err("Invalid option")
else:
log_err("Invalid option")
except KeyboardInterrupt:
print(f"\n{YELLOW}[!]{NORMAL} Interrupted")
continue
except EOFError:
break
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print(f"\n{YELLOW}[!]{NORMAL} Terminated")
sys.exit(0)
except Exception as e:
log_err(f"Error: {e}")
sys.exit(1)