dynamic_analysis.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:dynamic-firmware-analysis 作者: secjey 项目源码 文件源码
def tar2db(firmware_id):
    """Populates the db with information related to the filesystem."""
    print(bcolors.OKBLUE + "[-] Writing filesystem information into database..." + bcolors.ENDC)
    command = TAR2DB_COMMAND.format(FIRMADYNE_PATH, firmware_id, OUTPUT_DIR)
    print(bcolors.ITALIC + command + bcolors.ENDC)
    tar2db = pexpect.spawn(command)
    # either an error is raised because keys already exist
    # which means the info has already been written in the db
    # or the command terminates properly
    index = tar2db.expect(['Key.*already exists', 'No such file or directory: .*\n', pexpect.EOF])
    if index == 0:
        print(bcolors.WARNING + "[!] This step was already performed earlier..." + bcolors.ENDC)
        return True
    elif index == 1:
        missing_file = tar2db.after.split('\n')[0].split(':')[1].strip()
        print(bcolors.FAIL + "[!] The file {} does not exist...".format(missing_file) + bcolors.ENDC)
        return False
    else:
        print(bcolors.OKGREEN + "[+] Filesystem information successfully written!" + bcolors.ENDC)
    return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号