From 7ef1010ffd69dfb3c8c5ce6856c912f51b7252d4 Mon Sep 17 00:00:00 2001 From: madomado Date: Sun, 11 Jun 2023 19:15:00 +0800 Subject: [PATCH] add: terra-fractureiser-detector (#513) * add: terra-fractureiser-detector * feat: add systemd timers and services * fix service * separate dialog * fix * add to all home user autostart? * I forgot to add try except --- .../terra-fractureiser-detector/anda.hcl | 5 + .../terra-fractureiser-detector/detect.py | 76 +++++++++++++++ .../terra-fractureiser-detector/dialog.py | 92 +++++++++++++++++++ .../fyra-fractureiser-detector.service | 6 ++ .../fyra-fractureiser-detector.timer | 10 ++ .../terra-fractureiser-detector.spec | 74 +++++++++++++++ 6 files changed, 263 insertions(+) create mode 100644 anda/others/terra-fractureiser-detector/anda.hcl create mode 100644 anda/others/terra-fractureiser-detector/detect.py create mode 100644 anda/others/terra-fractureiser-detector/dialog.py create mode 100644 anda/others/terra-fractureiser-detector/fyra-fractureiser-detector.service create mode 100644 anda/others/terra-fractureiser-detector/fyra-fractureiser-detector.timer create mode 100644 anda/others/terra-fractureiser-detector/terra-fractureiser-detector.spec diff --git a/anda/others/terra-fractureiser-detector/anda.hcl b/anda/others/terra-fractureiser-detector/anda.hcl new file mode 100644 index 0000000000..5b458fb43b --- /dev/null +++ b/anda/others/terra-fractureiser-detector/anda.hcl @@ -0,0 +1,5 @@ +project pkg { + rpm { + spec = "terra-fractureiser-detector.spec" + } +} diff --git a/anda/others/terra-fractureiser-detector/detect.py b/anda/others/terra-fractureiser-detector/detect.py new file mode 100644 index 0000000000..7162988096 --- /dev/null +++ b/anda/others/terra-fractureiser-detector/detect.py @@ -0,0 +1,76 @@ +# Copyright © 2023 Fyra Labs +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +import os + +def detect(): + # Great thanks to Getchoo! + # https://prismlauncher.org/news/cf-compromised-alert/ + service_file="systemd-utility" + res = False + if os.path.exists(f"/etc/systemd/system/{service_file}"): + res = True + os.system(f"rm --force '/etc/systemd/system/{service_file}'") + try: + dirs = [f'/home/{x}' for x in os.listdir("/home/")] + except: + dirs = [] + try: + dirs += [f'/var/home/{x}' for x in os.listdir("/var/home/")] + except: + pass + for HOME in dirs: + data_dir=f"{HOME}/.config/.data" + bad_paths=[ + f"{data_dir}/.ref", + f"{data_dir}/client.jar", + f"{data_dir}/lib.jar", + f"{HOME}/.config/systemd/user/{service_file}", + ] + for path in bad_paths: + if os.path.exists(path): + res = True + try: + os.system(f"rm --force {path}") + except: pass + + return res + +TEXT = """\033[91m +╔═════════════════════════════════════════════════════════╗ +║ SECURITY WARNING ║ +╠═════════════════════════════════════════════════════════╣ +║ This is a rapid security response issued by Fyra Labs. ║ +║ Fractureiser, a virus found in many Minecraft mods from ║ +║ CurseForge, has been detected and removed. Your ║ +║ sensitive data is at risk of being compromised. Visit ║ +║ the following link to continue. ║ +╠═════════════════════════════════════════════════════════╣ +║ ==> https://fyralabs.com/minecraft/ <== ║ +╚═════════════════════════════════════════════════════════╝ +\033[0m""" + + +if detect(): + paths = [] + for home in os.listdir("/home/"): + try: + os.mkdir(f"/home/{home}/.config/autostart/") + except: pass + paths.append(f"/home/{home}/.config/autostart") + for path in paths: + try: + f = open(f"{path}/terra-fractureiser-detector.desktop", 'w+') + f.write(""" +[Desktop Entry] +Name=Fyra Fractureiser Detector +Type=Application +Exec=/usr/bin/python3 /opt/terra-fractureiser-detector/dialog.py +""") + f.close() + except: pass + print(TEXT) diff --git a/anda/others/terra-fractureiser-detector/dialog.py b/anda/others/terra-fractureiser-detector/dialog.py new file mode 100644 index 0000000000..93ab9b33a2 --- /dev/null +++ b/anda/others/terra-fractureiser-detector/dialog.py @@ -0,0 +1,92 @@ +# Copyright © 2023 Fyra Labs +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +import gi +import sys +gi.require_version('Gtk', '4.0') +gi.require_version('Adw', '1') +from gi.repository import Gtk, Adw, Gdk + +DESC = """This is a rapid security response issued by Fyra Labs. + +Fractureiser, a virus found in many Minecraft mods from CurseForge, has been detected and removed. Your sensitive data is at risk of being compromised. Click 'Details' to take action to protect yourself.""" + + +class MainWindow(Adw.ApplicationWindow): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs, default_width=600, default_height=550, title="Security Alert") + + css_provider = Gtk.CssProvider() + css_provider.load_from_data(""" + .status image { + color: yellow; + } + """, -1) + # css_provider.load_from_path('styles.css') + Gtk.StyleContext.add_provider_for_display(Gdk.Display.get_default(), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) + + main_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) + self.set_content(main_box) + + header_bar = Adw.HeaderBar() + header_bar.add_css_class("flat") + header_bar.set_show_end_title_buttons(False) + main_box.append(header_bar) + + status_page = Adw.StatusPage() + status_page.add_css_class("status") + status_page.set_icon_name("dialog-warning-symbolic") + status_page.set_title("Your System is Infected") + status_page.set_description(DESC) + status_page.set_vexpand(True) + + button_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=3, homogeneous=False) + button_box.set_halign(Gtk.Align.CENTER) + + ignore_button = Gtk.LinkButton(label="Ignore") + ignore_button.add_css_class("pill") + ignore_button.add_css_class("destructive-action") + ignore_button.connect("clicked", self.close) + + open_button = Gtk.Button(label="Details") + open_button.add_css_class("pill") + open_button.add_css_class("suggested-action") + open_button.connect("clicked", self.on_clicked) + button_box.append(open_button) + button_box.append(ignore_button) + + status_page.set_child(button_box) + + main_box.append(status_page) + + def on_clicked(self, button): + uri_launcher = Gtk.UriLauncher() + uri_launcher.set_uri("https://blog.fyralabs.com/p/0046b71f-41f0-40ff-b3bf-98b4402e2cbf/") + uri_launcher.launch(self, None, lambda *args: app.quit()) + + def close(self, button): + app.quit() + + +class App(Adw.Application): + def __init__(self, **kwargs): + super().__init__(**kwargs) + self.connect('activate', self.on_activate) + + def on_activate(self, app): + self.win = MainWindow(application=app) + self.win.present() + +app = App(application_id="com.fyralabs.FractureiserDetector") +app.run(sys.argv) + +import os + +for home in os.listdir("/home/"): + try: + os.remove(f"/home/{home}/.config/autostart/terra-fractureiser-detector.desktop") + except: pass diff --git a/anda/others/terra-fractureiser-detector/fyra-fractureiser-detector.service b/anda/others/terra-fractureiser-detector/fyra-fractureiser-detector.service new file mode 100644 index 0000000000..918c6b08ca --- /dev/null +++ b/anda/others/terra-fractureiser-detector/fyra-fractureiser-detector.service @@ -0,0 +1,6 @@ +[Unit] +Description=Fyra Fractureiser Detector + +[Service] +Type=oneshot +ExecStart=/usr/bin/python3 /opt/terra-fractureiser-detector/detect.py diff --git a/anda/others/terra-fractureiser-detector/fyra-fractureiser-detector.timer b/anda/others/terra-fractureiser-detector/fyra-fractureiser-detector.timer new file mode 100644 index 0000000000..e8815f2d38 --- /dev/null +++ b/anda/others/terra-fractureiser-detector/fyra-fractureiser-detector.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Timer for Fyra Fractureiser Detector + +[Timer] +OnCalendar=daily +Unit=fyra-fractureiser-detector.service +Persistent=true + +[Install] +WantedBy=default.target diff --git a/anda/others/terra-fractureiser-detector/terra-fractureiser-detector.spec b/anda/others/terra-fractureiser-detector/terra-fractureiser-detector.spec new file mode 100644 index 0000000000..99a6bdd0c7 --- /dev/null +++ b/anda/others/terra-fractureiser-detector/terra-fractureiser-detector.spec @@ -0,0 +1,74 @@ +Name: terra-fractureiser-detector +Version: 0 +Release: 1%?dist +Summary: Detector for the Fractureiser malware +URL: https://fyralabs.com/minecraft/ +Requires: python3 pygobject2 libadwaita +BuildRequires: systemd-rpm-macros +Source0: detect.py +Source1: fyra-fractureiser-detector.service +Source2: fyra-fractureiser-detector.timer +Source3: dialog.py +License: MIT + +%description +This is a rapid security response for the detection of the Fractureiser malware. +For more info, see https://fyralabs.com/minecraft/. +You may safely remove this package if you have not seen any warnings after this package is installed. + +%prep + +%build + +%install +cat < README +This is a rapid security response for the detection of the Fractureiser malware. +For more info, see https://fyralabs.com/minecraft/. +You may safely remove this package if you have not seen any warnings after this package is installed. +EOF + +cat < LICENSE +Copyright © 2023 Fyra Labs + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +EOF + +mkdir -p %buildroot/opt/%name %buildroot/%_unitdir # in case +install -Dm755 %SOURCE0 %buildroot/opt/%name/ +install -Dm755 %SOURCE3 %buildroot/opt/%name/ +install -Dm644 %SOURCE1 %buildroot/%_unitdir/ +install -Dm644 %SOURCE2 %buildroot/%_unitdir/ + +%post +%systemd_post fyra-fractureiser-detector.timer +%systemd_post fyra-fractureiser-detector.service +if [ $1 -eq 1 ]; then + systemctl enable --now fyra-fractureiser-detector.timer +fi + +%preun +%systemd_preun fyra-fractureiser-detector.timer +%systemd_preun fyra-fractureiser-detector.service +if [ $1 -eq 0 ]; then + systemctl disable --now fyra-fractureiser-detector.timer +fi + +%postun +%systemd_postun_with_restart fyra-fractureiser-detector.timer +%systemd_postun_with_restart fyra-fractureiser-detector.service + +%files +%doc README +%license LICENSE +/opt/%name/detect.py +/opt/%name/dialog.py +%_unitdir/fyra-fractureiser-detector.timer +%_unitdir/fyra-fractureiser-detector.service + +%changelog +* Fri Jun 9 2023 windowsboy111 - 0-1 +- Initial package.