Code: Select all
InputBox, Url,, Enter URL to do whois on
WhoIs := WhoIs(Url)
XML := LoadXML(GeoIP(Url))
GeoIP := XML.SelectSingleNode("/Response/Ip").text
GeoCountry := XML.SelectSingleNode("/Response/CountryName").text
GeoRegion := XML.SelectSingleNode("/Response/RegionName").text
Gui, Add, Text,, GeoIP returned this data: %GeoIP%, %GeoRegion%, %GeoCountry%
Gui, Add, Text,, WhoIs returned this data:
Gui, Add, Edit, w500 h500, % WhoIs
Gui, Add, Text, gWeb cblue, Returned nothing? Load this url to let them know you're human.
Gui, Add, Edit, vEditAddr, % ParseWhoIs(WhoIs)
Gui, Add, Button, gSearchWho, Search for location with whois
Gui, Add, Button, gSearchGeo, Search for location with GeoIP
Gui, Show
return
Web:
Run, http://www.networksolutions.com/whois/registry-data.jsp?domain=%Url%
Exitapp
SearchWho:
Gui, Hide
GuiControlGet, EditAddr
MsgBox, % "The following address has been placed in the clipboard:`n" (Clipboard := EditAddr) "`n`nMake any necessary changes to it before we proceed"
Gui, Destroy
Gui, Pic:New, +LabelPicGui
Gui, Add, Pic,, % DownloadLocation(GeoCode(Clipboard))
Gui, Show
return
SearchGeo:
DownloadLocation([XML.SelectSingleNode("/Response/Latitude").text,XML.SelectSingleNode("/Response/Longitude").text])
Gui, Pic:New, +LabelPicGui
Gui, Add, Pic,, % DownloadLocation(GeoCode(Clipboard))
Gui, Show
return
GuiClose:
PicGuiClose:
ExitApp
return
loadXML(ByRef data)
{
o := ComObjCreate("MSXML2.DOMDocument.6.0")
o.async := false
o.loadXML(data)
return o
}
; ----------
; free GeoIP api
; ----------
GeoIP(Host)
{
static Base := "http://freegeoip.net/xml/"
HTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1")
HTTP.Open("GET", Base . Host)
HTTP.Send()
return HTTP.ResponseText
}
; ----------
; Parse the WhoIs output. Not always very successful
; ----------
ParseWhoIs(WhoIs)
{
RegexMatch(WhoIs, "i)\RAdmin[^\R]*Street\d*:\s*(.+?)\R", Street)
if !Street1
RegexMatch(WhoIs, "i)\RAdmin[^\R]*Address\d*:\s*(.+?)\R", Street)
RegexMatch(WhoIs, "i)\RAdmin[^\R]*City\d*:\s*(.+?)\R", City)
RegexMatch(WhoIs, "i)\RAdmin[^\R]*Province\d*:\s*(.+?)\R", State)
RegexMatch(WhoIs, "i)\RAdmin[^\R]*Country\d*:\s*(.+?)\R", Country)
return Street1 " " City1 " " State1 " " Country1
}
; ----------
; Download location to file
; ----------
DownloadLocation(Address)
{
static Base := "http://maps.googleapis.com/maps/api/staticmap?zoom=18&size=400x400&maptype=satellite&sensor=false&format=jpg¢er="
static FileName := A_ScriptName ".jpg"
Url := Base . Address[1] "," Address[2]
FileDelete, % FileName
UrlDownloadToFile, %URL%, % FileName
return FileName
}
; ----------
; Address to location
; ----------
GeoCode(Address)
{
static Base := "http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address="
URL := Base . UriEncode(Address)
Pbin := ComObjCreate("WinHttp.WinHttpRequest.5.1")
Pbin.Open("GET", URL)
Pbin.Send()
RegexMatch(PBin.ResponseText, "\<location\>\s*\<lat\>([^\<]+)\<\/lat\>\s*\<lng\>([^\<]+)\<\/lng\>\s*\<\/location\>", Match)
return [Match1, Match2]
}
; ----------
; Domain WHOIS api
; ----------
WhoIs(Domain)
{
static Base := "http://www.networksolutions.com/whois/registry-data.jsp?domain="
URL := Base . UriEncode(Domain)
Pbin := ComObjCreate("WinHttp.WinHttpRequest.5.1")
Pbin.Open("GET", URL)
Pbin.Send()
RegexMatch(Pbin.ResponseText, "\<pre style\=""width\:550px\;overflow\:hidden\;""\>(.*?)\<\/pre\>", Match)
return Match1
}
; ----------
; modified from jackieku's code (http://www.autohotkey.com/forum/post-310959.html#310959)
; ----------
UriEncode(Uri, Enc = "UTF-8")
{
StrPutVar(Uri, Var, Enc)
f := A_FormatInteger
SetFormat, IntegerFast, H
Loop
{
Code := NumGet(Var, A_Index - 1, "UChar")
If (!Code)
Break
If (Code >= 0x30 && Code <= 0x39 ; 0-9
|| Code >= 0x41 && Code <= 0x5A ; A-Z
|| Code >= 0x61 && Code <= 0x7A) ; a-z
Res .= Chr(Code)
Else
Res .= "%" . SubStr(Code + 0x100, -1)
}
SetFormat, IntegerFast, %f%
Return, Res
}
UriDecode(Uri, Enc = "UTF-8")
{
Pos := 1
Loop
{
Pos := RegExMatch(Uri, "i)(?:%[\da-f]{2})+", Code, Pos++)
If (Pos = 0)
Break
VarSetCapacity(Var, StrLen(Code) // 3, 0)
StringTrimLeft, Code, Code, 1
Loop, Parse, Code, `%
NumPut("0x" . A_LoopField, Var, A_Index - 1, "UChar")
StringReplace, Uri, Uri, `%%Code%, % StrGet(&Var, Enc), All
}
Return, Uri
}
StrPutVar(Str, ByRef Var, Enc = "")
{
Len := StrPut(Str, Enc) * (Enc = "UTF-16" || Enc = "CP1200" ? 2 : 1)
VarSetCapacity(Var, Len, 0)
Return, StrPut(Str, &Var, Enc)
}
google.com - Doesn't work too well, but meh.
auto-hotkey.com - Works pretty well
scratchr.org - Works pretty well