Skip to content

Instantly share code, notes, and snippets.

@Mike-Crowley
Last active March 18, 2023 05:06
Show Gist options
  • Save Mike-Crowley/ff3c432ad921799b736b45dff828acca to your computer and use it in GitHub Desktop.
Save Mike-Crowley/ff3c432ad921799b736b45dff828acca to your computer and use it in GitHub Desktop.
Query a single IP against shodan from PowerShell. I'm sure this has been done before...
function Get-ShodanIpLookup {
param (
[ipaddress]$Ip,
[string]$ApiKey = ""
)
if ($ApiKey -eq "") { Invoke-RestMethod -Uri "https://internetdb.shodan.io/$Ip" }
else { Invoke-RestMethod -uri "https://api.shodan.io/shodan/host/$($ip)?key=$ApiKey" }
# Free Service: https://internetdb.shodan.io/
# Paid API access: https://developer.shodan.io/api
}
#Example 1
Get-ShodanIpLookup -Ip 93.184.216.34
# Returns
# cpes : {}
# hostnames : {www.example.org, example.net, example.edu, example.com...}
# ip : 93.184.216.34
# ports : {80, 443}
# tags : {cdn}
# vulns : {}
#Example 2
Get-ShodanIpLookup -Ip 93.184.216.34 -ApiKey cEm<fake>GWfcg
# Returns
# city : Culver City
# region_code : CA
# os :
# tags : {cdn}
# ip : 1572395042
# isp : Edgecast Inc.
# area_code :
# longitude : -118.4276
# last_update : 2023-03-17T22:43:01.968549
# ports : {80, 443}
# latitude : 33.9728
# hostnames : {www.example.org, www.example.com, example.org, example.net...}
# country_code : US
# country_name : United States
# domains : {example.org, example.net, example.com, example.edu}
# org : NETBLK-03-EU-93-184-216-0-24
# data : {@{http=; tags=System.Object[]; opts=; timestamp=2023-03-17T18:21:42.916008; org=NETBLK-03-EU-93-184-216-0-24; isp=Edgecast Inc.; data=HTTP/1.1 404 Not Found
# Content-Type: text/html
# Date: Fri, 17 Mar 2023 18:21:42 GMT
# Server: ECS (sab/5798)
# Content-Length: 345
#
# ; _shodan=; port=80; hostnames=System.Object[]; location=; ip=1572395042; domains=System.Object[]; hash=-1479796315; os=; asn=AS15133; transport=tcp; ip_str=93.184.216.34}, @{http=; tags=System.Object[]; opts=;
# timestamp=2023-03-17T22:43:01.968549; org=NETBLK-03-EU-93-184-216-0-24; isp=Edgecast Inc.; data=HTTP/1.1 404 Not Found
# Content-Type: text/html
# Date: Fri, 17 Mar 2023 22:43:01 GMT
# Server: ECS (sab/56BC)
# Content-Length: 345
#
# ; _shodan=; port=443; ssl=; hostnames=System.Object[]; location=; ip=1572395042; domains=System.Object[]; hash=-370316800; os=; asn=AS15133; transport=tcp; ip_str=93.184.216.34}}
# asn : AS15133
# ip_str : 93.184.216.34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment