Skip to content

Instantly share code, notes, and snippets.

@M3T4L5T3F
Last active January 16, 2019 00:25
Show Gist options
  • Save M3T4L5T3F/fa656e86b155412d0ca9a6d3a9ab7f26 to your computer and use it in GitHub Desktop.
Save M3T4L5T3F/fa656e86b155412d0ca9a6d3a9ab7f26 to your computer and use it in GitHub Desktop.
Covert Physical Tracking POC
# POC Covert Physical Tracking script
# provides lat,long and address via google geocoding API on a timed loop
# By @M3T4L5T3F
# Inspired by:
#https://stackoverflow.com/users/3694461/colsw
#https://stackoverflow.com/questions/46287792/powershell-getting-gps-coordinates-in-windows-10-using-windows-location-api
#https://docs.microsoft.com/en-us/dotnet/api/system.device.location.geocoordinatewatcher?view=netframework-4.7.2
#https://www.syspanda.com/index.php/2018/01/13/google-geocode-api-powershell/
$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