The Spanner logo
    • Home
    • Blog
      • Blog home
      • RSS
    • Login
    • Home
    • Blog
      • Blog home
      • RSS
    • Login
    The Spanner logo

    The Spanner
    Web security blog

    Made by Gareth Heyes
    Follow me on Twitter: @garethheyes

    Javascript for hackers!

    Hackvertor logo
    Shazzer logo
    My Github account
    Recent posts
    Pure-CSS 3D world collision detection How to write a Hackvertor tagIntroducing Feedworm: A Privacy-First RSS Reader That Lives in DevToolsSpeedy RSVP extensionAutoVaderHackvertor history and tag finderShadow Repeater v1.2.3 releaseBurp Hackvertor v2.1.24 releaseHacking roomsXSSing TypeErrors in SafarivalueOf: Another way to get thisMaking the Unexploitable Exploitable with X-Mixed-Replace on FirefoxThe curious case of the evt parameterCSS-Only Tic Tac Toe ChallengeRewriting relative urls with the base tag in SafariBypassing DOMPurify with mXSSNew IE mutation vectorHow I smashed MentalJSMentalJS DOM bypassAnother XSS auditor bypassXSS Auditor bypassBypassing the IE XSS filterUnbreakable filterMentalJS bypassesmXSSJava SerializationBypassing the XSS filter using function reassignmentRPOSandboxed jQueryX-Domain scroll detection on IE using focusEpic fail IEnew operatorDecoding complex non-alphanumeric JavaScriptHacking FirefoxDOM ClobberingBypassing XSS AuditorThe evolution of codeNon-Alpha PHP in 6-7 charsetTweetable PHP-Non AlphaMentalJS for PHP

    Double encoding javascript

    By Gareth Heyes (@hackvertor)

    Published 18 years 3 months ago • Last updated March 22, 2025 • ⏱️ < 1 min read

    ← Back to articles

    I found a nice variation which allows multiple types of encoding without performing eval twice on the string. The code works using the Script function and because of this the code is rewritten by the javascript engine and converts the unicode into standard text.

    First a base of unicode is used first "\u0061\u006c\u0065\u0072\u0074\u0028\u0031\u0029" then each section of the is encoded with hex or octal. The final result can be viewed below:-

    <pre lang="html"> alert(Script('\x5c\x7500\66\61\134\165\6006c\x5c\x75\x30\x30\x36\x35 \134\165\60\60\67\62\x5c\x75\x30\x30\x37\x34\x5c\x75\x30\x30\x32 \x38\x5c\x75\x30\x30\x33\x31\x5c\x75\x30\x30\x32\x39')) </pre>

    The code can be executed like this:-

    <pre lang="html"> Script('\x5c\x7500\66\61\134\165\6006c\x5c\x75\x30\x30\x36\x35 \134\165\60\60\67\62\x5c\x75\x30\x30\x37\x34\x5c\x75\x30\x30\x32 \x38\x5c\x75\x30\x30\x33\x31\x5c\x75\x30\x30\x32\x39')() </pre>

    ← Back to articles