Last active
September 12, 2023 18:08
-
-
Save tas33n/e16546d945742419071d1218c60122f7 to your computer and use it in GitHub Desktop.
single sms mitm api with admin control and json databse.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Disable displaying errors to users | |
ini_set('display_errors', 0); | |
// Set the error reporting level to not display warnings and notices | |
error_reporting(E_ERROR | E_PARSE); | |
function registerKey($filename, $key, $value) | |
{ | |
if (file_exists($filename)) { | |
$existingData = json_decode(file_get_contents($filename), true); | |
} else { | |
$existingData = array(); | |
} | |
$existingData[$key] = $value; | |
$jsonData = json_encode($existingData, JSON_PRETTY_PRINT); | |
file_put_contents($filename, $jsonData); | |
$response["status"] = "Success"; | |
$response["message"] = "Admin Action complete."; | |
// Output JSON response | |
header('Content-Type: application/json'); | |
echo json_encode($response); | |
exit; | |
} | |
// Admin pass 3321 change it with your wish. | |
if ($_GET['admin'] === '3321') { | |
$filename = 'user_key_data.json'; // Replace with your JSON database file path | |
$keyToAdd = $_GET['key']; | |
$valueToAdd = $_GET['value']; | |
registerKey($filename, $keyToAdd, $valueToAdd); | |
} | |
function sendSMS($num, $msg) | |
{ | |
// Encode the data to be included in the URL | |
$encodedNum = urlencode($num); | |
$encodedMsg = urlencode($msg); | |
$url = "https://proxy.neopandora.com/index.php?user=MojibSms&number=$encodedNum&message=$encodedMsg"; | |
$curl = curl_init($url); | |
curl_setopt($curl, CURLOPT_URL, $url); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
// For debug only! | |
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); | |
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); | |
$resp = curl_exec($curl); | |
curl_close($curl); | |
return $resp; | |
} | |
// Read unique key data from JSON database (Assuming you have a file named "user_key_data.json") | |
$uniqueKeyDataFile = 'user_key_data.json'; | |
if (file_exists($uniqueKeyDataFile)) { | |
$uniqueKeyData = json_decode(file_get_contents($uniqueKeyDataFile), true); | |
} else { | |
$uniqueKeyData = array(); // Initialize as an empty array if the file doesn't exist | |
} | |
// Get unique key from the request | |
$uniqueKey = $_REQUEST["key"]; | |
$response = array(); | |
if (isset($uniqueKeyData[$uniqueKey])) { | |
if ($uniqueKeyData[$uniqueKey] >= 1) { | |
// Get data from the request | |
$num1 = $_REQUEST["num"]; | |
$msg1 = $_REQUEST["msg"]; | |
// Call the sendSMS function | |
$apiResponse = sendSMS($num1, $msg1); | |
// Parse the API response JSON | |
$apiResponseData = json_decode($apiResponse, true); | |
if (isset($apiResponseData["success"]) && $apiResponseData["success"] === true) { | |
// Reduce the unique key balance by 1 after a successful API post | |
$uniqueKeyData[$uniqueKey]--; | |
// Save the updated data back to the JSON database | |
file_put_contents($uniqueKeyDataFile, json_encode($uniqueKeyData, JSON_PRETTY_PRINT)); | |
// Create an array to store the data | |
$data = array( | |
"From" => $uniqueKey, | |
"Number" => $num1, | |
"Message" => $msg1, | |
"Date and Time" => date("Y.m.d, H:i:s"), | |
"IP Address" => $_SERVER['REMOTE_ADDR'] | |
); | |
// Load existing data from JSON file if it exists | |
$filename = 'log_data.json'; | |
if (file_exists($filename)) { | |
$existingData = json_decode(file_get_contents($filename), true); | |
} else { | |
$existingData = array(); | |
} | |
// Add new data to the existing array | |
$existingData[] = $data; | |
// Encode the combined data to JSON with pretty formatting | |
$jsonData = json_encode($existingData, JSON_PRETTY_PRINT); | |
// Write the JSON data back to the file | |
file_put_contents($filename, $jsonData); | |
$response["status"] = "success"; | |
$response["message"] = "SMS Sent Successfully"; | |
} else { | |
$response["status"] = "error"; | |
$response["message"] = "SMS Sending Failed"; | |
} | |
} else { | |
$response["status"] = "error"; | |
$response["message"] = "SMS Limit Exceeds!"; | |
} | |
} else { | |
$response["status"] = "error"; | |
$response["message"] = "invalid Key"; | |
} | |
// Output JSON response | |
header('Content-Type: application/json'); | |
echo json_encode($response); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment