Skip to content

Commit f4b4b21

Browse files
committed
Land rapid7#5990, reverse_hop_http fix
2 parents 866636b + 30102d4 commit f4b4b21

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

data/php/hop.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function findSendDelete($tempdir, $prefix, $one=true){
3333
if(array_key_exists('HTTP_X_INIT', $_SERVER)){
3434
$f = fopen($tempdir."/init", "w"); //only one init file
3535
}else{
36-
$prefix = "down_" . bin2hex($_SERVER['HTTP_X_URLFRAG']);
36+
$prefix = "down_" . sha1($_SERVER['HTTP_X_URLFRAG']);
3737
$f = fopen(tempnam($tempdir,$prefix), "w");
3838
}
3939
fwrite($f, $postdata);
@@ -45,9 +45,9 @@ function findSendDelete($tempdir, $prefix, $one=true){
4545
//get data
4646
$postdata = file_get_contents("php://input");
4747
//See if we should send anything down
48-
if($postdata === 'RECV'){
49-
findSendDelete($tempdir, "down_" . bin2hex($url));
50-
$fname = $tempdir . "/up_recv_" . bin2hex($url); //Only keep one RECV poll
48+
if($postdata === "RECV\x00"){
49+
findSendDelete($tempdir, "down_" . sha1($url));
50+
$fname = $tempdir . "/up_recv_" . sha1($url); //Only keep one RECV poll
5151
}else{
5252
$fname = tempnam($tempdir, "up_"); //actual data gets its own filename
5353
}

lib/msf/core/handler/reverse_hop_http.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ def self.general_handler_type
5454
"tunnel"
5555
end
5656

57+
#
58+
# Returns the socket type. (hop)
59+
#
60+
def type?
61+
return 'hop'
62+
end
63+
5764
#
5865
# Sets up a handler. Doesn't do much since it's all in start_handler.
5966
#
@@ -249,6 +256,7 @@ def send_new_stage(uri)
249256
# generate a new connect
250257
sum = uri_checksum_lookup(:connect)
251258
conn_id = generate_uri_uuid(sum, uuid)
259+
conn_id = conn_id[1..-1] if conn_id.start_with? '/'
252260
url = full_uri + conn_id + "/\x00"
253261

254262
print_status("Preparing stage for next session #{conn_id}")

0 commit comments

Comments
 (0)