Skip to content

Commit

Permalink
Merge pull request #69 from tristanlatr/60---show_html-flag
Browse files Browse the repository at this point in the history
Add options --show_html and --show_json
  • Loading branch information
tristanlatr authored May 9, 2023
2 parents 0cfd291 + 2791ba5 commit d23ea19
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
14 changes: 13 additions & 1 deletion docs/source/all-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,20 @@ All configuration options
- File path or None
- None

* - Inspect a report in database
* - Print a report in database
- NA
- ``--show``
- String
- None

* - Print a report in database in HTML format, use with --quiet to print only HTML content
- NA
- ``--show_html``
- String
- None

* - Print a report in database in JSON format, use with --quiet to print only JSON content
- NA
- ``--show_json``
- String
- None
2 changes: 1 addition & 1 deletion wpwatcher/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Project version and meta informations.
"""

__version__ = "3.0.6"
__version__ = "3.0.7"
__title__ = "wpwatcher"
__description__ = "WPWatcher - Automating WPScan to scan and report vulnerable Wordpress sites"
__author__ = "Florian Roth, Tristan Landes"
Expand Down
29 changes: 25 additions & 4 deletions wpwatcher/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ def main(_args: Optional[Sequence[Text]] = None) -> None:
filepath=configuration["wp_reports"],
daemon=args.daemon,
)
if args.show_html:
show(
urlpart=args.show_html,
filepath=configuration["wp_reports"],
daemon=args.daemon,
format='html',
)
if args.show_json:
show(
urlpart=args.show_json,
filepath=configuration["wp_reports"],
daemon=args.daemon,
format='json',
)

# Launch syslog test
if args.syslog_test:
Expand All @@ -80,18 +94,18 @@ def wprs(filepath: Optional[str] = None, daemon: bool = False) -> None:
exit(0)


def show(urlpart: str, filepath: Optional[str] = None, daemon: bool = False) -> None:
def show(urlpart: str, filepath: Optional[str] = None, daemon: bool = False, format:str='cli') -> None:
"""Inspect a report in database"""
db = DataBase(filepath, daemon=daemon)
matching_reports = [r for r in db._data if urlpart in r["site"]]
eq_reports = [r for r in db._data if urlpart == r["site"]]
if len(eq_reports):
print(
format_results(eq_reports[0], format="cli")
format_results(eq_reports[0], format=format)
)
elif len(matching_reports) == 1:
print(
format_results(matching_reports[0], format="cli")
format_results(matching_reports[0], format=format)
)
elif len(matching_reports) > 1:
print(
Expand All @@ -101,6 +115,7 @@ def show(urlpart: str, filepath: Optional[str] = None, daemon: bool = False) ->
repr(ReportCollection(matching_reports))
)
print("\nPlease be more specific. \n")
exit(1)
else:
print("No report found")
exit(1)
Expand Down Expand Up @@ -306,7 +321,13 @@ def get_arg_parser() -> argparse.ArgumentParser:
default=False,
)
parser.add_argument(
"--show", metavar="Site", help="Inspect a report in the Database"
"--show", metavar="Site", help="Print a report in the Database in text format."
)
parser.add_argument(
"--show_html", metavar="Site", help="Print a report in the Database in HTML format, use with --quiet to print only HTML content."
)
parser.add_argument(
"--show_json", metavar="Site", help="Print a report in the Database in JSON format, use with --quiet to print only JSON content."
)
return parser

Expand Down

0 comments on commit d23ea19

Please sign in to comment.