Skip to content

Commit 50588f3

Browse files
authored
Merge pull request #734 from jbeley/main
Fixed yara export in osqueryexport.py and added new functions
2 parents 2237bc5 + cd6cd3d commit 50588f3

File tree

1 file changed

+47
-2
lines changed

1 file changed

+47
-2
lines changed

misp_modules/modules/export_mod/osqueryexport.py

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
"windows-service-displayname",
1717
"windows-scheduled-task",
1818
"yara",
19+
"ip-dst",
20+
"ip-src",
21+
"filename",
22+
"sha256",
23+
"windows-service-name",
24+
"named pipe",
25+
"domain"
1926
]
2027

2128
userConfig = {}
@@ -28,7 +35,7 @@
2835

2936

3037
moduleinfo = {
31-
"version": "1.0",
38+
"version": "1.1",
3239
"author": "Julien Bachmann, Hacknowledge",
3340
"description": "OSQuery export of a MISP event.",
3441
"module-type": ["export"],
@@ -77,20 +84,58 @@ def handle_service(value):
7784

7885

7986
def handle_yara(value):
80-
return "not implemented yet, not sure it's easily feasible w/o dropping the sig on the hosts first"
87+
return "// WARNING make sure you examine and modify the path parameter below otherwise this is a very expensive search"
88+
return "SELECT * FROM file JOIN yara USING (path) WHERE (path LIKE '/%%' AND type = 'regular' AND size < 8000000 AND sigrule='%s' AND count > 0);" % value
8189

8290

8391
def handle_scheduledtask(value):
8492
return "SELECT * FROM scheduled_tasks WHERE name LIKE '%s';" % value
8593

8694

95+
def handle_ip_dst(value):
96+
return "SELECT * FROM process_open_sockets where remote_address LIKE '%s';" % value
97+
98+
99+
def handle_ip_src(value):
100+
return "SELECT * FROM process_open_sockets where local_address LIKE '%s';" % value
101+
102+
103+
def handle_filename(value):
104+
return "// WARNING make sure you examine and modify the path parameter below otherwise this is a very expensive search"
105+
return "select * from file where path LIKE '%s';" % value
106+
107+
108+
def handle_sha256(value):
109+
return "// WARNING make sure you examine and modify the file.directory parameter below otherwise this is a very expensive search"
110+
return "SELECT *, sha256 FROM file JOIN hash USING (path) WHERE file.directory LIKE '/%%' AND sha256 like '%s' ORDER BY mtime DESC LIMIT 1;" % value
111+
112+
113+
def handle_windows_service_name(value):
114+
return "SELECT * FROM services WHERE service_name LIKE '%s';" % value
115+
116+
117+
def handle_named_pipe(value):
118+
return "SELECT * FROM pipes WHERE name LIKE '%s';" % value
119+
120+
121+
def handle_domain(value):
122+
return "SELECT * FROM dns_cache WHERE name LIKE '%s';" % value
123+
124+
87125
handlers = {
88126
"regkey": handle_regkey,
89127
"regkey|value": handle_regkeyvalue,
90128
"mutex": handle_mutex,
91129
"windows-service-displayname": handle_service,
92130
"windows-scheduled-task": handle_scheduledtask,
93131
"yara": handle_yara,
132+
"ip-dst": handle_ip_dst,
133+
"ip-src": handle_ip_src,
134+
"filename": handle_filename,
135+
"sha256": handle_sha256,
136+
"windows-service-name": handle_windows_service_name,
137+
"named pipe": handle_named_pipe,
138+
"domain": handle_domain,
94139
}
95140

96141

0 commit comments

Comments
 (0)