How to obfuscate JavaScript using PHP? -
for example, how obfuscate sample code from:
/* code below write heading , paragraph, , represent start of homepage: */ document.getelementbyid("myh1").innerhtml="welcome homepage"; document.getelementbyid("myp").innerhtml="this first paragraph.";
into form:
var _0xcc34=["\x69\x6e\x6e\x65\x72\x48\x54\x4d\x4c","\x6d\x79\x48\x31","\x67\x65\x74\x45\x6c\x65\x6d\x65\x6e\x74\x42\x79\x49\x64","\x57\x65\x6c\x63\x6f\x6d\x65\x20\x74\x6f\x20\x6d\x79\x20\x48\x6f\x6d\x65\x70\x61\x67\x65","\x6d\x79\x50","\x54\x68\x69\x73\x20\x69\x73\x20\x6d\x79\x20\x66\x69\x72\x73\x74\x20\x70\x61\x72\x61\x67\x72\x61\x70\x68\x2e"];document[_0xcc34[2]](_0xcc34[1])[_0xcc34[0]]=_0xcc34[3];document[_0xcc34[2]](_0xcc34[4])[_0xcc34[0]]=_0xcc34[5];
using php?
i know can using http://javascriptobfuscator.com/ need inside php file, because dynamically changes.
ok. on theory how obsfucate.
- you need know language, need parser results.
- when know what, can start replacing things.
for stupid example replace instances of
document.getelementbyid('string');
ab(cd('fgevat');
like
function cd(s) { /* rot13 implemented here*/ } function ab(s) { return document.getelementbyid(s); } ab(cd('fgevat');
- you can use eval avoid unpacking clear text. , can go
like this
function h(s) { /*implement hexdecode in ugly way, , run eval() on resulting string */} h('2020202066756e6374696f6e206364287329207b202f2a20524f54313320696d706c656d656e74656420686572652a2f207d2066756e6374696f6e206162287329207b2072657475726e20646f63756d656e742e676574456c656d656e74427949642873293b207d206162286364282766676576617427293b'); // above code.
this r=1 stuff. , can done waay better deeper understanding of language, these absolutely trivial reverse
Comments
Post a Comment