JRSmile Posted February 23, 2018 Share Posted February 23, 2018 i thought i leave them here. used curl udf and json udf. expandcollapse popup#Include "Curl.au3" #Include "Json.au3" #include <Array.au3> ; Your own proxy server Global $ProxySever = "http://127.0.0.1:8888" Global $IPAM_LOGIN_TOKEN = phpIPAM_getToken("https://IPAMSERVER/api/test/user/","USER","PASS") ConsoleWrite ("LOGIN TOKEN = " & $IPAM_LOGIN_TOKEN & @CRLF) phpIPAM_searchDevice($IPAM_LOGIN_TOKEN,"13.13.1") Func phpIPAM_getToken($url,$username,$password) Local $Curl = Curl_Easy_Init() If Not $Curl Then Return Local $Html = $Curl ; any number as identify Local $Header = $Curl + 1 ; any number as identify Curl_Easy_Setopt($Curl, $CURLOPT_URL, $url) Curl_Easy_Setopt($Curl, $CURLOPT_USERAGENT, "AutoIt/Curl") Curl_Easy_Setopt($Curl, $CURLOPT_FOLLOWLOCATION, 1) Curl_Easy_Setopt($Curl, $CURLOPT_ACCEPT_ENCODING, "gzip") ; or set "" use all built-in supported encodings Curl_Easy_Setopt($Curl, $CURLOPT_WRITEFUNCTION, Curl_DataWriteCallback()) Curl_Easy_Setopt($Curl, $CURLOPT_WRITEDATA, $Html) Curl_Easy_Setopt($Curl, $CURLOPT_HEADERFUNCTION, Curl_DataWriteCallback()) Curl_Easy_Setopt($Curl, $CURLOPT_HEADERDATA, $Header) Curl_Easy_Setopt($Curl, $CURLOPT_COOKIE, "tool=curl; script=autoit; fun=yes;") Curl_Easy_Setopt($Curl, $CURLOPT_TIMEOUT, 30) Curl_Easy_Setopt($Curl, $CURLOPT_SSL_VERIFYPEER, 0) Curl_Easy_Setopt($Curl, $CURLOPT_POST,1) Curl_Easy_Setopt($Curl, $CURLOPT_USERNAME, $username) Curl_Easy_Setopt($Curl, $CURLOPT_PASSWORD, $password) Curl_Easy_Setopt($Curl, $CURLOPT_PROXY, $ProxySever) Local $Code = Curl_Easy_Perform($Curl) If $Code = $CURLE_OK Then ConsoleWrite("Content Type: " & Curl_Easy_GetInfo($Curl, $CURLINFO_CONTENT_TYPE) & @LF) ConsoleWrite("Download Size: " & Curl_Easy_GetInfo($Curl, $CURLINFO_SIZE_DOWNLOAD) & @LF) $Data2 = Json_Decode(BinaryToString(Curl_Data_Get($Html))) $json2 = Json_Encode($Data2, $Json_PRETTY_PRINT, " ", "\n", "\n", ",") MsgBox(0, 'Html',$json2) Json_Dump($Json2) ConsoleWrite(Json_Get($Data2, '["data"]["token"]')& @CRLF) Return Json_Get($Data2, '["data"]["token"]') Else ConsoleWrite(Curl_Easy_StrError($Code) & @LF) EndIf Curl_Easy_Cleanup($Curl) Curl_Data_Cleanup($Header) Curl_Data_Cleanup($Html) ConsoleWrite(@LF) EndFunc Func phpIPAM_searchDevice($IPAM_LOGIN_TOKEN,$device) Local $Curl = Curl_Easy_Init() If Not $Curl Then Return Local $Html = $Curl ; any number as identify Local $Header = $Curl + 1 ; any number as identify Curl_Easy_Setopt($Curl, $CURLOPT_URL, "https://IPAMSERVER/api/test/devices/search/"&$device&"/") Curl_Easy_Setopt($Curl, $CURLOPT_USERAGENT, "AutoIt/Curl") Curl_Easy_Setopt($Curl, $CURLOPT_FOLLOWLOCATION, 1) Curl_Easy_Setopt($Curl, $CURLOPT_ACCEPT_ENCODING, "gzip") ; or set "" use all built-in supported encodings Curl_Easy_Setopt($Curl, $CURLOPT_WRITEFUNCTION, Curl_DataWriteCallback()) Curl_Easy_Setopt($Curl, $CURLOPT_WRITEDATA, $Html) Curl_Easy_Setopt($Curl, $CURLOPT_HEADERFUNCTION, Curl_DataWriteCallback()) Curl_Easy_Setopt($Curl, $CURLOPT_HEADERDATA, $Header) Curl_Easy_Setopt($Curl, $CURLOPT_COOKIE, "tool=curl; script=autoit; fun=yes;") Curl_Easy_Setopt($Curl, $CURLOPT_TIMEOUT, 30) Curl_Easy_Setopt($Curl, $CURLOPT_SSL_VERIFYPEER, 0) Curl_Easy_Setopt($Curl, $CURLOPT_PROXY, $ProxySever) Local $Slist = Curl_Slist_Append(0, "User-Agent: AutoIt/Curl") $Slist = Curl_Slist_Append($Slist, "token: " & $IPAM_LOGIN_TOKEN) Curl_Easy_Setopt($Curl, $CURLOPT_HTTPHEADER, $Slist) Local $Code = Curl_Easy_Perform($Curl) If $Code = $CURLE_OK Then ConsoleWrite("Content Type: " & Curl_Easy_GetInfo($Curl, $CURLINFO_CONTENT_TYPE) & @LF) ConsoleWrite("Download Size: " & Curl_Easy_GetInfo($Curl, $CURLINFO_SIZE_DOWNLOAD) & @LF) Local $Data2 = Json_Decode(BinaryToString(Curl_Data_Get($Html))) Local $json2 = Json_Encode($Data2, $Json_PRETTY_PRINT, " ", "\n", "\n", ",") MsgBox(0, 'Html',$json2) Json_Dump($Json2) ;~ ConsoleWrite(Json_Get($Data2, '["data"]["token"]')& @CRLF) ;~ Return Json_Get($Data2, '["data"]["token"]') Else ConsoleWrite(Curl_Easy_StrError($Code) & @LF) EndIf Curl_Easy_Cleanup($Curl) Curl_Data_Cleanup($Header) Curl_Data_Cleanup($Html) ConsoleWrite(@LF) EndFunc $a=StringSplit("547275737420796F757220546563686E6F6C75737421","") For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4) Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI" Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile; MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-) Link to comment Share on other sites More sharing options...
argumentum Posted February 23, 2018 Share Posted February 23, 2018 (edited) I just learned about IPAM ( Explained - Windows Server 2016 ) thanks to you posting, now, how does phpIPAM does what ?, could not find an explanation in english ( video that is ). Thanks for sharing PS: I may have found an explanation on this video of solarwinds. Edited February 23, 2018 by argumentum Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
JRSmile Posted February 26, 2018 Author Share Posted February 26, 2018 (edited) On 23.2.2018 at 6:10 PM, argumentum said: I just learned about IPAM ( Explained - Windows Server 2016 ) thanks to you posting, now, how does phpIPAM does what ?, could not find an explanation in english ( video that is ). Thanks for sharing PS: I may have found an explanation on this video of solarwinds. try it yourself: https://phpipam.net/demo/ it is a better excel sheet if you want to document your network infrastructure. you can create subnets and devices and even scan them for uptime and document changes. vlan and vrf docomentation as wenn as subnets even racks and cables are planable. we use it to keep track which cable is connected to which device here. i am currently labling cable 40450 by hand and documenting it in the system with source destination, sort of cable, lwl or cat7, etc. phpipam is relatively new, it can automatically detect new devices in a network and read port configuration from managed switches. in addition you could combine it with power-dns a bind / Windows-DNS Server alternative to manage hostnames and domainnames as well. Edited February 26, 2018 by JRSmile Earthshine 1 $a=StringSplit("547275737420796F757220546563686E6F6C75737421","") For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4) Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI" Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile; MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-) Link to comment Share on other sites More sharing options...
Earthshine Posted February 26, 2018 Share Posted February 26, 2018 Nice! My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now