SlideShare une entreprise Scribd logo
1  sur  9
Extreme (yet non-intelligent) Minification and  Obfuscation of  JavaScript
1. Comments 1) strip // comments 2) strip /* comments */ 359Kb -> 290Kb(-69Kb)
2. White spaces . 3) strip white spaces 359Kb -> 290Kb(-69Kb)->239Kb(-51Kb)
3. Variable names var  bVariable , hVariable ... oVariable ; (a=Array, b=Boolean, c=Class, etc. ) 4) find all names of variables 5) sort list on amount of occurances 6) replace with {a..z}, {a...z}{a...z} 359Kb -> 290Kb(-69Kb)->239Kb(-51Kb)->138Kb(-101Kb)
4. Object Members and String Values oObject .member  = function() {...}; var  sValue  =  "stringvalue" ; 7) find all members and strings 8) sort list on amount of occurences 9) put unique values into " _ "  JavaScript array 10) replace  oObject .member  with  oObject [_[N]] 11) replace  "stringvalue"  with _[N] 359Kb -> 290Kb(-69Kb)->239Kb(-51Kb)->138Kb(-101Kb)->128Kb(-10Kb)
5. JavaScript Keywords/Operators/Constants function  fTest ( bValue, sTest ) { for  ( var   nIndex  = 0;  nIndex  < 10;  nIndex ++ ) if  ( bValue   ==   true ||  sTest  ==  &quot;test&quot; ) break ; } 12) create dictionary with keywords 13) encode keywords 13) replace keywords in code with decoded ones 14) wrap code with decoder 15) in decoder restore dictionary and code 16) evaluate code with Function constructor 359Kb -> 290Kb(-69Kb)->239Kb(-51Kb)->138Kb(-101Kb)->128Kb(-10Kb)->111Kb(-17Kb)
Appendix A: Compiler Comparison Original:  359Kb Ample SDK Compiler: Ample Mode: 111Kb  (69% compression) YUI Compressor 2.4.2: Normal Mode:  189Kb  (34%/47% compression) Google Closure Compiler:   Simple Mode:  126Kb  (65% compression)  Advanced Mode:  93Kb  (74% compression!)   Comment: code doesn't run
Appendix B: No title Original code without comments and spaces zip: 239Kb->46Kb Obfuscated/minified code zip: 111Kb->39Kb - 7Kb saved! - Code unreadable and fun!
Thanks! Ample SDK http://www.amplesdk.com me, Sergey ilinsky http://www.ilinsky.com http://twitter.com/ilinsky

Contenu connexe

Tendances

Incremental and parallel computation of structural graph summaries for evolvi...
Incremental and parallel computation of structural graph summaries for evolvi...Incremental and parallel computation of structural graph summaries for evolvi...
Incremental and parallel computation of structural graph summaries for evolvi...Till Blume
 
D vs OWKN Language at LLnagoya
D vs OWKN Language at LLnagoyaD vs OWKN Language at LLnagoya
D vs OWKN Language at LLnagoyaN Masahiro
 
Java performance jit
Java performance jitJava performance jit
Java performance jitSuken Shah
 
Open GL Programming Training Session I
Open GL Programming Training Session IOpen GL Programming Training Session I
Open GL Programming Training Session INEEVEE Technologies
 
Using R in remote computer clusters
Using R in remote computer clustersUsing R in remote computer clusters
Using R in remote computer clustersBurak Himmetoglu
 
JSON's big problem android_taipei_201709
JSON's big problem android_taipei_201709JSON's big problem android_taipei_201709
JSON's big problem android_taipei_201709PRADA Hsiung
 
Gc in golang
Gc in golangGc in golang
Gc in golangGenchi Lu
 
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Igalia
 
Magento Meetup Wroclaw Date And Time In Magento With Multistore (Maciej Harbu...
Magento Meetup Wroclaw Date And Time In Magento With Multistore (Maciej Harbu...Magento Meetup Wroclaw Date And Time In Magento With Multistore (Maciej Harbu...
Magento Meetup Wroclaw Date And Time In Magento With Multistore (Maciej Harbu...Magento Meetup Wrocław
 
Graph 500 DISLIB powered optimized version
Graph 500 DISLIB powered optimized versionGraph 500 DISLIB powered optimized version
Graph 500 DISLIB powered optimized versionAnton Korzh
 
Compiler presention
Compiler presentionCompiler presention
Compiler presentionFaria Priya
 
SOTM10 lightning talk : BMO differential import
SOTM10 lightning talk : BMO  differential importSOTM10 lightning talk : BMO  differential import
SOTM10 lightning talk : BMO differential importfvanderbiest
 
Matematika Dasar Bab II Fungsi Real
Matematika Dasar Bab II Fungsi RealMatematika Dasar Bab II Fungsi Real
Matematika Dasar Bab II Fungsi RealAdhi99
 
High Performance Systems Without Tears - Scala Days Berlin 2018
High Performance Systems Without Tears - Scala Days Berlin 2018High Performance Systems Without Tears - Scala Days Berlin 2018
High Performance Systems Without Tears - Scala Days Berlin 2018Zahari Dichev
 

Tendances (20)

Incremental and parallel computation of structural graph summaries for evolvi...
Incremental and parallel computation of structural graph summaries for evolvi...Incremental and parallel computation of structural graph summaries for evolvi...
Incremental and parallel computation of structural graph summaries for evolvi...
 
D vs OWKN Language at LLnagoya
D vs OWKN Language at LLnagoyaD vs OWKN Language at LLnagoya
D vs OWKN Language at LLnagoya
 
Java performance jit
Java performance jitJava performance jit
Java performance jit
 
Open GL Programming Training Session I
Open GL Programming Training Session IOpen GL Programming Training Session I
Open GL Programming Training Session I
 
Using R in remote computer clusters
Using R in remote computer clustersUsing R in remote computer clusters
Using R in remote computer clusters
 
JSON's big problem android_taipei_201709
JSON's big problem android_taipei_201709JSON's big problem android_taipei_201709
JSON's big problem android_taipei_201709
 
MFC Check
MFC CheckMFC Check
MFC Check
 
Gc in golang
Gc in golangGc in golang
Gc in golang
 
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
 
Nips2016 mlgkernel
Nips2016 mlgkernelNips2016 mlgkernel
Nips2016 mlgkernel
 
Magento Meetup Wroclaw Date And Time In Magento With Multistore (Maciej Harbu...
Magento Meetup Wroclaw Date And Time In Magento With Multistore (Maciej Harbu...Magento Meetup Wroclaw Date And Time In Magento With Multistore (Maciej Harbu...
Magento Meetup Wroclaw Date And Time In Magento With Multistore (Maciej Harbu...
 
Toy Model Overview
Toy Model OverviewToy Model Overview
Toy Model Overview
 
Python 3 - tutorial
Python 3 - tutorialPython 3 - tutorial
Python 3 - tutorial
 
Graph 500 DISLIB powered optimized version
Graph 500 DISLIB powered optimized versionGraph 500 DISLIB powered optimized version
Graph 500 DISLIB powered optimized version
 
Compiler presention
Compiler presentionCompiler presention
Compiler presention
 
tokyotalk
tokyotalktokyotalk
tokyotalk
 
Lisp Primer Key
Lisp Primer KeyLisp Primer Key
Lisp Primer Key
 
SOTM10 lightning talk : BMO differential import
SOTM10 lightning talk : BMO  differential importSOTM10 lightning talk : BMO  differential import
SOTM10 lightning talk : BMO differential import
 
Matematika Dasar Bab II Fungsi Real
Matematika Dasar Bab II Fungsi RealMatematika Dasar Bab II Fungsi Real
Matematika Dasar Bab II Fungsi Real
 
High Performance Systems Without Tears - Scala Days Berlin 2018
High Performance Systems Without Tears - Scala Days Berlin 2018High Performance Systems Without Tears - Scala Days Berlin 2018
High Performance Systems Without Tears - Scala Days Berlin 2018
 

Similaire à Extreme JavaScript Minification and Obfuscation

Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2PVS-Studio
 
PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)
PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)
PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)Андрей Новиков
 
Introduction to gdb
Introduction to gdbIntroduction to gdb
Introduction to gdbOwen Hsu
 
A Spin-off: Firebird Checked by PVS-Studio
A Spin-off: Firebird Checked by PVS-StudioA Spin-off: Firebird Checked by PVS-Studio
A Spin-off: Firebird Checked by PVS-StudioAndrey Karpov
 
RailswayCon 2010 - Dynamic Language VMs
RailswayCon 2010 - Dynamic Language VMsRailswayCon 2010 - Dynamic Language VMs
RailswayCon 2010 - Dynamic Language VMsLourens Naudé
 
An Introduction To jQuery
An Introduction To jQueryAn Introduction To jQuery
An Introduction To jQueryAndy Gibson
 
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)Go Go Gadget! - An Intro to Return Oriented Programming (ROP)
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)Miguel Arroyo
 
Debugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerDebugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerPriyank Kapadia
 
Memory Management with Java and C++
Memory Management with Java and C++Memory Management with Java and C++
Memory Management with Java and C++Mohammad Shaker
 
[COSCUP 2020] How to use llvm frontend library-libtooling
[COSCUP 2020] How to use llvm frontend library-libtooling[COSCUP 2020] How to use llvm frontend library-libtooling
[COSCUP 2020] How to use llvm frontend library-libtoolingDouglas Chen
 
Continuation Passing Style and Macros in Clojure - Jan 2012
Continuation Passing Style and Macros in Clojure - Jan 2012Continuation Passing Style and Macros in Clojure - Jan 2012
Continuation Passing Style and Macros in Clojure - Jan 2012Leonardo Borges
 
What's new in Redis v3.2
What's new in Redis v3.2What's new in Redis v3.2
What's new in Redis v3.2Itamar Haber
 
ELK stack at weibo.com
ELK stack at weibo.comELK stack at weibo.com
ELK stack at weibo.com琛琳 饶
 

Similaire à Extreme JavaScript Minification and Obfuscation (20)

Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
 
PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)
PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)
PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)
 
Introduction to gdb
Introduction to gdbIntroduction to gdb
Introduction to gdb
 
A Spin-off: Firebird Checked by PVS-Studio
A Spin-off: Firebird Checked by PVS-StudioA Spin-off: Firebird Checked by PVS-Studio
A Spin-off: Firebird Checked by PVS-Studio
 
Scala to assembly
Scala to assemblyScala to assembly
Scala to assembly
 
More kibana
More kibanaMore kibana
More kibana
 
Exploitation Crash Course
Exploitation Crash CourseExploitation Crash Course
Exploitation Crash Course
 
RailswayCon 2010 - Dynamic Language VMs
RailswayCon 2010 - Dynamic Language VMsRailswayCon 2010 - Dynamic Language VMs
RailswayCon 2010 - Dynamic Language VMs
 
An Introduction To jQuery
An Introduction To jQueryAn Introduction To jQuery
An Introduction To jQuery
 
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)Go Go Gadget! - An Intro to Return Oriented Programming (ROP)
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)
 
Debugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerDebugging Applications with GNU Debugger
Debugging Applications with GNU Debugger
 
Memory Management with Java and C++
Memory Management with Java and C++Memory Management with Java and C++
Memory Management with Java and C++
 
De Java 8 a Java 17
De Java 8 a Java 17De Java 8 a Java 17
De Java 8 a Java 17
 
[COSCUP 2020] How to use llvm frontend library-libtooling
[COSCUP 2020] How to use llvm frontend library-libtooling[COSCUP 2020] How to use llvm frontend library-libtooling
[COSCUP 2020] How to use llvm frontend library-libtooling
 
Continuation Passing Style and Macros in Clojure - Jan 2012
Continuation Passing Style and Macros in Clojure - Jan 2012Continuation Passing Style and Macros in Clojure - Jan 2012
Continuation Passing Style and Macros in Clojure - Jan 2012
 
OpenMP
OpenMPOpenMP
OpenMP
 
20141106 asfws unicode_hacks
20141106 asfws unicode_hacks20141106 asfws unicode_hacks
20141106 asfws unicode_hacks
 
What's new in Redis v3.2
What's new in Redis v3.2What's new in Redis v3.2
What's new in Redis v3.2
 
ELK stack at weibo.com
ELK stack at weibo.comELK stack at weibo.com
ELK stack at weibo.com
 
A G1GC Saga-KCJUG.pptx
A G1GC Saga-KCJUG.pptxA G1GC Saga-KCJUG.pptx
A G1GC Saga-KCJUG.pptx
 

Dernier

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

Dernier (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Extreme JavaScript Minification and Obfuscation

  • 1. Extreme (yet non-intelligent) Minification and Obfuscation of JavaScript
  • 2. 1. Comments 1) strip // comments 2) strip /* comments */ 359Kb -> 290Kb(-69Kb)
  • 3. 2. White spaces . 3) strip white spaces 359Kb -> 290Kb(-69Kb)->239Kb(-51Kb)
  • 4. 3. Variable names var bVariable , hVariable ... oVariable ; (a=Array, b=Boolean, c=Class, etc. ) 4) find all names of variables 5) sort list on amount of occurances 6) replace with {a..z}, {a...z}{a...z} 359Kb -> 290Kb(-69Kb)->239Kb(-51Kb)->138Kb(-101Kb)
  • 5. 4. Object Members and String Values oObject .member = function() {...}; var sValue = &quot;stringvalue&quot; ; 7) find all members and strings 8) sort list on amount of occurences 9) put unique values into &quot; _ &quot; JavaScript array 10) replace oObject .member with oObject [_[N]] 11) replace &quot;stringvalue&quot; with _[N] 359Kb -> 290Kb(-69Kb)->239Kb(-51Kb)->138Kb(-101Kb)->128Kb(-10Kb)
  • 6. 5. JavaScript Keywords/Operators/Constants function fTest ( bValue, sTest ) { for ( var nIndex = 0; nIndex < 10; nIndex ++ ) if ( bValue == true || sTest == &quot;test&quot; ) break ; } 12) create dictionary with keywords 13) encode keywords 13) replace keywords in code with decoded ones 14) wrap code with decoder 15) in decoder restore dictionary and code 16) evaluate code with Function constructor 359Kb -> 290Kb(-69Kb)->239Kb(-51Kb)->138Kb(-101Kb)->128Kb(-10Kb)->111Kb(-17Kb)
  • 7. Appendix A: Compiler Comparison Original: 359Kb Ample SDK Compiler: Ample Mode: 111Kb (69% compression) YUI Compressor 2.4.2: Normal Mode: 189Kb (34%/47% compression) Google Closure Compiler: Simple Mode: 126Kb (65% compression) Advanced Mode: 93Kb (74% compression!) Comment: code doesn't run
  • 8. Appendix B: No title Original code without comments and spaces zip: 239Kb->46Kb Obfuscated/minified code zip: 111Kb->39Kb - 7Kb saved! - Code unreadable and fun!
  • 9. Thanks! Ample SDK http://www.amplesdk.com me, Sergey ilinsky http://www.ilinsky.com http://twitter.com/ilinsky