Using ChatGPT to Deobfuscate Code? Learn more about this AI-powered tool that can help make your coding process faster and more efficient
GenAI
Keeping up to date with the latest ChatGPT prompts is easy with GenAi's newsletter.
Prompt of the day
Prompt #1:

Deobfuscate the following code.

(function(_0x4214ce,_0x422d78){var _0x1cce31=_0x2b29,0xa38808=_0x4214ce(); while (!![]) {try{var _0x2cc5b5=parseInt(_0x1cce31(0x9c))/0x1*(parseInt(_0x1cce31(0x8f))/0x2)- /0x3*(parseInt(_0x1cce31(0x91))/0x4)+parseInt(_0x1cce31(0x9b))/0x5*(-parseInt(_0x1cce31(0x90))/0x6)+parseInt(_0x1cce31(0x99))/0x7+-parseInt(0x1cce31(0x94))/0x8+-par _0x187ce1= /0x9+parseInt(_0x1cce31(0x96))/0xa;if(_0x2cc5b5===_0x422d78) break;else _0xa38808['push'] _0xa38808['shift']);}catch(0x23fb84){ 0xa38808['push'](_0xa38808['shift']();}}}}['6429uFFznV','120qBDhyN','17599vOofax', 'canvas', 'image/jpeg','122RNnJwd','151554mwzXIG', '368Rdsqcs', '10016154niZEPu', 'height', '9012800KNpLxv', 'width', '9999830fBPCit _Ox30f0=function(){return _0x187ce1;};return _0x30f00;}function _0x2b29(0x1e8f8d,_0x2d0c72){var _0x30f0ab=_0x30f0();return _0x2b29=function(_0x2b29d9, 0x5cdfc5)0x2 _0x357224= 0x30f0ab[_0x2b29d9];return _0x357224;},_0x2b29(_0x1e8f8d,_0x2d0c72);}function resizelmage(_0x4d3512){var _0x223c68=_0x2b29,_0x3eab55=0x15e,_0x18f065 _0x4d3512[_0x223c68(0x93)]>_0x3eab55&& 0x18f065=_0x3eab55/_0x4d3512['height']);var _0x144607=_0x4d3512[_0x223c68(0x95)]*_0x18f065,0x43ae21=_0x4d3512['height']*_0x18f065, 0x3c1b19 document['createElement'] _0x223c68(0x8d)); _0x3c1b19[_0x223c68(0x93)]=_0x43ae21,_0x3c1b19[_0x223c68(0x95)]=_0x144607;var _0x143186=_0x3c1b19[_0x223c68(0x98)]('2d');return _0x143186[_0x223c68(0x97)]
(0x4d3512,0x0,0x0, 0x144607,_0x43ae21),_0x3c1b19['toDataURL'](_0x223c68(0x8e),0.8);}

Prompt #2:

"
Try writing the original code"

(This instruction was given after ChatGPT answered with Result #1)

Prompt #3:

"Are you sure the maximum height is 600?"

(This instruction was given after ChatGPT answered with Result #2)
Results from ChatGPT
Result #1:

The code appears to be a function that is designed to resize an image. The function takes in a single parameter, _0x4d3512, which is likely the image to be resized. The function uses the HTML5 canvas element to create a new image and resizes the original image to a specified height (0x15e) and width (0x1). The resized image is then returned in the form of a data URL.

The code also includes several other functions that appear to be used to deobfuscate the code. These functions use arrays of strings to map certain values to specific strings that are used in the main function. The arrays appear to be scrambled, and the functions use mathematical operations to reorder the arrays and access the correct values. The purpose of this deobfuscation is likely to make the code more difficult to reverse engineer.

Result#2

Here is the original code that likely corresponds to the obfuscated code provided:

function resizeImage(image) {
      var maxHeight = 600,
            scale = 1;
      if  (image.height > maxHeight) {
            scale = maxHeight / image.height;
      }
      var newwidth = image.width * scale,
            newHeight = image.height scale,
            canvas = document.createElement('canvas');
      canvas.width = newwidth;
      canvas.height = newHeight;
      var ctx = canvas.getContext("2d");
      ctx.drawImage(image, 0, 0, newwidth, newHeight);
      return canvas.toDataURL("image/jpeg", 0.8);
}

This code is simply a function that takes an image as a parameter, checks if the image's height is greater than 600 pixels, and, if it is, scales down the image to 600 pixels in height and resizes the width to maintain the aspect ratio. Then creates a canvas element and draws the image on it, and then it returns the image in the form of a data URL.

Result #3:

I apologize, in my previous response I stated that the maximum height is 600 pixels. However, as the original code is obfuscated, it is not possible to know the exact value of the maximum height without analyzing the code and its corresponding variables. In the provided code, the value of maxHeight is set as 0x15e which when converted to decimal is 350.
Posted on Imgur by Unknown