if (isset($_REQUEST["MAX_FILE_SIZE"])) {
if (!is_uploaded_file($_FILES['userfile']['tmp_name'])) {
echo "Not an uploaded file: ".$_FILES['userfile']['tmp_name'].":?";
exit;
}
echo "- File output on the file: ('data' usually indicates firmware)
";
passthru("file ".$_FILES['userfile']['tmp_name']);
echo "
";
$score=0;
echo "- WB4K or CSYS header found:
";
$f=fopen($_FILES['userfile']['tmp_name'],"r");
$d=fread($f,4);
fclose($f);
if ($d=="WB4K" || $d="CSYS") {
echo "Yes: $d.
";
$score+=4;
} else {
echo "Nope.
";
}
echo "- Reference to vmlinux or vmlinuz found:
";
$f=fopen($_FILES['userfile']['tmp_name'],"r");
$found=0;
while(!feof($f) && !$found) {
$d=fread($f,1024*4);
if (strstr($d,"vmlinu")!==false) {
$found=1;
}
}
fclose($f);
if ($found) {
$score+=6;
echo "Yes.
";
} else {
echo "Nope.
";
}
echo "- Reference to another OS like vxworks or rtos found:
";
$f=fopen($_FILES['userfile']['tmp_name'],"r");
$found=0;
while(!feof($f) && !$found) {
$d=fread($f,1024*4);
if (stristr($d,"vxwork")!==false || stristr($d,"rtos")!==false) {
$found=1;
}
}
fclose($f);
if ($found) {
$score-=4;
echo "Yes.
";
} else {
echo "Nope.
";
}
echo "
";
echo "Total results: The device running this firmware probably ";
if ($score>5) {
echo "IS";
} else {
echo "IS NOT";
}
echo " running Linux.";
} else {
?>
Please upload the binary image of the routers firmware (no .zip, .exe, just the binary image)
}
?>