Skip to content

Commit

Permalink
Merge branch 'issue-109' into develop, close #109
Browse files Browse the repository at this point in the history
  • Loading branch information
elcodigok committed Apr 27, 2017
2 parents bc8b6cb + ecf3263 commit 63b3ce3
Show file tree
Hide file tree
Showing 4 changed files with 494 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ lib64
pip-log.txt
*.log

# report html
*.html

# Unit test / coverage reports
.coverage
.tox
Expand Down
39 changes: 36 additions & 3 deletions lib/cmdLineParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@


import os
from jinja2 import Environment, FileSystemLoader
import sys
import urllib2

Expand Down Expand Up @@ -50,6 +51,17 @@
from lib.restApiWordPress import restApiWordPress


PATH = os.path.dirname(os.path.abspath(__file__))
TEMPLATE_ENVIRONMENT = Environment(
autoescape=False,
loader=FileSystemLoader(os.path.join(PATH, '../templates')),
trim_blocks=False)


def render_template(template_filename, context):
return TEMPLATE_ENVIRONMENT.get_template(template_filename).render(context)


def cmdBanner():
"""Banner printing."""
print "\n"
Expand All @@ -70,9 +82,10 @@ def cmdBanner():
def cmdLineParser():
"""Implementation to WPHardening."""

version_wph = "1.6RC2"
usage = "usage: python %prog [options]"
version = colored('WPHardening', 'green') + ' version' + \
colored(' 1.6RC1', 'yellow') + '\n'
version = colored('WPHardening', 'green') + ' version ' + \
colored(version_wph, 'yellow') + '\n'

parser = OptionParser(usage, version=version)

Expand Down Expand Up @@ -127,7 +140,7 @@ def cmdLineParser():
"the target url for --plugins and --wp-config.")

hardening.add_option("--indexes", action="store_true", dest="indexes",
help="It allows you to display the contents of "
help="It deny you to display the contents of "
"directories.")

hardening.add_option("--minify", action="store_true", dest="minify",
Expand Down Expand Up @@ -191,6 +204,12 @@ def cmdLineParser():

if os.path.exists(options.path):

fname = "output.html"
context = {
'directory': options.path,
'version': version_wph
}

if checkWordpress(options.path, options.verbose).isWordPress():

if options.chown is not None:
Expand All @@ -200,20 +219,24 @@ def cmdLineParser():

if changeOwner.isValid():
changeOwner.changeOwner()
context['chown'] = options.chown

if options.chmod is not None:
chmodWordPress(
options.path, options.verbose
).changePermisions()
context['chmod'] = True

if options.robots is not None:
robotsWordPress(options.path).createRobots()
context['robots'] = True

if options.finger is not None:
deleteVersionWordPress(options.path).delete()
fingerprintingWordPress(
options.path, options.verbose
).searchStaticFile()
context['finger'] = True

if options.wpconfig is not None:

Expand All @@ -237,6 +260,7 @@ def cmdLineParser():

if options.indexes is not None:
indexesWordPress(options.path, options.verbose).createIndexes()
context['indexes'] = True

if options.timthumb is not None:
timthumbWordPress(options.path).checkTimbthumb()
Expand Down Expand Up @@ -266,15 +290,24 @@ def cmdLineParser():

if options.remove is not None:
removeWordPress(options.path).delete()
context['remove'] = True

if options.minify is not None:
minifyWordPress(options.path, options.verbose).minify()

if options.sixg is not None:
sixgWordPress(options.path, options.verbose).createFirewall()
context['sixg'] = True

if options.api is not None:
restApiWordPress(options.path).disableRestApi()
context['api'] = True

# output jinja2
with open(fname, 'w') as f:
html = render_template('index.html.tmpl', context)
f.write(html)

else:
log.add("Could not find the specified directory.")
print colored('\nCould not find the specified directory.\n', 'red')
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
GitPython
Jinja2
Loading

0 comments on commit 63b3ce3

Please sign in to comment.