Skip to content

Commit 1ed36a1

Browse files
committed
add example script to check data sharing settings for a Cb Response server
1 parent b05c160 commit 1ed36a1

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env python
2+
3+
import sys
4+
from cbapi.response.models import SensorGroup
5+
from cbapi.example_helpers import build_cli_parser, get_cb_response_object
6+
7+
8+
def main():
9+
parser = build_cli_parser("Check datasharing settings on server")
10+
11+
args = parser.parse_args()
12+
cb = get_cb_response_object(args)
13+
14+
virustotal_groups = []
15+
for sg in cb.select(SensorGroup):
16+
settings = cb.get_object("/api/v1/group/{0}/datasharing".format(sg.id)) or []
17+
for setting in settings:
18+
if setting.get("what") == "BIN" and setting.get("who") == "VIRUSTOTAL":
19+
virustotal_groups.append(sg)
20+
21+
if len(virustotal_groups) == 0:
22+
print("No sensor groups are configured to send unknown binaries to VirusTotal")
23+
return 0
24+
elif len(virustotal_groups) == len(cb.select(SensorGroup)):
25+
print("**ALL** sensor groups are configured to send unknown binaries to VirusTotal")
26+
return 1
27+
else:
28+
print("The following sensor groups are configured to send unknown binaries to VirusTotal:")
29+
for sg in virustotal_groups:
30+
print(" id {0}: {1}".format(sg.id, sg.name))
31+
return 1
32+
33+
34+
if __name__ == "__main__":
35+
sys.exit(main())

0 commit comments

Comments
 (0)