gurudesh/pytracebugs huggingface dataset:
# Buggy code
def api_key():
    """Print REST API Key"""

    if os.environ.get("MOBSF_API_KEY"):
        logger.info("\nAPI Key read from environment variable")
        return os.environ["MOBSF_API_KEY"]

    secret_file = os.path.join(settings.MobSF_HOME, "secret")
    if isFileExists(secret_file):
        try:
            _api_key = open(secret_file).read().strip()
            return gen_sha256_hash(_api_key)
        except Exception:
            PrintException("[ERROR] Cannot Read API Key")


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def api_key():
    """Print REST API Key"""

    if os.environ.get("MOBSF_API_KEY"):
        logger.info("\nAPI Key read from environment variable")
        return os.environ["MOBSF_API_KEY"]

    secret_file = os.path.join(settings.MobSF_HOME, "secret")
    if isFileExists(secret_file):
        try:
            _api_key = open(secret_file).read().strip()
            return gen_sha256_hash(_api_key)
        except Exception:
            PrintException("Cannot Read API Key")
# Buggy code
def createUserConfig(MobSF_HOME):
    try:
        CONFIG_PATH = os.path.join(MobSF_HOME, "config.py")
        if isFileExists(CONFIG_PATH) == False:
            SAMPLE_CONF = os.path.join(settings.BASE_DIR, "MobSF/settings.py")
            with io.open(SAMPLE_CONF, mode="r", encoding="utf8", errors="ignore") as f:
                dat = f.readlines()
            CONFIG = list()
            add = False
            for line in dat:
                if "^CONFIG-START^" in line:
                    add = True
                if "^CONFIG-END^" in line:
                    break
                if add:
                    CONFIG.append(line.lstrip())
            CONFIG.pop(0)
            COMFIG_STR = "".join(CONFIG)
            with io.open(CONFIG_PATH, mode="w", encoding="utf8", errors="ignore") as f:
                f.write(COMFIG_STR)
    except:
        PrintException("[ERROR] Cannot create config file")


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def createUserConfig(MobSF_HOME):
    try:
        CONFIG_PATH = os.path.join(MobSF_HOME, "config.py")
        if isFileExists(CONFIG_PATH) == False:
            SAMPLE_CONF = os.path.join(settings.BASE_DIR, "MobSF/settings.py")
            with io.open(SAMPLE_CONF, mode="r", encoding="utf8", errors="ignore") as f:
                dat = f.readlines()
            CONFIG = list()
            add = False
            for line in dat:
                if "^CONFIG-START^" in line:
                    add = True
                if "^CONFIG-END^" in line:
                    break
                if add:
                    CONFIG.append(line.lstrip())
            CONFIG.pop(0)
            COMFIG_STR = "".join(CONFIG)
            with io.open(CONFIG_PATH, mode="w", encoding="utf8", errors="ignore") as f:
                f.write(COMFIG_STR)
    except:
        PrintException("Cannot create config file")
# Buggy code
def make_migrations(base_dir):
    """Create Database Migrations"""
    try:
        python = get_python()
        manage = os.path.join(base_dir, "manage.py")
        args = [python, manage, "makemigrations"]
        subprocess.call(args)
        args = [python, manage, "makemigrations", "StaticAnalyzer"]
        subprocess.call(args)
    except:
        PrintException("[ERROR] Cannot Make Migrations")


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def make_migrations(base_dir):
    """Create Database Migrations"""
    try:
        python = get_python()
        manage = os.path.join(base_dir, "manage.py")
        args = [python, manage, "makemigrations"]
        subprocess.call(args)
        args = [python, manage, "makemigrations", "StaticAnalyzer"]
        subprocess.call(args)
    except:
        PrintException("Cannot Make Migrations")
# Buggy code
def migrate(BASE_DIR):
    """Migrate Database"""
    try:
        python = get_python()
        manage = os.path.join(BASE_DIR, "manage.py")
        args = [python, manage, "migrate"]
        subprocess.call(args)
    except:
        PrintException("[ERROR] Cannot Migrate")


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def migrate(BASE_DIR):
    """Migrate Database"""
    try:
        python = get_python()
        manage = os.path.join(BASE_DIR, "manage.py")
        args = [python, manage, "migrate"]
        subprocess.call(args)
    except:
        PrintException("Cannot Migrate")
# Buggy code
def kali_fix(BASE_DIR):
    try:
        if platform.system() == "Linux" and platform.dist()[0] == "Kali":
            fix_path = os.path.join(BASE_DIR, "scripts/kali_fix.sh")
            subprocess.call(["chmod", "a+x", fix_path])
            subprocess.call([fix_path], shell=True)
    except:
        PrintException("[ERROR] Cannot run Kali Fix")


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def kali_fix(BASE_DIR):
    try:
        if platform.system() == "Linux" and platform.dist()[0] == "Kali":
            fix_path = os.path.join(BASE_DIR, "scripts/kali_fix.sh")
            subprocess.call(["chmod", "a+x", fix_path])
            subprocess.call([fix_path], shell=True)
    except:
        PrintException("Cannot run Kali Fix")
# Buggy code
def FindVbox(debug=False):
    try:
        if settings.ANDROID_DYNAMIC_ANALYZER == "MobSF_VM":
            if len(settings.VBOXMANAGE_BINARY) > 0 and isFileExists(
                settings.VBOXMANAGE_BINARY
            ):
                return settings.VBOXMANAGE_BINARY
            if platform.system() == "Windows":
                # Path to VBoxManage.exe
                vbox_path = [
                    "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe",
                    "C:\Program Files (x86)\Oracle\VirtualBox\VBoxManage.exe",
                ]
                for path in vbox_path:
                    if os.path.isfile(path):
                        return path
            else:
                # Path to VBoxManage in Linux/Mac
                vbox_path = ["/usr/bin/VBoxManage", "/usr/local/bin/VBoxManage"]
                for path in vbox_path:
                    if os.path.isfile(path):
                        return path
            if debug:
                logger.warning("Could not find VirtualBox path.")
    except:
        if debug:
            PrintException("[ERROR] Cannot find VirtualBox path.")


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def FindVbox(debug=False):
    try:
        if settings.ANDROID_DYNAMIC_ANALYZER == "MobSF_VM":
            if len(settings.VBOXMANAGE_BINARY) > 0 and isFileExists(
                settings.VBOXMANAGE_BINARY
            ):
                return settings.VBOXMANAGE_BINARY
            if platform.system() == "Windows":
                # Path to VBoxManage.exe
                vbox_path = [
                    "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe",
                    "C:\Program Files (x86)\Oracle\VirtualBox\VBoxManage.exe",
                ]
                for path in vbox_path:
                    if os.path.isfile(path):
                        return path
            else:
                # Path to VBoxManage in Linux/Mac
                vbox_path = ["/usr/bin/VBoxManage", "/usr/local/bin/VBoxManage"]
                for path in vbox_path:
                    if os.path.isfile(path):
                        return path
            if debug:
                logger.warning("Could not find VirtualBox path.")
    except:
        if debug:
            PrintException("Cannot find VirtualBox path.")
# Buggy code
def RunProcess(args):
    try:
        proc = subprocess.Popen(
            args,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
        )
        dat = ""
        while True:
            line = proc.stdout.readline()
            if not line:
                break
            dat += str(line)
        return dat
    except:
        PrintException("[ERROR] Finding Java path - Cannot Run Process")
        return ""


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def RunProcess(args):
    try:
        proc = subprocess.Popen(
            args,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
        )
        dat = ""
        while True:
            line = proc.stdout.readline()
            if not line:
                break
            dat += str(line)
        return dat
    except:
        PrintException("Finding Java path - Cannot Run Process")
        return ""
# Buggy code
def PrintException(msg, web=False):
    try:
        LOGPATH = settings.LOG_DIR
    except:
        LOGPATH = os.path.join(settings.BASE_DIR, "logs/")
    if not os.path.exists(LOGPATH):
        os.makedirs(LOGPATH)
    exc_type, exc_obj, tb = sys.exc_info()
    f = tb.tb_frame
    lineno = tb.tb_lineno
    filename = f.f_code.co_filename
    linecache.checkcache(filename)
    line = linecache.getline(filename, lineno, f.f_globals)
    ts = time.time()
    st = datetime.datetime.fromtimestamp(ts).strftime("%Y-%m-%d %H:%M:%S")
    dat = (
        "\n["
        + st
        + "]\n"
        + msg
        + ' ({0}, LINE {1} "{2}"): {3}'.format(filename, lineno, line.strip(), exc_obj)
    )
    if platform.system() == "Windows":
        logger.error(dat)
    else:
        if web:
            logger.error(Color.BOLD + Color.ORANGE + dat + Color.END)
        else:
            logger.error(Color.BOLD + Color.RED + dat + Color.END)
    with open(LOGPATH + "MobSF.log", "a") as f:
        f.write(dat)


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def PrintException(msg, web=False):
    """Print Exception verbose"""
    exc_type, exc_obj, tb = sys.exc_info()
    f = tb.tb_frame
    lineno = tb.tb_lineno
    filename = f.f_code.co_filename
    linecache.checkcache(filename)
    line = linecache.getline(filename, lineno, f.f_globals)
    dat = (
        "\n"
        + msg
        + ' ({0}, LINE {1} "{2}"): {3}'.format(filename, lineno, line.strip(), exc_obj)
    )
    if web:
        logger.warning(dat)
    else:
        logger.error(dat)
# Buggy code
def print_n_send_error_response(request, msg, api, exp="Error Description"):
    """Print and log errors"""
    logger.error(Color.BOLD + Color.RED + "[ERROR] " + msg + Color.END)
    time_stamp = time.time()
    formatted_tms = datetime.datetime.fromtimestamp(time_stamp).strftime(
        "%Y-%m-%d %H:%M:%S"
    )
    data = "\n[" + formatted_tms + "]\n[ERROR] " + msg
    try:
        log_path = settings.LOG_DIR
    except:
        log_path = os.path.join(settings.BASE_DIR, "logs/")
    if not os.path.exists(log_path):
        os.makedirs(log_path)
    with open(os.path.join(log_path, "MobSF.log"), "a") as flip:
        flip.write(data)
    if api:
        api_response = {"error": msg}
        return api_response
    else:
        context = {"title": "Error", "exp": exp, "doc": msg}
        template = "general/error.html"
        return render(request, template, context, status=500)


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def print_n_send_error_response(request, msg, api=False, exp="Error Description"):
    """Print and log errors"""
    logger.error(msg)
    if api:
        api_response = {"error": msg}
        return api_response
    else:
        context = {"title": "Error", "exp": exp, "doc": msg}
        template = "general/error.html"
        return render(request, template, context, status=500)
# Buggy code
def isInternetAvailable():
    try:
        proxies, verify = upstream_proxy("https")
    except:
        PrintException("[ERROR] Setting upstream proxy")
    try:
        requests.get(
            "https://www.google.com", timeout=5, proxies=proxies, verify=verify
        )
        return True
    except requests.exceptions.HTTPError as err:
        try:
            requests.get(
                "https://www.baidu.com/", timeout=5, proxies=proxies, verify=verify
            )
            return True
        except requests.exceptions.HTTPError as err1:
            return False
    return False


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def isInternetAvailable():
    try:
        proxies, verify = upstream_proxy("https")
    except:
        PrintException("Setting upstream proxy")
    try:
        requests.get(
            "https://www.google.com", timeout=5, proxies=proxies, verify=verify
        )
        return True
    except requests.exceptions.HTTPError as err:
        try:
            requests.get(
                "https://www.baidu.com/", timeout=5, proxies=proxies, verify=verify
            )
            return True
        except requests.exceptions.HTTPError as err1:
            return False
    return False
# Buggy code
def zipdir(path, zip_file):
    """Zip a directory."""
    try:
        logger.info("Zipping")
        # pylint: disable=unused-variable
        # Needed by os.walk
        for root, _sub_dir, files in os.walk(path):
            for file_name in files:
                zip_file.write(os.path.join(root, file_name))
    except:
        PrintException("[ERROR] Zipping")


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def zipdir(path, zip_file):
    """Zip a directory."""
    try:
        logger.info("Zipping")
        # pylint: disable=unused-variable
        # Needed by os.walk
        for root, _sub_dir, files in os.walk(path):
            for file_name in files:
                zip_file.write(os.path.join(root, file_name))
    except:
        PrintException("Zipping")
# Buggy code
def getADB():
    """Get ADB binary path"""
    try:
        if len(settings.ADB_BINARY) > 0 and isFileExists(settings.ADB_BINARY):
            return settings.ADB_BINARY
        else:
            adb = "adb"
            if platform.system() == "Darwin":
                adb_dir = os.path.join(settings.TOOLS_DIR, "adb/mac/")
                subprocess.call(["chmod", "777", adb_dir])
                adb = os.path.join(settings.TOOLS_DIR, "adb/mac/adb")
            elif platform.system() == "Linux":
                adb_dir = os.path.join(settings.TOOLS_DIR, "adb/linux/")
                subprocess.call(["chmod", "777", adb_dir])
                adb = os.path.join(settings.TOOLS_DIR, "adb/linux/adb")
            elif platform.system() == "Windows":
                adb = os.path.join(settings.TOOLS_DIR, "adb/windows/adb.exe")
            return adb
    except:
        PrintException("[ERROR] Getting ADB Location")
        return "adb"


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def getADB():
    """Get ADB binary path"""
    try:
        if len(settings.ADB_BINARY) > 0 and isFileExists(settings.ADB_BINARY):
            return settings.ADB_BINARY
        else:
            adb = "adb"
            if platform.system() == "Darwin":
                adb_dir = os.path.join(settings.TOOLS_DIR, "adb/mac/")
                subprocess.call(["chmod", "777", adb_dir])
                adb = os.path.join(settings.TOOLS_DIR, "adb/mac/adb")
            elif platform.system() == "Linux":
                adb_dir = os.path.join(settings.TOOLS_DIR, "adb/linux/")
                subprocess.call(["chmod", "777", adb_dir])
                adb = os.path.join(settings.TOOLS_DIR, "adb/linux/adb")
            elif platform.system() == "Windows":
                adb = os.path.join(settings.TOOLS_DIR, "adb/windows/adb.exe")
            return adb
    except:
        PrintException("Getting ADB Location")
        return "adb"
# Buggy code
def adb_binary_or32bit_support():
    """Check if 32bit is supported. Also if the binary works"""
    adb_path = getADB()
    try:
        fnull = open(os.devnull, "w")
        subprocess.call([adb_path], stdout=fnull, stderr=fnull)
    except:
        msg = (
            "\n[WARNING] You don't have 32 bit execution support enabled or MobSF shipped"
            " ADB binary is not compatible with your OS."
            "\nPlease set the 'ADB_BINARY' path in settings.py"
        )
        if platform.system != "Windows":
            logger.warning(Color.BOLD + Color.ORANGE + msg + Color.END)
        else:
            logger.warning(msg)


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def adb_binary_or32bit_support():
    """Check if 32bit is supported. Also if the binary works"""
    adb_path = getADB()
    try:
        fnull = open(os.devnull, "w")
        subprocess.call([adb_path], stdout=fnull, stderr=fnull)
    except:
        msg = (
            "\nYou don't have 32 bit execution support enabled or MobSF shipped"
            " ADB binary is not compatible with your OS."
            "\nPlease set the 'ADB_BINARY' path in settings.py"
        )
        logger.warning(msg)
# Buggy code
def check_basic_env():
    """Check if we have basic env for MobSF to run"""
    logger.info("MobSF Basic Environment Check")
    try:
        import capfuzz
    except ImportError:
        PrintException("[ERROR] CapFuzz not installed!")
        os.kill(os.getpid(), signal.SIGTERM)
    try:
        import lxml
    except ImportError:
        PrintException("[ERROR] lxml is not installed!")
        os.kill(os.getpid(), signal.SIGTERM)
    if platform.system() == "Windows":
        java = settings.JAVA_PATH + "java.exe"
    else:
        java = settings.JAVA_PATH + "java"
    if not isFileExists(java):
        logger.error(
            "Oracle Java is not available or `JAVA_DIRECTORY` in settings.py is configured incorrectly!"
        )
        logger.info("JAVA_DIRECTORY=%s" % settings.JAVA_DIRECTORY)
        logger.info("""Example Configuration:
                 JAVA_DIRECTORY = "C:/Program Files/Java/jdk1.7.0_17/bin/"
                 JAVA_DIRECTORY = "/usr/bin/"
        """)
        os.kill(os.getpid(), signal.SIGTERM)


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def check_basic_env():
    """Check if we have basic env for MobSF to run"""
    logger.info("MobSF Basic Environment Check")
    try:
        import capfuzz
    except ImportError:
        PrintException("CapFuzz not installed!")
        os.kill(os.getpid(), signal.SIGTERM)
    try:
        import lxml
    except ImportError:
        PrintException("lxml is not installed!")
        os.kill(os.getpid(), signal.SIGTERM)
    if platform.system() == "Windows":
        java = settings.JAVA_PATH + "java.exe"
    else:
        java = settings.JAVA_PATH + "java"
    if not isFileExists(java):
        logger.error(
            "Oracle Java is not available or `JAVA_DIRECTORY` in settings.py is configured incorrectly!"
        )
        logger.info("JAVA_DIRECTORY=%s" % settings.JAVA_DIRECTORY)
        logger.info("""Example Configuration:
                 JAVA_DIRECTORY = "C:/Program Files/Java/jdk1.7.0_17/bin/"
                 JAVA_DIRECTORY = "/usr/bin/"
        """)
        os.kill(os.getpid(), signal.SIGTERM)
# Buggy code
def search(request):
    """
    Search Scan by MD5 Route
    """
    md5 = request.GET["md5"]
    if re.match("[0-9a-f]{32}", md5):
        db_obj = RecentScansDB.objects.filter(MD5=md5)
        if db_obj.exists():
            return HttpResponseRedirect("/" + db_obj[0].URL)
        else:
            return HttpResponseRedirect("/not_found")
    return HttpResponseRedirect("/error/")


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def search(request):
    """
    Search Scan by MD5 Route
    """
    md5 = request.GET["md5"]
    if re.match("[0-9a-f]{32}", md5):
        db_obj = RecentScansDB.objects.filter(MD5=md5)
        if db_obj.exists():
            return HttpResponseRedirect("/" + db_obj[0].URL)
        else:
            return HttpResponseRedirect("/not_found")
    return print_n_send_error_response(request, "Invalid Scan Hash")
# Buggy code
def download(request):
    """
    Download from MobSF Route
    """
    try:
        if request.method == "GET":
            allowed_exts = settings.ALLOWED_EXTENSIONS
            filename = request.path.replace("/download/", "", 1)
            # Security Checks
            if "../" in filename:
                logger.info("\n[ATTACK] Path Traversal Attack detected")
                return HttpResponseRedirect("/error/")
            ext = os.path.splitext(filename)[1]
            if ext in allowed_exts:
                dwd_file = os.path.join(settings.DWD_DIR, filename)
                if os.path.isfile(dwd_file):
                    wrapper = FileWrapper(open(dwd_file, "rb"))
                    response = HttpResponse(wrapper, content_type=allowed_exts[ext])
                    response["Content-Length"] = os.path.getsize(dwd_file)
                    return response
    except:
        PrintException("Error Downloading File")
    return HttpResponseRedirect("/error/")


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def download(request):
    """
    Download from MobSF Route
    """
    msg = "Error Downloading File "
    if request.method == "GET":
        allowed_exts = settings.ALLOWED_EXTENSIONS
        filename = request.path.replace("/download/", "", 1)
        # Security Checks
        if "../" in filename:
            return print_n_send_error_response(
                request, "Path Traversal Attack detected"
            )
        ext = os.path.splitext(filename)[1]
        if ext in allowed_exts:
            dwd_file = os.path.join(settings.DWD_DIR, filename)
            if os.path.isfile(dwd_file):
                wrapper = FileWrapper(open(dwd_file, "rb"))
                response = HttpResponse(wrapper, content_type=allowed_exts[ext])
                response["Content-Length"] = os.path.getsize(dwd_file)
                return response
    msg += filename
    return print_n_send_error_response(request, msg)
# Buggy code
def add_to_recent_scan(name, md5, url):
    """
    Add Entry to Database under Recent Scan
    """
    try:
        db_obj = RecentScansDB.objects.filter(MD5=md5)
        if not db_obj.exists():
            new_db_obj = RecentScansDB(NAME=name, MD5=md5, URL=url, TS=timezone.now())
            new_db_obj.save()
    except:
        PrintException("[ERROR] Adding Scan URL to Database")


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def add_to_recent_scan(name, md5, url):
    """
    Add Entry to Database under Recent Scan
    """
    try:
        db_obj = RecentScansDB.objects.filter(MD5=md5)
        if not db_obj.exists():
            new_db_obj = RecentScansDB(NAME=name, MD5=md5, URL=url, TS=timezone.now())
            new_db_obj.save()
    except:
        PrintException("Adding Scan URL to Database")
# Buggy code
def get_report(self, file_hash):
    """
    :param file_hash: md5/sha1/sha256
    :return: json response / None
    """
    try:
        url = self.base_url + "report"
        params = {"apikey": settings.VT_API_KEY, "resource": file_hash}
        headers = {"Accept-Encoding": "gzip, deflate"}
        try:
            proxies, verify = upstream_proxy("https")
        except:
            PrintException("[ERROR] Setting upstream proxy")
        try:
            response = requests.get(
                url, params=params, headers=headers, proxies=proxies, verify=verify
            )
            if response.status_code == 403:
                logger.error("VirusTotal Permission denied, wrong api key?")
                return None
        except:
            logger.error("VirusTotal ConnectionError, check internet connectivity")
            return None
        try:
            json_response = response.json()
            return json_response
        except ValueError:
            return None
    except:
        PrintException("[ERROR] in VirusTotal get_report")
        return None


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def get_report(self, file_hash):
    """
    :param file_hash: md5/sha1/sha256
    :return: json response / None
    """
    try:
        url = self.base_url + "report"
        params = {"apikey": settings.VT_API_KEY, "resource": file_hash}
        headers = {"Accept-Encoding": "gzip, deflate"}
        try:
            proxies, verify = upstream_proxy("https")
        except:
            PrintException("Setting upstream proxy")
        try:
            response = requests.get(
                url, params=params, headers=headers, proxies=proxies, verify=verify
            )
            if response.status_code == 403:
                logger.error("VirusTotal Permission denied, wrong api key?")
                return None
        except:
            logger.error("VirusTotal ConnectionError, check internet connectivity")
            return None
        try:
            json_response = response.json()
            return json_response
        except ValueError:
            return None
    except:
        PrintException("VirusTotal get_report")
        return None
# Buggy code
def upload_file(self, file_path):
    """
    :param file_path: file path to upload
    :return: json response / None
    """
    try:
        url = self.base_url + "scan"
        files = {"file": open(file_path, "rb")}
        headers = {"apikey": settings.VT_API_KEY}
        try:
            proxies, verify = upstream_proxy("https")
        except:
            PrintException("[ERROR] Setting upstream proxy")
        try:
            response = requests.post(
                url, files=files, data=headers, proxies=proxies, verify=verify
            )
            if response.status_code == 403:
                logger.error("VirusTotal Permission denied, wrong api key?")
                return None
        except:
            logger.error("VirusTotal ConnectionError, check internet connectivity")
            return None
        json_response = response.json()
        return json_response

    except:
        PrintException("[ERROR] in VirusTotal upload_file")
        return None


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def upload_file(self, file_path):
    """
    :param file_path: file path to upload
    :return: json response / None
    """
    try:
        url = self.base_url + "scan"
        files = {"file": open(file_path, "rb")}
        headers = {"apikey": settings.VT_API_KEY}
        try:
            proxies, verify = upstream_proxy("https")
        except:
            PrintException("Setting upstream proxy")
        try:
            response = requests.post(
                url, files=files, data=headers, proxies=proxies, verify=verify
            )
            if response.status_code == 403:
                logger.error("VirusTotal Permission denied, wrong api key?")
                return None
        except:
            logger.error("VirusTotal Connection Error, check internet connectivity")
            return None
        json_response = response.json()
        return json_response

    except:
        PrintException("VirusTotal upload_file")
        return None
# Buggy code
def get_hardcoded_cert_keystore(files):
    """Returns the hardcoded certificate keystore."""
    try:
        logger.info("Getting Hardcoded Certificates/Keystores")
        dat = ""
        certz = ""
        key_store = ""
        for file_name in files:
            ext = file_name.split(".")[-1]
            if re.search("cer|pem|cert|crt|pub|key|pfx|p12", ext):
                certz += escape(file_name) + "</br>"
            if re.search("jks|bks", ext):
                key_store += escape(file_name) + "</br>"
        if len(certz) > 1:
            dat += (
                "<tr><td>Certificate/Key Files Hardcoded inside the App.</td><td>"
                + certz
                + "</td><tr>"
            )
        if len(key_store) > 1:
            dat += (
                "<tr><td>Hardcoded Keystore Found.</td><td>" + key_store + "</td><tr>"
            )
        return dat
    except:
        PrintException("[ERROR] Getting Hardcoded Certificates/Keystores")


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def get_hardcoded_cert_keystore(files):
    """Returns the hardcoded certificate keystore."""
    try:
        logger.info("Getting Hardcoded Certificates/Keystores")
        dat = ""
        certz = ""
        key_store = ""
        for file_name in files:
            ext = file_name.split(".")[-1]
            if re.search("cer|pem|cert|crt|pub|key|pfx|p12", ext):
                certz += escape(file_name) + "</br>"
            if re.search("jks|bks", ext):
                key_store += escape(file_name) + "</br>"
        if len(certz) > 1:
            dat += (
                "<tr><td>Certificate/Key Files Hardcoded inside the App.</td><td>"
                + certz
                + "</td><tr>"
            )
        if len(key_store) > 1:
            dat += (
                "<tr><td>Hardcoded Keystore Found.</td><td>" + key_store + "</td><tr>"
            )
        return dat
    except:
        PrintException("Getting Hardcoded Certificates/Keystores")
# Buggy code
def dex_2_smali(app_dir, tools_dir):
    """Run dex2smali"""
    try:
        logger.info("DEX -> SMALI")
        dexes = get_dex_files(app_dir)
        for dex_path in dexes:
            logger.info("Converting " + dex_path + " to Smali Code")
            if len(settings.BACKSMALI_BINARY) > 0 and isFileExists(
                settings.BACKSMALI_BINARY
            ):
                bs_path = settings.BACKSMALI_BINARY
            else:
                bs_path = os.path.join(tools_dir, "baksmali.jar")
            output = os.path.join(app_dir, "smali_source/")
            args = [
                settings.JAVA_PATH + "java",
                "-jar",
                bs_path,
                dex_path,
                "-o",
                output,
            ]
            subprocess.call(args)
    except:
        PrintException("[ERROR] Converting DEX to SMALI")


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def dex_2_smali(app_dir, tools_dir):
    """Run dex2smali"""
    try:
        logger.info("DEX -> SMALI")
        dexes = get_dex_files(app_dir)
        for dex_path in dexes:
            logger.info("Converting " + dex_path + " to Smali Code")
            if len(settings.BACKSMALI_BINARY) > 0 and isFileExists(
                settings.BACKSMALI_BINARY
            ):
                bs_path = settings.BACKSMALI_BINARY
            else:
                bs_path = os.path.join(tools_dir, "baksmali.jar")
            output = os.path.join(app_dir, "smali_source/")
            args = [
                settings.JAVA_PATH + "java",
                "-jar",
                bs_path,
                dex_path,
                "-o",
                output,
            ]
            subprocess.call(args)
    except:
        PrintException("Converting DEX to SMALI")