Skip to content

Commit 0751619

Browse files
committed
Cleanup, catch possible parsing issues of rpcclient queruser output
1 parent b308998 commit 0751619

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

enum4linux-ng.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,25 +1852,31 @@ def get_details_from_rid(self, rid, name):
18521852
if match:
18531853
user_info = match.group(1)
18541854

1855-
regexMatch = r'^\t[A-Za-z][A-Za-z\s_\.0-9]*(:|\[[0-9\.]+\]\.\.\.)(\t|\s)?'
1856-
18571855
for line in filter(None, user_info.split('\n')):
1858-
if re.match(regexMatch, line):
1856+
if re.match(r'^\t[A-Za-z][A-Za-z\s_\.0-9]*(:|\[[0-9\.]+\]\.\.\.)(\t|\s)?', line):
18591857
if ":" in line:
18601858
key, value = line.split(":", 1)
18611859
if "..." in line:
18621860
key, value = line.split("...", 1)
18631861

1862+
# Skip user and full name, we have this information already
18641863
if "User Name" in key or "Full Name" in key:
18651864
continue
1865+
18661866
key = key.strip()
18671867
value = value.strip()
18681868
details[key] = value
18691869
else:
1870-
if key not in details:
1871-
details[key] = line
1872-
else:
1873-
details[key] += "\n" + line
1870+
# If the regex above does not match, the output of the rpcclient queruser call must have
1871+
# changed. In this case, this would throw an exception since 'key' would be referenced before
1872+
# assignment. We catch that exception.
1873+
try:
1874+
if key not in details:
1875+
details[key] = line
1876+
else:
1877+
details[key] += "\n" + line
1878+
except:
1879+
return Result(None, f"Could not parse result of 'rpcclient' command, please open a GitHub issue")
18741880

18751881
if "acb_info" in details and valid_hex(details["acb_info"]):
18761882
for key in ACB_DICT:

0 commit comments

Comments
 (0)