CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/external/source/msfJavaToolkit/testKeytool.rb
Views: 11766
1
#!/usr/bin/ruby
2
3
require 'rubygems'
4
require 'rjb'
5
6
Rjb::load(ENV['JAVA_HOME'] + '/lib/tools.jar:.',jvmargs=[])
7
8
# This is a completely hackish way to do this, and could break with future
9
# versions of the JDK. Need to find a better way to use sun.security.tools.KeyTool
10
# and .JarSigner than modifying the source. These rely on internal APIs that may
11
# change.
12
signer = Rjb::import('javaCompile.SignJar')
13
#clsKeyTool = Rjb::import('sun.security.tools.KeyTool')
14
#clsKeyTool = Rjb::import('sun.security.tools.KeyToolMSF')
15
#clsJarSigner = Rjb::import('javaCompile.SignJar.JarSignerMSF')
16
#clsJarSigner = Rjb::import('sun.security.tools.JarSigner')
17
#clsJarSigner = Rjb::import('sun.security.tools.JarSignerMSF')
18
19
#keytool = clsKeyTool
20
#jarsigner = clsJarSigner
21
22
outputJar = "output.jar"
23
24
#certCN cannot contain commas
25
certCN = "Metasploit Inc."
26
#keytoolOpts = "-genkey -alias signFiles -keystore msfkeystore " +
27
# "-storepass msfstorepass -dname \"cn=#{certCN}\" " +
28
# "-keypass msfkeypass"
29
30
keytoolOpts = ["-genkey", "-alias", "signFiles", "-keystore", "msfkeystore",
31
"-storepass", "msfstorepass", "-dname", "cn=#{certCN}",
32
"-keypass", "msfkeypass"]
33
34
35
signer._invoke('KeyToolMSF','[Ljava.lang.String;',keytoolOpts)
36
37
38
jarsignerOpts = ["-keystore", "msfkeystore", "-storepass", "msfstorepass",
39
"-keypass", "msfkeypass", "-signedJar", "s#{outputJar}",
40
outputJar, "signFiles"]
41
42
signer._invoke('JarSignerMSF','[Ljava.lang.String;',jarsignerOpts)
43
44
45
46