Example #1
0
    def check_avalon(self):
        avalon.info(avalon.FM.RST + 'Checking AVALON Framework Version...')
        avalonVersionCheck = subprocess.Popen(
            ["pip3", "freeze"], stdout=subprocess.PIPE).communicate()[0]
        pipOutput = avalonVersionCheck.decode().split('\n')
        for line in pipOutput:
            if 'avalon-framework' in line:
                localVersion = line.split('==')[-1]

        with urllib.request.urlopen(
                'https://raw.githubusercontent.com/K4YT3X/AVALON/master/__init__.py'
        ) as response:
            html = response.read().decode().split('\n')
            for line in html:
                if 'VERSION = ' in line:
                    serverVersion = line.split(' ')[-1].replace('\'', '')
                    break

        if serverVersion > localVersion:
            avalon.info('Here\'s a newer version of AVALON Framework: ' +
                        serverVersion)
            if avalon.ask('Update to the newest version?', True):
                os.system('pip3 install --upgrade avalon_framework')
            else:
                avalon.warning('Ignoring update')
        else:
            avalon.subLevelTimeInfo('Current version: ' + localVersion)
            avalon.info('AVALON Framework is already on the newest version')
Example #2
0
    def check_version(self, VERSION):
        """
        Arguments:
            VERSION {string} -- version number

        Returns:
            string -- server version number
        """
        avalon.info(avalon.FM.RST + 'Checking SCUTUM Version...')
        with urllib.request.urlopen(
                'https://raw.githubusercontent.com/K4YT3X/SCUTUM/master/scutum.py'
        ) as response:
            html = response.read().decode().split('\n')
            for line in html:
                if 'VERSION = ' in line:
                    server_version = line.split(' ')[-1].replace('\'', '')
                    break
            avalon.subLevelTimeInfo('Server version: ' + server_version)
            if server_version > VERSION:
                avalon.info('Here\'s a newer version of SCUTUM!')
                if avalon.ask('Update to the newest version?'):
                    self.install()
                else:
                    avalon.warning('Ignoring update')
            else:
                avalon.info('SCUTUM is already on the newest version')
        return server_version
Example #3
0
def sockDaemon():
    while True:
        sock0 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock0.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        sock0.bind(('0.0.0.0', 12022))
        sock0.listen(1)
        while True:
            try:
                conn, (rip, rport) = sock0.accept()
                avalon.subLevelTimeInfo('Client connected from ' + str(rip) +
                                        ':' + str(rport))
                recvd = conn.recv(1024).decode()
                if recvd.replace('\n', '') == PASSWD:
                    iptables.allow(rip)
                print(recvd)
                conn.close()
            except OSError:
                avalon.error('Socket port is being used!')
                sock0.close()
                avalon.info('Fail-Safe: Trying to reassign socket...')
                break
            except Exception as e:
                avalon.error('Socket: ' + str(e))
                sock0.close()
                avalon.info('Fail-Safe: Trying to reload socket daemon...')
            finally:
                conn.close()
                time.sleep(0.5)
Example #4
0
 def expire(addr):
     output = subprocess.Popen(['iptables', '-L', '--line-numbers'],
                               stdout=subprocess.PIPE).communicate()[0]
     output = output.decode().split('\n')
     for line in output:
         if addr in line:
             avalon.subLevelTimeInfo('Disallowing ' + addr)
             os.system('iptables -D INPUT ' + line.split(' ')[0])
             AUTHED_ADDR.pop(AUTHED_ADDR.index(addr))
Example #5
0
def check_version():
    avalon.info(avalon.FM.RST + 'Checking SCUTUM Version...')
    with urllib.request.urlopen(
            'https://raw.githubusercontent.com/K4YT3X/SCUTUM/master/scutum.py'
    ) as response:
        html = response.read().decode().split('\n')
        for line in html:
            if 'VERSION = ' in line:
                server_version = line.split(' ')[-1].replace('\'', '')
                break
        avalon.subLevelTimeInfo('Server version: ' + server_version)
        if server_version > VERSION:
            avalon.info('Here\'s a newer version of SCUTUM!')
            if avalon.ask('Update to the newest version?'):
                os.system(
                    'wget https://raw.githubusercontent.com/K4YT3X/SCUTUM/master/scutum.py -O '
                    + os.path.abspath(__file__))
            else:
                avalon.warning('Ignoring update')
        else:
            avalon.info('SCUTUM is already on the newest version')
    return server_version
Example #6
0
 def allow(addr):
     avalon.subLevelTimeInfo('Allowing ' + addr)
     os.system(
         'iptables -A INPUT -p tcp --dport 1080 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT -s '
         + addr)
     AUTHED_ADDR.append(addr)