-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a6979a
commit 31c048d
Showing
2 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
import ctypes | ||
import os | ||
import shutil | ||
import tempfile | ||
import time | ||
import subprocess | ||
import pyfiglet | ||
import colorama | ||
from colorama import Fore | ||
import sys | ||
|
||
colorama.init(autoreset=True) | ||
|
||
def is_admin(): | ||
try: | ||
return ctypes.windll.shell32.IsUserAnAdmin() | ||
except: | ||
return False | ||
|
||
def run_as_admin(): | ||
if is_admin(): | ||
return | ||
script = os.path.abspath(sys.argv[0]) | ||
params = ' '.join([f'"{arg}"' for arg in sys.argv[1:]]) | ||
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, f"{script} {params}", None, 1) | ||
|
||
def clear_terminal(): | ||
os.system('cls' if os.name == 'nt' else 'clear') | ||
|
||
def cleanmgr(): | ||
try: | ||
subprocess.run('cleanmgr', check=True) | ||
print(Fore.GREEN + "Clean tool ran successfully.") | ||
except subprocess.CalledProcessError as e: | ||
print(Fore.RED + f"Clean tool failed. {e}") | ||
|
||
def delete_temp_files(): | ||
user_temp_dir = tempfile.gettempdir() | ||
|
||
if not os.path.exists(user_temp_dir): | ||
print(Fore.RED + f"The temporary directory does not exist: {user_temp_dir}") | ||
return | ||
|
||
def try_delete_file(file_path, retries=3, delay=1): | ||
for attempt in range(retries): | ||
try: | ||
os.remove(file_path) | ||
return | ||
except OSError as e: | ||
if e.errno == 32: | ||
time.sleep(delay) | ||
else: | ||
print(Fore.RED + f"Failed to delete file: {file_path}. Error: {e}") | ||
return | ||
|
||
try: | ||
items = os.listdir(user_temp_dir) | ||
if not items: | ||
print(Fore.RED + "No files to delete in the temporary directory.") | ||
return | ||
|
||
for item in items: | ||
item_path = os.path.join(user_temp_dir, item) | ||
if os.path.isdir(item_path): | ||
try: | ||
shutil.rmtree(item_path) | ||
except Exception as e: | ||
print(Fore.RED + f"Failed to remove directory: {item_path}. Error: {e}") | ||
else: | ||
try_delete_file(item_path) | ||
|
||
print(Fore.GREEN + "Temporary folder cleaned.") | ||
except Exception as e: | ||
print(Fore.RED + f"Error deleting user temporary files: {e}") | ||
|
||
def delete_prefetch_files(): | ||
prefetch_dir = os.path.join(os.environ.get('SystemRoot', 'C:\\Windows'), 'Prefetch') | ||
|
||
if not os.path.exists(prefetch_dir): | ||
print(Fore.RED + f"The prefetch directory does not exist: {prefetch_dir}") | ||
return | ||
|
||
def try_delete_file(file_path, retries=3, delay=1): | ||
for attempt in range(retries): | ||
try: | ||
os.remove(file_path) | ||
return | ||
except OSError as e: | ||
if e.errno == 32: | ||
time.sleep(delay) | ||
else: | ||
print(Fore.RED + f"Failed to delete file: {file_path}. Error: {e}") | ||
return | ||
|
||
try: | ||
items = os.listdir(prefetch_dir) | ||
if not items: | ||
print(Fore.RED + "No files to delete in the prefetch directory.") | ||
return | ||
|
||
for item in items: | ||
item_path = os.path.join(prefetch_dir, item) | ||
if os.path.isdir(item_path): | ||
try: | ||
shutil.rmtree(item_path) | ||
except Exception as e: | ||
print(Fore.RED + f"Failed to remove directory: {item_path}. Error: {e}") | ||
else: | ||
try_delete_file(item_path) | ||
|
||
print(Fore.GREEN + "Prefetch folder cleaned.") | ||
except Exception as e: | ||
print(Fore.RED + f"Error deleting prefetch files: {e}") | ||
|
||
def main(): | ||
ascii_letters = pyfiglet.figlet_format("Nexus Tool", font="big") | ||
first_run = True | ||
|
||
if first_run: | ||
input(Fore.WHITE + "Press Enter to Continue...") | ||
first_run = False | ||
|
||
while True: | ||
clear_terminal() | ||
print(Fore.MAGENTA + ascii_letters) | ||
print(Fore.LIGHTBLUE_EX + "===> A simple cleaner for Windows <===") | ||
print() | ||
print(Fore.WHITE + "[-] What action would you like to perform?") | ||
print() | ||
print(Fore.GREEN + "[1] Delete Temp Files") | ||
print(Fore.GREEN + "[2] Run Cleaning Tool") | ||
print(Fore.GREEN + "[3] Delete Prefetch Files") | ||
print(Fore.GREEN + "[4] Exit") | ||
print() | ||
choice = input(Fore.WHITE + "Your Choice: ") | ||
|
||
if choice == '1': | ||
delete_temp_files() | ||
elif choice == '2': | ||
cleanmgr() | ||
elif choice == '3': | ||
delete_prefetch_files() | ||
elif choice == '4': | ||
print(Fore.GREEN + "Exiting...") | ||
break | ||
else: | ||
print(Fore.RED + "Invalid choice. Please enter a number between 1 and 4.") | ||
|
||
input(Fore.BLUE + "Press Enter to return to the menu...") | ||
|
||
if __name__ == "__main__": | ||
if not is_admin(): | ||
run_as_admin() | ||
else: | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# -*- mode: python ; coding: utf-8 -*- | ||
import sys | ||
from PyInstaller.utils.hooks import collect_data_files | ||
|
||
block_cipher = None | ||
|
||
# Collect data files from pyfiglet | ||
pyfiglet_fonts = collect_data_files('pyfiglet', subdir='fonts') | ||
|
||
a = Analysis( | ||
['NexusTool.py'], | ||
pathex=['.'], | ||
binaries=[], | ||
datas=[ | ||
('ifcon.ico', '.'), # Correct path for the new icon file | ||
*pyfiglet_fonts | ||
], | ||
hiddenimports=['pyfiglet'], | ||
hookspath=[], | ||
hooksconfig={}, | ||
runtime_hooks=[], | ||
excludes=[], | ||
cipher=block_cipher, | ||
noarchive=False, | ||
) | ||
|
||
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) | ||
|
||
exe = EXE( | ||
pyz, | ||
a.scripts, | ||
a.binaries, | ||
a.datas, | ||
[], | ||
name='NexusTool', | ||
debug=False, | ||
bootloader_ignore_signals=False, | ||
strip=False, | ||
upx=True, | ||
upx_exclude=[], | ||
runtime_tmpdir=None, | ||
console=True, # Set to True for console mode, False for GUI mode | ||
disable_windowed_traceback=False, | ||
argv_emulation=False, | ||
target_arch=None, | ||
codesign_identity=None, | ||
entitlements_file=None, | ||
icon='ifcon.ico', # Ensure the correct icon file is referenced | ||
) |