Get-ShodanDNSReverse.psm1

<#PSScriptInfo
 
.VERSION 1.1.2
 
.GUID 0633912f-7228-4daa-9c4f-4d7413e93a2a
 
.AUTHOR SimeonOnSecurity
 
.COMPANYNAME SimeonOnSecurity
 
.COPYRIGHT 2020 SimeonOnSecurity. All rights reserved.
 
.TAGS Shodan PowerShell Modules ShodanPS cmdlet
 
.PROJECTURI https://simeononsecurity.com/github/shodan-powershell/
 
.DESCRIPTION "Look up the hostnames that have been defined for the given list of IP addresses. Ex: Get-ShodanDNSReverse -ips google.com,bing.com -API"
 
.RELEASENOTES
Init
 
#>

function Get-ShodanDNSReverse {
    param(
        [Parameter(Mandatory = $false, Position = 0)]
        [string]$api,
        [Parameter(Mandatory = $true, Position = 1)]
        [string]$ips
    )
    $apistring = "&key=$api"
    If (!$api) {
        Write-Output "Please set the 'api' variable to your shodan API key."
    }
    Else {
        If (!$ips) {
            Write-Output "Please specify ips addresses with -ips [string]"
        }
        Else {
            (Invoke-WebRequest -UseBasicParsing "https://api.shodan.io/dns/reverse?ips=$ips$apistring").content | ConvertFrom-Json
        }
    }
}