Ejemplo n.º 1
0
    def handler(self, args, websites):
        """Handle injection without a domain list"""

        ## Victim parameters
        if args.covert:

            ## Broadcast mode
            if not args.t:

                ### Trace out what highjacker is
                vp = VictimParameters(inject_file=args.injection,
                                      covert=args.covert,
                                      hijack='hijacker')

            ## Targeted mode
            else:
                vp = VictimParameters(inject_file=args.injection,
                                      covert=args.covert)
        else:
            vp = VictimParameters(inject_file=args.injection)

        ## Broadcast mode
        if not args.t:
            if args.exclude_hosts is None:
                ph = PacketHandler(Args=args, i=args.i, victim_parameters=vp)
            else:
                ph = PacketHandler(Args=args,
                                   i=args.i,
                                   victim_parameters=vp,
                                   excluded=args.exclude_hosts)

        ## Targeted mode
        else:
            victims = []
            for victim in args.t:
                v1 = Victim(mac=victim, victim_parameters=vp)
                victims.append(v1)

            if args.exclude_hosts is None:
                ph = PacketHandler(Args=args, i=args.i, victims=victims)
            else:
                ph = PacketHandler(Args=args,
                                   i=args.i,
                                   victims=victims,
                                   excluded=args.exclude_hosts)

        ## Begin sniffing
        if 'mon' in args.m:
            snif = Sniffer(ph, m=args.m)
            snif.threaded_sniff(args)
        else:
            ## Broadcast mode
            if not args.t:
                snif = Sniffer(ph, m=args.m, filter='')

            ## Targeted mode
            else:
                snif = Sniffer(ph, m=args.m)

            snif.threaded_sniff(args)
Ejemplo n.º 2
0
    def handler(self, args):
        """Handle injection using the contents of a given file"""

        ## Victim parameters
        if args.covert:
            vp = VictimParameters(inject_file=args.injection,
                                  covert=args.covert)
        else:
            vp = VictimParameters(inject_file=args.injection)

        ## Broadcast mode
        if not args.t:
            ph = PacketHandler(Args=args, i=args.i, victim_parameters=vp)

        ## Targeted mode
        else:
            victims = []
            for victim in args.t:
                v1 = Victim(mac=victim, victim_parameters=vp)
                victims.append(v1)

            ph = PacketHandler(Args=args, i=args.i, victims=victims)

        ## Begin sniffing
        snif = Sniffer(ph, args, m=args.m)
        snif.threaded_sniff(args)  ## Here
Ejemplo n.º 3
0
def test_a_werewolf_who_has_consumed_a_victim_is_no_longer_hungry():
    human = Victim()
    werewolf = Werewolf("David","London", human_state=False, hungry=True)

    assert werewolf.is_hungry()
    werewolf.consume(human)
    assert not werewolf.is_hungry()
Ejemplo n.º 4
0
    def handler(self, args, websites):
        """Handle domain list"""
        ## Victim parameters
        if args.covert:
            vp = VictimParameters(websites=websites, covert=args.covert)
        else:
            vp = VictimParameters(websites=websites)

        ## Broadcast mode
        if not args.t:
            if args.exclude_hosts is None:
                ph = PacketHandler(Args=args, i=args.i, victim_parameters=vp)
            else:
                ph = PacketHandler(Args=args,
                                   i=args.i,
                                   victim_parameters=vp,
                                   excluded=args.exclude_hosts)

        ## Targeted mode
        else:
            victims = []
            for victim in args.t:
                v1 = Victim(mac=victim, victim_parameters=vp)
                victims.append(v1)

            if args.exclude_hosts is None:
                ph = PacketHandler(Args=args, i=args.i, victims=victims)
            else:
                ph = PacketHandler(Args=args,
                                   i=args.i,
                                   victims=victims,
                                   excluded=args.exclude_hosts)

        ## Begin sniffing
        if 'mon' in args.m:
            snif = Sniffer(ph, m=args.m)
            snif.threaded_sniff(args)
        else:
            snif = Sniffer(ph, m=args.m, filter='')
            snif.threaded_sniff(args)
Ejemplo n.º 5
0
    def process(self, interface, pkt, args):
        """Process packets coming from the sniffer.

        You can override the handler with one of your own,
        that you can use for any other packet type (e.g DNS),
        otherwise it uses the default packet handler looking
        for GET requests for injection and cookies.
        """
        ## You can write your own handler for packets
        ## If wanted, do something like:
        #if self.handler is not None:
        #self.handler(interface, pkt, args)
        #else:
        try:
            vicmac,\
            rtrmac,\
            dstmac,\
            vicip,\
            svrip,\
            vicport,\
            svrport,\
            acknum,\
            seqnum,\
            request,\
            cookie,\
            TSVal,\
            TSecr = self.proc_handler(pkt, args)

            ## Broadcast mode
            if not args.t:
                v1 = Victim(ip=vicip,
                            mac=vicmac,
                            victim_parameters=self.victim_parameters)
                self.newvictims.append(v1)

            self.proc_injection(vicmac, rtrmac, dstmac, vicip, svrip, vicport,
                                svrport, acknum, seqnum, request, cookie,
                                TSVal, TSecr, args)
        except:
            return
Ejemplo n.º 6
0
    def cookieManager(self, vicmac, vicip, cookie, args):
        """This function does cookie management for broadcast mode and targeted mode.

        A new mode is also added that can work in both broadcast
        added that if VictimParameters is set, it also performs a broadcast attack.
        """

        ### Need to comment this up...
        if len(self.victims) == 0:
            try:
                k = cookie[1]
            except:
                cookie = ["NONE", "NONE"]

            if cookie[1] is not None:
                exists = 0
                for victim in self.newvictims:
                    if victim.ip is not None:
                        if victim.ip == vicip:
                            victim.add_cookie(cookie, args)
                            exists = 1

                    else:
                        if victim.mac is not None:
                            if victim.mac.lower() == vicmac.lower():
                                victim.add_cookie(cookie, args)
                                exists = 1

                if exists == 0:
                    v1 = Victim(ip=vicip,
                                mac=vicmac,
                                victim_parameters=self.victim_parameters)
                    v1.add_cookie(cookie, args)
                    self.newvictims.append(v1)

            else:
                if cookie[0] is not None and cookie[1] is None:
                    newcookie = [cookie[0], "NONE"]
                    cookie = newcookie
                    for victim in self.newvictims:
                        if victim.ip is not None:
                            if victim.ip == vicip:
                                victim.add_cookie(cookie, args)

                        else:
                            if victim.mac is not None:
                                if victim.mac.lower() == vicmac.lower():
                                    victim.add_cookie(cookie, args)

                exists = 0
                for victim in self.newvictims:
                    if victim.ip is not None:
                        if victim.ip == vicip:
                            exists = 1

                    else:
                        if victim.mac is not None:
                            if victim.mac.lower() == vicmac.lower():
                                exists = 1

                if exists == 0:
                    v1 = Victim(ip=vicip,
                                mac=vicmac,
                                victim_parameters=self.victim_parameters)
                    self.newvictims.append(v1)

        else:
            vic_in_targets = 0
            try:
                k = cookie[1]
            except:
                try:
                    k = cookie[0]
                    cookie[1] = 'NONE'
                except:
                    cookie = ['NONE', 'NONE']

            if cookie[1] is not None:
                for victim in self.victims:
                    if victim.ip is not None:
                        if victim.ip == vicip:
                            vic_in_targets = 1
                            victim.add_cookie(cookie, args)

                    else:
                        if victim.mac is not None:
                            if victim.mac.lower() == vicmac.lower():
                                vic_in_targets = 1
                                victim.add_cookie(cookie, args)

            else:
                if cookie[0] is not None and cookie[1] is None:
                    newcookie = [cookie[0], 'NONE']
                    cookie = newcookie
                    for victim in self.victims:
                        if victim.ip is not None:
                            if victim.ip == vicip:
                                vic_in_targets = 1
                                victim.add_cookie(cookie, args)

                        else:
                            if victim.mac is not None:
                                if victim.mac.lower() == vicmac.lower():
                                    victim.add_cookie(cookie, args)
                                    vic_in_targets = 1

            ## IF VIC IS IN TARGETS, RETURN
            if vic_in_targets == 1:
                return

            if self.victim_parameters is not None:
                try:
                    k = cookie[1]
                except:
                    #print cookie
                    cookie = ['NONE', 'NONE']
                if cookie[1] is not None:
                    exists = 0
                    for victim in self.newvictims:
                        if victim.ip is not None:
                            if victim.ip == vicip:
                                victim.add_cookie(cookie, args)
                                exists = 1

                        else:
                            if victim.mac is not None:
                                if victim.mac.lower() == vicmac.lower():
                                    victim.add_cookie(cookie, args)
                                    exists = 1

                    if exists == 0:
                        v1 = Victim(ip=vicip,
                                    mac=vicmac,
                                    victim_parameters=self.victim_parameters)
                        v1.add_cookie(cookie, args)
                        self.newvictims.append(v1)

                else:
                    if cookie[0] is not None and cookie[1] is None:
                        newcookie = [cookie[0], 'NONE']
                        cookie = newcookie
                        for victim in self.newvictims:
                            if victim.ip is not None:
                                if victim.ip == vicip:
                                    victim.add_cookie(cookie, args)

                            else:
                                if victim.mac is not None:
                                    if victim.mac.lower() == vicmac.lower():
                                        victim.add_cookie(cookie, args)

                    exists = 0
                    for victim in self.newvictims:
                        if victim.ip is not None:
                            if victim.ip == vicip:
                                exists = 1

                        else:
                            if victim.mac is not None:
                                if victim.mac.lower() == vicmac.lower():
                                    exists = 1

                    if exists == 0:
                        v1 = Victim(ip=vicip,
                                    mac=vicmac,
                                    victim_parameters=self.victim_parameters)
                        self.newvictims.append(v1)
Ejemplo n.º 7
0
    def cookieManager(self,
                      vicmac,
                      vicip,
                      cookie,
                      args):
        """This function does cookie management for broadcast mode and targeted mode.

        A new mode is also added that can work in both broadcast
        added that if VictimParameters is set, it also performs a broadcast attack.
        """
        
        ### Need to comment this up...
        if len(self.victims) == 0:
            try:
                k = cookie[1]
            except:
                cookie = ["NONE", "NONE"]

            if cookie[1] is not None:
                exists = 0
                for victim in self.newvictims:
                    if victim.ip is not None:
                        if victim.ip == vicip:
                            victim.add_cookie(cookie, args)
                            exists = 1

                    else:
                        if victim.mac is not None:
                            if victim.mac.lower() == vicmac.lower():
                                victim.add_cookie(cookie, args)
                                exists = 1

                if exists == 0:
                    v1 = Victim(ip = vicip,
                                mac = vicmac,
                                victim_parameters = self.victim_parameters)
                    v1.add_cookie(cookie, args)
                    self.newvictims.append(v1)

            else:
                if cookie[0] is not None and cookie[1] is None:
                    newcookie = [cookie[0], "NONE"]
                    cookie = newcookie
                    for victim in self.newvictims:
                        if victim.ip is not None:
                            if victim.ip == vicip:
                                victim.add_cookie(cookie, args)

                        else:
                            if victim.mac is not None:
                                if victim.mac.lower() == vicmac.lower():
                                    victim.add_cookie(cookie, args)

                exists = 0
                for victim in self.newvictims:
                    if victim.ip is not None:
                        if victim.ip == vicip:
                            exists = 1

                    else:
                        if victim.mac is not None:
                            if victim.mac.lower() == vicmac.lower():
                                exists = 1

                if exists == 0:
                    v1 = Victim(ip = vicip,
                                mac = vicmac,
                                victim_parameters = self.victim_parameters)
                    self.newvictims.append(v1)

        else:
            vic_in_targets = 0
            try:
                k = cookie[1]
            except:
                try:
                    k = cookie[0]
                    cookie[1] = 'NONE'
                except:
                    cookie = ['NONE', 'NONE']

            if cookie[1] is not None:
                for victim in self.victims:
                    if victim.ip is not None:
                        if victim.ip == vicip:
                            vic_in_targets = 1
                            victim.add_cookie(cookie, args)

                    else:
                        if victim.mac is not None:
                            if victim.mac.lower() == vicmac.lower():
                                vic_in_targets = 1
                                victim.add_cookie(cookie, args)

            else:
                if cookie[0] is not None and cookie[1] is None:
                    newcookie = [cookie[0], 'NONE']
                    cookie = newcookie
                    for victim in self.victims:
                        if victim.ip is not None:
                            if victim.ip == vicip:
                                vic_in_targets = 1
                                victim.add_cookie(cookie, args)

                        else:
                            if victim.mac is not None:
                                if victim.mac.lower() == vicmac.lower():
                                    victim.add_cookie(cookie, args)
                                    vic_in_targets = 1

            ## IF VIC IS IN TARGETS, RETURN
            if vic_in_targets == 1:
                return

            if self.victim_parameters is not None:
                try:
                    k = cookie[1]
                except:
                    #print cookie
                    cookie = ['NONE', 'NONE']
                if cookie[1] is not None:
                    exists = 0
                    for victim in self.newvictims:
                        if victim.ip is not None:
                            if victim.ip == vicip:
                                victim.add_cookie(cookie, args)
                                exists = 1

                        else:
                            if victim.mac is not None:
                                if victim.mac.lower() == vicmac.lower():
                                    victim.add_cookie(cookie, args)
                                    exists = 1

                    if exists == 0:
                        v1 = Victim(ip = vicip,
                                    mac = vicmac,
                                    victim_parameters = self.victim_parameters)
                        v1.add_cookie(cookie, args)
                        self.newvictims.append(v1)

                else:
                    if cookie[0] is not None and cookie[1] is None:
                        newcookie = [cookie[0], 'NONE']
                        cookie = newcookie
                        for victim in self.newvictims:
                            if victim.ip is not None:
                                if victim.ip == vicip:
                                    victim.add_cookie(cookie, args)

                            else:
                                if victim.mac is not None:
                                    if victim.mac.lower() == vicmac.lower():
                                        victim.add_cookie(cookie, args)

                    exists = 0
                    for victim in self.newvictims:
                        if victim.ip is not None:
                            if victim.ip == vicip:
                                exists = 1

                        else:
                            if victim.mac is not None:
                                if victim.mac.lower() == vicmac.lower():
                                    exists = 1

                    if exists == 0:
                        v1 = Victim(ip = vicip,
                                    mac = vicmac,
                                    victim_parameters = self.victim_parameters)
                        self.newvictims.append(v1)
Ejemplo n.º 8
0
def test_a_werewolf_who_has_consumed_a_victim_makes_the_victim_dead():
    human = Victim()
    werewolf = Werewolf("David","London", human_state=False, hungry=True)

    werewolf.consume(human)
    assert human.status == "Dead"
Ejemplo n.º 9
0
def test_cannot_consume_victim_if_in_human_form():
    human = Victim()
    werewolf = Werewolf("David","London")

    assert werewolf.consume(human) == "No one was consumed"
Ejemplo n.º 10
0
def test_consumes_a_victim():
    human = Victim()
    werewolf = Werewolf("David","London")

    werewolf.consume(human)
Ejemplo n.º 11
0
def test_victim_starts_alive():
    human = Victim()
    assert human.status == "Alive"