Ejemplo n.º 1
0
def download_shellcode():
    """
    Download the selected shellcode.
    :return: a template showing the details about the selected shellcode and the source code.
    """
    shellcode_id = request.args.get('shellcode-id', None)
    shellcode = get_shellcode_by_id(shellcode_id)
    file_path = init_path + "/exploitdb/" + shellcode.file
    try:
        with open(file_path, 'r') as f:
            content = f.readlines()
            vulnerability_code = ''.join(content)
        copyfile(
            file_path,
            os.path.expanduser("~") + "/shellcode_" + shellcode_id +
            get_vulnerability_extension(shellcode.file))
        download_alert = "shellcode_" + shellcode_id + get_vulnerability_extension(
            shellcode.file) + " has been downloaded in your home directory"
        return render_template('code_viewer.html',
                               vulnerability_code=vulnerability_code,
                               vulnerability_description=shellcode.description,
                               vulnerability_file=shellcode.file,
                               vulnerability_author=shellcode.author,
                               vulnerability_date=shellcode.date,
                               vulnerability_type=shellcode.type,
                               vulnerability_platform=shellcode.platform,
                               file_path=file_path,
                               download_alert=download_alert,
                               shellcode_id=shellcode_id)
    except FileNotFoundError:
        error_msg = 'Sorry! This file does not exist :('
        return render_template('error_page.html', error=error_msg)
Ejemplo n.º 2
0
def view_shellcode_details():
    """
    Open details about the selected shellcode, included the source code.
    :return: a template showing the details about the selected shellcode and the source code.
    """
    shellcode_id = request.args.get('shellcode-id', None)
    shellcode = get_shellcode_by_id(shellcode_id)
    file_path = init_path + "/exploitdb/" + shellcode.file
    try:
        with open(file_path, 'r') as f:
            content = f.readlines()
            vulnerability_code = ''.join(content)
        return render_template('code_viewer.html',
                               vulnerability_code=vulnerability_code,
                               vulnerability_description=shellcode.description,
                               vulnerability_file=shellcode.file,
                               vulnerability_author=shellcode.author,
                               vulnerability_date=shellcode.date,
                               vulnerability_type=shellcode.type,
                               vulnerability_platform=shellcode.platform,
                               file_path=file_path,
                               shellcode_id=shellcode_id)
    except FileNotFoundError:
        error_msg = 'Sorry! This file does not exist :('
        return render_template('error_page.html', error=error_msg)