Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Encode.php: Difference between revisions

From John's Wiki
Created page with "Encodes a file as base64 gzip compressed payload file. <pre> <?php $input_file = 'info.php'; $output_file = 'x.php'; function removePhpTags($content) { $content = preg_replace('/^<\?php\s*/', '', $content); $content = preg_replace('/\s*\?>$/', '', $content); return $content; } $file_content = file_get_contents($input_file); $file_content = removePhpTags($file_content); $encoded = base64_encode(gzcompress($file_content)); $payload = "<?php eval(gzuncompress(base..."
 
No edit summary
 
Line 1: Line 1:
Encodes a file as base64 gzip compressed payload file.
Encodes a file as base64 gzip compressed payload file.


<pre>
<syntaxhighlight lang="php" line>
<?php
<?php
$input_file = 'info.php';
$input_file = 'info.php';
Line 19: Line 19:
file_put_contents($output_file, $payload);
file_put_contents($output_file, $payload);
?>
?>
</pre>
</syntaxhighlight>

Latest revision as of 21:36, 28 November 2024

Encodes a file as base64 gzip compressed payload file.

<?php
$input_file = 'info.php';
$output_file = 'x.php';

function removePhpTags($content) {
  $content = preg_replace('/^<\?php\s*/', '', $content);
  $content = preg_replace('/\s*\?>$/', '', $content);
  return $content;
}

$file_content = file_get_contents($input_file);
$file_content = removePhpTags($file_content);

$encoded = base64_encode(gzcompress($file_content));
$payload = "<?php eval(gzuncompress(base64_decode('$encoded')));?>";
file_put_contents($output_file, $payload);
?>