1
0
mirror of https://github.com/calebstewart/pwncat.git synced 2024-11-24 01:25:37 +01:00

Fixed caching issue when gathering facts

Hard to describe, but basically, enumerate.gather wouldn't return facts
enumerated via module recursion. It now does this properly.
This commit is contained in:
Caleb Stewart 2021-06-08 00:18:52 -04:00
parent 2e0969ce8c
commit ee416660ed

View File

@ -109,12 +109,15 @@ class Module(pwncat.modules.BaseModule):
if not types or any(
any(fnmatch.fnmatch(t2, t1) for t2 in fact.types) for t1 in types
):
if fact.type not in facts:
facts[fact.type] = [fact]
else:
facts[fact.type].append(fact)
if output is None:
yield fact
elif item.type not in facts:
facts[item.type] = [item]
else:
facts[item.type].append(item)
yield Status(fact.title(session))
for module in modules:
@ -139,17 +142,23 @@ class Module(pwncat.modules.BaseModule):
# Iterate over facts from the sub-module with our progress manager
try:
for item in module.run(session, types=types, cache=False):
if output is None:
yield item
elif item.type not in facts:
for item in module.run(session, types=types):
if item.type not in facts:
facts[item.type] = [item]
if output is None:
yield item
else:
yield Status(item.title(session))
else:
for fact in facts[item.type]:
if fact == item:
break
else:
facts[item.type].append(item)
if output is None:
yield item
else:
yield Status(item.title(session))
except ModuleFailed as exc:
session.log(f"[red]{module.name}[/red]: {str(exc)}")