Hamed
December 30th, 2009, 10:32
<?php
/**
* @author Hamed
* @copyright 2009
*/
class IBSng
{
public $ip;
public $port;
public $url;
public $data;
public $cookie;
public $htmlRes;
public $fp;
public $mc;
public $up;
public $uncodeddata;
//This function connect in Live conection
public function __construct($ip,$port,$username,$password)
{
$this->ip = $ip;
$this->port = $port;
$this->data = $data;
$this->fp = @fsockopen($ip, $port, $errno, $errstr, 30);
$upd = 'username='.$username.'&password='.$password.'';
$furl = 'https://'.$this->ip.'/IBSng/admin/';
fwrite($this->fp, "POST /IBSng/admin/ HTTP/1.1\r\n");
fwrite($this->fp, "Host: $this->ip \r\n");
fwrite($this->fp, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070201 Firefox/3.0.1 \r\n");
fwrite($this->fp, "Content-type: application/x-www-form-urlencoded\r\n");
fwrite($this->fp, "Content-length: " . strlen($upd) . "\r\n");
fwrite($this->fp, "Connection: Keep-Alive\r\n");
fwrite($this->fp, "Cookie: $this->cookie \r\n");
fwrite($this->fp, "Referer: $furl \r\n");
fwrite($this->fp, "Accept: */*\r\n");
fwrite($this->fp, "\r\n");
fwrite($this->fp, "$udp\r\n");
fwrite($this->fp, "\r\n");
fwrite($this->fp, "GET /IBSng/admin/ HTTP/1.1\r\n");
fwrite($this->fp, "Host: $this->ip \r\n");
fwrite($this->fp, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070201 Firefox/3.0.1 \r\n");
fwrite($this->fp, "Accept: */*\r\n");
fwrite($this->fp, "\r\n");
$headers = ''; $body = '';
while ($str = trim(fgets($this->fp, 8192))) $headers .= "$str\n";
while (!feof($this->fp)) $body .= fgets($this->fp);
@preg_match_all('#set-cookie: (.*);#i', $headers, $cookie_log);
$cookie =$cookie_log[1][0];
$this->cookie=$cookie;
}
//Give us uncodeddata
public function getOutput()
{
while(!feof($this->fp))
{
$uncodeddata .= fgets($this->fp,8192);
}
return $uncodeddata;
}
//Get cookie to be the best
public function GetCookie($url='/IBSng/admin/')
{
fwrite($this->fp, "GET $url HTTP/1.1\r\n");
fwrite($this->fp, "Host: $this->ip \r\n");
fwrite($this->fp, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070201 Firefox/3.0.1 \r\n");
fwrite($this->fp, "Accept: */*\r\n");
fwrite($this->fp, "\r\n");
while ($str = trim(fgets($this->fp, 8192))) $headers .= "$str\n";
while (!feof($this->fp)) $body .= fgets($this->fp);
@preg_match_all('#set-cookie: (.*);#i', $headers, $cookie_log);
$cookie =$cookie_log[1][0];
return $cookie;
}
//This function make post action do to all job (Important part of all)
public function DoAll($data,$url)
{
$purl = 'https://'.$this->ip.'/IBSng/admin/';
fwrite($this->fp, "POST $url HTTP/1.1\r\n");
fwrite($this->fp, "Host: $this->ip \r\n");
fwrite($this->fp, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070201 Firefox/3.0.1 \r\n");
fwrite($this->fp, "Content-type: application/x-www-form-urlencoded\r\n");
fwrite($this->fp, "Content-length: " . strlen($data) . "\r\n");
fwrite($this->fp, "Cookie: $this->cookie \r\n");
fwrite($this->fp, "Referer: $purl \r\n");
fwrite($this->fp, "Accept: */*\r\n");
fwrite($this->fp, "\r\n");
fwrite($this->fp, "$data\r\n");
fwrite($this->fp, "\r\n");
}
public function AddUser($group,$user,$pass)
{
$data = 'submit_form=1&add=1&interface_memento=1&count=1&isp_name=test&group_name='.$group.'&x=30&y=16';
$purl = 'https://'.$this->ip.'/IBSng/admin/';
fwrite($this->fp, "POST /IBSng/admin/user/add_new_users.php HTTP/1.1\r\n");
fwrite($this->fp, "Host: $this->ip \r\n");
fwrite($this->fp, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070201 Firefox/3.0.1 \r\n");
fwrite($this->fp, "Content-type: application/x-www-form-urlencoded\r\n");
fwrite($this->fp, "Content-length: " . strlen($data) . "\r\n");
fwrite($this->fp, "Cookie: $this->cookie \r\n");
fwrite($this->fp, "Referer: $purl \r\n");
fwrite($this->fp, "Accept: */*\r\n");
fwrite($this->fp, "\r\n");
fwrite($this->fp, "$data\r\n");
fwrite($this->fp, "\r\n");
$header = '';$body='';
while ($str = trim(fgets($this->fp, 4096))) $header .= "$str\n";
while (!feof($this->fp)) $body .= fgets($this->fp);
@preg_match_all('#user_id=(.*)&submit_form#i', $header, $uid);
$uid =$uid[1][0];
$data = 'password_len=6&target=user&target_id='.$uid.'&update=1&edit_tpl_cs=edit_tpl_cs&attr_update_method_0=normalAttrs&has_normal_username=t¤t_normal_username=&normal_username='.$username.'&password='.$password.'&x=30&y=16';
fwrite($this->fp, "POST /IBSng/admin/plugins/edit.php HTTP/1.1\r\n");
fwrite($this->fp, "Host: 85.9.127.2 \r\n");
fwrite($this->fp, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1 \r\n");
fwrite($this->fp, "Content-type: application/x-www-form-urlencoded\r\n");
fwrite($this->fp, "Content-length: " . strlen($data) . "\r\n");
fwrite($this->fp, "Cookie: $this->cookie \r\n");
fwrite($this->fp, "Referer: $purl \r\n");
fwrite($this->fp, "Accept: */*\r\n");
fwrite($this->fp, "\r\n");
fwrite($this->fp, "$data\r\n");
fwrite($this->fp, "\r\n");
return $uid;
}
//Show me cookie
public function showCookie()
{
echo $this->cookie;
}
public function search()
{
}
public function parseHttpResponse($content=null)
{
$hunks = explode("\r\n\r\n",trim($content));
if (!is_array($hunks) or count($hunks) < 2) { return false; }
$header = $hunks[count($hunks) - 2];
$body = $hunks[count($hunks) - 1];
$headers = explode("\n",$header);
unset($hunks);
unset($header);
if (!$this->validateHttpResponse($headers)) { return false; }
if (in_array('Transfer-Coding: chunked',$headers)) {
return trim($this->unchunkHttpResponse($body));
} else {
return trim($body);
}
}
public function validateHttpResponse($headers=null)
{
if (!is_array($headers) or count($headers) < 1) { return false; }
switch(trim(strtolower($headers[0])))
{
case 'http/1.0 100 ok':
case 'http/1.0 200 ok':
case 'http/1.1 100 ok':
case 'http/1.1 200 ok':
return true;
break;
}
return false;
}
public function unchunkHttpResponse($str=null)
{
if (!is_string($str) or strlen($str) < 1) { return false; }
$eol = "\r\n";
$add = strlen($eol);
$tmp = $str;
$str = '';
do {
$tmp = ltrim($tmp);
$pos = strpos($tmp, $eol);
if ($pos === false) { return false; }
$len = hexdec(substr($tmp,0,$pos));
if (!is_numeric($len) or $len < 0) { return false; }
$str .= substr($tmp, ($pos + $add), $len);
$tmp = substr($tmp, ($len + $pos + $add));
$check = trim($tmp);
} while(!empty($check));
unset($tmp);
return $str;
}
//Get HTML of last entry
public function GetHTML()
{
$this->htmlRes = $this->getOutput();
return $this->parseHttpResponse($this->htmlRes);
}
//Close all connections
public function __destruct()
{
fclose($this->fp);
}
}
$IBS = new IBSng('85.9.127.2',80,'','');
$group = '2-ESF_1024k_5.5G_1M_35.000';
$IBS->showCookie();
$uid = $IBS->AddUser($group,'Hamed','Hamed');
echo $uid;
?>
I don't get any submit when I use this script!
/**
* @author Hamed
* @copyright 2009
*/
class IBSng
{
public $ip;
public $port;
public $url;
public $data;
public $cookie;
public $htmlRes;
public $fp;
public $mc;
public $up;
public $uncodeddata;
//This function connect in Live conection
public function __construct($ip,$port,$username,$password)
{
$this->ip = $ip;
$this->port = $port;
$this->data = $data;
$this->fp = @fsockopen($ip, $port, $errno, $errstr, 30);
$upd = 'username='.$username.'&password='.$password.'';
$furl = 'https://'.$this->ip.'/IBSng/admin/';
fwrite($this->fp, "POST /IBSng/admin/ HTTP/1.1\r\n");
fwrite($this->fp, "Host: $this->ip \r\n");
fwrite($this->fp, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070201 Firefox/3.0.1 \r\n");
fwrite($this->fp, "Content-type: application/x-www-form-urlencoded\r\n");
fwrite($this->fp, "Content-length: " . strlen($upd) . "\r\n");
fwrite($this->fp, "Connection: Keep-Alive\r\n");
fwrite($this->fp, "Cookie: $this->cookie \r\n");
fwrite($this->fp, "Referer: $furl \r\n");
fwrite($this->fp, "Accept: */*\r\n");
fwrite($this->fp, "\r\n");
fwrite($this->fp, "$udp\r\n");
fwrite($this->fp, "\r\n");
fwrite($this->fp, "GET /IBSng/admin/ HTTP/1.1\r\n");
fwrite($this->fp, "Host: $this->ip \r\n");
fwrite($this->fp, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070201 Firefox/3.0.1 \r\n");
fwrite($this->fp, "Accept: */*\r\n");
fwrite($this->fp, "\r\n");
$headers = ''; $body = '';
while ($str = trim(fgets($this->fp, 8192))) $headers .= "$str\n";
while (!feof($this->fp)) $body .= fgets($this->fp);
@preg_match_all('#set-cookie: (.*);#i', $headers, $cookie_log);
$cookie =$cookie_log[1][0];
$this->cookie=$cookie;
}
//Give us uncodeddata
public function getOutput()
{
while(!feof($this->fp))
{
$uncodeddata .= fgets($this->fp,8192);
}
return $uncodeddata;
}
//Get cookie to be the best
public function GetCookie($url='/IBSng/admin/')
{
fwrite($this->fp, "GET $url HTTP/1.1\r\n");
fwrite($this->fp, "Host: $this->ip \r\n");
fwrite($this->fp, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070201 Firefox/3.0.1 \r\n");
fwrite($this->fp, "Accept: */*\r\n");
fwrite($this->fp, "\r\n");
while ($str = trim(fgets($this->fp, 8192))) $headers .= "$str\n";
while (!feof($this->fp)) $body .= fgets($this->fp);
@preg_match_all('#set-cookie: (.*);#i', $headers, $cookie_log);
$cookie =$cookie_log[1][0];
return $cookie;
}
//This function make post action do to all job (Important part of all)
public function DoAll($data,$url)
{
$purl = 'https://'.$this->ip.'/IBSng/admin/';
fwrite($this->fp, "POST $url HTTP/1.1\r\n");
fwrite($this->fp, "Host: $this->ip \r\n");
fwrite($this->fp, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070201 Firefox/3.0.1 \r\n");
fwrite($this->fp, "Content-type: application/x-www-form-urlencoded\r\n");
fwrite($this->fp, "Content-length: " . strlen($data) . "\r\n");
fwrite($this->fp, "Cookie: $this->cookie \r\n");
fwrite($this->fp, "Referer: $purl \r\n");
fwrite($this->fp, "Accept: */*\r\n");
fwrite($this->fp, "\r\n");
fwrite($this->fp, "$data\r\n");
fwrite($this->fp, "\r\n");
}
public function AddUser($group,$user,$pass)
{
$data = 'submit_form=1&add=1&interface_memento=1&count=1&isp_name=test&group_name='.$group.'&x=30&y=16';
$purl = 'https://'.$this->ip.'/IBSng/admin/';
fwrite($this->fp, "POST /IBSng/admin/user/add_new_users.php HTTP/1.1\r\n");
fwrite($this->fp, "Host: $this->ip \r\n");
fwrite($this->fp, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070201 Firefox/3.0.1 \r\n");
fwrite($this->fp, "Content-type: application/x-www-form-urlencoded\r\n");
fwrite($this->fp, "Content-length: " . strlen($data) . "\r\n");
fwrite($this->fp, "Cookie: $this->cookie \r\n");
fwrite($this->fp, "Referer: $purl \r\n");
fwrite($this->fp, "Accept: */*\r\n");
fwrite($this->fp, "\r\n");
fwrite($this->fp, "$data\r\n");
fwrite($this->fp, "\r\n");
$header = '';$body='';
while ($str = trim(fgets($this->fp, 4096))) $header .= "$str\n";
while (!feof($this->fp)) $body .= fgets($this->fp);
@preg_match_all('#user_id=(.*)&submit_form#i', $header, $uid);
$uid =$uid[1][0];
$data = 'password_len=6&target=user&target_id='.$uid.'&update=1&edit_tpl_cs=edit_tpl_cs&attr_update_method_0=normalAttrs&has_normal_username=t¤t_normal_username=&normal_username='.$username.'&password='.$password.'&x=30&y=16';
fwrite($this->fp, "POST /IBSng/admin/plugins/edit.php HTTP/1.1\r\n");
fwrite($this->fp, "Host: 85.9.127.2 \r\n");
fwrite($this->fp, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1 \r\n");
fwrite($this->fp, "Content-type: application/x-www-form-urlencoded\r\n");
fwrite($this->fp, "Content-length: " . strlen($data) . "\r\n");
fwrite($this->fp, "Cookie: $this->cookie \r\n");
fwrite($this->fp, "Referer: $purl \r\n");
fwrite($this->fp, "Accept: */*\r\n");
fwrite($this->fp, "\r\n");
fwrite($this->fp, "$data\r\n");
fwrite($this->fp, "\r\n");
return $uid;
}
//Show me cookie
public function showCookie()
{
echo $this->cookie;
}
public function search()
{
}
public function parseHttpResponse($content=null)
{
$hunks = explode("\r\n\r\n",trim($content));
if (!is_array($hunks) or count($hunks) < 2) { return false; }
$header = $hunks[count($hunks) - 2];
$body = $hunks[count($hunks) - 1];
$headers = explode("\n",$header);
unset($hunks);
unset($header);
if (!$this->validateHttpResponse($headers)) { return false; }
if (in_array('Transfer-Coding: chunked',$headers)) {
return trim($this->unchunkHttpResponse($body));
} else {
return trim($body);
}
}
public function validateHttpResponse($headers=null)
{
if (!is_array($headers) or count($headers) < 1) { return false; }
switch(trim(strtolower($headers[0])))
{
case 'http/1.0 100 ok':
case 'http/1.0 200 ok':
case 'http/1.1 100 ok':
case 'http/1.1 200 ok':
return true;
break;
}
return false;
}
public function unchunkHttpResponse($str=null)
{
if (!is_string($str) or strlen($str) < 1) { return false; }
$eol = "\r\n";
$add = strlen($eol);
$tmp = $str;
$str = '';
do {
$tmp = ltrim($tmp);
$pos = strpos($tmp, $eol);
if ($pos === false) { return false; }
$len = hexdec(substr($tmp,0,$pos));
if (!is_numeric($len) or $len < 0) { return false; }
$str .= substr($tmp, ($pos + $add), $len);
$tmp = substr($tmp, ($len + $pos + $add));
$check = trim($tmp);
} while(!empty($check));
unset($tmp);
return $str;
}
//Get HTML of last entry
public function GetHTML()
{
$this->htmlRes = $this->getOutput();
return $this->parseHttpResponse($this->htmlRes);
}
//Close all connections
public function __destruct()
{
fclose($this->fp);
}
}
$IBS = new IBSng('85.9.127.2',80,'','');
$group = '2-ESF_1024k_5.5G_1M_35.000';
$IBS->showCookie();
$uid = $IBS->AddUser($group,'Hamed','Hamed');
echo $uid;
?>
I don't get any submit when I use this script!