Skip to content

Commit

Permalink
fs closes payload
Browse files Browse the repository at this point in the history
  • Loading branch information
xmendez committed Apr 26, 2019
1 parent 3a35d17 commit 73307b5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/wfuzz/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def __init__(self, options):

def stop(self):
self.stats.cancelled = True
self.close()

def restart(self, seed):
self.seed = seed
Expand Down
15 changes: 7 additions & 8 deletions src/wfuzz/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,13 @@ def export_json(self):
return json.dumps(tmp, sort_keys=True, indent=4, separators=(',', ': '))

def payload(self, **kwargs):
self.data.update(kwargs)
# TODO: maybe compile here? or think how to make work and not deadlock from the api
self.data['compiled_genreq'] = requestGenerator(self)
return self.data['compiled_genreq'].get_dictio()
try:
self.data.update(kwargs)
self.data['compiled_genreq'] = requestGenerator(self)
for r in self.data['compiled_genreq'].get_dictio():
yield r
finally:
self.data['compiled_genreq'].close()

def fuzz(self, **kwargs):
self.data.update(kwargs)
Expand Down Expand Up @@ -303,7 +306,3 @@ def close(self):

if self.fz:
self.fz.cancel_job()

# TODO: deadlock when using api.payload()
elif self.data['compiled_genreq'] is not None:
self.data['compiled_genreq'].close()
12 changes: 2 additions & 10 deletions src/wfuzz/wfuzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ def usage():
\t--efield <expr> : Show the specified language expression together with the current payload
""")

# TODO: from .api import payload
from .api import FuzzSession
from .api import payload
from .exception import FuzzExceptBadOptions
import getopt

Expand Down Expand Up @@ -112,15 +111,11 @@ def usage():
field = value
raw_output = True

session = None

try:
session_options = CLParser(sys.argv).parse_cl()
# TODO: api.payload will block with new shodanp
session = FuzzSession(**session_options)
printer = None

for res in session.payload():
for res in payload(**session_options):
if len(res) > 1:
raise FuzzExceptBadOptions("wfpayload can only be used to generate one word dictionaries")
else:
Expand Down Expand Up @@ -148,9 +143,6 @@ def usage():
print(("\nFatal exception: %s" % str(e)))
except Exception as e:
print(("\nUnhandled exception: %s" % str(e)))
finally:
if session:
session.close()


def main_encoder():
Expand Down

0 comments on commit 73307b5

Please sign in to comment.