M7350 SIM Information Reader
✓ Auto-running SIM info check on page load...
'authenticator', 'action' => 0]);
$ch = curl_init("http://{$host}/cgi-bin/auth_cgi");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $nonceData,
CURLOPT_HTTPHEADER => [
'Content-Type: application/x-www-form-urlencoded; charset=UTF-8',
'X-Requested-With: XMLHttpRequest'
],
CURLOPT_TIMEOUT => 10,
]);
$response = curl_exec($ch);
if (curl_errno($ch)) {
throw new Exception("Connection failed: " . curl_error($ch));
}
curl_close($ch);
$nonceResult = json_decode($response, true);
if (!$nonceResult || !isset($nonceResult['nonce'])) {
throw new Exception("Failed to get nonce from router");
}
$nonce = $nonceResult['nonce'];
$n_out = htmlspecialchars($nonce);
// Step 2: Calculate digest and get token
$digest = md5($password . ':' . $nonce);
$loginData = json_encode([
'module' => 'authenticator',
'action' => 1,
'digest' => $digest
]);
$ch = curl_init("http://{$host}/cgi-bin/auth_cgi");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $loginData,
CURLOPT_HTTPHEADER => [
'Content-Type: application/x-www-form-urlencoded; charset=UTF-8',
'X-Requested-With: XMLHttpRequest'
],
CURLOPT_TIMEOUT => 10,
]);
$response = curl_exec($ch);
if (curl_errno($ch)) {
throw new Exception("Login failed: " . curl_error($ch));
}
curl_close($ch);
$loginResult = json_decode($response, true);
if (!$loginResult || !isset($loginResult['token'])) {
throw new Exception("Login Failed - check password.txt content.");
}
$token = $loginResult['token'];
$t_out = htmlspecialchars($token);
// Step 3: Fetch SIM information
$status = "Fetching SIM information...";
$simData = json_encode([
'token' => $token,
'module' => 'status',
'action' => 0
]);
$ch = curl_init("http://{$host}/cgi-bin/web_cgi");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $simData,
CURLOPT_HTTPHEADER => [
'Content-Type: application/x-www-form-urlencoded; charset=UTF-8',
'X-Requested-With: XMLHttpRequest'
],
CURLOPT_TIMEOUT => 10,
]);
$rawData = curl_exec($ch);
if (curl_errno($ch)) {
throw new Exception("Failed to fetch SIM info: " . curl_error($ch));
}
curl_close($ch);
// Function to extract values using regex
function extractValue($pattern, $data) {
preg_match($pattern, $data, $matches);
return isset($matches[1]) ? $matches[1] : null;
}
// Try to extract values using regex patterns
$simNumber = extractValue('/"simNumber":\s*"([^"]*)"/', $rawData);
$imsi = extractValue('/"imsi":\s*"([^"]*)"/', $rawData);
$imei = extractValue('/"imei":\s*"([^"]*)"/', $rawData);
if ($simNumber || $imsi || $imei) {
$output = '
SIM Number:
' . ($simNumber ? '+' . htmlspecialchars($simNumber) : 'Not found') . '
IMSI:
' . htmlspecialchars($imsi ?? 'Not found') . '
IMEI:
' . htmlspecialchars($imei ?? 'Not found') . '
Done.
';
$status = "✓ SIM information fetched successfully";
} else {
// Try JSON parsing as fallback
$jsonData = json_decode($rawData, true);
if ($jsonData && (isset($jsonData['simNumber']) || isset($jsonData['imsi']) || isset($jsonData['imei']))) {
$output = '
SIM Number:
' .
(isset($jsonData['simNumber']) && $jsonData['simNumber'] ?
'+' . htmlspecialchars($jsonData['simNumber']) : 'Not found') .
'
IMSI:
' . htmlspecialchars($jsonData['imsi'] ?? 'Not found') . '
IMEI:
' . htmlspecialchars($jsonData['imei'] ?? 'Not found') . '
Done.
';
$status = "✓ SIM information fetched successfully (JSON)";
} else {
$status = "No SIM information found in response";
$output = '
Debug - Raw Response:
' . htmlspecialchars($rawData) . '
';
}
}
} catch (Exception $e) {
$status = "Error: " . $e->getMessage();
$output = '
' . htmlspecialchars($e->getMessage()) . '
';
}
?>
Reading credentials from password.txt...
Nonce: |
Token: