r/PowerShell • • Nov 24 '20

When hackers gain powershell access to a machine, they will check the powershell history. Here's a practical example:

https://youtu.be/CndMDvjX8dg?t=1631
232 Upvotes

43 comments sorted by

View all comments

Show parent comments

1

u/MyOtherSide1984 Nov 25 '20

It's not I don't think. It's converted to plain text as it types it. Here's what I have. Let me know if this is different than expected. Ultimately, the console and script never sees my password, you'd have to interrupt the script and get it to type it elsewhere or copy/paste it in the split second window when the password is there, I think

$User = "username" $File = "C:\temp\Selenium\scriptsencrypted_password1_cox.txt" $MyCredential=New-Object -TypeName System.Management.Automation.PSCredential ` -ArgumentList $User, (Get-Content $File | ConvertTo-SecureString)

Sorry, on mobile

1

u/shaniftvm Nov 25 '20

It doesn't work for me. When I send $mycredential.password to selenium browser window using sendkeys, it sends the encrypted form of the password. Means, in browser, the typed password is system.security.securestring and not the actual password. Am I missing anything here?

1

u/MyOtherSide1984 Nov 25 '20

Ahh, yeh. So, I don't know why I had to do this, but I couldn't just send a normal PSCredential or the $variable.password. This is what I'm sending to the Selenium password field:

$Firefoxdriver.findelementbyid('okta-signin-password').sendkeys($CoxCredentials.getnetworkcredential().password)}

So you need the object and then utilize the getnetworkcredential().password property to output the plaintext password. Regrettably, this can also be done directly in the console. So this:

$CoxCredentials.getnetworkcredential().password

outputs the password directly into the console for all to read.

Here's my above comment in an easier to read format:

$User = "username"
$Coxpass = "C:\temp\Selenium\scriptsencrypted_password1_cox.txt"
$CoxCredentials=New-Object -TypeName System.Management.Automation.PSCredential `
 -ArgumentList $User, (Get-Content $coxpass | ConvertTo-SecureString)

#do some things
#here's the sendkeys password:

$Firefoxdriver.findelementbyid('okta-signin-password').sendkeys($CoxCredentials.getnetworkcredential().password)}