Skip to content

Commit 45add02

Browse files
committed
Support reading query from file
Signed-off-by: Ryan B <randomrhythm@rhythmengineering.com>
1 parent b487ca5 commit 45add02

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

Pull_Events/Cb_PE.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ ReceiveTimeout=120
44
PagesToPull=1000
55
APIVersion=4
66
[StringValues]
7-
7+
ClientCertPath=
8+
QueryFilePath=
89
[BooleanValues]
910
UseSocketTools=False
1011
Network=True

Pull_Events/Cb_Pull_Events.vbs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'Cb Pull Events v1.5.2 - Fix file baseline
1+
'Cb Pull Events v1.5.3 - Support reading query from file
22
'Pulls event data from the Cb Response API and dumps to CSV.
33
'Pass the query as a parameter to the script.
44
'Enclose entire query in double quotes (")
@@ -7,7 +7,7 @@
77
'/bmnc "m" - modules. "n" - network. "c" - cross process
88

99

10-
'Copyright (c) 2020 Ryan Boyle randomrhythm@rhythmengineering.com.
10+
'Copyright (c) 2021 Ryan Boyle randomrhythm@rhythmengineering.com.
1111

1212
'This program is free software: you can redistribute it and/or modify
1313
'it under the terms of the GNU General Public License as published by
@@ -117,13 +117,17 @@ strPortWatchlist = "PortWatch.txt" 'Network port watchlist name
117117
boolUseSocketTools = False 'Uses external library from SocketTools (needed when using old OS that does not support latest TLS standards)
118118
strLicenseKey = "" 'License key is required to use SocketTools
119119
strIniPath="Cb_pe.ini"
120+
queryFile = "" ' text file containing query to run
120121
'end config section
121122

122123
if objFSO.FileExists(strIniPath) = false then
123124
If InStr(strIniPath, "\") = 0 Then
124125
strIniPath = CurrentDirectory & "\" & strIniPath
125126
End If
126-
End if
127+
End If
128+
129+
130+
127131

128132
strReportPath = UpdatePath(strReportPath) 'add currentdirectory to path
129133
strBaselinePath = UpdatePath(strBaselinePath) 'add currentdirectory to path
@@ -156,6 +160,7 @@ boolReportUserName = ValueFromINI(strIniPath, "BooleanValues", "ReportUserName",
156160
boolReportProcessName = ValueFromINI(strIniPath, "BooleanValues", "ReportProcessName", boolReportProcessName)
157161
forceWatchlistInclusion = ValueFromINI(strIniPath, "BooleanValues", "IncludeQueryInWatchlist", forceWatchlistInclusion)
158162
boolDebug = ValueFromINI(strIniPath, "BooleanValues", "Debug", boolDebug)
163+
queryFile = ValueFromINI(strIniPath, "StringValues", "QueryFilePath", queryFile)
159164
'---End ini loading section
160165
else
161166
if BoolRunSilent = False then WScript.Echo strIniPath & " does not exist. Using script configured/default settings instead"
@@ -247,12 +252,15 @@ end if
247252
strCarBlackAPIKey = strTempAPIKey
248253

249254

250-
if WScript.Arguments.count < 1 then
255+
if WScript.Arguments.count < 1 And queryFile = "" then
251256
wscript.echo "No query parameter passed. Pass a CB query to the script as a argument"
252257
wscript.quit
253258
end if
254259

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
256264
wscript.echo "No query parameter passed. Pass a CB query to the script as a argument"
257265
wscript.quit
258266
else
@@ -318,6 +326,13 @@ else
318326
next
319327
end if
320328

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+
321336
if boolRegWatchlist = True then LoadCustomDict strRegWatchlist, DictRegWatchlist
322337
if boolFileWatchlist = True then loadWatchlist strCbQuery, "filemod:", DictFileWatchlist, strFileWatchlist
323338
if boolDomainWatchlist = True then loadWatchlist strCbQuery, "domain:", DictDomainWatchlist, strDomainWatchlist

0 commit comments

Comments
 (0)