1

I want to encode a php file with uuencode to use it with

eval(gzuncompress(convert_uudecode("somedata");

I only found a way to encode a string, but no way to encode a complete php file (or php code).

Thanks!

Stan
  • 129
  • 12

2 Answers2

1

Read the file first

http://php.net/manual/en/function.file-get-contents.php

Encode the content and then do whatever you want with it.

santaka
  • 193
  • 7
1

You can simply read data of your file

$contentString = file_get_contents(PATH_TO_PHP/some.php)

adn then do same eval(gzuncompress(convert_uudecode($contentString)));

UPDATE

if you need to have as result this string

<?php eval(gzuncompress(convert_uudecode("M>)S=6PEOVTBR_BL90,\x5c2(9D0;W+\x5c%.Q@UKL;O,7,K. ............. a")));

you have to do following

// Reading file content
$phpFileContent = file_get_content("PATH/some.php");

// Remove <?php and ?> from your content
$phpFileContent = str_replace(array('<?php', '?>'), '', $phpFileContent);

// Encoding and compressing
$phpFileContent = convert_uuencode(  gzcompress($phpFileContent) );

// Your result string
$result = '<?php eval(gzuncompress(convert_uudecode("' . $phpFileContent . '")));';

//which you can write to some other php file with file_put_contensts
file_put_contents ( 'PATH_TO_RESULT_FILE/result.php' , $result);
Armen
  • 4,064
  • 2
  • 23
  • 40
  • Ok thank you, thats what I need. Do I have to gzcompress and uuencode the string? I nneda output like here: http://pastebin.com/VXGPaByw – Stan Dec 07 '15 at 14:56
  • Yes, if your `some.php` file contain encoded data then you have to decode it through appropriate way `convert_uudecode` and `gzuncompress` then only pass it to `eval`. `file_get_contents` is just returns you content of given path file without any decodeing – Armen Dec 07 '15 at 19:35
  • OK, but how can I encode the data first? I need a output like in the sample link on top, e.g. `M>)S=6PEOVTBR_BL90,\x5c2(9D0;W+\x5c%.Q@UKL;O,7,K.-98!\x24`... I tried with `file_get_contents` and `convert_uuencode` but that gave me a wrong output. – Stan Dec 08 '15 at 09:15
  • check text under above *UPDATE* – Armen Dec 08 '15 at 10:32
  • Great Armen, it works like a charme. You are gorgeous. Thank you so much! – Stan Dec 08 '15 at 14:28