Skip to content

Commit da2d127

Browse files
committed
CLI support reorganised and tested on Linux
1 parent 746f1db commit da2d127

20 files changed

+159
-90
lines changed

LINUX-INSTALL.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
```
2+
# setup ve directory
3+
cd ~/x/w
4+
git clone https://github.com/hvqzao/ve
5+
6+
# configure ve
7+
./ve -P 2.7.13
8+
# <-- press [Enter] to confirm build settings
9+
10+
cat >.ve <<EOF
11+
PY="py-2.7.13"
12+
VE_BIN="bin"
13+
EOF
14+
15+
# enable ve
16+
. ./ve
17+
18+
# pip update
19+
pip install --upgrade pip
20+
21+
# get report-ng
22+
git clone https://github.com/hvqzao/report-ng
23+
24+
# meet report-ng requirements
25+
pip install cx_freeze==4.3.3
26+
pip install lxml==3.3.5
27+
# no wxpython
28+
pip install pillow
29+
pip install pyaml
30+
pip install beautifulsoup==3.2.1
31+
32+
cd report-ng
33+
```
34+
35+
# NOT TESTED:
36+
#
37+
# http://stackoverflow.com/questions/32284938/how-to-properly-install-wxpython
38+
# https://wiki.wxpython.org/How%20to%20install%20wxPython#Installing_wxPython-Phoenix_using_pip
39+
#
40+
# pip install --upgrade --trusted-host wxpython.org --pre -f http://wxpython.org/Phoenix/snapshot-builds/ wxPython_Phoenix
41+

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ of report-files. Application currently supports one set of switches:
5959
-r report-file
6060
```
6161

62+
Example use:
63+
64+
```
65+
python report-ng.py -t examples/example-2-scan-report-template.xml -c examples/example-2-content.yaml -k examples/example-2-kb.yaml -s examples/example-2-scan-export-Burp.xml -r examples/\!.xml
66+
```
67+
6268
## Word Template Preparation
6369

6470
This application was tested with Office 2010 Word documents saved with
@@ -232,7 +238,7 @@ Scan Details (Full) with XML Export Format. For Burp use Report Selected
232238
Issues, select XML and pick Base64-encode requests and responses.
233239

234240
At the time of writing, everything works smoothly with HP WebInspect 10.50,
235-
BurpSuite Pro 1.7.03 and Microsoft Office 2013. No modifications were
241+
BurpSuite Pro 1.7.19 and Microsoft Office 2013. No modifications were
236242
necessary.
237243

238244
## License

cxfreeze.cmd

100644100755
File mode changed.

examples/example-2-kb.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
- Name: ASP.NET Application Level-Trace Log
66
Severity: High
77
TestersComment: Less wise words here.
8+
- Name: Cross-site scripting (reflected)
9+
Severity: High
10+
TestersComment: <html><b><redwhite>A</redwhite></b> <red>B</red> <yellow>C</yellow>.</html>

report-ng.py

100644100755
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# report-ng
2-
# Copyright (c) 2015 Marcin Woloszyn (@hvqzao)
2+
# Copyright (c) 2014-2017 Marcin Woloszyn (@hvqzao)
33
#
44
# This program is free software; you can redistribute it and/or
55
# modify it under the terms of the GNU General Public License
@@ -16,7 +16,11 @@
1616
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1717

1818

19-
from src.gui import GUI
20-
2119
if __name__ == '__main__':
22-
GUI()
20+
import sys
21+
if len(sys.argv) > 1:
22+
from src.cli import CLI
23+
CLI()
24+
else:
25+
from src.gui import GUI
26+
GUI()

src/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# report-ng
2-
# Copyright (c) 2015 Marcin Woloszyn (@hvqzao)
2+
# Copyright (c) 2014-2015 Marcin Woloszyn (@hvqzao)
33
#
44
# This program is free software; you can redistribute it and/or
55
# modify it under the terms of the GNU General Public License

src/burp.py

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# report-ng
2-
# Copyright (c) 2015 Marcin Woloszyn (@hvqzao)
2+
# Copyright (c) 2014-2015 Marcin Woloszyn (@hvqzao)
33
#
44
# This program is free software; you can redistribute it and/or
55
# modify it under the terms of the GNU General Public License

src/cli.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# report-ng
2+
# Copyright (c) 2015-2017 Marcin Woloszyn (@hvqzao)
3+
#
4+
# This program is free software; you can redistribute it and/or
5+
# modify it under the terms of the GNU General Public License
6+
# as published by the Free Software Foundation; either version 2
7+
# of the License, or (at your option) any later version.
8+
#
9+
# This program is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with this program; if not, write to the Free Software
16+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
18+
19+
import sys
20+
21+
from report import Report
22+
from scan import Scan
23+
from version import Version
24+
25+
class CLI(Version):
26+
27+
def __init__(self):
28+
29+
#def flagged (key):
30+
# return key in sys.argv
31+
32+
def value (key):
33+
if key in sys.argv:
34+
index = sys.argv.index(key)
35+
if len(sys.argv) > index + 1:
36+
return sys.argv[index + 1]
37+
return None
38+
39+
def is_yaml (filename):
40+
ext = '.yaml'
41+
return filename[-len(ext):] == ext
42+
43+
template_file = value('-t')
44+
content_file = value('-c')
45+
kb_file = value('-k')
46+
scan_file = value('-s')
47+
report_file = value('-r')
48+
49+
if template_file and report_file:
50+
report = Report()
51+
report.template_load_xml(template_file)
52+
if content_file:
53+
if is_yaml(content_file):
54+
report.content_load_yaml(content_file)
55+
else:
56+
report.content_load_json(content_file)
57+
if kb_file:
58+
if is_yaml(kb_file):
59+
report.kb_load_yaml(kb_file)
60+
else:
61+
report.kb_load_json(kb_file)
62+
if scan_file:
63+
report.scan = Scan(scan_file)
64+
report.xml_apply_meta()
65+
report.save_report_xml(report_file)
66+
print 'Report saved.'
67+
else:
68+
print 'Usage: '
69+
print
70+
print ' ' + self.title + '.exe -t template-file [-c content-file] [-k kb-file] [-s scan-file] -r report-file'
71+
print ' generate report'
72+
print
73+
print ' ' + self.title + '.exe [--help]'
74+
print ' display usage and exit'
75+
76+
77+
if __name__ == '__main__':
78+
#sys.argv += ['--help']
79+
#sys.argv += ['-t','aaa']
80+
#sys.argv = [sys.argv[0], '-t', 'asdad']
81+
CLI()

src/gui.py

100644100755
Lines changed: 2 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# report-ng
2-
# Copyright (c) 2017 Marcin Woloszyn (@hvqzao)
2+
# Copyright (c) 2014-2017 Marcin Woloszyn (@hvqzao)
33
#
44
# This program is free software; you can redistribute it and/or
55
# modify it under the terms of the GNU General Public License
@@ -926,71 +926,6 @@ def __init__(self, parent, content='', *args, **kwargs):
926926
self.CenterOnScreen()
927927
self.Show()
928928

929-
def CLI(self):
930-
self.__CLI(application=self)
931-
932-
class __CLI(wx.Frame):
933-
934-
# application
935-
936-
def __init__(self, application=None, *args, **kwargs):
937-
self.application = application
938-
wx.Frame.__init__(self, None, *args, **kwargs)
939-
self.Bind(wx.EVT_CLOSE, lambda x: self.Destroy())
940-
#self.Show()
941-
import sys
942-
943-
def val (key):
944-
if key in sys.argv:
945-
return sys.argv[sys.argv.index('-t')+1]
946-
else:
947-
return None
948-
949-
def is_yaml (filename):
950-
ext = '.yaml'
951-
return filename[-len(ext):] == ext
952-
953-
template_file = val('-t')
954-
content_file = val('-c')
955-
kb_file = val('-k')
956-
scan_file = val('-s')
957-
report_file = val('-r')
958-
959-
if template_file and report_file:
960-
report = Report()
961-
report.template_load_xml(template_file)
962-
if content_file:
963-
if is_yaml(content_file):
964-
report.content_load_yaml(content_file)
965-
else:
966-
report.content_load_json(content_file)
967-
if kb_file:
968-
if is_yaml(kb_file):
969-
report.kb_load_yaml(kb_file)
970-
else:
971-
report.kb_load_json(kb_file)
972-
if scan_file:
973-
report.scan = Scan(scan_file)
974-
report.xml_apply_meta(vulnparam_highlighting=self.menu_view_v.IsChecked(), truncation=self.menu_view_i.IsChecked())
975-
report.save_report_xml(report_file)
976-
else:
977-
print 'Usage: '
978-
print
979-
print ' '+self.application.title+'.exe'
980-
print ' start GUI application'
981-
print
982-
print ' '+self.application.title+'.exe -t template-file [-c content-file] [-k kb-file] [-s scan-file] -r report-file'
983-
print ' generate report'
984-
print
985-
print ' '+self.application.title+'.exe [any other arguments]'
986-
print ' display usage and exit'
987-
988-
self.Close()
989-
990-
def Destroy(self):
991-
#print 'destroying CLI'
992-
super(wx.Frame, self).Destroy()
993-
994929
# GUI class
995930

996931
def __init__(self):
@@ -999,12 +934,7 @@ def __init__(self):
999934
wx_app = wx.App(redirect=True) # redirect in wxpython 3.0 defaults to False
1000935
#self.TextWindow(None, title='asdasd', content='bsdsdasd')
1001936
import sys
1002-
#sys.argv = [sys.argv[0], '--help']
1003-
#sys.argv = [sys.argv[0], '-t', 'asdad']
1004-
if len(sys.argv) > 1:
1005-
self.CLI()
1006-
else:
1007-
self.MainWindow()
937+
self.MainWindow()
1008938
wx_app.MainLoop()
1009939

1010940

src/mangle.py

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# report-ng
2-
# Copyright (c) 2015 Marcin Woloszyn (@hvqzao)
2+
# Copyright (c) 2014-2015 Marcin Woloszyn (@hvqzao)
33
#
44
# This program is free software; you can redistribute it and/or
55
# modify it under the terms of the GNU General Public License

0 commit comments

Comments
 (0)