Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/13/2021 in all areas

  1. spudw2k

    System Scan Report Tool

    Was revisiting an old script I made for work years ago; it performs a local system scan and produces an HTML report. the report was very basic and ugly...now it's less ugly, so I thought I'd share. It collects system info (i.e. manufacturer, model, serial, CPU, RAM, BIOS ver., etc.), network card info, a device list & installed software list. Requires DeviceAPI.au3 UDF by Weaponx #NoTrayIcon ;#RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Res_Fileversion=0.2.2.0 ;#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/cs=0 /cn=0 /cf=0 /cv=0 /sf=1 /sv=1 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #NoAutoIt3Execute Global $version = "0.2.2" #cs - Version History 0.2.2 Bug fix [*] Corrected _WriteArrayToLog() destination file for debug 0.2.1 Minor Updates [+] Added System Info Attributes (OS, OS Version, Organization and Registered Owner) 0.2.0 Misc Updates [+] HTML Report Format - Initial Bootstrap CSS support [*] Minor report changes [*] Changed log write logic 0.1.5 Minor Updates [+] Added Obfuscation to Reduce Script Size [+] Set FileVersion to Match Script Version [+] Disabled external AutoIt script/code execution. 0.1.4 Significant Updates / Script Cleanup [-] Removed Omitted code from version 0.1.3 [*] Code Cleanup [*] Optimized Network Info WMI Query [+] Added HTML Footer [*] Changed HTML Report Header and added timestamps [*] Changed Script name to SystemScan 0.1.3 Major Updates / Script Cleanup & HTML Report [-] Removed Omitted code from version 0.1.2 [+] Added HTML Report Functions [+] Added Data Array Sort [*] Omitted Software & Device Hash Checking and Scan Force and Scan Version Reg Key [*] Omitted Uninstall String 0.1.2 Minor Updates / Script Cleanup [*] Changed All Collection Functions to Output Data Arrays [+] Created Array to Log File Method [-] Removed TimeZone from System Info Collection [*] Omitted User Name from System Info Collection [*] Omitted GUID Generation [*] Changed Scan Force to not remove or check Software and Device Signatures [*] Misc Code Cleanup [*] Omitted Software install date conversions 0.1.1 Minor Updates / Script Cleanup 0.1 Alpha Build #ce #Region - Initialization ;#AutoIt3Wrapper_Change2CUI=Y #include <Array.au3> ;Include Native AutoIt Library for Array Functions #include <DeviceAPI.au3> ;By Weaponx - https://www.autoitscript.com/forum/topic/77731-device-management-api/ #include <Constants.au3> ;Include Native AutoIt Library for AutoIt Constants #include <Date.au3> ;Include Native AutoIt Library for Date/Time Functions #include <Misc.au3> ;Include Native AutoIt Library for Misc. Functions (_Singleton()) ;Initialize Global $exitTimer = 0, $host = @ComputerName, $debug = 0 ;Define Global Variables for Timer, Hostname & Debug Flags Global $destDir = @ScriptDir & "\" ;Define LogFile Destination If Not _Singleton("DomainScan") Then Exit ;Enforce Singleton Execution If Not FileExists($destDir) Then DirCreate($destDir) ;Create Destination Dir Local $log = $destdir & "\" & @ComputerName & ".htm" $log = FileOpen($log, 2) FileDelete($destDir & "DomainScanLog.txt") ;Remove Debug Logfile ;Parse Command-Line Arguments for Debug and ScanForce Options If $CMDLINE[0] Then If StringInStr($CMDLINERAW, "debug") Then $debug = 1 ;Unused Function with Example Usage ;If StringInstr($CMDLINERAW,"/fileinfolist") Then ;domainscan.exe /fileinfolist "C:\dir\file.txt" ;_FileInfoList($CMDLINE[$CMDLINE[0]]) ;EndIf EndIf ;==>Initialize #EndRegion - Initialization #Region - Main ;Establish Local WMI Connection $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") If Not IsObj($objWMIService) Then If $debug Then _DebugLog("Failed to Establish WMI Connection") _Exit() EndIf If $debug Then _DebugLog("Established WMI Connection") ;==>Establish WMI Connection ;Timeout Timer $exitTimer = TimerInit() AdlibRegister("_ExitTimer", 30000) OnAutoItExitRegister("_Exit") ;==>Timeout Timer ;Collect System Data _WriteHTMLReportHeader($destDir) _AddSystemInfo($host) _AddSystemNetworkInfo($host) _AddSystemDevices($host) _AddSystemInstalledSoft($host) _WriteHTMLReportFooter($destDir) _Exit() ;==>Collect System Data ;Save log to NAS ;==>Save log to NAS #EndRegion - Main #Region - User Defined Functions Func _AddSystemInfo($hostname) ;Collect System Information If $debug Then _DebugLog("Collecting System Information") ;Execute WMI Queries $colItems = $objWMIService.ExecQuery("SELECT Name FROM Win32_Processor") For $objItem In $colItems $CPU = StringLeft(StringStripWS($objItem.name, 7), 64) Next $colItems = $objWMIService.ExecQuery("SELECT SerialNumber, SMBIOSBIOSVersion, ReleaseDate FROM Win32_BIOS") For $objItem In $colItems $Serial = $objItem.SerialNumber $BIOSVer = $objItem.SMBIOSBIOSVersion $ManufactureDate = $objItem.ReleaseDate $RealDate = ObjCreate("WbemScripting.SWbemDateTime") $RealDate.value = $ManufactureDate $ManufactureDate = StringRegExpReplace($RealDate.GetVarDate, "(\d{4,4})(\d{2,2})(\d{2,2})(\d{2,2})(\d{2,2})(\d{2,2})", "$2\/$3\/$1 $4:$5") $RealDate = 0 Next $colItems = $objWMIService.ExecQuery("SELECT TotalPhysicalMemory, Manufacturer, Model, Domain, UserName FROM Win32_ComputerSystem") For $objItem In $colItems $RAM = Round($objItem.TotalPhysicalMemory / 1024 / 1024) $Manufacturer = $objItem.Manufacturer $Model = StringLeft(StringStripWS($objItem.Model, 2), 30) $Domain = StringLeft($objItem.Domain, StringInStr($objItem.Domain, ".") - 1) Next $colItems = $objWMIService.ExecQuery("SELECT Caption, Version, Organization, RegisteredUser, LastBootUpTime, CurrentTimeZone FROM Win32_OperatingSystem") For $objItem In $colItems $OS = $objItem.Caption $OSVersion = $objItem.Version $Organization = $objItem.Organization $RegisteredUser = $objItem.RegisteredUser $LastBootTime = $objItem.LastBootUpTime $RealDate = ObjCreate("WbemScripting.SWbemDateTime") $RealDate.value = $LastBootTime $LastBootTime = StringRegExpReplace($RealDate.GetVarDate, "(\d{4,4})(\d{2,2})(\d{2,2})(\d{2,2})(\d{2,2})(\d{2,2})", "$2\/$3\/$1 $4:$5") $RealDate = 0 Next $colItems = 0 ;Collect Local Administrator Members $localadmins = "" Dim $filter[1] = ["Groups"] $colGroups = ObjGet("WinNT://" & $hostname & "") $colGroups.Filter = $filter For $objGroup In $colGroups If $objGroup.Name = "Administrators" Then For $objUser In $objGroup.Members If $objUser.Name Then $localadmins &= $objUser.Name & "|" Next EndIf Next If StringRight($localadmins, 1) = "|" Then $localadmins = StringTrimRight($localadmins, 1) $localadmins = StringLeft($localadmins, 255) ;Create Data Array Dim $arrSysInfo[2][14] = [["OS", "OS Version", "Owner", "Organization", "Manufacturer", "Model", "Serial", "BIOS Version", "BIOS Date", "CPU", "RAM", "Domain", "Last Boot Time", "Local Admins"], _ [$OS, $OSVersion, $RegisteredUser, $Organization, $Manufacturer, $Model, $Serial, $BIOSVer, $ManufactureDate, $CPU, $RAM, $Domain, $LastBootTime, $localadmins]] ;Save Collected Info If $debug Then _WriteArrayToLog($arrSysInfo, $destDir, "SystemInfo.CSV") $arrSysInfo[1][13] = StringReplace($arrSysInfo[1][13], "|", "</br>") _WriteArrayToHTML(__ArrayTranspose($arrSysInfo), $destDir, "System Information") If $debug Then _DebugLog("System Information Collected") EndFunc ;==>_AddSystemInfo Func _AddSystemNetworkInfo($hostname) ;Collect System Network Information If $debug Then _DebugLog("Collecting System Network Information") ;Execute WMI Queries Dim $arrNetInfo[1][8] = [["Interface Name", "MAC", "IP", "Subnet", "Gateway", "DNS1", "DNS2", "WINS"]] Dim $netIdx = 1 $colItems = $objWMIService.ExecQuery("SELECT IPAddress, Description, MACAddress, IPSubnet, DefaultIPGateway, DNSServerSearchOrder, WINSPrimaryServer FROM Win32_NetworkAdapterConfiguration Where IPEnabled = True") For $objItem In $colItems If $objItem.IPAddress(0) <> "0.0.0.0" Then $NIC = StringLeft($objItem.Description, 90) $MAC = $objItem.MACAddress $IP = $objItem.IPAddress(0) $Subnet = $objItem.IPSubnet(0) $Gateway = $objItem.DefaultIPGateway(0) $DNS1 = $objItem.DNSServerSearchOrder(0) $DNS2 = $objItem.DNSServerSearchOrder(1) $WINS = $objItem.WINSPrimaryServer(0) ReDim $arrNetInfo[$netIdx + 1][8] $arrNetInfo[$netIdx][0] = $NIC $arrNetInfo[$netIdx][1] = $MAC $arrNetInfo[$netIdx][2] = $IP $arrNetInfo[$netIdx][3] = $Subnet $arrNetInfo[$netIdx][4] = $Gateway $arrNetInfo[$netIdx][5] = $DNS1 $arrNetInfo[$netIdx][6] = $DNS2 $arrNetInfo[$netIdx][7] = $WINS $netIdx += 1 EndIf Next $colItems = 0 _ArraySort($arrNetInfo, 0, 1, UBound($arrNetInfo) - 1) ;Save Collected Data If $debug Then _WriteArrayToLog($arrNetInfo, $destDir, "NetworkInfo.CSV") _WriteArrayToHTML(__ArrayTranspose($arrNetInfo), $destDir, "Network Information") If $debug Then _DebugLog("System Network Information Collected") EndFunc ;==>_AddSystemNetworkInfo Func _AddSystemInstalledSoft($hostname) ;Collect Installed Software Listing If $debug Then _DebugLog("Collecting Installed Software") ;Populate Software Collection Array Dim $arrSoft[1][3] = [["Software Title", "Version", "Install Date"]] Dim $appIdx = 1 If @OSArch <> "X64" Then $y = 1 Else $y = 2 EndIf For $x = 1 To $y $keyIdx = 0 ;Index of Uninstall SubKeys If $x = 1 Then $regRoot = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" ;Registry Tree for Uninstall Info Else $regRoot = "HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" ;Registry Tree for Uninstall Info EndIf While 1 $keyIdx += 1 ;Increment Index each loop $keyName = RegEnumKey($regRoot, $keyIdx) ;Query Registry Key at Index $keyIdx If @error Then ExitLoop ;If not end of registry tree Local $appName = StringLeft(StringStripWS(RegRead($regRoot & "\" & $keyName, "DisplayName"), 7), 80) ;Get Application Name If $appName Then Local $versionNum = RegRead($regRoot & "\" & $keyName, "DisplayVersion") ;Get Version Number Local $installdate = RegRead($regRoot & "\" & $keyName, "InstallDate") ;Get Install Date If Not $versionNum Then $versionNum = "" ReDim $arrSoft[$appIdx + 1][3] $arrSoft[$appIdx][0] = $appName $arrSoft[$appIdx][1] = $versionNum $arrSoft[$appIdx][2] = $installdate $appIdx += 1 EndIf WEnd Next _ArraySort($arrSoft, 0, 1, UBound($arrSoft) - 1) If $debug Then _DebugLog("Adding System Software") ;Save Collected Info If $debug Then _WriteArrayToLog($arrSoft, $destDir, "Software.CSV") _WriteArrayToHTML($arrSoft, $destDir, "Installed Software") EndFunc ;==>_AddSystemInstalledSoft Func _AddSystemDevices($hostname) ;Collect Installed System Devices If $debug Then _DebugLog("Collecting System Devices") ;Populate Installed System Devices Array Dim $arrHW[1][3] = [["Device Name", "Class", "Manufacturer"]] $devIDX = 1 _DeviceAPI_Open() _DeviceAPI_GetAllDevices() ;Build list of ALL device classes While _DeviceAPI_EnumDevices() ReDim $arrHW[$devIDX + 1][3] $arrHW[$devIDX][0] = _DeviceAPI_GetDeviceRegistryProperty($SPDRP_DEVICEDESC) $arrHW[$devIDX][1] = _DeviceAPI_GetClassName(_DeviceAPI_GetDeviceRegistryProperty($SPDRP_CLASSGUID)) $arrHW[$devIDX][2] = _DeviceAPI_GetDeviceRegistryProperty($SPDRP_MFG) $devIDX += 1 WEnd _DeviceAPI_DestroyDeviceInfoList() ;Cleanup for good measure _DeviceAPI_Close() _ArraySort($arrHW, 0, 1, UBound($arrHW) - 1) If $debug Then _DebugLog("Adding System Devices") ;Save Collected Info If $debug Then _WriteArrayToLog($arrHW, $destDir, "Devices.CSV") _WriteArrayToHTML($arrHW, $destDir, "System Devices") EndFunc ;==>_AddSystemDevices Func __ArrayTranspose(ByRef $arr) If Not IsArray($arr) Then Return SetError(1, 0, 0) If Not UBound($arr, 0) = 2 Then Return SetError(2, 0, 0) Dim $arrTrans[UBound($arr, 2)][UBound($arr, 1)] For $x = 0 To UBound($arrTrans, 2) - 1 For $y = 0 To UBound($arrTrans) - 1 $arrTrans[$y][$x] = $arr[$x][$y] Next Next Return $arrTrans EndFunc ;==>__ArrayTranspose Func _DebugLog($str) FileWriteLine($destDir & "DomainScanLog.txt", @HOUR & ":" & @MIN & ":" & @SEC & " - " & $str) EndFunc ;==>_DebugLog Func _Exit() $exitTimer = 0 $objWMI = 0 FileClose($log) Exit EndFunc ;==>_Exit Func _ExitTimer() $time = 1200000 If $debug Then _DebugLog("Timer Check: " & TimerDiff($exitTimer) & @TAB & $time) If TimerDiff($exitTimer) > $time Then Exit EndFunc ;==>_ExitTimer Func _Today() Return @YEAR & @MON & @MDAY EndFunc ;==>_Today Func _WriteArrayToHTML($arr, $dest, $title) $xDim = UBound($arr, 1) - 1 $yDim = UBound($arr, 2) - 1 FileWriteLine($log, "<div class=""container""><h3><a href='#" & StringReplace($title," ","_") & "' data-toggle='collapse'>" & $title & "</a></h3>") FileWriteLine($log, "<div id='" & StringReplace($title," ","_") & "' class='collapse'><table border='0'>") $varRowColor = 0 For $x = 0 To $xDim If $varRowColor = 0 Then $varRowColor = 1 $varRowColorValue = "#9BCDFF" Else $varRowColor = 0 $varRowColorValue = "#C4E1FF" EndIf FileWrite($log, "<tr bgcolor='" & $varRowColorValue & "'>") For $y = 0 To $yDim FileWrite($log, "<td>" & $arr[$x][$y] & "</td>") Next FileWrite($log, "</tr>" & @CRLF) Next FileWriteLine($log, "</table></div></div></br>") EndFunc ;==>_WriteArrayToHTML Func _WriteArrayToLog($arr, $dest, $filename) $xDim = UBound($arr, 1) - 1 $yDim = UBound($arr, 2) - 1 For $x = 0 To $xDim For $y = 0 To $yDim FileWrite($destdir & "\" & @ComputerName & "_" & $filename, '"' & $arr[$x][$y] & '"') If $y < $yDim Then FileWrite($destdir & "\" & @ComputerName & "_" & $filename, ",") Else FileWrite($destdir & "\" & @ComputerName & "_" & $filename, @CRLF) EndIf Next Next EndFunc ;==>_WriteArrayToLog Func _WriteHTMLReportHeader($dest) $title = @ComputerName & " System Scan" FileWriteLine($log, '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">') FileWriteLine($log, '<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>') FileWriteLine($log, '<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>') FileWriteLine($log, '<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>') FileWriteLine($log, "<title>" & $title & "</title>" & @CRLF & _ "<div class=""jumbotron jumbotron-fluid""><div class=""container""><center><h1>" & $title & "</h1></div></div>" & _ "<div class=""container"">Scan Initiated: " & @MON & "/" & @MDAY & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & "</br></br></br></div>") EndFunc ;==>_WriteHTMLReportHeader Func _WriteHTMLReportFooter($dest) FileWriteLine($log, "</div></br><div class=""container"">Scan Complete: " & @MON & "/" & @MDAY & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & "</div>") FileClose($log) ShellExecute($dest & "\" & @ComputerName & ".htm") EndFunc ;==>_WriteHTMLReportFooter Func MyErrFunc() If $oMyError.number = -2147352567 Then Return 0 If $debug Then _DebugLog("Intercepted a COM Error !" & @CRLF & @CRLF & "err.description is: " & @TAB & $oMyError.description) Local $err = $oMyError.number If $err = 0 Then $err = -1 $g_eventerror = $err ; to check for after this function returns EndFunc ;==>MyErrFunc #EndRegion - User Defined Functions #Region - Functions Not Implemented ;Func _AddFileInfo($hostname,$file) ; If Not FileExists($file) Then Return 0 ; $attribs = FileGetAttrib($file) ; $size = FileGetSize($file) ; $version = FileGetVersion($file) ; $modtime = FileGetTime($file,0,1) ; $cretime = FileGetTime($file,1,1) ; $acctime = FileGetTime($file,2,1) ;EndFunc ;Func _FileInfoList($filelist) ; If Not FileExists($filelist) Then Return 0 ; Dim $arrList ; _FileReadToArray($filelist,$arrList) ; For $x = 1 to $arrList[0] ; ;_AddFileInfo(@ComputerName,$arrList[$x]) ; Next ;EndFunc #EndRegion - Functions Not Implemented The script produces a report that looks like this.
    1 point
  2. Hello, I just made another TCP server. I will use the server for data collection and a lot of clients can get the data from TCP. I now use it for UDP broadcast some devices to get their IP's. You can also use it for chat's. It is very low level, but so you have more options than with the pure AutoIt functions. Just start the server in SciTE to see the console outputs. Then you can start up to 63 clients to talk to the server. I hope you like it. Server script: #include "socket_UDF.au3" ;funkey 2013.06.21 _WSAStartup() Global $iSocket Global $iReturn Global $iPort = 20500 Global $sIP_Connected Global $iPort_Connected Global $tBuffer = DllStructCreate("char buffer[512]") $iSocket = _socket($AF_INET, $SOCK_STREAM, $IPPROTO_TCP) ConsoleWrite("Listen Socket: " & $iSocket & @CRLF) Global $tReUse = DllStructCreate("BOOLEAN reuse") DllStructSetData($tReUse, "reuse", True) ; enable reusing the same port $iReturn = _setsockopt($iSocket, $SOL_SOCKET, $SO_REUSEADDR, $tReUse) ; set reusing option for the port If $iReturn Then ConsoleWrite("SetSockOpt error setting reusing the same port!. Windows Sockets Error Codes: " & _WSAGetLastError() & @CRLF) EndIf $iReturn = _bind($iSocket, @IPAddress1, $iPort) ;local IP-Address and port to use If $iReturn Then ConsoleWrite("Bind error: " & $iReturn & @CRLF) ; 0 is OK EndIf $iReturn = _listen($iSocket, 1) If $iReturn Then ConsoleWrite("Listen error: " & $iReturn & @CRLF) ; 0 is OK EndIf Global $iNewSocket Global $tReadFds = DllStructCreate($tagFd_set) Global $tReadFds_Copy = DllStructCreate($tagFd_set) _FD_ZERO($tReadFds) _FD_SET($iSocket, $tReadFds) Global $iSocketMax = $iSocket Global $iSocketNow Global $sDataRcv While 1 DllCall('ntdll.dll', 'none', 'RtlMoveMemory', 'struct*', $tReadFds_Copy, 'struct*', $tReadFds, 'ULONG_PTR', DllStructGetSize($tReadFds)) $iReturn = _select($iSocketMax + 1, $tReadFds_Copy, 2000) ;timeout 2 seconds If _FD_ISSET($iSocket, $tReadFds_Copy) Then $iNewSocket = _accept($iSocket, $sIP_Connected, $iPort_Connected) _FD_SET($iNewSocket, $tReadFds) _FD_SHOW($tReadFds) If $iNewSocket > $iSocketMax Then $iSocketMax = $iNewSocket ConsoleWrite("New connected socket: " & $iNewSocket & @TAB & "IP: " & $sIP_Connected & @TAB & "Port: " & $iPort_Connected & @LF) EndIf For $i = 2 To DllStructGetData($tReadFds, "fd_count") $iSocketNow = DllStructGetData($tReadFds, "fd_array", $i) If _FD_ISSET($iSocketNow, $tReadFds_Copy) Then DllCall('ntdll.dll', 'none', 'RtlZeroMemory', 'struct*', $tBuffer, 'ULONG_PTR', DllStructGetSize($tBuffer)) If _recv($iSocketNow, $tBuffer) = $SOCKET_ERROR Then _closesocket($iSocketNow) _FD_CLR($iSocketNow, $tReadFds) Else $sDataRcv = DllStructGetData($tBuffer, 1) ConsoleWrite("Data received: " & $sDataRcv & @LF) If $sDataRcv == "CloseServer!" Then ExitLoop 2 EndIf EndIf EndIf Next WEnd For $i = 1 To DllStructGetData($tReadFds, "fd_count") _closesocket(DllStructGetData($tReadFds, "fd_array", $i)) Next _WSACleanup() Func _FD_SHOW(ByRef $tFd_set) For $i = 1 To DllStructGetData($tFd_set, "fd_count") ConsoleWrite($i & ":" & @TAB & DllStructGetData($tFd_set, "fd_array", $i) & @LF) Next EndFunc ;==>_FD_SHOWsocket_UDF and example.rar
    1 point
  3. I am not sure if Signing would solve my issues, also because as stated 2 of the 4 flagged files are from the standard NSIS installer utility and I would never sign exe's or dll's of others. Just for clarity, as I've mentioned on several occasions before, when I stop maintaining au3stripper and Tidy, nobody will be able to maintain them as I am the only one having their source code. I know they run pretty solid, but they aren't in a state to be put on github. The simple reason for this is that they are build over a period of several years through BCX and PellesC, and not in a state I would want to publish them. I have thought about starting again in VS CPP but never started the project (yet). Jos
    1 point
  4. So you need to declare the data as binary. The inbuild function automatically detects it. #include "socket_UDF.au3" _WSAStartup() Global $iSock = _socket($AF_INET, $SOCK_STREAM, $IPPROTO_TCP) ConsoleWrite("Socket: " & $iSock & @CRLF) Global $tTimeVal = DllStructCreate("DWORD timeout") DllStructSetData($tTimeVal, "timeout", 5000) ; Timeout 200ms $iSockError = _setsockopt($iSock, $SOL_SOCKET, $SO_RCVTIMEO, $tTimeVal) ; set Timeout for recv If $iSockError Then ConsoleWrite("SetSockOpt error setting recv timeout!. Windows Sockets Error Codes: " & _WSAGetLastError() & @CRLF) _closesocket($iSock) TCPShutdown() ;WSACleanup EndIf Global $iConnect = _connect($iSock, "184.168.101.36", 80) ConsoleWrite("Connect error: " & $iConnect & @CRLF) ; 0 is OK If $iConnect Then ConsoleWrite("Windows Sockets Error Codes: " & _WSAGetLastError() & @CRLF) _closesocket($iSock) TCPShutdown() ;WSACleanup EndIf ;~ Global $sToSend = "GET /getip.php HTTP/1.1" & @CRLF & "Host: updatevng.com" & @CRLF & @CRLF ;~ Global $bToSend = Binary($sToSend) ;~ ConsoleWrite($bToSend & @CRLF) Global $bToSend = Binary("0xec0108900f1ae6010a0408131001520408031000520408051000720a08021206332e31342e31726c0814126865326130386133616162323432666562343638633862336433376434643432332362636131373139626339613034393032233837343236383937323130353632353233353632233030313031313030393331313433372330303a31453a45343a30303a36443a3637720508a501120072120815120e636f6d2e686474742e6e706c6179720408161200721a081712166656566a75705547536869647249796932746a774133720408181200720e088d0112094d6e63414844593536720508df011200") ;~ Global $tSendBuffer = DllStructCreate("char[" & StringLen($sToSend) & "]") Global $tSendBuffer = DllStructCreate("byte[" & BinaryLen($bToSend) & "]") ;~ DllStructSetData($tSendBuffer, 1, $sToSend) DllStructSetData($tSendBuffer, 1, $bToSend) Global $iSend = _send($iSock, $tSendBuffer) ConsoleWrite("Bytes sent: " & $iSend & @CRLF) Global $tRecvBuffer = DllStructCreate("char["&10*1024&"]") Global $iRecv = _recv($iSock, $tRecvBuffer) ConsoleWrite("Bytes received: " & $iRecv & @CRLF) ConsoleWrite("Data received: " & DllStructGetData($tRecvBuffer, 1) & @CRLF) _closesocket($iSock) _WSACleanup()
    1 point
  5. Try something like: #include <Array.au3> #include <Excel.au3> Local $oExcel =_Excel_Open(False) ; Set to false if want to run in backgroun $datawb = _Excel_BookOpen($oExcel,@ScriptDir & "\Book1.xlsx") $datawb.worksheets("Sheet1").Activate $LastRow = $datawb.ActiveSheet.UsedRange.Rows.Count $aMyData = _Excel_RangeRead($datawb, Default, "A1:D" & $LastRow) _Excel_BookClose($datawb, False) If Not WinExists("[CLASS:Notepad]", "") Then Run("notepad.exe") Local $hWnd = WinWait("[CLASS:Notepad]", "", 10) WinActivate($hWnd, "") For $x = 1 To UBound($aMyData) - 1 If $aMyData[$x][0] = "2B" Then ;~ Example 1 - Loop through each column For $y = 0 To UBound($aMyData, 2) - 1 ControlSend($hWnd, "", "Edit1", $aMyData[$x][$y] & ($y < UBound($aMyData, 2) - 1 ? @TAB : @CRLF)) Next ;~ Example 2 - Using _ArrayToString for a single line item ControlSend($hWnd, "", "Edit1", "~~~~ _ArrayToString Example ~~~~" & @CRLF) ControlSend($hWnd, "", "Edit1", _ArrayToString($aMyData, @TAB, $x, $x) & @CRLF) EndIf Next
    1 point
  6. _WD_Alert should do the trick, and if it doesn't you can always inject JavaScript to hijack the popup function: window.alert = Function.prototype.bind(); window.alert is the browser function to display a popup like that, and my code creates a new dummy function which does nothing and replaces that with the browser function.
    1 point
  7. I'd say that it's the script writer's responsibility to perform these checks. However, the UDF could do a better job of detecting that the webdriver console exited with errors. No worries. Just don't let it happen again! 😜
    1 point
×
×
  • Create New...