예제 #1
0
    def pxe(self, args):
        """process the pxe command"""
        args, config = self._shared(args, "pxe")
        release = args.release

        path = os.path.join(config["paths"]["tftpboot"], "seedbank", release)
        if not os.path.isdir(path):
            if release in config["netboots"]:
                err = '"%s" is not available, run "seedbank manage -n %s" to ' "download and prepare the release" % (
                    release,
                    release,
                )
            else:
                err = '"%s" is not a valid release, run "seedbank list -n" to ' "list valid releases " % release
            raise self.exception(err)

        if args.macaddress:
            if len(args.macaddress) == 12:
                pass
            elif not re.match("([a-fA-F0-9]{2}[:|\-]?){6}", args.macaddress):
                err = '"%s" is not a valid MAC address' % args.macaddress
                raise self.exception(err)
            args.address = utils.format_address(args.macaddress)
        else:
            ip_address = utils.resolve_ip_address(args.fqdn)
            args.address = utils.ip_to_hex(ip_address)

        pxe_linux = pxe.GeneratePxe(args)
        pxe_linux.state_remove()
        pxe_linux.write(pxe_linux.generate())
        pxe_linux.hook_enable()

        logging.info('"%s" will be installed with "%s" after the next PXE boot', args.fqdn, args.release)
예제 #2
0
    def pxe(self, args):
        """process the pxe command"""
        args, config = self._shared(args, 'pxe')
        release = args.release

        path = os.path.join(config['paths']['tftpboot'], 'seedbank', release)
        if not os.path.isdir(path):
            if release in config['netboots']:
                err = '"%s" is not available, run "seedbank manage -n %s" to '\
                    'download and prepare the release' % (release, release)
            else:
                err = '"%s" is not a valid release, run "seedbank list -n" to '\
                    'list valid releases ' % release
            raise self.exception(err)

        if args.macaddress:
            if len(args.macaddress) == 12:
                pass
            elif not re.match('([a-fA-F0-9]{2}[:|\-]?){6}', args.macaddress):
                err = '"%s" is not a valid MAC address' % args.macaddress
                raise self.exception(err)
            args.address = utils.format_address(args.macaddress)
        else:
            ip_address = utils.resolve_ip_address(args.fqdn)
            args.address = utils.ip_to_hex(ip_address)

        pxe_linux = pxe.GeneratePxe(args)
        pxe_linux.state_remove()
        pxe_linux.write(pxe_linux.generate())
        pxe_linux.hook_enable()

        logging.info(
            '"%s" will be installed with "%s" after the next PXE boot',
            args.fqdn, args.release)
예제 #3
0
파일: parse.py 프로젝트: dmeulen/seedBank
    def pxe(self, args):
        """process the pxe command"""
        try:
            _, release, _ = args.release.split("-")
        except:
            err = (
                '"%s" is an unknown release (first run "seedbank '
                'manage -n <release>" to download and prepare the '
                'release, run "seedbank list -n" to list available '
                "releases" % args.release
            )
            raise self.exception(err)

        args, config = self._shared(args, release)

        path = os.path.join(config["paths"]["tftpboot"], "seedbank", args.release)
        if not os.path.isdir(path):
            if release in config["distributions"]["netboots"]:
                err = (
                    '"%s" is not available, run "seedbank manage -n "%s" to '
                    "download an prepare the release" % args.release
                )
            raise self.exception(err)

        if args.macaddress:
            if len(args.macaddress) == 12:
                pass
            elif not re.match("([a-fA-F0-9]{2}[:|\-]?){6}", args.macaddress):
                err = '"%s" is not a valid MAC address' % args.macaddress
                raise self.exception(err)
            args.address = utils.format_address(args.macaddress)
        else:
            ip_address = utils.resolve_ip_address(args.fqdn)
            args.address = utils.ip_to_hex(ip_address)

        pxe_linux = pxe.GeneratePxe(args)
        pxe_linux.state_remove()
        pxe_linux.write(pxe_linux.generate())
        pxe_linux.hook_enable()
예제 #4
0
 def set_tcp_info(self, info):
     '''
     设置TCP参数
     '''
     command = Command('010601', '00000089')
     read_command = Command('010600', '00000000')
     old_info = self.send_command(read_command)['data']
     mac = old_info[:12]
     ip = ip_to_hex(info['ip'])
     mask = ip_to_hex(info['mask'])
     gateway = ip_to_hex(info['gateway'])
     dns1 = ip_to_hex(info['dns1'])
     dns2 = ip_to_hex(info['dns2'])
     work_type = info['work_type']
     tcp_listen = hex(info['tcp_listen'])[2:]
     udp_listen = hex(info['udp_listen'])[2:]
     remote_port = hex(info['remote_port'])[2:]
     remote_ip = ip_to_hex(info['remote_ip'])
     dhcp = info['dhcp']
     remote_domain = str_to_hex(info['remote_domain'])
     data = mac + ip + mask + gateway + dns1 + dns2 + work_type + tcp_listen + udp_listen + remote_port + remote_ip + dhcp + remote_domain
     data = data.ljust(274, '0')
     res = self.send_command(command, data=data)
     return res
예제 #5
0
    for thread in threads_list:
        thread.start()

    for thread in threads_list:
        thread.join()

    for service in scanned_services:
        print(service)

    print(f'Scanned in {round(time() - start_time, 2)} seconds')


threads = int(argv[1])
diapason = argv[2]
diapason_start, diapason_end = utils.get_start_end(diapason)
nmap_args = ['nmap'] + argv[3:]
scanned_services = []

diapason_start_int10 = int.from_bytes(utils.ip_to_hex(diapason_start), 'big')
diapason_end_int10 = int.from_bytes(utils.ip_to_hex(diapason_end), 'big')

addresses_amount = diapason_end_int10 - diapason_start_int10 + 1
threads_list = []
lock = Lock()

start_time = time()
CMD_ENCODING = '866'

if __name__ == '__main__':
    main()