Skip to content

Commit 27bd2a4

Browse files
committed
workaround Y2k38 issues in java certificate generation
1 parent 9597e52 commit 27bd2a4

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/msf/core/payload/android.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def sign_jar(jar)
7878
cert.public_key = key.public_key
7979

8080
# Some time within the last 3 years
81-
cert.not_before = Time.now - rand(3600*24*365*3)
81+
cert.not_before = Time.now - rand(3600 * 24 * 365 * 3)
8282

8383
# From http://developer.android.com/tools/publishing/app-signing.html
8484
# """
@@ -89,7 +89,14 @@ def sign_jar(jar)
8989
# requirement. You cannot upload an application if it is signed
9090
# with a key whose validity expires before that date.
9191
# """
92-
cert.not_after = cert.not_before + 3600*24*365*20 # 20 years
92+
#
93+
# 32-bit Ruby (and 64-bit Ruby on Windows) cannot deal with
94+
# certificate not_after times later than Jan 1st 2038, since long is 32-bit.
95+
# Set not_after to a random time 2~ years before the first bad date.
96+
#
97+
# FIXME: this will break again in 2031, hopefully all 32-bit systems will
98+
# be dead by then...
99+
cert.not_after = Time.new("2034/01/01") + rand(3600 * 24 * 365 * 2)
93100

94101
# If this line is left out, signature verification fails on OSX.
95102
cert.sign(key, OpenSSL::Digest::SHA1.new)

modules/exploits/multi/browser/java_signed_applet.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ def load_cert
216216
@cert.issuer = x509_name
217217
@cert.public_key = @key.public_key
218218
@cert.not_before = Time.now
219-
@cert.not_after = @cert.not_before + 3600*24*365*3 # 3 years
219+
# FIXME: this will break in the year 2037 on 32-bit systems
220+
@cert.not_after = @cert.not_before + 3600 * 24 * 365 # 1 year
220221
end
221222
end
222223

0 commit comments

Comments
 (0)