示例#1
0
 elif args.uninstall:
     # Removes scutum completely from the system
     # Note that the configuration file will be removed too
     if avalon.ask('Removal Confirm: ', False):
         installer.removeScutum()
     else:
         avalon.warning('Removal Canceled')
         exit(0)
 elif args.reset:
     # resets the arptable, ufw and accept all incoming connections
     # This will expose the computer entirely on the network
     log.writeLog(str(datetime.datetime.now()) + ' ---- START ----')
     os.system('arptables -P INPUT ACCEPT')
     os.system('arptables --flush')
     if ufwHandled.lower() == "true":
             ufwctrl = Ufw(log)
             ufwctrl.disable()
     avalon.info('RST OK')
     log.writeLog(str(datetime.datetime.now()) + ' RESET OK')
 elif args.purgelog:
     # Deletes the log file of scutum
     # TODO: delete rotated logs too
     log.purge()
     avalon.info('LOG PURGE OK')
     exit(0)
 elif args.enable or args.disable:
     if args.enable:
         # Enable scutum will write scrips for wicd and network-manager
         # scutum will be started automatically
         log.writeLog(str(datetime.datetime.now()) + " SCUTUM ENABLED")
         if "wicd" in NetworkControllers.split(","):
示例#2
0
    def install(self):
        """
        This is the main function for installer
        """
        global ifacesSelected

        config = configparser.ConfigParser()
        config["Interfaces"] = {}
        config["NetworkControllers"] = {}
        config["Ufw"] = {}

        if os.path.islink(self.SCUTUM_BIN_FILE) or os.path.isfile(
                self.SCUTUM_BIN_FILE):
            os.remove(
                self.SCUTUM_BIN_FILE)  # Remove old file or symbolic links

        os.system("ln -s " + self.INSTALL_DIR + "/scutum.py " +
                  self.SCUTUM_BIN_FILE)

        self.install_service()  # install and register service files
        os.system("systemctl enable scutum")  # enable service
        os.system("systemctl start scutum")  # start service

        if not os.path.isfile('/usr/bin/arptables') and not os.path.isfile(
                '/sbin/arptables'):  # Detect if arptables installed
            print(
                avalon.FM.BD + avalon.FG.R +
                '\nWe have detected that you don\'t have arptables installed!'
                + avalon.FM.RST)
            print('SCUTUM requires arptables to run')
            if not self.sysInstallPackage("arptables"):
                avalon.error("arptables is required for scutum. Exiting...")
                exit(1)

        ifacesSelected = []
        while True:
            print(avalon.FM.BD +
                  '\nWhich interface do you wish to install for?' +
                  avalon.FM.RST)
            ifaces = []
            with open('/proc/net/dev', 'r') as dev:
                for line in dev:
                    try:
                        if line.split(':')[1]:
                            ifaces.append(line.split(':')[0])
                    except IndexError:
                        pass
            if not len(ifaces) == 0:
                idx = 0
                for iface in ifaces:
                    print(str(idx) + '. ' + iface.replace(' ', ''))
                    idx += 1
            print('99. Manually Enter')
            selection = avalon.gets('Please select (index number): ')

            try:
                if selection == '99':
                    manif = avalon.gets('Interface: ')
                    if manif not in ifacesSelected:
                        ifacesSelected.append(manif)
                    if avalon.ask('Add more interfaces?', False):
                        pass
                    else:
                        break
                elif int(selection) >= len(ifaces):
                    avalon.error('Selected interface doesn\'t exist!')
                else:
                    ifacesSelected.append(ifaces[int(selection)].replace(
                        ' ', ''))
                    if avalon.ask('Add more interfaces?', False):
                        pass
                    else:
                        break
            except ValueError:
                avalon.error('Invalid Input!')
                avalon.error('Please enter the index number!')

        config["Interfaces"]["interfaces"] = ",".join(ifacesSelected)

        while True:
            print(avalon.FM.BD +
                  '\nWhich network controller do you want to install for?' +
                  avalon.FM.RST)
            print('1. WICD')
            print('2. Network-Manager')
            print('3. Both')

            selection = avalon.gets('Please select: (index number): ')

            if selection == '1':
                if self.installWicdScripts() is not True:
                    avalon.error(
                        "SCUTUM Script for WICD has failed to install!")
                    avalon.error("Aborting Installation...")
                    exit(1)
                config["NetworkControllers"]["controllers"] = "wicd"
                break
            elif selection == '2':
                if self.installNMScripts(ifacesSelected) is not True:
                    avalon.error(
                        "SCUTUM Script for NetworkManager has failed to install!"
                    )
                    avalon.error("Aborting Installation...")
                    exit(1)
                config["NetworkControllers"]["controllers"] = "NetworkManager"
                break
            elif selection == '3':
                ifaces = ["wicd", "NetworkManager"]
                if self.installWicdScripts() is not True:
                    avalon.warning("Deselected WICD from installation")
                    ifaces.remove("wicd")
                if self.installNMScripts(ifacesSelected) is not True:
                    avalon.warning(
                        "Deselected NetworkManager from installation")
                    ifaces.remove("NetworkManager")
                if len(ifaces) == 0:
                    avalon.error("All SCUTUM Scripts have failed to install!")
                    avalon.error("Aborting Installation...")
                    exit(1)
                config["NetworkControllers"]["controllers"] = ",".join(ifaces)
                break
            else:
                avalon.error('Invalid Input!')

        print(avalon.FM.BD + '\nEnable UFW firewall?' + avalon.FM.RST)
        print(
            "Do you want SCUTUM to help configuring and enabling UFW firewall?"
        )
        print("This will prevent a lot of scanning and attacks")
        if avalon.ask('Enable?', True):
            ufwctrl = Ufw(False)
            print("UFW can configure UFW Firewall for you")
            print("However this will reset your current UFW configurations")
            print(
                "It is recommended to do so the first time you install SCUTUM")
            if avalon.ask("Let SCUTUM configure UFW for you?", True):
                ufwctrl.initialize(True)
            else:
                avalon.info("Okay. Then we will simply enable it for you")
                ufwctrl.enable()

            print(
                "If you let SCUTUM handle UFW, then UFW will be activated and deactivated with SCUTUM"
            )
            if avalon.ask("Let SCUTUM handle UFW?", True):
                config["Ufw"]["handled"] = "true"
            else:
                config["Ufw"]["handled"] = "false"
        else:
            avalon.info("You can turn it on whenever you change your mind")

        print(avalon.FM.BD + '\nInstall Easy TCP controllers?' + avalon.FM.RST)
        print("Easy tcp controller helps you open/close ports quickly")
        print("ex. \"openport 80\" opens port 80")
        print("ex. \"closeport 80\" closes port 80")
        print("ex. \"openport 80 443\" opens port 80 and 443")
        print("ex. \"closeport 80 443\" closes port 80 and 443")
        if avalon.ask("Install Easy TCP conrollers?", True):
            self.install_easytcp_controllers()

        print(avalon.FM.BD + '\nInstall SCUTUM GUI?' + avalon.FM.RST)
        print("SCUTUM GUI is convenient for GUI Interfaces")
        print("ex. KDE, GNOME, XFCE, etc.")
        print("However, there\'s not point to install GUI on servers")
        if avalon.ask("Install SCUTUM GUI?", True):
            self.install_scutum_gui()

        with open(self.CONFPATH, 'w') as configfile:
            config.write(configfile)  # Writes configurations
示例#3
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Name: SCUTUM Easy TCP: closeport
Author: K4YT3X
Date Created: Sep 15, 2017
Last Modified: Sep 28, 2017

Description: This script closes oprts on UFW Firewall

This class is migrated from Project: DefenseMatrix

Version 1.1
"""

from iptables import Ufw
from logger import Logger
import avalon_framework as avalon
import sys

log = Logger()
ufwctrl = Ufw(log)
try:
    ports = []
    for port in sys.argv[1:]:
        ports.append(int(port))
    for port in ports:
        ufwctrl.expire(port)
except ValueError:
    avalon.error("Not a valid port number!")
示例#4
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Name: SCUTUM Easy TCP: openport
Author: K4YT3X
Date Created: Sep 15, 2017
Last Modified: Sep 28, 2017

Description: This script opens ports on UFW Firewall

This class is migrated from Project: DefenseMatrix

Version 1.1
"""

from iptables import Ufw
from logger import Logger
import avalon_framework as avalon
import sys

log = Logger()
ufwctrl = Ufw(log)
try:
    ports = []
    for port in sys.argv[1:]:
        ports.append(int(port))
    for port in ports:
        ufwctrl.allow(port)
except ValueError:
    avalon.error("Not a valid port number!")