JS Obfuscation: Why, How & When...

With huge number of available code decompilers out there on the internet, it is becoming more important day by day to hide our source code, so that any reverse engineer cannot decompile it.

Interpreted languages like Python & JavaScript have made obfuscation more necessary to protect the source code. Even though you package your app as an executable, you source code can still be viewed from the memory.

What is Code Obfuscation?

Code Obfuscation is the technology for making lives of reverse engineers hard so as to keep our source code safe.

It's similiar to the Oxford provided defination for obfuscation the action of making something obscure, unclear, or unintelligible.

Code Obfuscation is the process of converting the actual source code to a unreadable and un-understandable code.

Here's a Javascript Obfuscated Code Example

Real Source Code

function NewObject(prefix)

{

var count=0;

this.SayHello=function(msg)

{

count++;

alert(prefix+msg);

}

this.GetCount=function()

{

return count;

}

}

var obj=new NewObject("Message : ");

obj.SayHello("You are welcome.");

Obfuscated Code

function

_0xeca37b(prefix){var

_0x="2|0|4|1|3".split("|"),_0x9ea8dc=0;while(!![]){switch(+_0x[_0x9ea8dc++]){case

0:var _0x1ee67g=function(s,h){return s^h;}(625455,625455);continue;case

1:this['\x53\x61\x79\x48\x65\x6c\x6c\x6f']=function(msg){var

_0x0g9ab="1|0".split("|"),_0x2=0;while(!![]){switch(+_0x0g9ab[_0x2++]){case

0:alert(prefix+msg);continue;case

1:_0x1ee67g++;continue;}break;}};continue;case 2:var

_0x5ffb=function(s,h){return

s+h;}(251253^251249,985180^985178);continue;case

3:this['\x47\x65\x74\x43\x6f\x75\x6e\x74']=function(){return

_0x1ee67g;};continue;case 4:_0x5ffb=function(){return

960658^960662;}();continue;}break;}}var _0x29e1b=new _0xeca37b(" :

egasseM"['\x73\x70\x6c\x69\x74']("")['\x72\x65\x76\x65\x72\x73\x65']()['\x6a\x6f\x69\x6e'](""));_0x29e1b['\x53\x61\x79\x48\x65\x6c\x6c\x6f'](".emoclew

era

uoY"['\x73\x70\x6c\x69\x74']("")['\x72\x65\x76\x65\x72\x73\x65']()['\x6a\x6f\x69\x6e'](""));

How does Code Obfuscation work?

As you can see, in the obfuscated code, the variable names have been changed, function name changed into random hex.

Also, unnecessary variables and loops have been added so that no reverse engineer can understand it.

I would also recommend you to experiment with it yourself, here is the link to the online JS obfuscator which I used in the above example:https://js-obfuscator.com

How is Code Obfuscation different from Code Uglifying

Code Uglifying is very different from Code Obfuscation. Code Uglification only removes excess space characters and tab characters, the uglified code can be easily brought back to it's earlier state using Beautifier use as Prettier for VS Code.

Why obfuscate your code?

Let's say you and your team is working hard on a new commercial application for your company. The application is obviously paid $. You released the first public version (v1.0.0).

Now, after 2 days you get to know that your app is available as a free download on a 3rd party torrent website. You would be too sad after hearing this news.

Your months and years of hard work was stolen!!

This situation could be prevented.

How?

If you had obfuscated your Source Code before compiling it and releasing.

原文鏈接:https://www.fairysoftware.com/tips/202404130002.html

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末辣苏,一起剝皮案震驚了整個(gè)濱河市闭翩,隨后出現(xiàn)的幾起案子雕欺,更是在濱河造成了極大的恐慌,老刑警劉巖抛杨,帶你破解...
    沈念sama閱讀 212,454評(píng)論 6 493
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡剂癌,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,553評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門翰绊,熙熙樓的掌柜王于貴愁眉苦臉地迎上來佩谷,“玉大人,你說我怎么就攤上這事辞做×找” “怎么了?”我有些...
    開封第一講書人閱讀 157,921評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵秤茅,是天一觀的道長(zhǎng)稚补。 經(jīng)常有香客問我,道長(zhǎng)框喳,這世上最難降的妖魔是什么课幕? 我笑而不...
    開封第一講書人閱讀 56,648評(píng)論 1 284
  • 正文 為了忘掉前任,我火速辦了婚禮五垮,結(jié)果婚禮上乍惊,老公的妹妹穿的比我還像新娘。我一直安慰自己放仗,他們只是感情好润绎,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,770評(píng)論 6 386
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著诞挨,像睡著了一般莉撇。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上惶傻,一...
    開封第一講書人閱讀 49,950評(píng)論 1 291
  • 那天棍郎,我揣著相機(jī)與錄音,去河邊找鬼银室。 笑死涂佃,一個(gè)胖子當(dāng)著我的面吹牛励翼,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播辜荠,決...
    沈念sama閱讀 39,090評(píng)論 3 410
  • 文/蒼蘭香墨 我猛地睜開眼汽抚,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了侨拦?” 一聲冷哼從身側(cè)響起殊橙,我...
    開封第一講書人閱讀 37,817評(píng)論 0 268
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎狱从,沒想到半個(gè)月后膨蛮,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,275評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡季研,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,592評(píng)論 2 327
  • 正文 我和宋清朗相戀三年敞葛,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片与涡。...
    茶點(diǎn)故事閱讀 38,724評(píng)論 1 341
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡惹谐,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出驼卖,到底是詐尸還是另有隱情氨肌,我是刑警寧澤,帶...
    沈念sama閱讀 34,409評(píng)論 4 333
  • 正文 年R本政府宣布酌畜,位于F島的核電站怎囚,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏桥胞。R本人自食惡果不足惜恳守,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 40,052評(píng)論 3 316
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望贩虾。 院中可真熱鬧催烘,春花似錦、人聲如沸缎罢。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,815評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽策精。三九已至舰始,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間蛮寂,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,043評(píng)論 1 266
  • 我被黑心中介騙來泰國(guó)打工易茬, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留酬蹋,地道東北人及老。 一個(gè)月前我還...
    沈念sama閱讀 46,503評(píng)論 2 361
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像范抓,于是被迫代替她去往敵國(guó)和親骄恶。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,627評(píng)論 2 350

推薦閱讀更多精彩內(nèi)容