Added bundling to handle many sessions at once.

bug/bundler_fix
scriptjunkie 2014-02-13 13:42:07 -06:00
parent c0983138a0
commit 022c52d087
No known key found for this signature in database
GPG Key ID: E89DE255C921A2C6
2 changed files with 42 additions and 36 deletions

View File

@ -10,7 +10,7 @@ $url = $_SERVER["QUERY_STRING"];
//like /path/hop.php?/uRIcksm_lOnGidENTifIEr
//Looks for a file with a name or contents prefix, if found, send it and deletes it
function findSendDelete($tempdir, $prefix){
function findSendDelete($tempdir, $prefix, $one=true){
if($dh = opendir($tempdir)){
while(($file = readdir($dh)) !== false){
if(strpos($file, $prefix) !== 0){
@ -18,9 +18,11 @@ function findSendDelete($tempdir, $prefix){
}
readfile($tempdir."/".$file);
unlink($tempdir."/".$file);
if($one){
break;
}
}
}
}
//handle control
@ -37,7 +39,7 @@ if($url === "/control"){
fwrite($f, $postdata);
fclose($f);
}else{
findSendDelete($tempdir, "up_");
findSendDelete($tempdir, "up_", false);
}
}else if($_SERVER['REQUEST_METHOD'] === 'POST'){
//get data
@ -56,6 +58,8 @@ if($url === "/control"){
$urlen = strlen($url);
fwrite($f, pack('V', $urlen));
fwrite($f, $url);
$postdatalen = strlen($postdata);
fwrite($f, pack('V', $postdatalen));
fwrite($f, $postdata);
fclose($f);
//Initial query will be a GET and have a 12345 in it

View File

@ -104,21 +104,22 @@ module ReverseHopHttp
next
end
# validate response
# validate responses, handle each message down
received = res.body
next if received.length < 12 || received.slice!(0, MAGIC.length) != MAGIC
until received.length < 12 || received.slice!(0, MAGIC.length) != MAGIC
# good response
delay = 0 # we're talking, speed up
urlen = received.slice!(0,4).unpack('V')[0]
urlpath = received.slice!(0,urlen)
datalen = received.slice!(0,4).unpack('V')[0]
# do not want handlers to change while we dispatch this
hop_http.lock.lock
#received is now the binary contents of the message
#received now starts with the binary contents of the message
if hop_http.handlers.include? urlpath
pack = Rex::Proto::Http::Packet.new
pack.body = received
pack.body = received.slice!(0,datalen)
hop_http.current_url = urlpath
hop_http.handlers[urlpath].call(hop_http, pack)
hop_http.lock.unlock
@ -142,6 +143,7 @@ module ReverseHopHttp
hop_http.lock.unlock
end
end
end
hop_http.monitor_thread = nil #make sure we're out
ReverseHopHttp.hop_handlers.delete(full_uri)
end