Re: shell script cgi

From: Brian Hatch (vuln-devat_private)
Date: Sat Nov 16 2002 - 08:29:38 PST

  • Next message: Gary O'leary-Steele: "ColdFusion Heap Overflow -continued"

    > thought the wrong way in my last message.
    > 
    > Try the following string for $HTTP_USER_AGENT:
    > 
    > "`cat /etc/passwd`"
    
    The HTTP_USER_AGENT string is set by Apache (etc)
    as an environment variable.  Let's make the unradical
    assumption that your browser is not a shell script,
    and thus is setting it correctly without any shell
    expansion problems possible.  So HTTP_USER_AGENT is
    set to
    
    	`cat /etc/passwd`
    
    To emulate this, let's set it ourselves in a normal shell:
    
    	bash$ export VAR='`cat /etc/passwd`'
    	bash$ echo $VAR
    	`cat /etc/passwd`
    
    I use the single quotes here to make sure no expansion
    tricks are possible, which is how your web browser will
    work.  The var is set exactly.  Excellent.  Can we abuse
    it?
    
    	bash$ echo $VAR
    	`cat /etc/passwd`
    	bash$ echo "$VAR"
    	`cat /etc/passwd`
    
    Nope.  How 'bout if we have:
    
    	bash$ export VAR='blahblahblah *'
    	bash$ echo $VAR
    	blahblahblah file1.cgi file2.cgi file3.cgi
    	bash$ echo "$VAR"
    	blahblahblah *
    
    See that with no quotes you can get a file listing through
    shell expansion.
    
    
    
    --
    Brian Hatch                  I used to be a lumberjack,
       Systems and                but I just couldn't hack
       Security Engineer          it, so they gave me the ax.
    http://www.ifokr.org/bri/
    
    Every message PGP signed
    
    
    



    This archive was generated by hypermail 2b30 : Sat Nov 16 2002 - 18:32:58 PST