|
1 | | -'Cb Pull Events v1.5.2 - Fix file baseline |
| 1 | +'Cb Pull Events v1.5.3 - Support reading query from file |
2 | 2 | 'Pulls event data from the Cb Response API and dumps to CSV. |
3 | 3 | 'Pass the query as a parameter to the script. |
4 | 4 | 'Enclose entire query in double quotes (") |
|
7 | 7 | '/bmnc "m" - modules. "n" - network. "c" - cross process |
8 | 8 |
|
9 | 9 |
|
10 | | -'Copyright (c) 2020 Ryan Boyle randomrhythm@rhythmengineering.com. |
| 10 | +'Copyright (c) 2021 Ryan Boyle randomrhythm@rhythmengineering.com. |
11 | 11 |
|
12 | 12 | 'This program is free software: you can redistribute it and/or modify |
13 | 13 | 'it under the terms of the GNU General Public License as published by |
@@ -117,13 +117,17 @@ strPortWatchlist = "PortWatch.txt" 'Network port watchlist name |
117 | 117 | boolUseSocketTools = False 'Uses external library from SocketTools (needed when using old OS that does not support latest TLS standards) |
118 | 118 | strLicenseKey = "" 'License key is required to use SocketTools |
119 | 119 | strIniPath="Cb_pe.ini" |
| 120 | +queryFile = "" ' text file containing query to run |
120 | 121 | 'end config section |
121 | 122 |
|
122 | 123 | if objFSO.FileExists(strIniPath) = false then |
123 | 124 | If InStr(strIniPath, "\") = 0 Then |
124 | 125 | strIniPath = CurrentDirectory & "\" & strIniPath |
125 | 126 | End If |
126 | | -End if |
| 127 | +End If |
| 128 | + |
| 129 | + |
| 130 | + |
127 | 131 |
|
128 | 132 | strReportPath = UpdatePath(strReportPath) 'add currentdirectory to path |
129 | 133 | strBaselinePath = UpdatePath(strBaselinePath) 'add currentdirectory to path |
@@ -156,6 +160,7 @@ boolReportUserName = ValueFromINI(strIniPath, "BooleanValues", "ReportUserName", |
156 | 160 | boolReportProcessName = ValueFromINI(strIniPath, "BooleanValues", "ReportProcessName", boolReportProcessName) |
157 | 161 | forceWatchlistInclusion = ValueFromINI(strIniPath, "BooleanValues", "IncludeQueryInWatchlist", forceWatchlistInclusion) |
158 | 162 | boolDebug = ValueFromINI(strIniPath, "BooleanValues", "Debug", boolDebug) |
| 163 | +queryFile = ValueFromINI(strIniPath, "StringValues", "QueryFilePath", queryFile) |
159 | 164 | '---End ini loading section |
160 | 165 | else |
161 | 166 | if BoolRunSilent = False then WScript.Echo strIniPath & " does not exist. Using script configured/default settings instead" |
@@ -247,12 +252,15 @@ end if |
247 | 252 | strCarBlackAPIKey = strTempAPIKey |
248 | 253 |
|
249 | 254 |
|
250 | | -if WScript.Arguments.count < 1 then |
| 255 | +if WScript.Arguments.count < 1 And queryFile = "" then |
251 | 256 | wscript.echo "No query parameter passed. Pass a CB query to the script as a argument" |
252 | 257 | wscript.quit |
253 | 258 | end if |
254 | 259 |
|
255 | | -if WScript.Arguments(0) = "" and strCbQuery = "" then |
| 260 | +If queryFile <> "" Then |
| 261 | + 'we will use the query in the file instead of arguments. |
| 262 | + |
| 263 | +ElseIf WScript.Arguments(0) = "" and strCbQuery = "" then |
256 | 264 | wscript.echo "No query parameter passed. Pass a CB query to the script as a argument" |
257 | 265 | wscript.quit |
258 | 266 | else |
@@ -318,6 +326,13 @@ else |
318 | 326 | next |
319 | 327 | end if |
320 | 328 |
|
| 329 | + |
| 330 | +If queryFile <> "" And strCbQuery = "" Then |
| 331 | + queryFile = CurrentDirectory & "\" & queryFile |
| 332 | + set readfilePath = objFSO.OpenTextFile(queryFile, 1, false) |
| 333 | + if not readfilePath.AtEndOfStream then strCbQuery = readfilepath.readall |
| 334 | +End If |
| 335 | + |
321 | 336 | if boolRegWatchlist = True then LoadCustomDict strRegWatchlist, DictRegWatchlist |
322 | 337 | if boolFileWatchlist = True then loadWatchlist strCbQuery, "filemod:", DictFileWatchlist, strFileWatchlist |
323 | 338 | if boolDomainWatchlist = True then loadWatchlist strCbQuery, "domain:", DictDomainWatchlist, strDomainWatchlist |
|
0 commit comments