EdMal

Script Fake Admin Page (ip log)

Sep 18th, 2024
162
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.77 KB | Cybersecurity | 0 0
  1. <?php
  2. // Отримання IP-адреси
  3. if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
  4.     $ip = $_SERVER['HTTP_CLIENT_IP'];
  5. } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  6.     $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
  7. } else {
  8.     $ip = $_SERVER['REMOTE_ADDR'];
  9. }
  10.  
  11. // Файл для зберігання IP-адрес і часу
  12. $file = 'ip_attempts.json';
  13.  
  14. // Встановлюємо поточний час у читаємому форматі
  15. $current_time_readable = date("Y-m-d H:i:s");
  16.  
  17. // Перевірка наявності файлу та читання даних
  18. if (file_exists($file)) {
  19.     $ip_attempts = json_decode(file_get_contents($file), true);
  20. } else {
  21.     $ip_attempts = [];
  22. }
  23.  
  24. // Перевірка на наявність IP та часу останньої спроби
  25. if (isset($ip_attempts[$ip])) {
  26.     $last_attempt_time = strtotime($ip_attempts[$ip]);
  27.     $time_diff = time() - $last_attempt_time;
  28.  
  29.     // Якщо з останньої спроби минуло менше години (3600 секунд), не записуємо
  30.     if ($time_diff < 3600) {
  31.         $recent_attempt = true;
  32.     } else {
  33.         $recent_attempt = false;
  34.     }
  35. } else {
  36.     $recent_attempt = false;
  37. }
  38.  
  39. // Якщо не було недавньої спроби, записуємо нову спробу з датою
  40. if (!$recent_attempt) {
  41.     $ip_attempts[$ip] = $current_time_readable;
  42.     file_put_contents($file, json_encode($ip_attempts));
  43. }
  44.  
  45. // Визначення мови за параметром у URL або за налаштуваннями браузера
  46. $available_languages = ['uk', 'en'];
  47. $lang = 'en'; // Мова за замовчуванням
  48. if (isset($_GET['lang']) && in_array($_GET['lang'], $available_languages)) {
  49.     $lang = $_GET['lang'];
  50. } elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
  51.     $browser_lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
  52.     if (in_array($browser_lang, $available_languages)) {
  53.         $lang = $browser_lang;
  54.     }
  55. }
  56.  
  57. // Тексти на двох мовах
  58. $texts = [
  59.     'uk' => [
  60.         'title' => 'Увага! Спроба злому',
  61.         'warning' => 'Виявлена спроба злому',
  62.         'ip_logged' => 'Ваша IP-адреса: <strong>%s</strong> зафіксована та передана до служби безпеки.',
  63.         'legal_action' => 'Будь-які подальші спроби будуть переслідуватися законом!',
  64.         'go_home' => 'Повернутись на головну'
  65.     ],
  66.     'en' => [
  67.         'title' => 'Warning! Hacking attempt',
  68.         'warning' => 'Hacking attempt detected',
  69.         'ip_logged' => 'Your IP address: <strong>%s</strong> has been recorded and reported to security.',
  70.         'legal_action' => 'Any further attempts will be prosecuted by law!',
  71.         'go_home' => 'Return to homepage'
  72.     ]
  73. ];
  74. ?>
  75.  
  76. <!DOCTYPE html>
  77. <html lang="<?php echo $lang; ?>">
  78. <head>
  79.     <meta charset="UTF-8">
  80.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  81.     <meta name="robots" content="noindex, nofollow">
  82.     <title><?php echo $texts[$lang]['title']; ?></title>
  83.     <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
  84.     <style>
  85.         .image-container {
  86.             text-align: center;
  87.             margin-top: 20px;
  88.         }
  89.         .image-container img {
  90.             max-width: 100%;
  91.             height: auto;
  92.             width: 300px; /* Встановлюємо фіксовану ширину зображення */
  93.         }
  94.     </style>
  95. </head>
  96. <body class="bg-light">
  97.     <div class="container">
  98.         <div class="row justify-content-center">
  99.             <div class="col-md-8">
  100.                 <div class="alert alert-danger mt-5 p-4 text-center">
  101.                     <h1 class="display-4"><?php echo $texts[$lang]['title']; ?></h1>
  102.                     <p class="lead"><?php echo $texts[$lang]['warning']; ?></p>
  103.                     <hr class="my-4">
  104.                     <p><?php printf($texts[$lang]['ip_logged'], $ip); ?></p>
  105.                     <p><?php echo $texts[$lang]['legal_action']; ?></p>
  106.                     <a href="/" class="btn btn-primary mt-4"><?php echo $texts[$lang]['go_home']; ?></a>
  107.                 </div>
  108.                 <div class="image-container">
  109.                     <img src="https://upload.wikimedia.org/wikipedia/commons/3/3f/Stamp_of_Ukraine_s1985.jpg">
  110.                 </div>
  111.                 <div class="text-center mt-3">
  112.                     <a href="?lang=uk" class="btn btn-link">Ukrainian</a> |
  113.                     <a href="?lang=en" class="btn btn-link">English</a>
  114.                 </div>
  115.             </div>
  116.         </div>
  117.     </div>
  118. </body>
  119. </html>
Advertisement
Comments
  • EdMal
    1 year
    # text 0.29 KB | 0 0
    1. 1. We transfer the main admin to another safe directory
    2. 2. Create the /admin directory at the root of the site with the index.php file with the above content
    3.  
    4. Profit
    5.  
    6. ---
    7. All visitors who visited yoursite.com/admin/ will receive a message about a hacking attempt with a log of the IP address
Add Comment
Please, Sign In to add comment