Moderators Dragos Posted March 30, 2011 Moderators Report Posted March 30, 2011 IP Tools este un script scris in AutoIT cu ajutorul caruia poti folosi diverse instrumente pentru IP-uri.Ideea a pornit de la vechiul topic al lui Nytro si baietii care cereau un nou link de descarcare, insa poate va evolua spre ceva mai amplu in viitor.Scriptul foloseste un api pentru a se conecta la un site cu scopul localizarii IP-ului. Nu ma deranjeaza daca modificati sursa, insa aveti grija ca la prea multe query-uri catre site, api-ul este blocat.Pentru a-l descarca, apasati aici. Exista o probabilitate ca .exe-ul sa fie detectat de antivirus deoarece este packuit cu UPX.Aveti mai jos sursa.#include <GUIConstantsEx.au3>#include <INet.au3>#include <String.au3>Opt('MustDeclareVars', 1)Opt('TrayIconHide',1) Local $msg,$upd,$ip,$api,$link,$ss Local $city, $lat,$long,$country, $code, $regcode Local $tabs, $label,$status,$label2,$label3, $input1, $button1, $l1, $response $ip = _GetIP() $api = "409f44a12b8bccd245b898f11300a54abfb709ca89f4ce8905d12e21f4bbe982" $link = "http://api.ipinfodb.com/v2/ip_query.php?key=" & $api & "&ip=" & $ip $ss = _INetGetSource($link) $city = _StringBetween($ss,"<City>","</City>") $lat = _StringBetween($ss,"<Latitude>","</Latitude>") $long = _StringBetween($ss,"<Longitude>","</Longitude>") $country = _StringBetween($ss,"<CountryName>","</CountryName>") $code = _StringBetween($ss,"<CountryCode>","</CountryCode>") $regcode = _StringBetween($ss,"<RegionCode>","</RegionCode>") GUICreate("[RST] IP Tools BETA by Synthesis", 320, 330) $upd = GuiCtrlCreateLabel("Status: Ready", 10,311,340,100) $tabs = GuiCtrlCreateTab(10, 10, 300, 300) GuiCtrlCreateTabItem("Your IP") $label = GuiCtrlCreateLabel("Your IP is " & $ip & @CRLF & @CRLF & "LOCATION " & @CRLF & "City: " & $city[0] & @CRLF & "Country: " & $country[0] & @CRLF & @CRLF & "COORDINATES" & @CRLF & "Latitude: " & $lat[0] & @CRLF & "Longitude: " & $long[0] & @CRLF & @CRLF & "MISCELLANEOUS" & @CRLF & "Country code: " & $code[0] & @CRLF & "Region code: " & $regcode[0], 15,60,280,250,0x1) GuiCtrlCreateTabItem("Locate an IP") $input1 = GuiCtrlCreateInput($ip,50,50,150,23,0x1) $button1 = GuiCtrlCreateButton("Locate",210,49,60,25,0x1) $label2 = GuiCtrlCreateLabel("", 15,90,280,230,0x1) GuiCtrlSetFont ($upd, 9,400,2) GuiCtrlSetFont($tabs, 10) GuiCtrlSetFont($label, 10) GuiCtrlSetFont($label2, 10) GuiCtrlSetFont($input1, 10) GuiCtrlSetFont($button1, 10) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button1 $l1 = GuiCtrlRead($input1) $response = StringRegExp($l1,'((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9]))') If ($response == 0) Then GuiCtrlSetData($upd, "Error: Invalid IP provided") Else GuiCtrlSetData($upd, "Status: Locating") $link = "http://api.ipinfodb.com/v2/ip_query.php?key=" & $api & "&ip=" & $l1 $ss = _INetGetSource($link) $city = _StringBetween($ss,"<City>","</City>") $lat = _StringBetween($ss,"<Latitude>","</Latitude>") $long = _StringBetween($ss,"<Longitude>","</Longitude>") $country = _StringBetween($ss,"<CountryName>","</CountryName>") $code = _StringBetween($ss,"<CountryCode>","</CountryCode>") $regcode = _StringBetween($ss,"<RegionCode>","</RegionCode>") GuiCtrlSetData($label2, "LOCATION " & @CRLF & "City: " & $city[0] & @CRLF & "Country: " & $country[0] & @CRLF & @CRLF & "COORDINATES" & @CRLF & "Latitude: " & $lat[0] & @CRLF & "Longitude: " & $long[0] & @CRLF & @CRLF & "MISCELLANEOUS" & @CRLF & "Country code: " & $code[0] & @CRLF & "Region code: " & $regcode[0]) GuiCtrlSetData($upd, "Status: The IP has been located in " & $country[0] & ".") EndIf EndSelect WEnd GUIDelete() Exit 1 Quote
phantomas90 Posted March 30, 2011 Report Posted March 30, 2011 Tare programelul. Doar l-am compilat si l-am executat odata:Se pare ca pt noi nu vede decat coordonatele tarii. Am incercat si pe un IP random si mi l-a gasit ca fiind din Republica Ceha dar avea si zecimale la coordonate. Quote
Moderators Dragos Posted March 30, 2011 Author Moderators Report Posted March 30, 2011 Tare programelul. Doar l-am compilat si l-am executat odata:Se pare ca pt noi nu vede decat coordonatele tarii. Am incercat si pe un IP random si mi l-a gasit ca fiind din Republica Ceha dar avea si zecimale la coordonate.Pe IP-ul meu mi-a returnat ok Quote
sulea Posted March 31, 2011 Report Posted March 31, 2011 (edited) vorbeam aiurea Edited March 31, 2011 by sulea Quote
phantomas90 Posted March 31, 2011 Report Posted March 31, 2011 (edited) edited.Am introdus codu asta langa al tau pentru localizare pe harta.$nr_lat=$lat $nr_long=$long $hDownload = InetGet("http://maps.google.com/maps/api/staticmap?center=" & $nr_lat & "," & $nr_long & "&zoom=12&size=400x400&sensor=false","staticmap.png", 1, 1) ;****************************************************************** ; Create a GUI for the original image $hGUI1 = GUICreate("Original", 400, 300, 0, 0) GUISetState() _GDIPlus_Startup () $hImage = _GDIPlus_ImageLoadFromFile ("staticmap.png") ; Draw original image $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND ($hGUI1) _GDIPlus_GraphicsDrawImage ($hGraphic1, $hImage, 0, 0) ; Release resources _GDIPlus_GraphicsDispose ($hGraphic1) _GDIPlus_ImageDispose ($hImage) _GDIPlus_Shutdown () FileDelete("staticmap.png")------------------------------------------------------------------------Mai lucrez la partea cu marker, sa pot sa-l pun pe harta si eventual cateva controale de zoom.Atentie: google static maps are limita 1000 de requesturi pe zi.Asta e codul facut de mine separat pt teste:#include <GUIConstantsEx.au3>#include <INet.au3>#include <String.au3>#include <GuiConstantsEx.au3>#include <GDIPlus.au3>#include <ScreenCapture.au3>GUICreate("Image_location",300,300,50,50,-1)GUISetState(@SW_SHOW)$lat=GUICtrlCreateInput("",80,20,100,20,-1)$long=GUICtrlCreateInput("",80,50,100,20,-1)$zoom=GUICtrlCreateInput("",80,80,40,20,-1)$MapType=GUICtrlCreateCombo("roadmap",80,110,100,20,-1)GUICtrlSetData($MapType,"roadmap|satellite|terrain|hybrid","roadmap")$Size=GUICtrlCreateCombo("400x400",80,140,100,20,-1)GUICtrlSetData($Size,"400x400|640x640|500x500|","400x400");---------------------------------------------------------GUICtrlCreateLabel("Latitudine:",5,22,50,20,-1)GUICtrlCreateLabel("Longitudine:",5,52,70,20,-1)GUICtrlCreateLabel("Zoom:",5,82,70,20,-1)GUICtrlCreateLabel("MapType:",5,112,70,20,-1)GUICtrlCreateLabel("Size:",5,142,70,20,-1);---------------------------------------------------------$buton_harta=GUICtrlCreateButton("Arata harta",200,10,100,50,-1)$buton_exit=GUICtrlCreateButton("Exit",200,250,100,50,-1)While 1 $msg = GUIGetMsg() if $msg=$buton_harta Then $nr_lat=GUICtrlRead($lat) $nr_long=GUICtrlRead($long) $zoom2=GUICtrlRead($zoom) $MapType2=GUICtrlRead($MapType) $Size2=GUICtrlRead($Size) $hDownload = InetGet("hhttp://maps.google.com/maps/api/staticmap?center=" & $nr_lat & "," & $nr_long & "&zoom="& $zoom2 & "&size=" & $Size2 &"&maptype="& $MapType2 & "&markers=color:blue%|label:A%7C" & $nr_lat & "," & $nr_long & "&sensor=false","staticmap.png", 1, 1) ;****************************************************************** ; Create a GUI for the original image $x=StringTrimLeft ($Size,4) $xx=int($x) $hGUI1 = GUICreate("Coordonatele cerute",400,400,400,0,-1) GUISetState() _GDIPlus_Startup () $hImage = _GDIPlus_ImageLoadFromFile ("staticmap.png") ; Draw original image $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND ($hGUI1) _GDIPlus_GraphicsDrawImage ($hGraphic1, $hImage, 0, 0) ; Release resources _GDIPlus_GraphicsDispose ($hGraphic1) _GDIPlus_ImageDispose ($hImage) _GDIPlus_Shutdown () ;****************************************************************** EndIf if $msg=$gui_event_close then GUIDelete($hGUI1) FileDelete("staticmap.png") EndIf If $msg = $buton_exit Then FileDelete("staticmap.png") ExitLoop EndIf WEnd-------------------------------------------------Am rezolvat, am modificat sursele postate mai sus.Acum merge. In programul facut de synthesis la apasarea "Locate" va arata harta.@pax: uite cat costa un ip2location pt un server:-------Ce facem noi poate nu va ajunge la acest stadiu dar cred ca va fi folositor cuiva. Edited April 10, 2011 by phantomas90 Quote
HellScream Posted June 12, 2011 Report Posted June 12, 2011 pe versiunea originala (ce fara harta) desi apar coordonatele, ele nu sunt exacte. M-a gasit in partea opusa a orasului. Ar fi frumos sa se optimizeze coordonatele la cere este gasit ip-ul astfel incat sa stii inclusiv strada si numarul.Ar fi o chestie buna. Pana atunci, spun multumesc si pt tool-ul asta. Quote
phantomas90 Posted June 13, 2011 Report Posted June 13, 2011 @hellscream totul e legat de linia asta:hhttp://maps.google.com/maps/api/staticmap?center=" & $nr_lat & "," & $nr_long & "&zoom="& $zoom2 & "&size=" & $Size2 &"&maptype="& $MapType2 & "&markers=color:blue%|label:A%7C" & $nr_lat & "," & $nr_long & "&[COLOR="Red"]sensor=false[/COLOR]","staticmap.png"Citeste aici sa vezi care e treaba cu acel sensor: static maps api si vino cu o idee de optimizare.Ce am inteles eu de acolo e ca sensor=true se da doar atunci cand folosesti un device gen gps sau telefon cu gps. Acum treaba cu coordonatele e in functie de providerul de net. Am testat cu syntesis, din BV: eu am coordonate intregi, el are zecimale. Quote
HellScream Posted June 13, 2011 Report Posted June 13, 2011 Da, ai dreptate. Nu m-am gandit la provider. Oricum, e bine ca gaseste orasul. Si, daca e sa stau sa ma gandesc mai bine, e oricum amuzant. SPre exemplu tu stai in RACADAU, si te gaseste in Steagu`, sau prin TRACTORU. Quote
Moderators Dragos Posted June 13, 2011 Author Moderators Report Posted June 13, 2011 Nu intotdeauna gaseste coordonatele potrivite, e problema cu provider-ul. De exemplu, IP-ul pe care ti-l atribuie un stick de net RDS (nu DIGI) iti va zice intotdeauna ca e de Bucuresti. Quote
phantomas90 Posted June 13, 2011 Report Posted June 13, 2011 @hellscream uite si optimizarea:Ai doua puncte: A1 si B1 de coordonate cunoscute. Punctele A, B si C le "ceri" tu coordonatele. si rezulta un triunghi ABC. Trasezi 2 cercuri: Unul cu centrul in A1 si cu raza A1-A si celalalt centru in B1 si raza B1-B. Ele se intersecteaza in doua puncte.(eu nu le-am mai denumit dar poti sa le zici C1 si C2).Apoi compari rapoartele (A1-A)/(C1-C) cu (A1-A)/(C2-C) si alegi punctul pentru care raportul da cel mai mic rezultat.E o metoda asemenatoare cu metoda triangulatiei. Quote
Moderators Dragos Posted June 13, 2011 Author Moderators Report Posted June 13, 2011 @hellscream uite si optimizarea:Ai doua puncte: A1 si B1 de coordonate cunoscute. Punctele A, B si C le "ceri" tu coordonatele. si rezulta un triunghi ABC. Trasezi 2 cercuri: Unul cu centrul in A1 si cu raza A1-A si celalalt centru in B1 si raza B1-B. Ele se intersecteaza in doua puncte.(eu nu le-am mai denumit dar poti sa le zici C1 si C2).Apoi compari rapoartele (A1-A)/(C1-C) cu (A1-A)/(C2-C) si alegi punctul pentru care raportul da cel mai mic rezultat.E o metoda asemenatoare cu metoda triangulatiei.Poti sa o aplici si in script Quote
phantomas90 Posted June 13, 2011 Report Posted June 13, 2011 (edited) Acum e nevoie de ajutorul vostru.Aici veti gasi programul. Deschideti, alegeti tipul de harta si zoom-ul si dati "arata harta". Dupa ce apare harta va aparea si un msgbox in care vor fi afisate coordonatele:scrieti-le undeva. Dupa care intrati pe google maps/earth si va cautati locatia voastra exacta, apoi reveniti cu un post de genu:"Am rulat programul si mi-a aratat coordonatele: X,Y.Coordonatele mele reale sunt X1,Y1.Providerul meu de internet este: Orange-disconnecting peopleIP-ul meu este:aaa.bbb.ccc.ddd"Va rog sa fiti cat mai seriosi, fiecare informatie de aici va fi luata ca referinta cand se calculeaza abaterile cauzate de ip2location.Puteam sa includ ceva in sursa sa-mi dea direct datele pe un ftp, dar las la latitudinea voastra.Cum se va face asta:Iau cate un IP si coordonatele reale, rulez acest ip2location pentrul acel IP si pentru mine. apoi fac translatie cu v/2(v fiind vectorul de translatie) a punctului meu. apoi aplic chestia asta in functie de cate ip-uri de test am la dispozitie. Asfel la 100 de IP-uri+coordonate voi avea o eroare maxima de 5m.Programul de mai sus, in faza actuala nu permite decat localizarea ip-lui propriu. In faza finala va fi free dar fara sursa. Oricine vrea sa contribuie va primi sursa.Va multumesc! Edited June 18, 2011 by phantomas90 Quote