1. Tim Tomes
  2. Recon-ng
  3. Issues


Issue #2 resolved

Spool Output

Tim Tomes
repo owner created an issue

Add the ability to spool all framework output to a file.

Comments (9)

  1. Tim Tomes reporter

    2 of us spent a bunch of time on this last night and today. We came up with 2 possibilities:

    • Hijack stdout using something like the following:
    # In recon-ng.py, have a global flag which determines whether or not you are in spool mode.
    __builtin__.spool = 0
    # In framework.py, create a class like this:
    class writer :
        def __init__(self, filename) :
            spool = open(filename)
            self.writers = (sys.stdout, spool)
        def write(self, text) :
            for w in self.writers :
    # In framework.py, add a method to the framework to control spooling.
        def do_spool(self, params):
            if not __builtin__.spool:
                sys.stdout = writer(self.goptions['spool_file'])
                self.output('Spooling ON.')
                sys.stdout = sys.__stdout__
                self.output('Spooling OFF.')

    However, this breaks things like tab completion.

    • Create a custom print function and force all developers to use it by implementing from __future__ import print_function.

    While this is a little unorthodox and less pythonic, it is much more flexible and makes for an easy transition to Python3.

  2. Quentin Kaiser

    If you change the stdout value when creating a Cmd.py instance it will output to the file you provide and not to the default sys.stdout so the user won't see anything :)

  3. Tim Tomes reporter

    I don't want the output to change at all from what it is doing now. Tee functionality would be perfect. Continue to see stdout as is, but also write to a file. Make sense?

  4. Quentin Kaiser

    The user see exactly the same thing as before and tab completion works. The framework print to an output file too when spooling is on. The question is : is this relevant to print to the output file the commands that the user enter ? What about completion ? Do we output it in the file too ?

  5. Tim Tomes reporter

    I think the output should be identical so that when users or clients review the data, the fully understand the input that drove the output. Also, I would open file in append mode. That way users don't accidentally blow out old data that they forgot to rename, move, etc.

  6. Log in to comment