Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/external/source/msfJavaToolkit/testKeytool.rb
Views: 11766
#!/usr/bin/ruby12require 'rubygems'3require 'rjb'45Rjb::load(ENV['JAVA_HOME'] + '/lib/tools.jar:.',jvmargs=[])67# This is a completely hackish way to do this, and could break with future8# versions of the JDK. Need to find a better way to use sun.security.tools.KeyTool9# and .JarSigner than modifying the source. These rely on internal APIs that may10# change.11signer = Rjb::import('javaCompile.SignJar')12#clsKeyTool = Rjb::import('sun.security.tools.KeyTool')13#clsKeyTool = Rjb::import('sun.security.tools.KeyToolMSF')14#clsJarSigner = Rjb::import('javaCompile.SignJar.JarSignerMSF')15#clsJarSigner = Rjb::import('sun.security.tools.JarSigner')16#clsJarSigner = Rjb::import('sun.security.tools.JarSignerMSF')1718#keytool = clsKeyTool19#jarsigner = clsJarSigner2021outputJar = "output.jar"2223#certCN cannot contain commas24certCN = "Metasploit Inc."25#keytoolOpts = "-genkey -alias signFiles -keystore msfkeystore " +26# "-storepass msfstorepass -dname \"cn=#{certCN}\" " +27# "-keypass msfkeypass"2829keytoolOpts = ["-genkey", "-alias", "signFiles", "-keystore", "msfkeystore",30"-storepass", "msfstorepass", "-dname", "cn=#{certCN}",31"-keypass", "msfkeypass"]323334signer._invoke('KeyToolMSF','[Ljava.lang.String;',keytoolOpts)353637jarsignerOpts = ["-keystore", "msfkeystore", "-storepass", "msfstorepass",38"-keypass", "msfkeypass", "-signedJar", "s#{outputJar}",39outputJar, "signFiles"]4041signer._invoke('JarSignerMSF','[Ljava.lang.String;',jarsignerOpts)4243444546