示例#1
0
def scapy_layers_dot11_Dot11_rsn(self):
    """Return the payload of the RSN Dot11Elt as a Dot11EltRSN"""
    elt = self.find_elt_by_id(48)
    if elt:
        try:
            return Dot11EltRSN(str(elt))
        except Exception, e:
            Printer.error('Bad Dot11EltRSN got[{0:s}]'.format(elt.info))
            Printer.exception(e)
示例#2
0
def scapy_layers_dot11_Dot11_rates(self, id=1):
    """Return the payload of the rates Dot11Elt if it exists"""
    elt = self.find_elt_by_id(id)
    if elt:
        try:
            return Dot11EltRates(str(elt)).rates
        except Exception, e:
            Printer.error('Bad Dot11EltRates got[{0:s}]'.format(elt.info))
            Printer.exception(e)
示例#3
0
def scapy_layers_dot11_Dot11_channel(self):
    """Return the payload of the channel Dot11Elt if it exists"""
    elt = self.find_elt_by_id(3)
    if elt:
        try:
            return int(ord(elt.info))
        except Exception, e:
            Printer.error('Bad Dot11Elt channel got[{0:s}]'.format(elt.info))
            Printer.exception(e)
示例#4
0
def scapy_layers_dot11_Dot11_rsn(self):
    """Return the payload of the RSN Dot11Elt as a Dot11EltRSN"""
    elt = self.find_elt_by_id(48)
    if elt:
        try:
            return Dot11EltRSN(str(elt))
        except Exception, e:
            Printer.error("Bad Dot11EltRSN got[{0:s}]".format(elt.info))
            Printer.exception(e)
示例#5
0
def scapy_layers_dot11_Dot11_channel(self):
    """Return the payload of the channel Dot11Elt if it exists"""
    elt = self.find_elt_by_id(3)
    if elt:
        try:
            return int(ord(elt.info))
        except Exception, e:
            Printer.error("Bad Dot11Elt channel got[{0:s}]".format(elt.info))
            Printer.exception(e)
示例#6
0
def scapy_layers_dot11_Dot11_rates(self, id=1):
    """Return the payload of the rates Dot11Elt if it exists"""
    elt = self.find_elt_by_id(id)
    if elt:
        try:
            return Dot11EltRates(str(elt)).rates
        except Exception, e:
            Printer.error("Bad Dot11EltRates got[{0:s}]".format(elt.info))
            Printer.exception(e)
class Client(threading.Thread):

    def __init__(self):
        threading.Thread.__init__(self)
        self.printer = Printer("client")

    def run(self):

        sock = socket.create_connection((Config.monitor_ip, Config.monitor_port))
        for line in sock.makefile():
            response = self.generate_response(line)
            self.printer.command(response)
            sock.send(response)

        sock.close()

    def generate_response(self, line):

        line = line.strip()
        directive, args = [x.strip() for x in line.split(':', 1)]

        self.printer.directive(line)

        if directive == "REQUIRE":
            if args == "IDENT":
                return "IDENT %s\n" % Config.ident
            elif args == "PASSWORD":
                return "PASSWORD %s\n" % Config.password
            elif args == "ALIVE":
                if Config.cookie == "":
                    self.printer.info("Alive request but we don't know the cookie!")
                else:
                    return "ALIVE %s\n" % Config.cookie
            elif args == "HOST_PORT":
                return "HOST_PORT %s %s\n" % (Config.host_ip, Config.host_port)
            else:
                self.printer.error("Unknown require: " + line)
        elif directive == "RESULT":
            args = args.split(' ', 1)
            if args[0] == "PASSWORD":
                Config.cookie = args[1]
                self.printer.info("Got cookie: " + Config.cookie)
            elif args[0] == "HOST_PORT":
                self.printer.info("Login successful! (%s)" % args[1])
            else:
                self.printer.error("Unknown result: " + line)
        elif directive == "WAITING":
            pass
        elif directive == "COMMENT":
            pass
        elif directive == "COMMAND_ERROR":
            if "unable to connect to host" in args:
                return ""
            else:
                self.printer.error(line)
        else:
            self.printer.error("Unknown directive: " + line)

        return ""
示例#8
0
    def apply_filter(self, packet):
        try:
            # Verify the RadioTap header, scanner, and WE all match
            # if packet.haslayer(RadioTap) and not self.options.input_file:
                # assert (self.options.channel == packet[RadioTap].Channel), 'got[{0}] expect[{1}]'.format(packet[RadioTap].Channel, self.options.channel)

                # channel = self.options.we.get_channel()
                # assert (self.options.channel == channel), 'got[{0}] expected[{1}]'.format(channel, self.options.channel)

            # Track AP and STA
            if packet.haslayer(Dot11):
                self.notify(packet)
                return True

            # That's unexpected.  print for debugging
            else:
                Printer.error(packet.show())
        except Exception, exc:
            Printer.exception(exc)
示例#9
0
class tcp_handler(SocketServer.StreamRequestHandler):

    def setup(self):

        self.printer = Printer("server")
        SocketServer.StreamRequestHandler.setup(self)

    def generate_response(self, line):

        line = line.strip()
        directive, args = [x.strip() for x in line.split(':', 1)]

        self.printer.directive(line)

        if directive == "REQUIRE":
            if args == "IDENT":
                return "IDENT %s\n" % Config.ident
            elif args == "ALIVE":
                if Config.cookie == "":
                    self.printer.info("Alive request but we don't know the cookie!")
                else:
                    return "ALIVE %s\n" % Config.cookie
            elif args == "QUIT":
                return "QUIT\n"
            else:
                self.printer.error("Unknown require: " + line)
        elif directive == "RESULT":
            args = args.split(' ', 1)
            if args[0] == "ALIVE" and args[1] == "Identity has been verified.":
                self.printer.info("Alive verified")
            elif args[0] == "QUIT":
                self.printer.info("server has quit")
            else:
                self.printer.error("Unknown result")
        elif directive == "PARTICIPANT_PASSWORD_CHECKSUM":
            self.printer.info("Got checksum: %s" % args)
        elif directive == "WAITING":
            pass
        elif directive == "COMMENT":
            pass
        else:
            self.printer.error("Unknown directive: " + line)

        return ""

    def handle(self):

        for line in self.rfile:
            response = self.generate_response(line)
            self.printer.command(response)
            self.wfile.write(response)