Commit 6941fb47 by fwkz

Adding mute() decorator that suppress functions from printing to sys.stdout.

parent 78c76930
......@@ -9,6 +9,7 @@ from routersploit.utils import (
random_text,
http_request,
boolify,
mute,
)
from routersploit import exploits
......
......@@ -8,6 +8,7 @@ from routersploit import (
print_success,
print_table,
http_request,
mute,
)
......@@ -62,6 +63,7 @@ class Exploit(exploits.Exploit):
else:
print_error("Credentials could not be found")
@mute
def check(self):
url = sanitize_url("{}:{}/password.cgi".format(self.target, self.port))
......
......@@ -87,6 +87,23 @@ def stop_after(space_number):
return _outer_wrapper
class DummyFile(object):
""" Mocking file object. Optimalization for the "mute" decorator. """
def write(self, x): pass
def mute(fn):
""" Suppress function from printing to sys.stdout """
@wraps(fn)
def wrapper(self, *args, **kwargs):
sys.stdout = DummyFile()
try:
return fn(self, *args, **kwargs)
finally:
sys.stdout = sys.__stdout__
return wrapper
def __cprint(*args, **kwargs):
""" Color print()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment