1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| <?php class notouchitsclass { public $data;
public function __construct($data) { $this->data = $data; }
public function __destruct() { eval($this->data); } }
class SessionRandom {
public function generateRandomString() { $length = rand(1, 50);
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = '';
for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; }
return $randomString; }
}
class SessionManager { private $sessionPath; private $sessionId; private $sensitiveFunctions = ['system', 'eval', 'exec', 'passthru', 'shell_exec', 'popen', 'proc_open'];
public function __construct() { if (session_status() == PHP_SESSION_NONE) { throw new Exception("Session has not been started. Please start a session before using this class."); } $this->sessionPath = session_save_path(); $this->sessionId = session_id(); }
private function getSessionFilePath() { return $this->sessionPath . "/sess_" . $this->sessionId; }
public function filterSensitiveFunctions() { $sessionFile = $this->getSessionFilePath();
if (file_exists($sessionFile)) { $sessionData = file_get_contents($sessionFile);
foreach ($this->sensitiveFunctions as $function) { if (strpos($sessionData, $function) !== false) { $sessionData = str_replace($function, '', $sessionData); } } file_put_contents($sessionFile, $sessionData);
return "Sensitive functions have been filtered from the session file."; } else { return "Session file not found."; } } }
|