Print Page | Close Window

Script Object and bytecode loader

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: JavaScript
Forum Description: Discussions relating to the use of JavaScript within PDF.
URL: http://forums.planetpdf.com/forum_posts.asp?TID=1188
Printed Date: 17 Oct 2019 at 4:21am
Software Version: Web Wiz Forums 11.10 - http://www.webwizforums.com


Topic: Script Object and bytecode loader
Posted By: bulk88
Subject: Script Object and bytecode loader
Date Posted: 23 Apr 2014 at 3:54pm
Ever wondered how the JSByteCodeWin.bin binary blob bytecode file works?  Here is some undocumented code explaining how to create and load bytecode. Run it in Acrobat's JS Console. It is not in the same format as JSByteCodeWin.bin. JSByteCodeWin.bin looks like 2 bytes per character UTF16, the string returned by freeze() has normal looking words in it. Loading from disk is a separate API and is not part of Script class so you have to figure out yourself how to get it into a JS string.  The output of freeze() is probably unique to build of Acrobat, so you cant use it to obfuscate code.

    app.beginPriv();
    this.level1 = new Object();
    delete this.level1.testcomp;
    s = new Script();
    s.compile("this.level1.testcomp = function () {return \"retval\";}");
    t = new Script();
    app.alert(escape(s.freeze()));
    t.thaw(s.freeze());
    app.alert("toSource is "+t.toSource());
    try{
    app.alert("testcomp is "+this.level1.testcomp);
    }
    catch(err){
    app.alert(err);
    }
    t.exec();
    app.alert("testcomp is "+this.level1.testcomp);
    app.endPriv();




Replies:
Posted By: try67
Date Posted: 23 Apr 2014 at 5:40pm
Interesting stuff... Thanks!


-------------
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 - http://www.webwizforums.com
Copyright ©2001-2017 Web Wiz Ltd. - https://www.webwiz.net