Skip to content

Commit

Permalink
[ADD] unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav WEB committed Jan 31, 2017
1 parent 92eb395 commit 502b9ec
Show file tree
Hide file tree
Showing 11 changed files with 279 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ opendoor.egg-info/
/dist/
/tmp/
/reports/
/data/directories.dat.back
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ install:
- pip install mock
- pip install nose
- pip install unittest2
- pip install json2html
- pip install urllib3
- pip install tabulate
- pip install pypandoc
- pip install coveralls
notifications:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ sudo apt-get install python-socksipy

#### [Changelog](CHANGELOG.md) (last changes)

<sub>v3.0.1-alfa (31.01.2017)</sub>
<sub>v3.0.1-beta (31.01.2017)</sub>
-------------------------
- relieved of unnecessary dependencies
- fully optimized code inside
Expand Down
196 changes: 196 additions & 0 deletions data/shells.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
accept_language.py
angel.py
azrailphp.py
b1n4ry.py
b374k.py
bv7binary.py
c100.py
c99.py
commandshell.py
cwshell.py
cyberwarrior.py
ernebypass.py
g6shell.py
g6sshell.py
gazashell.py
h4cker.py
indishell.py
injection.py
iranshell.py
ironshell.py
k2ll33d.py
kacak.py
locus7shell.py
lostdcshell.py
mailershell.py
matamu.py
megabor.py
pouyaserver.py
r57.py
safe_mode_bypass.py
saudishell.py
simattacker.py
simshell.py
sosyeteshell.py
sqlshell.py
symlink.py
syrianshell.py
tryagshell.py
tryagshell.py
unknown.py
untitled.py
uploadshell.py
webacoo.py
webadmin.py
webroot.py
weevely.py
wsoshell.py
zehir4shell.py
zehirshell.py
accept_language.inc
angel.inc
azrailphp.inc
b1n4ry.inc
b374k.inc
bv7binary.inc
c100.inc
c99.inc
commandshell.inc
cwshell.inc
cyberwarrior.inc
ernebypass.inc
g6shell.inc
g6sshell.inc
gazashell.inc
h4cker.inc
indishell.inc
injection.inc
iranshell.inc
ironshell.inc
k2ll33d.inc
kacak.inc
locus7shell.inc
lostdcshell.inc
mailershell.inc
matamu.inc
megabor.inc
pouyaserver.inc
r57.inc
safe_mode_bypass.inc
saudishell.inc
simattacker.inc
simshell.inc
sosyeteshell.inc
sqlshell.inc
symlink.inc
syrianshell.inc
tryagshell.inc
tryagshell.inc
unknown.inc
untitled.inc
uploadshell.inc
webacoo.inc
webadmin.inc
webroot.inc
weevely.inc
wsoshell.inc
zehir4shell.inc
zehirshell.inc
accept_language.php.php
angel.php
azrailphp.php
b1n4ry.php
b374k.php
bv7binary.php
c100.php
c99.php
commandshell.php
cwshell.php
cyberwarrior.php
ernebypass.php
g6shell.php
g6sshell.php
gazashell.php
h4cker.php
indishell.php
injection.php
iranshell.php
ironshell.php
k2ll33d.php
kacak.php
locus7shell.php
lostdcshell.php
mailershell.php
matamu.php
megabor.php
pouyaserver.php
r57.php
safe_mode_bypass.php
saudishell.php
simattacker.php
simshell.php
sosyeteshell.php
sqlshell.php
symlink.php
syrianshell.php
tryagshell.php
tryagshell.php
unknown.php
untitled.php
uploadshell.php
webacoo.php
webadmin.php
webroot.php
weevely.php
wsoshell.php
zehir4shell.php
zehirshell.php
accept_language.phtml
angel.phtml
azrailphp.phtml
b1n4ry.phtml
b374k.phtml
bv7binary.phtml
c100.phtml
c99.phtml
commandshell.phtml
cwshell.phtml
cyberwarrior.phtml
ernebypass.phtml
g6shell.phtml
g6sshell.phtml
gazashell.phtml
h4cker.phtml
indishell.phtml
injection.phtml
iranshell.phtml
ironshell.phtml
k2ll33d.phtml
kacak.phtml
locus7shell.phtml
lostdcshell.phtml
mailershell.phtml
matamu.phtml
megabor.phtml
pouyaserver.phtml
r57.phtml
safe_mode_bypass.phtml
saudishell.phtml
simattacker.phtml
simshell.phtml
sosyeteshell.phtml
sqlshell.phtml
symlink.phtml
syrianshell.phtml
tryagshell.phtml
tryagshell.phtml
unknown.phtml
untitled.phtml
uploadshell.phtml
webacoo.phtml
webadmin.phtml
webroot.phtml
weevely.phtml
wsoshell.phtml
zehir4shell.phtml
zehirshell.phtml
2 changes: 1 addition & 1 deletion opendoor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import sys


for module in ['urllib3', 'json2html','tabulate']:
for module in ['urllib3', 'json2html','tabulate','importlib']:
try:
__import__(module)
except ImportError:
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
packages=find_packages(), include_package_data=True,

# Choose your license
license='GPL', test_suite='tests',
license='GPL',
# Unittests suite directory
test_suite='tests',

# What does your project relate to?
keywords=['owasp scanner', 'directory scanner', 'access directory scanner', 'web spider', 'auth scanner',
Expand Down
14 changes: 7 additions & 7 deletions src/core/filesystem/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def makedir(directory, mode=0777):

if not os.path.exists(directory):
try:
directory = os.path.join(os.getcwd(), directory)
directory = os.path.join(directory)
os.makedirs(directory + '/', mode=mode)
except OSError as e:
if e.errno != errno.EEXIST:
Expand All @@ -71,7 +71,7 @@ def getabsname(filename):
:return: str
"""

filename = os.path.join(os.getcwd(), filename)
filename = os.path.join(filename)
return os.path.abspath(filename)

@staticmethod
Expand Down Expand Up @@ -116,7 +116,7 @@ def makefile(filename):
:return: Bool
"""

filename = os.path.join(os.getcwd(), filename)
filename = os.path.join(filename)

if False is os.path.exists(filename):
try:
Expand All @@ -141,7 +141,7 @@ def readline(filename, handler, handler_params, loader):
:return: str
"""

filepath = os.path.join(os.getcwd(), filename)
filepath = os.path.join(filename)
if not os.path.isfile(filepath):
raise FileSystemError("{0} is not a file ".format(filepath))
if not os.access(filepath, os.R_OK):
Expand All @@ -162,7 +162,7 @@ def read(filename):
:return: list
"""

filepath = os.path.join(os.getcwd(), filename)
filepath = os.path.join(filename)

if not os.path.isfile(filepath):
raise FileSystemError("{0} is not a file ".format(file))
Expand All @@ -182,7 +182,7 @@ def readcfg(filename):
:return: ConfigParser.RawConfigParser
"""

filepath = os.path.join(os.getcwd(), filename)
filepath = os.path.join(filename)
if not os.path.isfile(filepath):
raise FileSystemError("{0} is not a file ".format(filepath))
if not os.access(filepath, os.R_OK):
Expand All @@ -206,7 +206,7 @@ def writelist(filename, data, separator=''):
:return: None
"""

filepath = os.path.join(os.getcwd(), filename)
filepath = os.path.join(filename)
if not os.path.isfile(filepath):
raise FileSystemError("{0} is not a file ".format(file))
if not os.access(filepath, os.W_OK):
Expand Down
2 changes: 1 addition & 1 deletion src/lib/reporter/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
from .std import StdReportPlugin as std
from .txt import TextReportPlugin as txt
from .json import JsonReportPlugin as json

from .html import HtmlReportPlugin as html

64 changes: 64 additions & 0 deletions src/lib/reporter/plugins/html.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# -*- coding: utf-8 -*-

"""
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Development Team: Stanislav WEB
"""


from .provider import PluginProvider
from src.core import filesystem , FileSystemError
from src.lib import tpl
from json2html.jsonconv import Json2Html

class HtmlReportPlugin(PluginProvider):
""" HtmlReportPlugin class"""

PLUGIN_NAME = 'HtmlReport'
EXTENSION_SET = '.html'

def __init__(self, taget, data):
"""
PluginProvider constructor
:param str taget: target host
:param dict data: result set
"""

PluginProvider.__init__(self, taget, data)

try:
config = filesystem.readcfg('setup.cfg')
directory = config.get('opendoor', 'reports')
self.__target_dir = "".join((directory, self._target))
filesystem.makedir(self.__target_dir)
except FileSystemError as e:
raise Exception(e)

def process(self):
"""
Process data
:return: str
"""

try:
filesystem.clear(self.__target_dir, extension=self.EXTENSION_SET)
filename = "".join((self.__target_dir, filesystem.sep, self._target, self.EXTENSION_SET))
filesystem.makefile(filename)
resultset = Json2Html().convert(json=self._data, table_attributes='border="1" cellpadding="2"')
filesystem.writelist(filename, resultset)
tpl.info(key='report', plugin=self.PLUGIN_NAME, dest=filesystem.getabsname(filename))

except FileSystemError as e:
raise Exception(e)

2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Development Team: Stanislav WEB
"""

pass
pass
1 change: 1 addition & 0 deletions tests/reports/.coverage.WEB.15782.418693
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!coverage.py: This is a private format, don't read it directly!{"lines": {}}

0 comments on commit 502b9ec

Please sign in to comment.