Chat GPT can de-obfuscate code ?

Abdel moneem Saadaoui
3 min readMar 28, 2023

Code obfuscation is a technique used to hide the code’s true purpose or to make it harder to understand or reverse engineer. It can be used for legitimate purposes, such as protecting intellectual property, but it can also be used for malicious purposes, such as hiding malware or other types of attacks.

However, de-obfuscating code is possible and there are several techniques that can be used to achieve this. One of the most common techniques is to use a de-obfuscation tool. There are several tools available that can automatically de-obfuscate code. These tools work by analyzing the code and identifying the obfuscation techniques used. Once the techniques are identified, the tool can then reverse the obfuscation to reveal the original code.

Today’s tool of choice is chatGPT. as in a few simple prompt we were able to de-obfuscate javascript code.

This is the original code that we are going to use obfuscator.io to make it non-human readable

// node class
class Node extends Tree {
constructor(left, v, right) {
super()
this.v = v;
this.left = left;
this.right = right;
}
}
// leaf class
class Leaf extends Tree {
constructor(v) {
super()
this.v = v;
}
}

After processing the code we receive the following result

function _0x40bf(_0x301426,_0x58e265){var _0x3f1815=_0x3f18();return _0x40bf=function(_0x40bfa8,_0x1e4b56){_0x40bfa8=_0x40bfa8-0x199;var _0x4c01ef=_0x3f1815[_0x40bfa8];return _0x4c01ef;},_0x40bf(_0x301426,_0x58e265);}function _0x3f18(){var _0x13c65f=['100664yFrvKv','10696cPgfhL','18nwfIao','1908117zlBWEu','right','208175XHSqyo','535162wjgYdO','16895549QFMKov','20UdExBY','328KCUQEl','166418WEXZUy','3TxWFWv'];_0x3f18=function(){return _0x13c65f;};return _0x3f18();}(function(_0x48057e,_0x4c0490){var _0x2c9a73=_0x40bf,_0x1e839b=_0x48057e();while(!![]){try{var _0x3d95fb=-parseInt(_0x2c9a73(0x1a2))/0x1+-parseInt(_0x2c9a73(0x19a))/0x2+parseInt(_0x2c9a73(0x19b))/0x3*(-parseInt(_0x2c9a73(0x19c))/0x4)+-parseInt(_0x2c9a73(0x1a1))/0x5*(parseInt(_0x2c9a73(0x19e))/0x6)+-parseInt(_0x2c9a73(0x19d))/0x7*(parseInt(_0x2c9a73(0x199))/0x8)+parseInt(_0x2c9a73(0x19f))/0x9*(-parseInt(_0x2c9a73(0x1a4))/0xa)+parseInt(_0x2c9a73(0x1a3))/0xb;if(_0x3d95fb===_0x4c0490)break;else _0x1e839b['push'](_0x1e839b['shift']());}catch(_0x59e0fd){_0x1e839b['push'](_0x1e839b['shift']());}}}(_0x3f18,0x4490b));class Node extends Tree{constructor(_0x5f2e74,_0x251154,_0x17bb75){var _0x394bd8=_0x40bf;super(),this['v']=_0x251154,this['left']=_0x5f2e74,this[_0x394bd8(0x1a0)]=_0x17bb75;}}class Leaf extends Tree{constructor(_0x22105c){super(),this['v']=_0x22105c;}}

Now we proceed to input the obfuscated code to ChatGPT and letting it know that it is an obfuscated code , without specifying the language used or any other parameteres

Prompt to inform chat gpt that this is an obfuscated code
We receive the following observation by ChatGPT
We run the following prompt and we can see the magic happening
and Voila !

We can go further and ask chatGPT how the process happened and we get the following response.

To conclude , ChatGPT, being a large language model, is capable of deobfuscating code through its understanding of programming languages and syntax. Deobfuscation involves the process of making obfuscated or obscured code more readable and understandable by replacing short, meaningless variable names with more descriptive ones, and by formatting the code to make it easier to read. With its knowledge of coding practices and syntax, ChatGPT can effectively transform complex and obfuscated code into a more readable and understandable form.

--

--