PHP modify PE header

February 1st, 2009 by admin

<?php
$myFile = “test.exe”;
$fh = fopen($myFile, ‘r’);
$theData = fread($fh, filesize($myFile));
fclose($fh);

$A=chr(0×41);

$str_hex = bin2hex($theData);
$len = count($str_hex);

for ($i=0;$i<12;$i++)
{

$str_hex[$i] = $A;
$str_bin = pack(’H*’, $str_hex);
}

$myFile = “File.exe”;
$fh = fopen($myFile,’w');
fwrite($fh, $str_bin);
fclose($fh);

?>

Share and Enjoy:

Leave a Reply