Skip to content
This repository has been archived by the owner on Oct 12, 2021. It is now read-only.

Basic Python 3 Conversion #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions engine/brute.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import os
import urllib

from core import *
from wordpress import *
from thread_engine import ThreadEngine
from engine.core import *
from engine.wordpress import *
from engine.thread_engine import ThreadEngine

class Brute_Engine:
def __init__(self, wordpress, brute, usernames, users_list, passwords_list):
Expand Down Expand Up @@ -39,7 +39,7 @@ def __init__(self, wordpress, brute, usernames, users_list, passwords_list):

print(notice("Bruteforcing detected users: "))
for user in wordpress.users:
print info("User found "+ user['slug'])
print(info("User found "+ user['slug']))
self.bruteforcing_pass(wordpress, user['slug'], passwords_list)


Expand Down
18 changes: 9 additions & 9 deletions engine/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ def unzip_file(filename):
warning : user-agents.txt and timthumbs.txt are zip files
"""
def database_update():
print "\033[93mUpdating database\033[92m - Last update: \033[0m" + database_last_date('database/local_vulnerable_files.xml')
print("\033[93mUpdating database\033[92m - Last update: \033[0m" + database_last_date('database/local_vulnerable_files.xml'))
update_url = "https://data.wpscan.org/"
update_files = [ 'local_vulnerable_files.xml', 'local_vulnerable_files.xsd',
'timthumbs.txt', 'user-agents.txt', 'wp_versions.xml', 'wp_versions.xsd',
'wordpresses.json', 'plugins.json', 'themes.json']

for f in update_files:
print "\t\033[93mDownloading \033[0m"+ f +" \033[92mFile updated !\033[0m"
print("\t\033[93mDownloading \033[0m"+ f +" \033[92mFile updated !\033[0m")
download_raw_file(update_url+f, "database/"+f, True)

unzip_file("database/user-agents.txt")
Expand Down Expand Up @@ -214,26 +214,26 @@ def display_vulnerable_component(name, version, file):
with open('database/' + file + '.json') as data_file:
data = json.load(data_file)

print warning("Name: %s - v%s" % (name, version))
print(warning("Name: %s - v%s" % (name, version)))
if name in data.keys():

# Display the out of date info if the version is lower of the latest version
if is_lower(version, data[name]['latest_version'], False):
print info("The version is out of date, the latest version is %s" % data[name]['latest_version'])
print(info("The version is out of date, the latest version is %s" % data[name]['latest_version']))

# Display the vulnerability if it's not patched version
for vuln in data[name]['vulnerabilities']:
if 'fixed_in' in vuln.keys() and (vuln['fixed_in'] == None or is_lower(version, vuln['fixed_in'], True)):

# Main informations
print "\t",vulnerable("%s : %s - ID:%s" % (vuln['vuln_type'], vuln['title'] , vuln['id']) )
print "\t",display("Fixed in %s"% vuln['fixed_in'])
print("\t",vulnerable("%s : %s - ID:%s" % (vuln['vuln_type'], vuln['title'] , vuln['id']) ))
print("\t",display("Fixed in %s"% vuln['fixed_in']))

# Display references
print "\t",display("References:")
print("\t",display("References:"))
for refkey in vuln['references'].keys():
for ref in vuln['references'][refkey]:
if refkey != 'url':
print "\t\t - %s %s" % (refkey.capitalize(), ref)
print("\t\t - %s %s" % (refkey.capitalize(), ref))
else:
print "\t\t - %s" %ref
print("\t\t - %s" % ref)
14 changes: 7 additions & 7 deletions engine/fuzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import json

from tornado import ioloop, httpclient
from core import *
from wordpress import *
from engine.core import *
from engine.wordpress import *
from lxml import etree
from multiprocessing import Process, Pool

Expand All @@ -22,7 +22,7 @@ def __init__(self, wordpress, fuzz):
description : fuzz every component used by the wordpress
"""
def fuzzing_component_aggressive(self, wordpress):
print notice("Enumerating components from aggressive fuzzing ...")
print(notice("Enumerating components from aggressive fuzzing ..."))

# Load json file
with open('fuzz/wordpress.fuzz') as data_file:
Expand All @@ -45,7 +45,7 @@ def fuzzing_component_aggressive(self, wordpress):
description : fuzz every themes used by the wordpress
"""
def fuzzing_themes_aggressive(self, wordpress):
print notice("Enumerating themes from aggressive fuzzing ...")
print(notice("Enumerating themes from aggressive fuzzing ..."))

# Load json file
with open('fuzz/wp_themes.fuzz') as data_file:
Expand All @@ -68,7 +68,7 @@ def fuzzing_themes_aggressive(self, wordpress):
description : fuzz every plugins used by the wordpress
"""
def fuzzing_plugins_aggressive(self, wordpress):
print notice("Enumerating plugins from aggressive fuzzing ...")
print(notice("Enumerating plugins from aggressive fuzzing ..."))

# Load json file
with open('fuzz/wp_plugins.fuzz') as data_file:
Expand Down Expand Up @@ -106,9 +106,9 @@ def aggressive_request_themes(response):
def aggressive_request_component(response):
if (response.code) == 200:
if "reauth" in response.effective_url:
print "[i] Authentication Needed: " + response.effective_url+ " - found"
print("[i] Authentication Needed: " + response.effective_url+ " - found")
else:
print "[i] File: " + response.effective_url+ " - found"
print("[i] File: " + response.effective_url+ " - found")

global iter_aggressive
iter_aggressive-= 1
Expand Down
6 changes: 3 additions & 3 deletions engine/load_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import os
import imp

from wordpress import *
from engine.wordpress import *

class Load_Plugins:
plugin_folder = "./plugins"

def __init__(self, wordpress):
available_plugins = os.listdir(self.plugin_folder)
for plugins in available_plugins:
if not ".pyc" in plugins and not "__init__" in plugins:
if not ".pyc" in plugins and not "__init__" in plugins and not "__pycache__" in plugins:

# Find and load the package
name = plugins.replace('.py','')
Expand All @@ -26,5 +26,5 @@ def __init__(self, wordpress):
loaded = imp.load_module('plugins.' + name, f, file, desc)

# Run the __init__
print notice('Plugin %s loaded.' % loaded.name)
print(notice('Plugin %s loaded.' % loaded.name))
loaded.__init__(wordpress)
32 changes: 16 additions & 16 deletions engine/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import json

from tornado import ioloop, httpclient
from core import *
from wordpress import *
from engine.core import *
from engine.wordpress import *
from lxml import etree
from multiprocessing import Process, Pool

Expand All @@ -30,7 +30,7 @@ def fingerprint_wp_version_meta_based(self, wordpress):
match = regex.findall(wordpress.index.text)
if match != []:
wordpress.version = match[0]
print critical("WordPress version %s identified from advanced fingerprinting" % wordpress.version)
print(critical("WordPress version %s identified from advanced fingerprinting" % wordpress.version))
return True
return False

Expand All @@ -45,7 +45,7 @@ def fingerprint_wp_version_feed_based(self, wordpress):
match = regex.findall(r)
if match != []:
wordpress.version = match[0]
print critical("WordPress version %s identified from advanced fingerprinting" % wordpress.version)
print(critical("WordPress version %s identified from advanced fingerprinting" % wordpress.version))
return True
return False

Expand Down Expand Up @@ -79,7 +79,7 @@ def fingerprint_wp_version_hash_based(self, wordpress):
# Detect the version
if ddl_hash == root[i][j].get('md5'):
wordpress.version = root[i][j][0].text
print critical("WordPress version %s identified from advanced fingerprinting" % wordpress.version)
print(critical("WordPress version %s identified from advanced fingerprinting" % wordpress.version))
return


Expand Down Expand Up @@ -110,7 +110,7 @@ def list_wp_version_vulnerabilities(self, wordpress, file):

# This version doesn't exist
if wordpress.version not in data:
print warning("The version %s isn't in the database - Please try the option --update" % (wordpress.version))
print(warning("The version %s isn't in the database - Please try the option --update" % (wordpress.version)))
return

if data[wordpress.version]["vulnerabilities"] == []:
Expand All @@ -124,28 +124,28 @@ def list_wp_version_vulnerabilities(self, wordpress, file):
for vuln in data[version]["vulnerabilities"]:

# Basic infos
print warning("\t%s : %s - ID:%s" % (vuln['vuln_type'], vuln['title'] , vuln['id']) )
print info("\tFixed in %s"% vuln['fixed_in'])
print(warning("\t%s : %s - ID:%s" % (vuln['vuln_type'], vuln['title'] , vuln['id'])))
print(info("\tFixed in %s"% vuln['fixed_in']))

# Display references
print info("\tReferences:")
print(info("\tReferences:"))
for refkey in vuln['references'].keys():
for ref in vuln['references'][refkey]:

if refkey != 'url':
print "\t\t - %s %s" % (refkey.capitalize(), ref)
print("\t\t - %s %s" % (refkey.capitalize(), ref))
else:
print "\t\t - %s" %ref
print("\t\t - %s" % ref)

print ""
print("")


"""
name : enumerating_themes_passive(self, wordpress)
description : enumerate every theme used by the wordpress
"""
def enumerating_themes_passive(self, wordpress):
print notice("Enumerating themes from passive detection ...")
print(notice("Enumerating themes from passive detection ..."))

# Theme name (css file)
regex = re.compile('wp-content/themes/(.*?)/.*?[css|js].*?ver=([0-9\.]*)')
Expand Down Expand Up @@ -173,7 +173,7 @@ def enumerating_themes_passive(self, wordpress):
description : enumerate every plugins used by the wordpress
"""
def enumerating_plugins_passive(self, wordpress):
print notice("Enumerating plugins from passive detection ...")
print(notice("Enumerating plugins from passive detection ..."))

# Plugin name (js file)
regex = re.compile('wp-content/plugins/(.*?)/.*?[css|js].*?ver=([0-9\.]*)')
Expand Down Expand Up @@ -201,7 +201,7 @@ def enumerating_plugins_passive(self, wordpress):
description : enumerate every themes used by the wordpress
"""
def enumerating_themes_aggressive(self, wordpress):
print notice("Enumerating themes from aggressive detection ...")
print(notice("Enumerating themes from aggressive detection ..."))

# Load json file
with open('database/themes.json') as data_file:
Expand All @@ -222,7 +222,7 @@ def enumerating_themes_aggressive(self, wordpress):
description : enumerate every plugins used by the wordpress
"""
def enumerating_plugins_aggressive(self, wordpress):
print notice("Enumerating plugins from aggressive detection ...")
print(notice("Enumerating plugins from aggressive detection ..."))

# Load json file
with open('database/plugins.json') as data_file:
Expand Down
12 changes: 6 additions & 6 deletions engine/thread_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
# -*- coding: utf-8 -*-
from threading import Thread
# from time import sleep
from core import critical, info
from engine.core import critical, info


class ThreadEngine(object):
def __init__(self, max_threads):
if max_threads < 1:
print critical('Threads number must be > 0')
print(critical('Threads number must be > 0'))
exit()
self.max_threads = max_threads
self.threads = []
print info('Start %d threads ...' % self.max_threads)
print(info('Start %d threads ...' % self.max_threads))

def new_task(self, task, args):
""" Try to launch the new task,
Expand All @@ -38,9 +38,9 @@ def launch_task(self, task, args):

def clean_threads(self):
""" Remove ended threads """
for thread in self.threads:
if not thread.isAlive():
self.threads.remove(thread)
for thread in self.threads:
if not thread.isAlive():
self.threads.remove(thread)

def wait(self):
""" Wait for threads end """
Expand Down
Loading