2010-01-27 19:46:39 +00:00
|
|
|
#!/usr/bin/ruby
|
|
|
|
|
|
|
|
require 'rubygems'
|
|
|
|
require 'rjb'
|
|
|
|
|
|
|
|
Rjb::load(ENV['JAVA_HOME'] + '/lib/tools.jar:.',jvmargs=[])
|
|
|
|
|
|
|
|
# This is a completely hackish way to do this, and could break with future
|
|
|
|
# versions of the JDK. Need to find a better way to use sun.security.tools.KeyTool
|
|
|
|
# and .JarSigner than modifying the source. These rely on internal APIs that may
|
|
|
|
# change.
|
2010-01-28 22:53:36 +00:00
|
|
|
signer = Rjb::import('javaCompile.SignJar')
|
|
|
|
#clsKeyTool = Rjb::import('sun.security.tools.KeyTool')
|
2010-01-27 19:46:39 +00:00
|
|
|
#clsKeyTool = Rjb::import('sun.security.tools.KeyToolMSF')
|
2010-01-28 22:53:36 +00:00
|
|
|
#clsJarSigner = Rjb::import('javaCompile.SignJar.JarSignerMSF')
|
|
|
|
#clsJarSigner = Rjb::import('sun.security.tools.JarSigner')
|
2010-01-27 19:46:39 +00:00
|
|
|
#clsJarSigner = Rjb::import('sun.security.tools.JarSignerMSF')
|
|
|
|
|
2010-01-28 22:53:36 +00:00
|
|
|
#keytool = clsKeyTool
|
|
|
|
#jarsigner = clsJarSigner
|
2010-01-27 19:46:39 +00:00
|
|
|
|
|
|
|
outputJar = "output.jar"
|
|
|
|
|
|
|
|
#certCN cannot contain commas
|
|
|
|
certCN = "Metasploit Inc."
|
|
|
|
#keytoolOpts = "-genkey -alias signFiles -keystore msfkeystore " +
|
|
|
|
# "-storepass msfstorepass -dname \"cn=#{certCN}\" " +
|
|
|
|
# "-keypass msfkeypass"
|
|
|
|
|
|
|
|
keytoolOpts = ["-genkey", "-alias", "signFiles", "-keystore", "msfkeystore",
|
|
|
|
"-storepass", "msfstorepass", "-dname", "cn=#{certCN}",
|
|
|
|
"-keypass", "msfkeypass"]
|
|
|
|
|
|
|
|
|
2010-01-28 22:53:36 +00:00
|
|
|
signer._invoke('KeyToolMSF','[Ljava.lang.String;',keytoolOpts)
|
2010-01-27 19:46:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
jarsignerOpts = ["-keystore", "msfkeystore", "-storepass", "msfstorepass",
|
|
|
|
"-keypass", "msfkeypass", "-signedJar", "s#{outputJar}",
|
|
|
|
outputJar, "signFiles"]
|
|
|
|
|
2010-01-28 22:53:36 +00:00
|
|
|
signer._invoke('JarSignerMSF','[Ljava.lang.String;',jarsignerOpts)
|
2010-01-27 19:46:39 +00:00
|
|
|
|
|
|
|
|