Skip to content

Commit dedf372

Browse files
author
HD Moore
committed
Simplify the uri_req_len logic, thanks @bcook-r7
1 parent 9668481 commit dedf372

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

lib/msf/core/payload/windows/reverse_http.rb

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,19 @@ def generate_uri
7777
uri_max_len = 256 - "#{datastore['LHOST']}:#{datastore['LPORT']}/".length
7878
uri_req_len = datastore['HTTPStagerURILength'].to_i
7979

80-
if uri_req_len > 0
81-
82-
if uri_req_len > uri_max_len
83-
raise ArgumentError, "Maximum HTTPStagerURILength is #{uri_max_len}"
84-
end
80+
if uri_req_len == 0
81+
uri_req_len = 30 + rand(uri_max_len-30)
82+
end
8583

86-
if uri_req_len < 5
87-
raise ArgumentError, "Minimum HTTPStagerURILength is 5"
88-
end
84+
if uri_req_len > uri_max_len
85+
raise ArgumentError, "Maximum HTTPStagerURILength is #{uri_max_len}"
86+
end
8987

90-
return "/" + generate_uri_checksum(Msf::Handler::ReverseHttp::URI_CHECKSUM_INITW, uri_req_len)
88+
if uri_req_len < 5
89+
raise ArgumentError, "Minimum HTTPStagerURILength is 5"
9190
end
9291

93-
# Generate a random 30+ byte URI
94-
"/" + generate_uri_checksum(Msf::Handler::ReverseHttp::URI_CHECKSUM_INITW, 30 + rand(uri_max_len-30))
92+
"/" + generate_uri_checksum(Msf::Handler::ReverseHttp::URI_CHECKSUM_INITW, uri_req_len)
9593
end
9694

9795
#

0 commit comments

Comments
 (0)