A
A
Alexander Kazakov2020-04-21 19:02:10
JavaScript
Alexander Kazakov, 2020-04-21 19:02:10

How to convert text to a string (sequence) like \xNN?

Hello.
On one of the projects, I covered the url from bots using some kind of online string converter.
The view string has been converted to
var url = '/partners/ajax.php';

var url = '\x2F\x70\x61\x72\x74\x6E\x65\x72\x73\x2F\x61\x6A\x61\x78\x2E\x70\x68\x70';


Now there is a need to fix the url, but I can’t google the conversion function or the online service again.
Tell me what exactly this 16-sequence is and how to convert a string into it, please.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Sokolov, 2020-04-21
@ferym

var url = '/partners/ajax.php';

var obfuscated = url.split('')
  .map(c => '\\x' + c.charCodeAt(0).toString(16).toUpperCase())
  .join('');
//  "\\x2F\\x70\\x61\\x72\\x74\\x6E\\x65\\x72\\x73\\x2F\\x61\\x6A\\x61\\x78\\x2E\\x70\\x68\\x70" 

alert(obfuscated); // \x2F\x70\x61\x72\x74\x6E\x65\x72\x73\x2F\x61\x6A\x61\x78\x2E\x70\x68\x70

M
Mikhail Osher, 2020-04-21
@miraage

decodeURIComponent('\x2F\x70\x61\x72\x74\x6E\x65\x72\x73\x2F\x61\x6A\x61\x78\x2E\x70\x68\x70')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question