Пример #1
0
def get_metadata():
    if request.query.file_hash == '':
        response.status = 400
        return jsonize({'message': 'file_hash parameter is missing'})
    file_hash = clean_hash(request.query.file_hash)
    if not valid_hash(file_hash):
        response.status = 400
        return jsonize({'message': 'Invalid hash format (use MD5, SHA1 or SHA2)'})
    file_hash = get_file_id(file_hash)
    if file_hash is None:
        response.status = 404
        return jsonize({'message': 'Metadata not found in the database'})

    mdc = MetaController()
    res = mdc.read(file_hash)
    if res is None:
        log_event("metadata", file_hash)
    return dumps(change_date_to_str(res))
Пример #2
0
def get_metadata():
    file_hash=clean_hash(request.query.file_hash)
    if file_hash is None:
        return
    if len(file_hash) == 32: #ToDo: validate hash
        key = 'md5'
    elif len(file_hash) == 40:
        key = 'sha1'
    else:
        response.code = 400
        return jsonize({'message':'Invalid hash format (use MD5, SHA1 or SHA2)'})

    mdc=MetaController()
    res=mdc.read(file_hash)
    if res==None:
        response.code = 404
        return jsonize({'message':'Metadata not found in the database'})
    log_event("metadata",file_hash)

    return dumps(change_date_to_str(res))
Пример #3
0
def get_metadata():
    file_hash=clean_hash(request.query.file_hash)
    if file_hash is None:
        return
    if len(file_hash) == 32: #ToDo: validate hash
        key = 'md5'
    elif len(file_hash) == 40:
       key = 'sha1'
    #elif len(file_hash) == 64:
    #   key = 'sha256'
    else:
        response.code = 400
        return jsonize({'message':'Invalid hash format (use MD5, SHA1 or SHA2)'})
    
    mdc=MetaController()
    res=mdc.read(file_hash)
    if res==None:
        response.code = 404
        return jsonize({'message':'Metadata not found in the database'})
    log_event("metadata",file_hash)
    
    return dumps(res)
Пример #4
0
def upload_file(data_bin):
    pc=PackageController()
    file_id=hashlib.sha1(data_bin).hexdigest()
    res=pc.searchFile(file_id)
    if(res==None): # File not found. Add it to the package.
        pc.append(file_id,data_bin)
        print("Added: %s" % (file_id,))
        log_event("file added",str(file_id))
        return "ok"
    else:
        if(res==0):#file already exists
            log_event("file already exists",str(file_id))
            return "already exists"
        else:#existe y esta bloqueado por vt
            log_event("file already exists",str(file_id))
            return "virustotal"
Пример #5
0
def upload_file(data_bin):
    pc = PackageController()
    file_id = hashlib.sha1(data_bin).hexdigest()
    res = pc.searchFile(file_id)
    if (res == None):  # File not found. Add it to the package.
        pc.append(file_id, data_bin)
        print("Added: %s" % (file_id, ))
        log_event("file added", str(file_id))
        return "ok"
    else:
        if (res == 0):  #file already exists
            log_event("file already exists", str(file_id))
            return "already exists"
        else:  #existe y esta bloqueado por vt
            log_event("file already exists", str(file_id))
            return "virustotal"