@@ -68,25 +68,26 @@ def start_handler
68
68
end
69
69
@@hophandlers [ full_uri ] = self
70
70
self . monitor_thread = Rex ::ThreadFactory . spawn ( 'ReverseHopHTTP' , false , uri ,
71
- self ) do |uri , hophttp |
71
+ self ) do |uri , hop_http |
72
72
control = "#{ uri . request_uri } control"
73
- hophttp . control = control
74
- hophttp . send_new_stage ( control ) # send stage to hop
73
+ hop_http . control = control
74
+ hop_http . send_new_stage ( control ) # send stage to hop
75
75
@finish = false
76
76
delay = 1 # poll delay
77
- until @finish and hophttp . handlers . empty?
77
+ until @finish and hop_http . handlers . empty?
78
78
sleep delay
79
79
delay = delay + 1 if delay < 10 # slow down if we're not getting anything
80
- crequest = hophttp . mclient . request_raw ( { 'method' => 'GET' , 'uri' => control } )
81
- res = hophttp . mclient . send_recv ( crequest ) # send poll to the hop
80
+ crequest = hop_http . mclient . request_raw ( { 'method' => 'GET' , 'uri' => control } )
81
+ res = hop_http . mclient . send_recv ( crequest ) # send poll to the hop
82
+ next if res == nil
82
83
if res . error
83
84
print_error ( res . error )
84
85
next
85
86
end
86
87
87
88
# validate response
88
89
received = res . body
89
- magic = hophttp . magic
90
+ magic = hop_http . magic
90
91
next if received . length < 12 or received . slice! ( 0 , magic . length ) != magic
91
92
92
93
# good response
@@ -95,17 +96,17 @@ def start_handler
95
96
urlpath = received . slice! ( 0 , urlen )
96
97
97
98
#received is now the binary contents of the message
98
- if hophttp . handlers . include? urlpath
99
+ if hop_http . handlers . include? urlpath
99
100
pack = Rex ::Proto ::Http ::Packet . new
100
101
pack . body = received
101
- hophttp . current_url = urlpath
102
- hophttp . handlers [ urlpath ] . call ( hophttp , pack )
102
+ hop_http . current_url = urlpath
103
+ hop_http . handlers [ urlpath ] . call ( hop_http , pack )
103
104
else
104
105
#New session!
105
106
conn_id = urlpath . gsub ( "/" , "" )
106
107
# Short-circuit the payload's handle_connection processing for create_session
107
108
# We are the dispatcher since we need to handle the comms to the hop
108
- create_session ( hophttp , {
109
+ create_session ( hop_http , {
109
110
:passive_dispatcher => self ,
110
111
:conn_id => conn_id ,
111
112
:url => uri . to_s + conn_id + "/\x00 " ,
@@ -114,10 +115,10 @@ def start_handler
114
115
:ssl => false ,
115
116
} )
116
117
# send new stage to hop so next inbound session will get a unique ID.
117
- hophttp . send_new_stage ( control )
118
+ hop_http . send_new_stage ( control )
118
119
end
119
120
end
120
- hophttp . monitor_thread = nil #make sure we're out
121
+ hop_http . monitor_thread = nil #make sure we're out
121
122
@@hophandlers . delete ( full_uri )
122
123
end
123
124
end
@@ -258,7 +259,7 @@ def send_new_stage(control)
258
259
)
259
260
res = self . mclient . send_recv ( crequest )
260
261
print_status ( "Uploaded stage to hop #{ full_uri } " )
261
- print_error ( res . error ) if res . error
262
+ print_error ( res . error ) if res != nil and res . error
262
263
263
264
#return conn info
264
265
[ conn_id , url ]
0 commit comments