Skip to content

Commit 883654f

Browse files
committed
Land rapid7#9653, fix Y2k38 issue (until Jan 1, 2038)
2 parents d843750 + 4fec2e7 commit 883654f

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/msf/core/payload/android.rb

Lines changed: 11 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,16 @@ 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 randomly starting in late 2033, hopefully
98+
# all 32-bit systems will be dead by then...
99+
#
100+
# The timestamp 0x78045d81 equates to 2033-10-22 00:00:01 UTC
101+
cert.not_after = Time.at(0x78045d81 + rand(0x7fffffff - 0x78045d81))
93102

94103
# If this line is left out, signature verification fails on OSX.
95104
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)