Beispiel #1
0
	def break_shifter(self, sig, frame):
		self.screen.shifter_break = True
		while not self.screen.Shifter_stopped:
			pass
		self.screen.clear()
		del self.screen

		if V__:
			__HEADERS = [pull.BOLD+'NO', 'ESSID', 'PWR', 'ENC', 'CIPHER', 'AUTH', 'CH', 'BSSID', 'VENDOR', 'CL'+pull.END]
		else:
			__HEADERS = [pull.BOLD+'NO', 'ESSID', 'PWR', 'ENC', 'CIPHER', 'AUTH', 'CH', 'BSSID'+pull.END]
		tabulator__ = []
		###
		__sig_LIST = []
		for ap in self.shift.results():
			__sig_LIST.append(ap['pwr'])
		__sig_LIST = sorted(__sig_LIST, reverse=True)
		###
		count = 1
		for sig in __sig_LIST:
			for ap in self.shift.results():
				if ap['pwr'] == sig:
					ap['count'] = count
					count += 1; self.shift.results().remove(ap)
					self.WiFiAP.append(ap)
		###
		for ap in self.WiFiAP:
			if V__:
				tabulator__.append([ap['count'], pull.GREEN+ap['essid']+pull.END, ap['pwr'], ap['auth'], ap['cipher'], \
						ap['psk'], ap['channel'], ap['bssid'].upper(), pull.DARKCYAN+ap['vendor']+pull.END, ap['clients'] ])
			else:
				tabulator__.append([ap['count'], pull.GREEN+ap['essid']+pull.END, ap['pwr'], ap['auth'], ap['cipher'], \
						ap['psk'], ap['channel'], ap['bssid'].upper()])
		print "\n"+tabulate(tabulator__, headers=__HEADERS)+"\n"
		os.kill(os.getpid(), SIGINT)
Beispiel #2
0
    def Shifter(self, sniffer, iface_instance):

        __HEADERS = [
            'NO', 'ESSID', 'PWR', 'ENC', 'CIPHER', 'AUTH', 'CH', 'BSSID'
        ]

        while not self.shifter_break:
            tabulator__, __sig_LIST, self.__WiFiAP, __sig_FOUND = [], [], [], []

            for ap in sniffer.results():
                __sig_LIST.append(ap['pwr'])

            __sig_LIST = sorted(__sig_LIST, reverse=True)
            count = 1

            for sig in __sig_LIST:
                for ap in sniffer.results():
                    if ap['pwr'] == sig and not ap['bssid'] in __sig_FOUND:
                        __sig_FOUND.append(ap['bssid'])
                        ap['count'] = count
                        count += 1
                        self.__WiFiAP.append(ap)

            for ap in self.__WiFiAP:
                tabulator__.append([ap['count'], ap['essid'], ap['pwr'], ap['auth'], ap['cipher'], \
                  ap['psk'], ap['channel'], ap['bssid'].upper()])

            self.screen.addstr(0, 0, "[%s] Channel [%s] Time Elapsed [%d] Networks Found"\
                  % (self.cch(iface_instance.cch), self.c_time(), len(tabulator__)))
            self.screen.addstr(
                1, 0, "\n" + tabulate(tabulator__, headers=__HEADERS) + "\n")
            self.screen.refresh()

        self.Shifter_stopped = not False
Beispiel #3
0
    def __execute_test(self, test_path, test, wrapped):
        print(
            tabulate([
                "Running " + test, "Scoped: " + str(wrapped),
                "Path: " + test_path
            ], [25, 17, 0]))
        start = self.__now_ms()
        env = dict(os.environ)
        stdout = None
        stderr = None
        return_code = 0

        if wrapped:
            env['LD_PRELOAD'] = self.__lib_path

        p = subprocess.Popen('./' + test,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE,
                             cwd=test_path,
                             env=env,
                             universal_newlines=True)

        try:
            stdout, stderr = p.communicate(timeout=self.__process_timeout)
            return_code = p.returncode
        except subprocess.TimeoutExpired:
            p.kill()
            return_code = 124  # timeout return code
            stderr = "Exit by timeout. Timeout: " + self.__process_timeout

        self.__send_result(
            w.TestResult(test, wrapped, stdout, stderr,
                         self.__now_ms() - start, return_code))
Beispiel #4
0
    def __print_summary(self):
        def _to_test_result(code):
            return ("fail", "pass")[code == 0]

        cols_width = [20, 15, 15, 20, 20]
        self.__print("Test results:")
        self.__print("")
        self.__print(
            tabulate([
                "Test", "Raw result", "Scoped result", "Raw duration (ms)",
                "Scoped duration (ms)"
            ], cols_width))
        for k, v in self.__results.items():
            self.__print(
                tabulate([
                    k,
                    _to_test_result(v["raw"].return_code),
                    _to_test_result(v["scoped"].return_code),
                    v["raw"].duration, v["scoped"].duration
                ], cols_width))
        send_arguments = '%(srpc)ssocket.write_buffer_list(%(srpc)sbuffers, "%(function_name)s(%(variables)s)")' % (locals())


    if (buffers_add_results):
        buffers_add_results.insert(0, 'std::list< boost::asio::const_buffer > %(srpc)sbuffers;' %(locals ()))
        buffers_add_results.append ('%(srpc)sbuffers.push_back( boost::asio::buffer( &%(srpc)sconnection_magic, sizeof(%(srpc)sconnection_magic) ) );' % (locals()))
        send_results = ('%(srpc)ssocket.write_buffer_list(%(srpc)sbuffers, "%(function_name)s(%(variables)s)")' % (locals()))
    else:
        send_results = ('%(srpc)ssocket.write_scalar(%(srpc)sconnection_magic, "connection_magic", -1)' % (locals ()))

    if not recieve_results: recieve_results = 'true'
    if not recieve_arguments: recieve_arguments = 'true'

    function_prototype = '%(return_type)s %(namespace)s::%(function_name)s(%(typespec_names)s)' % locals()
    special_prototype = '  %(return_type)s %(function_name)s(%(typespec_names)s);' % locals()

    server_magic   = uniquestr(str2magic(server_name))
    function_magic = str2magic(function_prototype)
    if body is not None:
        function_call = body % (locals())
    server_switch_case = templates.server_switch_case % (locals ())

    return dict(
        srpc = srpc, # manglin prefix
        server_magic = server_magic,
        wrapper_function_prototype = function_prototype,
        function_implementation = templates.function_implementation % (locals()),
        server_switch_case = tabulate(server_switch_case, tabs=10),
        special_prototype = special_prototype,
        )
Beispiel #6
0
        send_results = (
            '%(srpc)ssocket.write_buffer_list(%(srpc)sbuffers, "%(function_name)s(%(variables)s)")'
            % (locals()))
    else:
        send_results = (
            '%(srpc)ssocket.write_scalar(%(srpc)sconnection_magic, "connection_magic", -1)'
            % (locals()))

    if not recieve_results: recieve_results = 'true'
    if not recieve_arguments: recieve_arguments = 'true'

    function_prototype = '%(return_type)s %(namespace)s::%(function_name)s(%(typespec_names)s)' % locals(
    )
    special_prototype = '  %(return_type)s %(function_name)s(%(typespec_names)s);' % locals(
    )

    server_magic = uniquestr(str2magic(server_name))
    function_magic = str2magic(function_prototype)
    if body is not None:
        function_call = body % (locals())
    server_switch_case = templates.server_switch_case % (locals())

    return dict(
        srpc=srpc,  # manglin prefix
        server_magic=server_magic,
        wrapper_function_prototype=function_prototype,
        function_implementation=templates.function_implementation % (locals()),
        server_switch_case=tabulate(server_switch_case, tabs=10),
        special_prototype=special_prototype,
    )