Skip to content

Commit 1eb6c51

Browse files
committed
Add like_search file input and disable preset option
1 parent e8d8966 commit 1eb6c51

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

nxc/modules/mssql_dumper.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ def options(self, context, module_options):
1818
"""
1919
SHOW_DATA Display the actual row data values of the matched columns (default: True)
2020
REGEX Semicolon-separated regex(es) to search for in **Cell Values**
21-
LIKE_SEARCH Comma-separated list of column names to specifically look for
21+
LIKE_SEARCH Comma-separated list or filename of column names to specifically look for
22+
USE_PRESET Use a predefined set of regex patterns for common PII (default: True)
2223
SAVE Save the output to sqlite database (default: True)
2324
"""
2425
self.regex_patterns = []
@@ -32,7 +33,12 @@ def options(self, context, module_options):
3233
except re.error as e:
3334
context.log.fail(f"[!] Invalid regex pattern '{pattern}': {e}")
3435
like_input = module_options.get("LIKE_SEARCH", "")
35-
self.like_search = [s.strip().lower() for s in like_input.split(",") if s.strip()]
36+
if os.path.isfile(like_input):
37+
with open(like_input) as f:
38+
self.like_search = [line.strip().lower() for line in f if line.strip()]
39+
else:
40+
self.like_search = [s.strip().lower() for s in like_input.split(",") if s.strip()]
41+
self.use_preset = module_options.get("USE_PRESET", "true").lower() in ["true", "1", "yes"]
3642
self.save = module_options.get("SAVE", "true").lower() in ["true", "1", "yes"]
3743

3844
def pii(self):
@@ -80,7 +86,11 @@ def on_login(self, context, connection):
8086
columns = connection.conn.sql_query(f"SELECT column_name FROM information_schema.columns WHERE table_name = '{table_name}'")
8187

8288
# find matching columns
83-
search_keys = self.pii() + self.like_search
89+
search_keys = []
90+
if self.use_preset:
91+
search_keys += self.pii()
92+
if self.like_search:
93+
search_keys += self.like_search
8494
matched = [col for col in columns if any(key in col["column_name"].lower() for key in search_keys)]
8595
if matched:
8696
column_str = ", ".join(f"[{c['column_name']}]" for c in matched)

0 commit comments

Comments
 (0)