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
    Introducing 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 PHPOpera x domain with video tutorialSandboxing and parsing jQuery in 100ms

    JSReg javascript parser

    By Gareth Heyes (@hackvertor)

    Published 17 years 3 months ago • Last updated March 22, 2025 • ⏱️ 2 min read

    ← Back to articles

    My host won't let me compile Spidermonkey on my server :( and I need a javascript parser for my next version of Hackvertor. I can't really afford a new server, so I decided to write my own :) It's nowhere near finished yet but I thought I'd give you a peak at the pre-pre-beta.

    I use regular expressions (hence the name) to match parts of the string and return the relevant result. I'm trying a line by line approach and although at first I didn't think it would be possible it seems to be working well. It has no objects, conditions, arrays or even user-definable functions but it will parse basic math, strings, variables and call alert or eval.

    I use instances of the parser within matches to further reduce the code and I've found matching parts of strings returning the result and continuing parsing is easier to code rather than trying to match the string as a whole. If it's a success I'll release it as open source, if not at least my regular expressions will have gotten better. I don't think it will be a full javascript parser but rather a simplified version of javascript but who knows.

    A code sample and the demo url are available below:-

    <pre lang="javascript"> x='12'+'3'; y=eval; y('alert(x)') </pre>

    JSReg demo

    ← Back to articles