Example #1
0
def file_search(name=None, hash=None, tags=None, limit=None, offset=None,
                verbose=False):
    """Search a file by name or hash value

    :param name: name of the file ('*name*' will be searched)
    :type name: str
    :param hash: one of sha1, md5 or sha256 full hash value
    :type hash: str of (64, 40 or 32 chars)
    :param tags: list of tagid
    :type tags: list of int
    :param limit: max number of files to receive
        (optional default:25)
    :type limit: int
    :param offset: index of first result
        (optional default:0)
    :type offset: int
    :param verbose: enable verbose requests (optional default:False)
    :type verbose: bool
    :return: return tuple of total files and list of matching files already
        scanned
    :rtype: tuple(int, list of IrmaResults)
    """
    cli = IrmaApiClient(API_ENDPOINT, max_tries=max_tries, pause=pause,
                        verify=verify, verbose=verbose)
    fileapi = IrmaFilesApi(cli)
    (total, files_list) = fileapi.search(name=name, hash=hash, tags=tags,
                                         limit=limit, offset=offset)
    return (total, files_list)
Example #2
0
def file_tag_remove(sha256, tagid, verbose=False):
    """Remove a tag to a File

    :param sha256: file sha256 hash
    :type sha256: str of (64 chars)
    :param tagid: tag id
    :type tagid: int
    :return: No return
    """
    cli = IrmaApiClient(API_ENDPOINT, verbose=verbose)
    fileapi = IrmaFilesApi(cli)
    fileapi.tag_remove(sha256, tagid)
    return
Example #3
0
def file_tag_add(sha256, tagid, verbose=False):
    """Add a tag to a File

    :param sha256: file sha256 hash
    :type sha256: str of (64 chars)
    :param tagid: tag id
    :type tagid: int
    :return: No return
    """
    cli = IrmaApiClient(API_ENDPOINT, max_tries=max_tries, pause=pause,
                        verify=verify, verbose=verbose)
    fileapi = IrmaFilesApi(cli)
    fileapi.tag_add(sha256, tagid)
    return
Example #4
0
def file_download(sha256, dest_filepath, verbose=False):
    """Download file identified by sha256 to dest_filepath

    :param sha256: file sha256 hash value
    :type sha256: str of 64 chars
    :param dest_filepath: destination path
    :type dest_filepath: str
    :param verbose: enable verbose requests (optional default:False)
    :type verbose: bool
    :return: return tuple of total files and list of results for the given file
    :rtype: tuple(int, list of IrmaResults)
    """
    cli = IrmaApiClient(API_ENDPOINT, verbose=verbose)
    fileapi = IrmaFilesApi(cli)
    fileapi.download(sha256, dest_filepath)
    return
Example #5
0
def file_results(sha256, limit=None, offset=None, verbose=False):
    """List all results for a given file identified by sha256

    :param sha256: file sha256 hash value
    :type sha256: str of 64 chars
    :param limit: max number of files to receive
        (optional default:25)
    :type limit: int
    :param offset: index of first result
        (optional default:0)
    :type offset: int
    :param verbose: enable verbose requests (optional default:False)
    :type verbose: bool
    :return: tuple(int, list of IrmaResults)
    """
    cli = IrmaApiClient(API_ENDPOINT, verbose=verbose)
    fileapi = IrmaFilesApi(cli)
    (total, files_list) = fileapi.results(sha256, limit=limit, offset=offset)
    return (total, files_list)