1
0
mirror of https://github.com/calebstewart/pwncat.git synced 2024-11-30 20:34:15 +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( if not types or any(
any(fnmatch.fnmatch(t2, t1) for t2 in fact.types) for t1 in types 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: if output is None:
yield fact yield fact
elif item.type not in facts:
facts[item.type] = [item]
else: else:
facts[item.type].append(item) yield Status(fact.title(session))
for module in modules: for module in modules:
@ -139,17 +142,23 @@ class Module(pwncat.modules.BaseModule):
# Iterate over facts from the sub-module with our progress manager # Iterate over facts from the sub-module with our progress manager
try: try:
for item in module.run(session, types=types, cache=False): for item in module.run(session, types=types):
if item.type not in facts:
facts[item.type] = [item]
if output is None: if output is None:
yield item yield item
elif item.type not in facts: else:
facts[item.type] = [item] yield Status(item.title(session))
else: else:
for fact in facts[item.type]: for fact in facts[item.type]:
if fact == item: if fact == item:
break break
else: else:
facts[item.type].append(item) facts[item.type].append(item)
if output is None:
yield item
else:
yield Status(item.title(session))
except ModuleFailed as exc: except ModuleFailed as exc:
session.log(f"[red]{module.name}[/red]: {str(exc)}") session.log(f"[red]{module.name}[/red]: {str(exc)}")