<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <title>Identity Monitoring - Intelligence X</title>

    <link href="css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <link href="fonts/OpenSans.css" rel="stylesheet" type="text/css" />
    <link href="css/bootstrap.min.css" rel="stylesheet" />
    <link href="css/uniform.default.min.css" rel="stylesheet" type="text/css" />
    <link href="css/ark.css" rel="stylesheet" type="text/css" />

    <script src="js/jquery.min.js"></script>
    <script src="js/config.js"></script>
    <script>
        apiGet = function apiGet(url, parameters, success, error) {
            $.ajax({
                type: 'GET',
                url: API_URL + url + "?k=" + API_KEY + parameters,
                success: success,
                error: error
            });
        }

        apiPost = function apiPost(url, data, success, error) {
            $.ajax({
                type: 'POST',
                url: API_URL + url + "?k=" + API_KEY,
                data: data,
                success: success,
                error: error
            });
        }

        var terminate;
        $(document).on('click', '#dataleak3', function(e) {
            e.preventDefault();
            var value1 = $('#searchField3').val();
            if (value1 == '') {
                return
            }
            var param2;
            if (terminate != '') {
                param2 = "&terminate=" + terminate;
                terminate = '';
            }
            apiSearch('accounts/csv', "&selector=" + value1 + param2, 'result2', 'status')
        });

        function apiOutputResult(text, outputHTML) {
            var resultE = document.getElementById(outputHTML);
            resultE.innerHTML += text;
        }

        function apiSearchResult(id, outputHTML, statusHTML) {
            apiGet('accounts/csv/preview', "&id=" + id,
                function(p) {
                    apiOutputResult(p.text, outputHTML);
                    $('#count1').html(p.count + ' records');
                    $('#count2').html(Math.round(p.sizef1 / 1024) + ' KB');
                    $('#count3').html(Math.round(p.sizef2 / 1024) + ' KB');

                    if (p.status < 2) {
                        setTimeout(function() {
                            apiSearchResult(id, outputHTML, statusHTML);
                        }, 1000);
                    } else {
                        $('#' + statusHTML).html('Finished.');
                    }
                },
                function(error) {
                    apiOutputResult('An error has occured.', outputHTML);
                    $('#' + statusHTML).html('Error.');
                }
            );
        }

        function apiSearch(api, params, outputHTML, statusHTML) {
            $('#' + outputHTML).html('');
            $('#' + statusHTML).html('Searching...');
            apiGet(api, params,
                function(p) {
                    if (p.status == 1) {
                        $('#' + outputHTML).html('The hash was not found.');
                        $('#' + statusHTML).html('Finished.');
                        return
                    } else if (p.status == 2) {
                        $('#' + outputHTML).html('The selector is invalid.');
                        $('#' + statusHTML).html('Finished.');
                        return
                    }

                    terminate = p.id;

                    $('#link1').attr('href', API_URL + 'accounts/csv/download?f=0&id=' + p.id + "&k=" + API_KEY);
                    $('#link2').attr('href', API_URL + 'accounts/csv/download?f=1&id=' + p.id + "&k=" + API_KEY);
                    $('#link3').attr('href', API_URL + 'accounts/csv/download?f=2&id=' + p.id + "&k=" + API_KEY);
                    $('#link1').removeClass('disabled');
                    $('#link2').removeClass('disabled');
                    $('#link3').removeClass('disabled');

                    apiSearchResult(p.id, outputHTML, statusHTML);
                },
                function(error) {
                    $('#' + outputHTML).html('An error has occured.');
                    $('#' + statusHTML).html('Error.');
                }
            );
        }
    </script>
</head>

<body class="cover fixed_header">

    <div class="wrapper">
        <!-- HEAD NAV -->
        <div class="navbar navbar-default navbar-static-top navbar-main" role="navigation">
            <div class="navbar-header">
                <a class="navbar-brand" href="index.html"><img src="img/IntelligenceX.svg" alt="Intelligence X" width="180"></a>
            </div>
            <div class=" navbar-right">
                <a href="/logout" style="font-size: 16px;padding: 20px;"><i class="fa fa-sign-out"></i>Logout</a>
            </div>

        </div>
        <!-- END: HEAD NAV -->

        <div class="navbar navbar-default navbar-static-top navbar-top" role="navigation">
            <ul class="nav navbar-nav">
                <li><a href="index.html"><i class="fa fa-search fa-fw"></i>Search Data Leaks</a></li>
                <li class="active"><a href="export.html"><i class="fa fa-download fa-fw"></i>Export Leaked Accounts</a></li>
                <li><a href="changelog.html"><i class="fa fa-book fa-fw"></i>Changelog</a></li>
                <li><a href="Leaks API.pdf"><i class="fa fa-download fa-fw"></i>API documentation</a></li>
                <li><a href="status.html"><i class="fa fa-code fa-fw"></i>API status</a></li>
                <li><a href="faq.html"><i class="fa fa-question-circle fa-fw"></i>FAQ</a></li>
            </ul>
        </div>

        <!-- BODY -->
        <div class="body">

            <section class="content">

                <!--<ol class="breadcrumb">
                    <li class="active"><i class="fa fa-home fa-fw"></i> Home</li>
                </ol>-->

                <div class="header">
                    <div class="col-md-12">
                        <h3 class="header-title">Export Leaked Accounts</h3>

                        <p class="header-info">This searches for a domain or email address to find leaked accounts. You can download the results as CSV file. Download links are invalidated 10 minutes after the search is finished.<br>CSV fields: User, Password, Password Type, Bucket, Date, Source Short, Source Long, Search Result ID
                        </p>
                    </div>
                </div>

                <!-- CONTENT -->
                <div class="main-content" style="padding-bottom: 5px;">

                    <div class="row">
                        <form>
                            <fieldset style="border: 1px solid silver;margin: 0 2px;padding: .35em .625em;">
                                <legend style="margin:0;border:0;font-size: 13px;width: auto;">Enter selector to look up</legend>
                                <input type="search" id="searchField3" placeholder="Email or domain" size="50">
                                <button class="btn btn-primary " type="submit" id="dataleak3">Search</button><span style="margin-left: 20px;">Status: <span id="status">Ready.</span></span>
                            </fieldset>
                        </form>

                        <table style="width: 100%; margin-bottom: 20px; padding:5px">
                            <tr>
                                <th style="padding:5px">Download Link</th>
                                <th style="padding:5px">Records Available</th>
                                <th style="padding:5px">Description</th>
                            </tr>
                            <tr>
                                <td style="padding:0 5px 0 5px"><a id="link1" download="Leaked Accounts.csv" class="download-link disabled">Leaked Accounts.csv 💾</a></td>
                                <td style="padding:0 5px 0 5px"><span id="count1">0 records</span></td>
                                <td style="padding:0 5px 0 5px">All leaked accounts in CSV format.</td>
                            </tr>
                            <tr>
                                <td style="padding:0 5px 0 5px"><a id="link2" download="Leaked Accounts [Full Lines].txt" class="download-link disabled">Leaked Accounts [Full Lines].txt</a></td>
                                <td style="padding:0 5px 0 5px"><span id="count2">0 MB</span></td>
                                <td style="padding:0 5px 0 5px">Full lines of original data that include the leaked accounts mentioned in the CSV file.</td>
                            </tr>
                            <tr>
                                <td style="padding:0 5px 0 5px"><a id="link3" download="Nonleak Findings [Full Lines].txt" class="download-link disabled">Nonleak Findings [Full Lines].txt</a></td>
                                <td style="padding:0 5px 0 5px"><span id="count3">0 MB</span></td>
                                <td style="padding:0 5px 0 5px">Full lines that contain the matching selector, but were not identified to contain leaked accounts.</td>
                            </tr>
                        </table>
                                
                        <div>
                            <pre id="result2">Preview will appear here. Download the CSV file above ⬆️ to get all records and available fields.</pre>
                        </div>

                        <hr>&copy; 2020 - 2024 Intelligence X


                    </div>

                </div>
                <!-- END: CONTENT -->
            </section>
        </div>
        <!-- END: BODY -->
    </div>

    <script src="js/jquery.uniform.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/jquery.dataTables.min.js"></script>
    <script src="js/ark.min.js"></script>
    <script src="js/jquery.autosize.min.js"></script>

</body>

</html>