Permalink
Browse files

MyObfuscate packer support

  • Loading branch information...
1 parent 93883e8 commit 58e0473bc82be72406db432493d6735c78f5eb36 @Dither committed May 4, 2011
Showing with 75 additions and 3 deletions.
  1. +1 −1 config.xml
  2. +7 −0 includes/common.js
  3. +64 −0 includes/unpacker_myobfuscate.js
  4. +2 −2 options.html
  5. +1 −0 popup.html
View
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
-<widget xmlns="http://www.w3.org/ns/widgets" id="extensions:readable-javascript" version="1.11">
+<widget xmlns="http://www.w3.org/ns/widgets" id="extensions:readable-javascript" version="1.12">
<name>Readable JavaScript</name>
<author href="http://my.opera.com/DitherSky/blog/">Dither</author>
<description>Extension for auto-formatting and colorizing JavaScript code. Triggered by files with .js extension in their URL or by toolbar button.</description>
View
@@ -40,5 +40,12 @@ function unpacker_filter(source)
return unpacker_filter(unpacked);
}
}
+
+ if (MyObfuscate.detect(stripped_source)) {
+ unpacked = MyObfuscate.unpack(stripped_source);
+ if (unpacked !== stripped_source) {
+ return unpacker_filter(unpacked);
+ }
+ }
return source;
}
@@ -0,0 +1,64 @@
+// ==UserScript==
+// @include *.js*
+// ==/UserScript==
+
+//
+// simple unpacker/deobfuscator for scripts messed up with myobfuscate.com
+//
+// written by Einar Lielmanis <einar@jsbeautifier.org>
+//
+// usage:
+//
+// if (MyObfuscate.detect(some_string)) {
+// var unpacked = MyObfuscate.unpack(some_string);
+// }
+//
+//
+
+var MyObfuscate = {
+ detect: function (str) {
+ return /^var _?[0O1lI]{3}\=('|\[).*\)\)\);/.test(str);
+ },
+
+ unpack: function (str) {
+ if (MyObfuscate.detect(str)) {
+ var modified_source = str.replace(';eval(', ';unpacked_source = (');
+ var unpacked_source = '';
+ eval(modified_source);
+ if (unpacked_source) {
+ if (MyObfuscate.starts_with(unpacked_source, 'var _escape')) {
+ // fetch the urlencoded stuff from the script,
+ var matches = /'([^']*)'/.exec(unpacked_source);
+ var unescaped = unescape(matches[1]);
+ if (MyObfuscate.starts_with(unescaped, '<script>')) {
+ unescaped = unescaped.substr(8, unescaped.length - 8);
+ }
+ if (MyObfuscate.ends_with(unescaped, '</script>')) {
+ unescaped = unescaped.substr(0, unescaped.length - 9);
+ }
+ unpacked_source = unescaped;
+ }
+ }
+ return unpacked_source ? "// Unpacker warning: be careful when using myobfuscate.com for your projects:\n" +
+ "// scripts obfuscated by the free online version call back home.\n" +
+ "\n//\n" + unpacked_source : str;
+ }
+ return str;
+ },
+
+ starts_with: function (str, what) {
+ return str.substr(0, what.length) === what;
+ },
+
+ ends_with: function (str, what) {
+ return str.substr(str.length - what.length, what.length) === what;
+ },
+
+ run_tests: function (sanity_test) {
+ var t = sanity_test || new SanityTest();
+
+ return t;
+ }
+
+
+}
View
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html><head><meta charset='UTF-8'><title id='widget_title'>Opera Extensions | Readable JavaScript</title>
+<html><head><meta charset='UTF-8'><title id='widget_title'>Readable JavaScript</title>
<link rel='stylesheet' href='css/options.css'>
<script type='text/javascript' src='includes/common.js'></script>
<script>
@@ -97,7 +97,7 @@ <h3 id='label_preferences'>Preferences</h3>
<label for='preserve_newlines' id='preserve_newlines_label'>Preserve empty lines</label>
<br/>
<input type='checkbox' id='detect_packers'/>
-<label for='detect_packers' id='detect_packers_label'> Detect packers</label>
+<label for='detect_packers' id='detect_packers_label'>Detect packers</label>
<br/>
<input type='checkbox' id='keep_array_indentation'/>
<label for='keep_array_indentation_label' id='keep_array_indentation_label'>Keep array indentation</label>
View
@@ -5,6 +5,7 @@
<script type='text/javascript' src='includes/unpacker_bookmarklet.js'></script>
<script type='text/javascript' src='includes/unpacker_javascriptobfuscator.js'></script>
<script type='text/javascript' src='includes/unpacker_p_a_c_k_e_r.js'></script>
+<script type='text/javascript' src='includes/unpacker_myobfuscate.js'></script>
<script type='text/javascript' src='includes/common.js'></script>
<script type='text/javascript'>
document.getElementsByTagName('html')[0].setAttribute('lang', window.navigator.language.slice(0,2));

0 comments on commit 58e0473

Please sign in to comment.