I am trying to add random bytes to binary (.exe) files to increase it size using php. So far I got this:
function junk($bs)
{
// string length: 256 chars
$tmp = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
for($i=0;$i<=$bs;$i++)
{
$tmp = $tmp . $tmp;
}
return $tmp;
}
$fp = fopen('test.exe', 'ab');
fwrite($fp, junk(1));
fclose($fp);
This works fine and the resulting exe is functional but if I want to do junk(100) to add more size to the file I get the php error "Fatal error: Allowed memory size..."
In which other way could I achieve this without getting an error? Would it be ok to loop the fwrite xxx times?