📄 phpop3clean.demo.partial_md5_match_checker.php
字号:
<?php
//////////////////////////////////////////////////////////////////// phPOP3clean() by James Heinrich <info@silisoftware.com> //// available at http://phpop3clean.sourceforge.net ///////////////////////////////////////////////////////////////////
$pattern = '17435|';
@list($basesize, $garbagebytelist) = explode('|', $pattern);
$garbagebytes = explode(';', $garbagebytelist);
$AllFileContents = array();
$dir = 'c:\\virii\\';
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if (eregi('\.dat$', $file)) {
$rawfiledata = file_get_contents($dir.$file);
$standardizeddata = $rawfiledata;
if ($basesize) {
$standardizeddata = substr($standardizeddata, 0, $basesize);
}
foreach ($garbagebytes as $byteaddr) {
if ($byteaddr) {
if (ereg('^([0-9]+)\-([0-9]+)$', $byteaddr, $matches) && ($matches[2] > $matches[1])) { for ($i = $matches[1]; $i <= $matches[2]; $i++) { $standardizeddata{$i} = "\x00"; } } else {
$standardizeddata{$byteaddr} = "\x00"; }
$standardizeddata{$byteaddr} = "\x00";
}
}
$AllFileContents[$file] = $standardizeddata;
$fp = fopen(str_replace('.dat', '.new', $dir.$file), 'wb');
fwrite($fp, $standardizeddata);
fclose($fp);
}
}
closedir($dh);
}
echo 'Scanned '.count($AllFileContents).' files<hr>';
echo '<hr><pre>';
$prevfile = '';
$prevmd5 = '';
$automask = '';
foreach ($AllFileContents as $filename => $filedata) {
$thismd5 = md5($filedata);
echo $thismd5.' = '.$filename.'<br>';
if ($prevmd5 && ($thismd5 != $prevmd5)) {
$maskstart = min(filesize($dir.str_replace('.dat', '.new', $filename)), filesize($dir.str_replace('.dat', '.new', $prevfile)));
$commandline = substr($dir, 0, 2).' && cd "'.substr($dir, 2).'" && copy /y "c:\\program files\\support tools\\bindiff.exe" . > nul && bindiff /d0 '.str_replace('.dat', '.new', $prevfile).' '.str_replace('.dat', '.new', $filename);;
$bindiffoutput = `$commandline`;
$ArrayOfTextDifferences = explode('===============================================================================', $bindiffoutput);
array_shift($ArrayOfTextDifferences);
$IgnoreBytes = array();
$ArrayOfTextDifferences2 = array();
foreach ($ArrayOfTextDifferences as $DifferenceLine) {
$lines = explode("\n", $DifferenceLine);
foreach ($lines as $line) {
$line = trim($line);
if ($line) {
$ArrayOfTextDifferences2[] = $line;
}
}
}
foreach ($ArrayOfTextDifferences2 as $DifferenceLine) {
if (eregi('^([0-9A-F]{8})([ ]+)<(([0-9A-F]{2}[ ]?)+)>[ ]+[^ ]+([ ]+)<(([0-9A-F]{2}[ ]?)+)>[ ]+[^ ]+$', $DifferenceLine, $matches)) {
$startOffset = hexdec($matches[1]);
$paddingBytes = (strlen($matches[2]) - 1) / 3;
$diffByteValuesArray = explode(' ', $matches[3]);
if (count($diffByteValuesArray) > 4) {
$maskstart = $startOffset;
break;
}
for ($i = 0; $i < count($diffByteValuesArray); $i++) {
$IgnoreBytes[] = ($startOffset + $paddingBytes + $i);
}
}
}
$automask = $maskstart.'|'.implode(';', $IgnoreBytes);
echo '<hr><b>New mask:</b><br><tt>'.$automask.'</tt><hr>';
}
$prevfile = $filename;
$prevmd5 = $thismd5;
}
echo '</pre>';
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -