Leaderboard
Popular Content
Showing content with the highest reputation on 09/21/2024 in all areas
-
Latest update just released. See below for change log.2 points
-
Find Proxmox web interface ( or any local site really )
MattyD reacted to argumentum for a topic
I needed to ping Proxmox but it didn't so, let's "ping" the web interface ( or any TCP IPv4 in sight really ). If it connects, there is something there. #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <AutoItConstants.au3> #include <Date.au3> #include <GuiIPAddress.au3> Local $iW = 400, $iH = 200 Global $hGui = GUICreate(Chr(160) & "Find web interface", $iW, $iH) Global $idInput = _GUICtrlIpAddress_Create($hGui, nextLeft(5), 5, nextLeft(120), 21, -1, BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE)) _GUICtrlIpAddress_Set($idInput, GetDefaultRange()) Global $idPort = GUICtrlCreateInput("8006", nextLeft(), 5, nextLeft(100), 21, -1, BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE)) Global $idBttn = GUICtrlCreateButton("Run", nextLeft(), 5, nextLeft(125), 21) Global $idEdit = GUICtrlCreateEdit("The default port is 8006 because" & @CRLF & 'am looking for the running Proxmox.', 5, 30, $iW - 10, $iH - 30) GUICtrlSetData($idEdit, @CRLF & @CRLF & "Can take comma delimited (8006,443)" & @CRLF & "Use at will.", 1) GUISetState() While 1 Switch GUIGetMsg() Case -3 GUIDelete() Exit Case $idBttn idCtrlsSetState($GUI_DISABLE) GUICtrlSetData($idEdit, "") findSite() idCtrlsSetState($GUI_ENABLE) EndSwitch WEnd Func findSite() Local $aETTF ; "Estimated Time To Finish" data holder _EstimatedTime($aETTF) ; called with just the data holder to init. it Local $sHint, $vData, $n, $iSocket, $octets = _GUICtrlIpAddress_Get($idInput) Local $aPorts = StringSplit(StringReplace(GUICtrlRead($idPort), '(', ''), ',') For $m = 1 To $aPorts[0] $aPorts[$m] = Int($aPorts[$m]) If $aPorts[$m] < 1 Or $aPorts[$m] > 65535 Then Return GUICtrlSetData($idEdit, '..port(s) should be that of a web site') Next Local $aOct = StringSplit($octets, ".") If UBound($aOct) <> 5 Then Return GUICtrlSetData($idEdit, '..IPv4 should be X.X.X.') $octets = $aOct[1] & '.' & $aOct[2] & '.' & $aOct[3] & '.' TCPStartup() Opt("TCPTimeout", 100) For $n = 1 To 254 _EstimatedTime($aETTF, $n, 255) If GUIGetMsg() = -3 Then ExitLoop GUICtrlSetData($idBttn, $aETTF[1] & " - " & $aETTF[4] & " %") For $m = 1 To $aPorts[0] If Int($aPorts[$m]) < 1 Or $aPorts[$m] > 65535 Then ContinueLoop $iSocket = TCPConnect($octets & $n, $aPorts[$m]) If @error Then ContinueLoop $vData = Binary("") Sleep(10) $vData = TCPRecv($iSocket, 4096, 1) TCPCloseSocket($iSocket) If BinaryLen($vData) Then $sHint = Get22hint($vData) Else $sHint = GetHint($octets & $n, $aPorts[$m]) EndIf GUICtrlSetData($idEdit, $octets & $n & ':' & $aPorts[$m] & (StringLen($sHint) ? ' ' & @TAB & '[ ' & $sHint & ' ]' : '') & @CRLF, 1) Next Next TCPShutdown() GUICtrlSetData($idBttn, "...") While GUIGetMsg() WEnd GUICtrlSetData($idEdit, ($n = 255 ? "Done" : "Canceled") & ' ( ' & $aETTF[0] & ' )' & @CRLF, 1) GUICtrlSetData($idBttn, "Run") EndFunc ;==>findSite Func Get22hint($vData) Local $a1 = StringSplit(BinaryToString($vData), Chr(0)) ; filter nul Local $a2 = StringSplit(BinaryToString($a1[1]), @CRLF) ; get 1st line/only line Return $a2[1] EndFunc ;==>Get22hint Func GetHint($IPv4, $iPort) Local $sHttp = ($iPort = 80 ? "http" : "https") Local $iPID = Run(@ComSpec & ' /C curl -k -v -L ' & $sHttp & '://"' & $IPv4 & ':' & $iPort, @ScriptDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ProcessWaitClose($iPID) Local $sHint = "", $sTxt = StdoutRead($iPID) & StderrRead($iPID) If StringInStr($sTxt, '<title>') Then $sHint = StringMid($sTxt, StringInStr($sTxt, '<title>') + 7, StringInStr($sTxt, '</title>') - StringInStr($sTxt, '<title>') - 7) Return $sHint EndIf ; to dig deep use something like NMAP ( https://nmap.org/ ). This is just a simple tool. If StringInStr($sTxt, 'TrueNAS') Then Return 'TrueNAS' If StringInStr($sTxt, "Issue another request to this URL: 'https://" & $IPv4 & "/ui/'") Then Return 'TrueNAS' If StringInStr($sTxt, 'HTTP/1.1 403 Forbidden') Then Return 'HTTP/1.1 403 Forbidden' If StringInStr($sTxt, '< Server: ') Then Local $a1 = StringSplit($sTxt, '< Server: ', 1) Local $a2 = StringSplit($a1[2], @CRLF, 0) Return 'Server: ' & $a2[1] EndIf Return "" EndFunc ;==>GetHint Func nextLeft($i = 0) Local Static $iLeft = 0 $iLeft += $i Return ($i ? $i : $iLeft) EndFunc ;==>nextLeft Func idCtrlsSetState($iState) GUICtrlSetState($idBttn, $iState) _GUICtrlIpAddress_ShowHide($idInput, ($iState = $GUI_DISABLE ? @SW_HIDE : @SW_SHOW)) GUICtrlSetState($idPort, ($iState = $GUI_DISABLE ? $GUI_HIDE : $GUI_SHOW)) GUICtrlSetState($idEdit, $iState) EndFunc ;==>idCtrlsSetState Func GetDefaultRange() Local $sTxt = GetDefaultGateway() Return StringLeft($sTxt, StringInStr($sTxt, '.', 0, 3)) & 'X' EndFunc ;==>GetDefaultRange Func GetDefaultGateway() ; https://www.autoitscript.com/forum/topic/193342-how-to-change-default-gateway-and-preferred-dns-server/?do=findComment&comment=1387443 Local $out = "", $PID = Run(@ComSpec & " /c route print", @ScriptDir, @SW_HIDE, $STDOUT_CHILD) While 1 $out &= StdoutRead($PID) If @error Then ExitLoop WEnd Return StringRegExp($out, "\s*0.0.0.0\s+0.0.0.0\s+(\d+\.\d+\.\d+\.\d+).*", 1)[0] EndFunc ;==>GetDefaultGateway ;=============================================================================== ; ; Function Name: _EstimatedTime() ; https://www.autoitscript.com/forum/topic/177371-_estimatedtime-calculate-estimated-time-of-completion/ ; Description: calculate estimated time of completion ; Parameter(s): $a - holds the data ; $iCurrentCount - Current count ; $iTotalCount - Total count ; Requirement(s): #include <Date.au3> ; Return Value(s): false on incomplete data for assessment ; Author(s): argumentum ; Note(s): read the comments ; ;=============================================================================== Func _EstimatedTime(ByRef $a, $iCurrentCount = "", $iTotalCount = "") If $iCurrentCount & $iTotalCount = "" Then ; initialize $a = "" Dim $a[12] $a[5] = TimerInit() ; handle for TimerDiff() $a[0] = "00:00:00" $a[1] = "00:00:00" $a[2] = _NowCalc() ; starting date and time $a[3] = "" $a[4] = "0" Else If $iTotalCount = 0 Then Return False If $iCurrentCount > $iTotalCount Then $iCurrentCount = $iTotalCount _TicksToTime(Int(TimerDiff($a[5])), $a[6], $a[7], $a[8]) _TicksToTime(Int((TimerDiff($a[5]) / $iCurrentCount) * ($iTotalCount - $iCurrentCount)), $a[9], $a[10], $a[11]) $a[0] = StringFormat("%02i:%02i:%02i", $a[6], $a[7], $a[8]) ; elapsed time $a[1] = StringFormat("%02i:%02i:%02i", $a[9], $a[10], $a[11]) ; estimated total time $a[3] = _DateAdd("s", Int((TimerDiff($a[5]) / $iCurrentCount) * ($iTotalCount) / 1000), $a[2]) ; estimated date and time of completion $a[4] = Int($iCurrentCount / $iTotalCount * 100) ; percentage done EndIf Return True EndFunc ;==>_EstimatedTime Not much of an example but I scanned my network in under 30 secs. Nice toy to have Edit: added a hint of what may be at that IPv4 and comma delimited ports can be used. Edit2: Version with IP and mask: for those that may need it. ( or just @MattyD ) Edit3: Compiled it and placed it in the download area. ..and I should have put the data in a listview with a click-click to open the finding but, how many times will one not find their computers Edit4: Added the listview to double-click and go to the ip:port.1 point -
This sets the first element of the array to the number of elements in the array. Details can be found here - Section "Arrays".1 point
-
If you look in the help file for RegWrite there are following lines: Return Value Success: 1. Failure: 0 and sets the @error flag to non-zero if error writing registry key or value. @error: 1 = unable to open requested key 2 = unable to open requested main key 3 = unable to remote connect to the registry -1 = unable to open requested value -2 = value type not supported. So if @error=1 then if for any reason RegWrite files to open key you will get that first splash message "NOTICE!!", "The Reg String " & $sString & " was not succesfully updated!" If you want that message to be shown for each error that is listed above then you should write: "If @error Then" which means "if @error is anything except 0 then". When there is not an error, when everything goes well, then @error has value of 0.1 point
-
Find Proxmox web interface ( or any local site really )
argumentum reacted to MattyD for a topic
Nice, I was more thinking along the lines of something like this though - it'll allow you scan to scan an entire subnet if you're not using a /24. GetRange("10.0.0.78", "255.255.240.0") Func GetRange($sIP, $sNetMask) Local $aIPRange[2][4], $iIP, $iMask $aIP = StringSplit($sIP, ".", 2) $aMask = StringSplit($sNetMask, ".", 2) For $i = 0 To 3 $iIP = BitShift($iIP, -8) $iMask = BitShift($iMask, -8) $iIP += $aIP[$i] $iMask += $aMask[$i] Next Local $iNet = BitAND($iIP, $iMask) Local $iFirst = $iNet + 1 Local $iBCast = BitOr($iNet, BitNot($iMask)) Local $iLast = $iBCast - 1 Local $sIP2, $iIP For $i = $iFirst To $iLast $iIP = $i $sIP2 = "" For $j = 1 To 4 $sIP2 = BitAND($iIP, 0xFF) & "." & $sIP2 $iIP = BitShift($iIP, 8) Next ConsoleWrite(StringTrimRight($sIP2, 1) & @CRLF) Next EndFunc you'd then just nest the for loops... On second thought, its probably better to calculate the dotted notation on the fly. - Updated example!1 point -
Find Proxmox web interface ( or any local site really )
MattyD reacted to argumentum for a topic
you're right. Added that1 point -
Save Windows Position/Size Of Open Windows
ioa747 reacted to Lorecarver for a topic
@ioa747 That did it!!! Thank you gain, this helped me out alot!!! :)1 point