Пример #1
0
def main():
    """ Get file list from args and execute """
    global args

    args = parser.parse_args()
    add_destination(log_stdout)

    for filename in args.filename:
        try:
            print('Loading {}'.format(color.cyan(filename)))

            if from_file(filename):
                result = color.green('Success.')
            else:
                result = color.red('No match.')

            print('==> {}'.format(result))

        except ParserException as exc:
            print(color.yellow('ERROR parsing file %s: %s' % (filename, exc)))
        except (ConnectionException, ProxyException) as exc:
            print(
                color.yellow('ERROR connecting to host in file %s: %s' %
                             (filename, exc)))
        except ExploException as exc:
            print(color.yellow('ERROR in file %s: %s' % (filename, exc)))
Пример #2
0
def pretty_print_request(req):
    """ Print a request """

    output = '{} {} {}\n'.format(color.yellow(req.method), color.cyan(req.url), color.grayscale[14]('HTTP/1.1'))
    output += '\n'.join('{}: {}'.format(color.grayscale[14](k), color.cyan(v)) for k, v in req.headers.items())
    output += '\n\n{}'.format(req.body)

    Message.log(level='request', message=output)
Пример #3
0
def log_stdout(message):
    if 'message' in message:

        level = message.get('level', '')
        if level == 'request' or level == 'response':
            if args and not args.verbose:
                return

            print('\n')

        level_msg = color.yellow('Warning: ') if level == 'warning' else ''

        print("{}{}".format(level_msg, message['message']))
Пример #4
0
def pretty_print_response(res):
    """ Print a response """

    # Status line
    output = color.yellow('HTTP') + color.grayscale[14]('/1.1 %s %s\n' % (res.status_code, res.reason))

    # Headers
    for name, value in res.headers.items():
        output += '%s: %s\n' % (color.grayscale[14](name), color.cyan(value))

    output += '\n'

    # Body
    output += res.text

    Message.log(level='response', message=output)