-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
I need a region scanner. I know my full model code is "SM-S908BZWGEUB", but i don't know the region (and there's 500+ of them), and even worse, I know the url does not use the "full" model code, but a substring of the full code. (SM-S908BZWGEUB is a Samsung Galaxy S22 Ultra sold somewhere in Europe...)
wrote one in PHP but I'm not good at C# and idk what to do with the scanner, leaving it here
sample usage:
$ time php test2.php SM-F916N
total urls to check per model string: 509
total urls to check: 2545
Checking model string 1/5: SM-F916N
http://fota-cloud-dn.ospserver.net/firmware/KTC/SM-F916N/version.xml : 200
http://fota-cloud-dn.ospserver.net/firmware/LUC/SM-F916N/version.xml : 200
http://fota-cloud-dn.ospserver.net/firmware/SKC/SM-F916N/version.xml : 200
http://fota-cloud-dn.ospserver.net/firmware/KOO/SM-F916N/version.xml : 200
509/509 - 509/2545Checking model string 2/5: SM-F916
443/509 - 952/2545
code
<?php
declare(strict_types=1);
use function var_dump as d;
function getCSCList(): array
{
$raw = file_get_contents('https://raw.githubusercontent.com/zacharee/SamloaderKotlin/master/common/src/commonMain/kotlin/tk/zwander/common/data/csc/CSCDB.kt');
// CSCItem("AVF", "AL", "Vodafone"),
$matches = [];
preg_match_all('/CSCItem\\s*\\(\\"([^\\"]+)/', $raw, $matches);
return $matches[1];
}
$model = $argv[1] ?? '';
if ($argc !== 2 || empty($model)) {
echo "Usage: php scanner.php <model>\n";
exit(1);
}
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => "http://fota-cloud-dn.ospserver.net/firmware/{$model}/version.xml",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_AUTOREFERER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
//CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 6.1; rv:40.0) Gecko/20100101 Firefox/40.0",
CURLOPT_USERAGENT => 'csc_scanner/0.0.1',
));
$csclist = getCSCList();
$modelStrings = array();
for ($i = strlen($model); $i >= strlen("SM-S"); $i--) {
$modelStrings[] = substr($model, 0, $i);
}
$totalModelStrings = count($modelStrings);
$totalPerModelString = count($csclist);
$grandTotalUrls = $totalPerModelString * count($modelStrings);
echo "total urls to check per model string: {$totalPerModelString}\n";
echo "total urls to check: {$grandTotalUrls}\n";
$urlsChecked = 0;
foreach ($modelStrings as $modelStringKey => $model) {
$modelStringKeyPlusOne = $modelStringKey + 1;
echo "\rChecking model string {$modelStringKeyPlusOne}/{$totalModelStrings}: {$model}\n";
foreach ($csclist as $key => $str) {
$keyPlusOne = $key + 1;
$url = "http://fota-cloud-dn.ospserver.net/firmware/{$str}/{$model}/version.xml";
curl_setopt($ch, CURLOPT_URL, $url);
$response = curl_exec($ch);
++$urlsChecked;
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpcode !== 403) {
echo "\r{$url}" . str_repeat(" ", 3) . ": {$httpcode}\n";
} else {
echo "\r{$keyPlusOne}/{$totalPerModelString} - {$urlsChecked}/{$grandTotalUrls}";
}
}
}
Metadata
Metadata
Assignees
Labels
No labels