(self, files, payload, machine=None, tags=None,
                  options=None)
return task_id
Post a new analysis task to Cuckoo.

        Args:
            files: file information for file object or url
            payload (dict): POST parameters
            machine (str): the machine label to submit to (or None if any
                machine)
            options (dict): Task options
        Returns:
            Task ID or None
Post a new analysis task to Cuckoo.
Post a new analysis task to Cuckoo .
def post_task(self, files, payload, machine=None, tags=None,
                  options=None):
        """
        Post a new analysis task to Cuckoo.

        Args:
            files: file information for file object or url
            payload (dict): POST parameters
            machine (str): the machine label to submit to (or None if any
                machine)
            options (dict): Task options
        Returns:
            Task ID or None
        """
        if machine:
            payload['machine'] = machine
        else:
            machine = 'any'
        if options:
            payload['options'] = options

        # Set the response object to be None.
        r = None

        if self.obj._meta['crits_type'] in ('Domain', 'IP', 'Indicator'):
            # Submit a url to the cuckoo instnace if the crits_type was an
            # Indicator, IP, or Domain.
            r = requests.post(self.base_url + '/tasks/create/url',
                              files=files, data=payload, proxies=self.proxies)
        elif self.obj._meta['crits_type'] == 'Sample':
            # Submit a file to the cuckoo instance if the crits_type was a
            # Sample.
            r = requests.post(self.base_url + '/tasks/create/file',
                              files=files, data=payload, proxies=self.proxies)

        # TODO: check return status codes
        if r.status_code != requests.codes.ok:
            msg = "Failed to submit file to machine '%s'." % machine
            self._error(msg)
            self._debug(r.text)
            return None

        response = dict(r.json())

        if 'task_ids' in response:
            task_id = response['task_ids'][0]
        else:
            task_id = response['task_id']

        self._info("Options: {0}".format(options))
        self._info("Submitted Task ID %s for machine %s" % (task_id, machine))

        return task_id
def post_task ( self , files , payload , machine = None , tags = None , options = None ) : if machine : payload [ 'machine' ] = machine else : machine = 'any' if options : payload [ 'options' ] = options # Set the response object to be None. r = None if self . obj . _meta [ 'crits_type' ] in ( 'Domain' , 'IP' , 'Indicator' ) : # Submit a url to the cuckoo instnace if the crits_type was an # Indicator, IP, or Domain. r = requests . post ( self . base_url + '/tasks/create/url' , files = files , data = payload , proxies = self . proxies ) elif self . obj . _meta [ 'crits_type' ] == 'Sample' : # Submit a file to the cuckoo instance if the crits_type was a # Sample. r = requests . post ( self . base_url + '/tasks/create/file' , files = files , data = payload , proxies = self . proxies ) # TODO: check return status codes if r . status_code != requests . codes . ok : msg = "Failed to submit file to machine '%s'." % machine self . _error ( msg ) self . _debug ( r . text ) return None response = dict ( r . json ( ) ) if 'task_ids' in response : task_id = response [ 'task_ids' ] [ 0 ] else : task_id = response [ 'task_id' ] self . _info ( "Options: {0}" . format ( options ) ) self . _info ( "Submitted Task ID %s for machine %s" % ( task_id , machine ) ) return task_id