Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php /* Milad WorkShop Decoder Telegram Bot by @khmv4tfti @WordPressX Telegram Chan..

Decoded Output download

<?php 
/* Milad WorkShop Decoder Telegram Bot by @khmv4tfti 
    @WordPressX Telegram Channel 
    Edit Lines => 13 & 15 
*/ 
error_reporting(0); 
header('content-type : text/html; charset=utf-8'); 
$input = file_get_contents('php://input'); 
$update = json_decode($input, true); 
$message = $update['message']; 
$chat_id = $update['message']['chat']['id']; 
$command = $update['message']['text']; 
$bot_username = '@botusername';   // BOT username with @  
 
define('BOT_TOKEN', 'Your Token Goes Here'); // BOT Token 
define('API_URL', 'https://api.telegram.org/bot' . BOT_TOKEN); 
 
 
$text = "Hi, I can help you decode files which are encoded by Miladworkshop encoder. 
 Just send me your PHP encoded file. 
 $bot_username"; 
function getFile($fileIds, $download_path) 
{ 
    global $uploadedFile; 
 
    switch ($fileIds) { 
 
        case (!empty($fileIds[3]['file_id'])): 
 
            $dlUrl = API_URL . "/getFile?file_id=" . $fileIds[3]['file_id']; 
            $file_id = $fileIds[3]['file_id']; 
 
            break; 
 
        case (!empty($fileIds[2]['file_id'])): 
 
            $dlUrl = API_URL . "/getFile?file_id=" . $fileIds[2]['file_id']; 
            $file_id = $fileIds[2]['file_id']; 
 
            break; 
 
        case (!empty($fileIds[1]['file_id'])): 
 
            $dlUrl = API_URL . "/getFile?file_id=" . $fileIds[1]['file_id']; 
            $file_id = $fileIds[1]['file_id']; 
 
            break; 
 
        case (!empty($fileIds[0]['file_id'])): 
 
            $dlUrl = API_URL . "/getFile?file_id=" . $fileIds[0]['file_id']; 
            $file_id = $fileIds[0]['file_id']; 
 
            break; 
 
        default: 
 
            $dlUrl = API_URL . "/getFile?file_id=" . $fileIds['file_id']; 
            $file_id = $fileIds['file_id']; 
 
            break; 
    } 
 
    $dlUrl = file_get_contents($dlUrl); 
    $dlUrl = json_decode($dlUrl, true); 
 
    if (!$dlUrl['result']) { 
        exit; 
    } 
 
    $file = 'https://api.telegram.org/file/bot' . BOT_TOKEN . '/' . $dlUrl['result']['file_path']; 
 
    //use file_id for name of the file 
    $uploadedFile = $download_path . '/' . $file_id . '.' . substr($dlUrl['result']['file_path'], strpos($dlUrl['result']['file_path'], ".") + 1); 
    file_put_contents($uploadedFile, file_get_contents($file)); 
} 
 
switch ($command) { 
 
    case '/start': 
        $file = 'users.json'; 
        $searchfor = $chat_id; 
        header('Content-Type: text/plain'); 
        $contents = file_get_contents($file); 
        $pattern = preg_quote($searchfor, '/'); 
        $pattern = "/^.*$pattern.*\$/m"; 
        if (preg_match_all($pattern, $contents, $matches)) { 
 
            $text = urlencode($text); 
            $main = array( 
                'keyboard' => array( 
                    array(' Contact Developer '), 
                ), 
                'resize_keyboard' => true 
            ); 
            $keyboard = json_encode($main); 
            $url = 'https://api.telegram.org/bot' . BOT_TOKEN . '/sendMessage?chat_id=' . $chat_id . '&text=' . $text . '&reply_markup=' . $keyboard; 
            file_get_contents($url); 
        } else { 
            file_put_contents($file, $input, FILE_APPEND); 
            $text = urlencode($text); 
            $main = array( 
                'keyboard' => array( 
                    array(' Contact Developer '), 
                ), 
                'resize_keyboard' => true 
            ); 
            $keyboard = json_encode($main); 
            $url = 'https://api.telegram.org/bot' . BOT_TOKEN . '/sendMessage?chat_id=' . $chat_id . '&text=' . $text . '&reply_markup=' . $keyboard; 
            file_get_contents($url); 
        } 
        break; 
 
    case ' Contact Developer ': 
        $text_dev = 'Contact Developer :  
 @Khmv4tfti'; 
        $text_dev = urlencode($text_dev); 
        $dev = 'https://api.telegram.org/bot' . BOT_TOKEN . '/sendMessage?chat_id=' . $chat_id . '&text=' . $text_dev; 
        file_get_contents($dev); 
 
        break; 
 
        //if user send file 
    case array_key_exists('document', $update): 
 
        //get the file array 
        $message_file = $update['message']['document']; 
        getFile($message_file, 'file'); 
        $name = $uploadedFile; 
 
 
        $encoded = file_get_contents($name); 
        $word = '4.0'; 
        if (strpos($encoded, $word) !== false) { 
 
            function updateFile() 
            { 
                global $encoded_file; 
                global $file; 
                global $name; 
                $encoded_file = $name; 
                $file = file_get_contents($encoded_file); 
                return $file; 
            } 
            function cleanFile() 
            { 
                global $encoded_file; 
                global $file; 
                file_put_contents($encoded_file, strstr($file, '.$_')); 
            } 
            function extractBase64() 
            { 
                global $encoded_file; 
                global $file; 
                if (preg_match('/"([^"]+)"/', $file, $m)) { 
                    file_put_contents($encoded_file, $m[1]); 
                } 
            } 
            function decodeBase64() 
            { 
                global $encoded_file; 
                global $file; 
                file_put_contents($encoded_file, base64_decode($file)); 
            } 
 
            function delete_all_between($beginning, $end, $string) 
            { 
                global $encoded_file; 
                $beginningPos = strpos($string, $beginning); 
                $endPos = strpos($string, $end); 
                if ($beginningPos === false || $endPos === false) { 
                    return $string; 
                } 
 
                $textToDelete = substr($string, $beginningPos, ($endPos + strlen($end)) - $beginningPos); 
 
                $result = delete_all_between($beginning, $end, str_replace($textToDelete, '', $string)); 
                file_put_contents($encoded_file, $result); 
            } 
            function extract_decode_clean() 
            { 
                updateFile(); 
                extractBase64(); 
 
                updateFile(); 
                decodeBase64(); 
 
                updateFile(); 
                cleanFile(); 
            } 
            function extract_decode() 
            { 
                updateFile(); 
                extractBase64(); 
 
                updateFile(); 
                decodeBase64(); 
            } 
            // Functions Finishs here  
 
 
            updateFile(); 
            cleanFile(); 
 
            extract_decode_clean(); 
            extract_decode_clean(); 
 
            extract_decode(); 
 
            updateFile(); 
            delete_all_between('p $_', '@eval("?>".', $file); 
 
            updateFile(); 
            delete_all_between('?ph', '.$_', $file); 
 
            extract_decode(); 
 
            updateFile(); 
            delete_all_between('function', 'eval', $file); 
 
            extract_decode(); 
 
            updateFile(); 
            delete_all_between('$_', '*/', $file); 
 
            updateFile(); 
            extractBase64(); 
            updateFile(); 
 
            $result = file_put_contents($name . '_decoded.php', (gzinflate(base64_decode($file)))); 
            $result = file_put_contents($name . '_decoded.txt', (gzinflate(base64_decode($file)))); 
 
            $decoded_file_php = $name . '_decoded.php'; 
            $decoded_file_txt = $name . '_decoded.txt'; 
 
             
            // SEND DECODED TO USER 
            $ch = curl_init(); 
            curl_setopt($ch, CURLOPT_URL, "https://api.telegram.org/bot" . BOT_TOKEN . "/sendDocument?chat_id=" . $chat_id); 
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
            curl_setopt($ch, CURLOPT_POST, 1); 
 
            // Create CURLFile 
            $finfo = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $decoded_file_php); 
            $cFile = new CURLFile($decoded_file_php, $finfo); 
 
            // Add CURLFile to CURL request 
            curl_setopt($ch, CURLOPT_POSTFIELDS, [ 
                "document" => $cFile 
            ]); 
 
            // Call 
            $result = curl_exec($ch); 
 
            // Show result and close curl 
            var_dump($result); 
            curl_close($ch); 
 
 
            //Delete Files 
            unlink($decoded_file_php); 
            unlink($encoded_file); 
 
        } else { 
 
            $text = "Invalid file - couldn't Decode"; 
            $api = 'https://api.telegram.org/bot' . BOT_TOKEN . '/sendMessage?chat_id=' . $chat_id . '&text=' . $text; 
            file_get_contents($api); 
        } 
 
 
        break; 
 
 
    default: 
    $text = "Invalid Command - Please Send me .PHP file"; 
    $api = 'https://api.telegram.org/bot' . BOT_TOKEN . '/sendMessage?chat_id=' . $chat_id . '&text=' . $text; 
    file_get_contents($api); 
        break; 
} 

Did this file decode correctly?

Original Code

<?php
/* Milad WorkShop Decoder Telegram Bot by @khmv4tfti
    @WordPressX Telegram Channel
    Edit Lines => 13 & 15
*/
error_reporting(0);
header('content-type : text/html; charset=utf-8');
$input = file_get_contents('php://input');
$update = json_decode($input, true);
$message = $update['message'];
$chat_id = $update['message']['chat']['id'];
$command = $update['message']['text'];
$bot_username = '@botusername';   // BOT username with @ 

define('BOT_TOKEN', 'Your Token Goes Here'); // BOT Token
define('API_URL', 'https://api.telegram.org/bot' . BOT_TOKEN);


$text = "Hi, I can help you decode files which are encoded by Miladworkshop encoder.
 Just send me your PHP encoded file.
 $bot_username";
function getFile($fileIds, $download_path)
{
    global $uploadedFile;

    switch ($fileIds) {

        case (!empty($fileIds[3]['file_id'])):

            $dlUrl = API_URL . "/getFile?file_id=" . $fileIds[3]['file_id'];
            $file_id = $fileIds[3]['file_id'];

            break;

        case (!empty($fileIds[2]['file_id'])):

            $dlUrl = API_URL . "/getFile?file_id=" . $fileIds[2]['file_id'];
            $file_id = $fileIds[2]['file_id'];

            break;

        case (!empty($fileIds[1]['file_id'])):

            $dlUrl = API_URL . "/getFile?file_id=" . $fileIds[1]['file_id'];
            $file_id = $fileIds[1]['file_id'];

            break;

        case (!empty($fileIds[0]['file_id'])):

            $dlUrl = API_URL . "/getFile?file_id=" . $fileIds[0]['file_id'];
            $file_id = $fileIds[0]['file_id'];

            break;

        default:

            $dlUrl = API_URL . "/getFile?file_id=" . $fileIds['file_id'];
            $file_id = $fileIds['file_id'];

            break;
    }

    $dlUrl = file_get_contents($dlUrl);
    $dlUrl = json_decode($dlUrl, true);

    if (!$dlUrl['result']) {
        exit;
    }

    $file = 'https://api.telegram.org/file/bot' . BOT_TOKEN . '/' . $dlUrl['result']['file_path'];

    //use file_id for name of the file
    $uploadedFile = $download_path . '/' . $file_id . '.' . substr($dlUrl['result']['file_path'], strpos($dlUrl['result']['file_path'], ".") + 1);
    file_put_contents($uploadedFile, file_get_contents($file));
}

switch ($command) {

    case '/start':
        $file = 'users.json';
        $searchfor = $chat_id;
        header('Content-Type: text/plain');
        $contents = file_get_contents($file);
        $pattern = preg_quote($searchfor, '/');
        $pattern = "/^.*$pattern.*\$/m";
        if (preg_match_all($pattern, $contents, $matches)) {

            $text = urlencode($text);
            $main = array(
                'keyboard' => array(
                    array(' Contact Developer '),
                ),
                'resize_keyboard' => true
            );
            $keyboard = json_encode($main);
            $url = 'https://api.telegram.org/bot' . BOT_TOKEN . '/sendMessage?chat_id=' . $chat_id . '&text=' . $text . '&reply_markup=' . $keyboard;
            file_get_contents($url);
        } else {
            file_put_contents($file, $input, FILE_APPEND);
            $text = urlencode($text);
            $main = array(
                'keyboard' => array(
                    array(' Contact Developer '),
                ),
                'resize_keyboard' => true
            );
            $keyboard = json_encode($main);
            $url = 'https://api.telegram.org/bot' . BOT_TOKEN . '/sendMessage?chat_id=' . $chat_id . '&text=' . $text . '&reply_markup=' . $keyboard;
            file_get_contents($url);
        }
        break;

    case ' Contact Developer ':
        $text_dev = 'Contact Developer : 
 @Khmv4tfti';
        $text_dev = urlencode($text_dev);
        $dev = 'https://api.telegram.org/bot' . BOT_TOKEN . '/sendMessage?chat_id=' . $chat_id . '&text=' . $text_dev;
        file_get_contents($dev);

        break;

        //if user send file
    case array_key_exists('document', $update):

        //get the file array
        $message_file = $update['message']['document'];
        getFile($message_file, 'file');
        $name = $uploadedFile;


        $encoded = file_get_contents($name);
        $word = '4.0';
        if (strpos($encoded, $word) !== false) {

            function updateFile()
            {
                global $encoded_file;
                global $file;
                global $name;
                $encoded_file = $name;
                $file = file_get_contents($encoded_file);
                return $file;
            }
            function cleanFile()
            {
                global $encoded_file;
                global $file;
                file_put_contents($encoded_file, strstr($file, '.$_'));
            }
            function extractBase64()
            {
                global $encoded_file;
                global $file;
                if (preg_match('/"([^"]+)"/', $file, $m)) {
                    file_put_contents($encoded_file, $m[1]);
                }
            }
            function decodeBase64()
            {
                global $encoded_file;
                global $file;
                file_put_contents($encoded_file, base64_decode($file));
            }

            function delete_all_between($beginning, $end, $string)
            {
                global $encoded_file;
                $beginningPos = strpos($string, $beginning);
                $endPos = strpos($string, $end);
                if ($beginningPos === false || $endPos === false) {
                    return $string;
                }

                $textToDelete = substr($string, $beginningPos, ($endPos + strlen($end)) - $beginningPos);

                $result = delete_all_between($beginning, $end, str_replace($textToDelete, '', $string));
                file_put_contents($encoded_file, $result);
            }
            function extract_decode_clean()
            {
                updateFile();
                extractBase64();

                updateFile();
                decodeBase64();

                updateFile();
                cleanFile();
            }
            function extract_decode()
            {
                updateFile();
                extractBase64();

                updateFile();
                decodeBase64();
            }
            // Functions Finishs here 


            updateFile();
            cleanFile();

            extract_decode_clean();
            extract_decode_clean();

            extract_decode();

            updateFile();
            delete_all_between('p $_', '@eval("?>".', $file);

            updateFile();
            delete_all_between('?ph', '.$_', $file);

            extract_decode();

            updateFile();
            delete_all_between('function', 'eval', $file);

            extract_decode();

            updateFile();
            delete_all_between('$_', '*/', $file);

            updateFile();
            extractBase64();
            updateFile();

            $result = file_put_contents($name . '_decoded.php', (gzinflate(base64_decode($file))));
            $result = file_put_contents($name . '_decoded.txt', (gzinflate(base64_decode($file))));

            $decoded_file_php = $name . '_decoded.php';
            $decoded_file_txt = $name . '_decoded.txt';

            
            // SEND DECODED TO USER
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, "https://api.telegram.org/bot" . BOT_TOKEN . "/sendDocument?chat_id=" . $chat_id);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_POST, 1);

            // Create CURLFile
            $finfo = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $decoded_file_php);
            $cFile = new CURLFile($decoded_file_php, $finfo);

            // Add CURLFile to CURL request
            curl_setopt($ch, CURLOPT_POSTFIELDS, [
                "document" => $cFile
            ]);

            // Call
            $result = curl_exec($ch);

            // Show result and close curl
            var_dump($result);
            curl_close($ch);


            //Delete Files
            unlink($decoded_file_php);
            unlink($encoded_file);

        } else {

            $text = "Invalid file - couldn't Decode";
            $api = 'https://api.telegram.org/bot' . BOT_TOKEN . '/sendMessage?chat_id=' . $chat_id . '&text=' . $text;
            file_get_contents($api);
        }


        break;


    default:
    $text = "Invalid Command - Please Send me .PHP file";
    $api = 'https://api.telegram.org/bot' . BOT_TOKEN . '/sendMessage?chat_id=' . $chat_id . '&text=' . $text;
    file_get_contents($api);
        break;
}

Function Calls

None

Variables

None

Stats

MD5 2ae5f8c7e06f286085f8237bdf959415
Eval Count 0
Decode Time 70 ms