Skip to content

Commit

Permalink
Merge pull request xmendez#15 from misterade/master
Browse files Browse the repository at this point in the history
Added json printer
  • Loading branch information
xmendez committed May 11, 2016
2 parents 5dd6336 + 89584eb commit e30f492
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 13 deletions.
60 changes: 47 additions & 13 deletions plugins/printers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import socket
import sys
import json as jjson
from xml.dom import minidom

import os
Expand Down Expand Up @@ -38,11 +39,11 @@ def header(self, summary):
doc = minidom.Document()

#<magictree class="MtBranchObject">
self.node_mt = doc.createElement("magictree")
self.node_mt = doc.createElement("magictree")
self.node_mt.setAttribute("class", "MtBranchObject")

#<testdata class="MtBranchObject">
node_td = doc.createElement("testdata")
node_td = doc.createElement("testdata")
node_td.setAttribute("class", "MtBranchObject")
self.node_mt.appendChild(node_td)

Expand Down Expand Up @@ -80,7 +81,7 @@ def result(self, fuzz_result):

location = ""
if 'Location' in fuzz_result.history.fr_headers()['response']:
location = fuzz_result.history.fr_headers()['response']['Location']
location = fuzz_result.history.fr_headers()['response']['Location']

if fuzz_result.code == 301 or fuzz_result.code == 302 and location:
self.__create_xml_element(node_url, "RedirectLocation", location)
Expand Down Expand Up @@ -194,14 +195,14 @@ def _write(self, text, line_suffix, color = ("", 8)):
else:
WConio.textcolor(wc)

self._write_line(text, line_suffix)
self._write_line(text, line_suffix)

if wc != "":
if self.OS!='nt':
sys.stdout.write("\033[0;0m")
else:
WConio.textcolor(8)

def _print(self, res, line_suffix):
self._erase()

Expand All @@ -211,13 +212,13 @@ def _print(self, res, line_suffix):
if res.exception:
self._write("XXX", line_suffix, self._get_code_color(res.code) if self.colour else ("",8))
else:
self._write("%03d" % (res.code), line_suffix, self._get_code_color(res.code) if self.colour else ("",8))
self._write("%03d" % (res.code), line_suffix, self._get_code_color(res.code) if self.colour else ("",8))
self._write(" %4d L\t %5d W\t %5d Ch\t \"%s\"%s" % (res.lines, res.words, res.chars, res.description, line_suffix), line_suffix, txt_color)

if line_suffix != "":
for i in res.plugins_res:
print " |_ %s\r" % i.issue

sys.stdout.flush()

def header(self, summary):
Expand Down Expand Up @@ -274,12 +275,12 @@ def _print(self, res, line_suffix):

txt_color = ("", 8) if not res.is_baseline or not self.colour else (term_colors.fgCyan, 8)

self._write("%05d: " % (res.nres), line_suffix, txt_color)
self._write("%.3fs C=" % (res.timer), line_suffix, txt_color)
self._write("%05d: " % (res.nres), line_suffix, txt_color)
self._write("%.3fs C=" % (res.timer), line_suffix, txt_color)

location = ""
if 'Location' in res.history.fr_headers()['response']:
location = res.history.fr_headers()['response']['Location']
location = res.history.fr_headers()['response']['Location']
elif res.history.fr_url() != res.history.fr_redirect_url():
location = "(*) %s" % res.history.fr_url()

Expand All @@ -290,13 +291,46 @@ def _print(self, res, line_suffix):
if res.exception:
self._write("XXX", line_suffix, self._get_code_color(res.code) if self.colour else ("",8))
else:
self._write("%03d" % (res.code), line_suffix, self._get_code_color(res.code) if self.colour else ("",8))
self._write("%03d" % (res.code), line_suffix, self._get_code_color(res.code) if self.colour else ("",8))

self._write(" %4d L\t %5d W\t %5d Ch %20.20s %51.51s \"%s\"%s" % (res.lines, res.words, res.chars, server[:17], location[:48], res.description, line_suffix), line_suffix, txt_color)

if line_suffix != "":
for i in res.plugins_res:
print " |_ %s\r" % i.issue

sys.stdout.flush()

@moduleman_plugin("header", "footer", "noresult", "result")
class json:
name = "json"
description = "Results in json format"
category = ["default"]
priority = 99

json_res = []

def header(self, res):
pass

def result(self, res):
server = ""
if 'Server' in res.history.fr_headers()['response']:
server = res.history.fr_headers()['response']['Server']
location = ""
if 'Location' in res.history.fr_headers()['response']:
location = res.history.fr_headers()['response']['Location']
elif res.history.fr_url() != res.history.fr_redirect_url():
location = "(*) %s" % res.history.fr_url()
post_data = {}
if res.history.fr_method().lower() == "post":
for n, v in res.history.fr_parameters()['post'].items():
post_data[n] = v

res_entry = {"lines": res.lines, "words": res.words, "chars" : res.chars, "url":res.url, "description":res.description, "location" : location, "server" : server, "server" : server, "postdata" : post_data}
self.json_res.append(res_entry)

def noresult(self, res):
pass
def footer(self, summary):
print jjson.dumps(self.json_res)
Empty file modified wfuzz.py
100644 → 100755
Empty file.

0 comments on commit e30f492

Please sign in to comment.