Created
March 4, 2014 15:32
-
-
Save darkoperator/9348627 to your computer and use it in GitHub Desktop.
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 Import-ShodanAPIKey | |
| { | |
| [CmdletBinding()] | |
| Param | |
| ( | |
| [Parameter(Mandatory=$true, | |
| ValueFromPipelineByPropertyName=$true, | |
| Position=1)] | |
| [securestring]$MasterPassword | |
| ) | |
| Begin | |
| { | |
| # Test if configuration file exists. | |
| if (!(Test-Path "$($env:AppData)\Posh-Shodan\api.key")) | |
| { | |
| throw "Configuration has not been set, Set-ShodanAPIKey to configure the API Keys." | |
| } | |
| } | |
| Process | |
| { | |
| $ConfigFileContent = Get-Content -Path "$($env:AppData)\Posh-Shodan\api.key" | |
| $SecString = ConvertTo-SecureString -SecureKey $MasterPassword $ConfigFileContent | |
| $APIKey = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecString)) | |
| $Global:ShodanAPIKey = $APIKey | |
| } | |
| End | |
| { | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment