Created
May 8, 2019 13:06
-
-
Save RyanHirsch/fa613dfa606f6e4388f2fae56f883d03 to your computer and use it in GitHub Desktop.
Extract and Log credentials to make connecting to lab boxes easier.
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
function loadJquery(version = "3.4.1") { | |
var jqry = document.createElement('script'); | |
jqry.src = `https://cdnjs.cloudflare.com/ajax/libs/jquery/${version}/jquery.js`; | |
document.getElementsByTagName('head')[0].appendChild(jqry); | |
return jQuery.noConflict(); | |
} | |
function getCredentials($) { | |
const $credential = $("h3:contains(Credentials)").parent() | |
const $servers = $credential.find(".credential-topic-label").map(function getParent() { | |
return $(this).parent(); | |
}); | |
const credentials = $servers.map(function extractCreds() { | |
const $container = $(this); | |
const name = $container.find(".credential-topic-label").text().trim(); | |
const username = $container.find(".credential-type:contains(Username)").next().find(".credential-value").val().trim(); | |
const host = $container.find(".credential-type:contains(Public ip)").next().find(".credential-value").text().trim(); | |
const password = $container.find(".credential-type:contains(Password)").next().find(".credential-value").val().trim(); | |
return {name, connect: `ssh ${username}@${host}`, password}; | |
}).get().sort((a, b) => a.name < b.name ? -1 : 1); | |
return credentials; | |
} | |
(function() { | |
const jquery = loadJquery(); | |
console.table(getCredentials(jquery)); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment