Prerequisites
Minimum Version: Requires SysTrack 10.1 or later.
Notes
The SF_VBScript View refreshes once a day and collects events up to the end of the previous day. An event appears in the dashboard after the first refresh on a later day.
If you update or reinstall this DEX Pack, you must reassign the View created below to the SF_VBScript Role.
Installation Steps
To install this DEX Pack, complete the following steps:
Import the Kit
There are two ways to import the DEX Pack to SysTrack:
Import the pack directly from the Kits page in SysTrack. See the Import Online Kits guide for more information.
Import a local file downloaded from the DEX and Kit Downloads page. Click the Download Kit link for the pack and follow the Import Local Kits guide to finish the import.
Create the SF_VBScript View
This DEX Pack requires you to create the SF_VBScript View. The View sends the VBScript event data to the dashboard.
To create the new View:
Go to Configure > Views.
Click the padlock icon in the upper-right to enable editing.
Click the plus icon to add a new View.
Fill in the Settings as follows:
In View Name, enter
SF_VBScript. Table Name showsVUSF_VBSCRIPT.In Existing Category, select Custom.
In Expires in, select 30 Days.
In When Expired, select Append Data.
Clear when overdue by.
Set the Refresh drop-downs to Daily, Inside, 24x7, and Every Day.
Copy the SF_VBScript SQL Query, and paste it into the box under SQL Selection > Generic.
Click Test SQL. A Success message should appear at the top of the screen. If the test is not successful, the query may have been copied incorrectly.
Click Create View at the top-right.
SF_VBScript SQL Query
WITH EventPreSplit AS (
SELECT
WGUID,
EVENTTIME,
REPLACE(REPLACE(ProcessTreeEnhancedRaw,',ProcessTreeEnhanced = "',''),'",','') + ';' AS ProcessTreeRemaining,
EVENT_DESC,
RECUID
FROM (
SELECT
*,
SUBSTRING(EVENT_DESC,ProcessTreeEnhancedStartPos,100000) AS ProcessTreeEnhancedRaw
FROM (
SELECT
T0.WGUID,
T0.EVENTTIME,
CHARINDEX(',ProcessTreeEnhanced = "',S2.STRVALUE,1) AS ProcessTreeEnhancedStartPos,
S2.STRVALUE AS EVENT_DESC,
T0.RECUID
FROM SAEVENTLOG AS T0
LEFT JOIN SASTR AS S0 ON S0.STRINGID = T0.LOGNAME_ID
LEFT JOIN SASTR AS S1 ON S1.STRINGID = T0.SRCNAME_ID
LEFT JOIN SASTREVTDESC AS S2 ON S2.STRINGID = T0.EVENTDESC_ID
WHERE
S0.STRVALUE = 'Application'
AND S1.STRVALUE = 'VBScriptDeprecationAlert'
AND T0.EVENTID = 4096
AND DATEDIFF(D, T0.EVENTTIME, <LASTREFRESHTIME>) <= 0
AND DATEDIFF(D, T0.EVENTTIME, GETUTCDATE()) > 0
) AS T0
) AS T0
)
,ProcTreeSplit AS (
SELECT
WGUID,
EVENTTIME,
SUBSTRING(ProcessTreeRemaining,CHARINDEX(';',ProcessTreeRemaining,1)+1,10000000) AS ProcessTreeRemaining,
SUBSTRING(ProcessTreeRemaining,1,CHARINDEX(';',ProcessTreeRemaining,1)) AS ProcessTreeExtracted,
EVENT_DESC,
RECUID,
1 AS ProcPos
FROM EventPreSplit
UNION ALL
SELECT
WGUID,
EVENTTIME,
SUBSTRING(ProcessTreeRemaining,CHARINDEX(';',ProcessTreeRemaining,1)+1,10000000) AS ProcessTreeRemaining,
SUBSTRING(ProcessTreeRemaining,1,CHARINDEX(';',ProcessTreeRemaining,1)) AS ProcessTreeExtracted,
EVENT_DESC,
RECUID,
ProcPos + 1
FROM ProcTreeSplit
WHERE ProcessTreeExtracted > ''
)
,FinalExtracted AS (
SELECT
CASE WHEN ProcPos = 1 THEN ISNULL(REVERSE(SUBSTRING(ReversedScriptString,StartPos+1,EndPos-StartPos-1)),ProcessTreeExtracted) END AS ScriptName,
*
FROM (
SELECT
CASE
WHEN CHARINDEX('"sbv.',ReversedScriptString,1) > 0 THEN CHARINDEX('"sbv.',ReversedScriptString,1)
WHEN CHARINDEX('"ebv.',ReversedScriptString,1) > 0 THEN CHARINDEX('"ebv.',ReversedScriptString,1)
WHEN CHARINDEX('"fsw.',ReversedScriptString,1) > 0 THEN CHARINDEX('"fsw.',ReversedScriptString,1)
ELSE CHARINDEX('"ath.',ReversedScriptString,1)
END AS StartPos,
CHARINDEX('\',ReversedScriptString,1) AS EndPos,
*
FROM (
SELECT
*,
SUBSTRING(ProcessTreeExtracted,1,EndPos2) AS ProcName,
CASE
WHEN ProcPos = 1 AND (ProcessTreeExtracted LIKE '%.vbs"%' OR ProcessTreeExtracted LIKE '%.vbe"%' OR ProcessTreeExtracted LIKE '%.wsf"%' OR ProcessTreeExtracted LIKE '%.hta"%')
THEN REVERSE(ProcessTreeExtracted)
END AS ReversedScriptString
FROM (
SELECT
*,
CASE
WHEN CHARINDEX('(',ProcessTreeExtracted,1) > 0 THEN CHARINDEX('(',ProcessTreeExtracted,1) - 1
ELSE CHARINDEX(';',ProcessTreeExtracted,1) - 1
END AS EndPos2
FROM ProcTreeSplit
WHERE ProcessTreeExtracted > ''
) AS T0
) AS T0
) AS T0
)
SELECT
WGUID,
GETUTCDATE() AS VWTIME,
DATEADD(D, DATEDIFF(D, 0, EVENTTIME), 0) AS DOTY,
OWNER_PROC,
SCRIPT_NAME,
COUNT(*) AS EXEC_COUNT
FROM (
SELECT DISTINCT
WGUID,
EVENTTIME,
RECUID,
FIRST_VALUE(ProcName) OVER (PARTITION BY RECUID ORDER BY IgnoreList ASC, ProcPos ASC) AS OWNER_PROC,
MAX(ScriptName) OVER (PARTITION BY RECUID) AS SCRIPT_NAME
FROM (
SELECT
CASE
WHEN ProcName IN (
'explorer.exe',
'cmd.exe',
'powershell.exe',
'pwsh.exe',
'wscript.exe',
'cscript.exe',
'conhost.exe',
'schtasks.exe',
'taskeng.exe',
'taskhostw.exe',
'services.exe',
'svchost.exe',
'msiexec.exe',
'mshta.exe',
'rundll32.exe',
'wmic.exe',
'wininit.exe'
) THEN 1
ELSE 0
END AS IgnoreList,
*
FROM FinalExtracted
) AS T0
) AS T0
GROUP BY
WGUID,
DATEADD(D, DATEDIFF(D, 0, EVENTTIME), 0),
OWNER_PROC,
SCRIPT_NAMEAssign the SF_VBScript View to the VBScript Role
Navigate to Configure > Roles.
Select SF_VBScript from the drop-down at the top.
Click the Views tab in the center of the page.
Select the Enable checkbox for SF_VBScript in the list.
Click Save Changes at the top right.
Assign the Role to Relevant Configurations
This DEX Pack requires you to assign the SF_VBScript Role to the Configurations of the systems that you want to monitor:
Navigate to Configure > Configurations.
Click the padlock icon in the upper-right to enable editing.
Use the drop-down at the top to select a relevant Configuration, or create a new Configuration.
Assign the SF_VBScript Role to the Configuration by dragging it from Available Roles to Assigned Roles.
Click Save Changes at the top-right.
Repeat this process for any other relevant Configurations.