Leaderboard
Popular Content
Showing content with the highest reputation on 12/14/2018 in all areas
-
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.4 points
-
SciTE advanced.
pixelsearch and one other reacted to mLipok for a topic
Long time ago had the same problem. I did not have the knowledge, but I wanted to learn and by the way, I wanted to do something useful for the community. Now I have much more knowledge but I have too many professional duties, so I do not have as much time for the community as I wanted. As I can see @caramen acts prudently, first asks, gathers knowledge, creates youtube Video, modifies it on a regular basis, but at the same time, other members should to teach and admonish him, what needs to be improved in his project, which he shares with us. I think we should praise his work, because what he does, he tries to do it right. I only hope that @caramen will keep improving his video content according to the good advice that he has already received and I hope that he will receive in the future.2 points -
Unable to Activate window without Title
IrkenElite86 reacted to Nine for a topic
use the $hWnd handle on winactivate. Report the result like $result = WinActivate ($hWnd) and remember that a window that is "Always On Top" could still cover up a window you Activated. After a successful activation @extended is set to 1 if the the window was already active, 2 if not. msgbox both $result and @extended1 point -
Arrays 101: All you need to know about them!
FrancescoDiMuro reacted to TheDcoder for a topic
@FrancescoDiMuro Good example, I will try to adapt it for my OP and edit it in1 point -
SciTE advanced.
FrancescoDiMuro reacted to JLogan3o13 for a topic
Not intending to derail the topic completely, but I will say I agree @mLipok, we are all here because we want to contribute. Just seems more prudent to learn something for yourself first and be comfortable with it before trying to teach others. Based on the first comment in this thread, it sounded like the OP was going to attempt to teach while learning himself, which rarely goes well. There was another "All you could ever want to know about subject X" thread started not too long ago where the OP then spent the first couple of pages fixing it due to responses from others pointing out how mistaken he was in some of his beliefs on the subject. If the intent, as stated is just the "how to download, install, etc." perhaps that is something to add to the FAQs on the Wiki1 point -
SciTE advanced.
FrancescoDiMuro reacted to JLogan3o13 for a topic
If this is the case, why undertake teaching something to others before learning it thoroughly yourself?1 point -
Uptodate way to communicate with websites
FrancescoDiMuro reacted to Danp2 for a topic
See Autoit FAQ #311 point -
I would prefer when we tell people to use the Full version when they really want to do serious scripting as that has soo many advantages! Jos1 point
-
Arrays 101: All you need to know about them!
TheDcoder reacted to FrancescoDiMuro for a topic
@TheDcoder Do you think that could be useful (and to "complete" the explanation) of looping through arrays, describing the Step parameter of the For...Next...Step loop? In some cases, when you have a defined set of elements, which may be "structured" in the same way in the content of the array, and you are looking for a specific element that you know you can find every five elements for example, you could use the Step parameter. By the way, amazing and definitely useful post!1 point -
"Bridging" IE UDF and (Chrome) Webdriver UDFs?
Earthshine reacted to junkew for a topic
You could read faq 31 for all different solutions to tackle recognition of objects. So far i have not seen a tool that unifies all ui technologies in one top generic layer. Windows, web, java, mobile, mainframe seems to be impossible to get one commandset in clicking, sendkeys, snapshotting.1 point -
_DebugArrayDisplay should only be used for debugging the scripts it's used in. If you're using it for anything else, then you missed that point in its name. It already does way more than it needs to do for simply displaying an array's contents in a script to make sure that you're array contains what you expect it to. It's great that you have modified it to your liking, but I would hope it doesn't get into production AutoIt.1 point
-
"Bridging" IE UDF and (Chrome) Webdriver UDFs?
Earthshine reacted to Danp2 for a topic
Hi Jim, I do not know if the UDF will work with your older version of Autoit. You should be able to install more than one version of Autoit, so I'm not understanding why you are "stuck" using this older version. Dan1 point -
I am trying to search a bmp inside a bmp or a screenshot, so I found this BmpSearch - Search for Bitmap within Bitmap by Beege, but the error Variable must be of type "Object".: Local $iRowInc = ($tSizeSource.X - $tSizeFind.X) * 4 Local $iRowInc = ($tSizeSource^ ERROR come out I tried many way to solve but failed Eg. ObjCreate _WinAPI_LoadImage Someone please help me, thank you.1 point
-
need to execute cmd commands
behdadsoft reacted to darkjohn20 for a topic
$CMD = "ipconfig /flushdns" RunWait(@ComSpec & " /c " & $CMD)1 point -
Give XY the specified area to the virtual Controlid?
Earthshine reacted to fanniehickson for a topic
I have an interface (mobile emulator for task management) that does not control it, but the title of the window. I do not want to use the mouseclick feature, but just click the cursor. This is where I came up and I do not know if this is possible or not. Can we make a variable car that takes two X and Y coordinates (one square) to create virtual instructions that do not actually exist, but in order to deceive the automate, is it really a control click in this area? And how?0 points