Skip to content

Commit c8f9397

Browse files
authored
Merge pull request #83 from ccsplit/master
Make changes to the setup.py originally suggested by @MohitS10
2 parents 46086d6 + 04c01b9 commit c8f9397

26 files changed

+89
-46
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ install:
88
- pip install -r test-requirements.txt
99
- pip install pep8
1010
before_script:
11-
- pep8 -v *.py lib/
11+
- pep8 -v *.py VHostScan/
1212
script:
1313
- pytest

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
recursive-include VHostScan *.txt

README.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Install via pip using:
2828
$ pip install -r requirements.txt
2929
```
3030

31+
Or simply run `python setup.py install` and the dependencies should be installed. If there is an issue regarding
32+
running `python setup.py build_ext`, you will need to reinstall `numpy` using `pip uninstall numpy` and `pip install numpy==1.12.0`. This should resolve the issue as there are sometimes issues with numpy being installed through setup.py.
33+
3134
# Usage
3235

3336
| Argument | Description |
@@ -65,7 +68,7 @@ _Note that a number of these examples reference 10.10.10.29. This IP refers to B
6568
The most straightforward example runs the default wordlist against example.com using the default of port 80:
6669

6770
```bash
68-
$ VHostScan.py -t example.com
71+
$ VHostScan -t example.com
6972
```
7073

7174
### Quick Example with SSL
@@ -81,21 +84,21 @@ $ VHostScan.py -t example.com --ssl
8184
Say you have an SSH port forward listening on port 4444 fowarding traffic to port 80 on example.com's development machine. You could use the following to make VHostScan connect through your SSH tunnel via localhost:4444 but format the header requests to suit connecting straight to port 80:
8285

8386
```bash
84-
$ VHostScan.py -t localhost -b example.com -p 4444 -r 80
87+
$ VHostScan -t localhost -b example.com -p 4444 -r 80
8588
```
8689

8790
### STDIN
8891
VHostScan Supports piping from other applications and will treat information passed to VHostScan as wordlist data, for example:
8992
```bash
90-
$ cat bank.htb | VHostScan.py -t 10.10.10.29
93+
$ cat bank.htb | VHostScan -t 10.10.10.29
9194
```
9295

9396
![VHOSTScan STDIN Example](https://github.com/codingo/codingo.github.io/blob/master/assets/Bank%20VHOST%20Pipe%20Example.png)
9497

9598
### STDIN and WordList
9699
You can still specify a wordlist to use along with stdin. In these cases wordlist information will be appended to stdin. For example:
97100
```bash
98-
$ echo -e 'a.example.com\b.example.com' | VHostScan.py -t localhost -w ./wordlists/wordlist.txt
101+
$ echo -e 'a.example.com\b.example.com' | VHostScan -t localhost -w ./wordlists/wordlist.txt
99102
```
100103
### Fuzzy Logic
101104
Here is an example with fuzzy logic enabled. You can see the last comparison is much more similar than the first two (it is comparing the content not the actual hashes):
@@ -111,4 +114,11 @@ pip install -r test-requirements.txt
111114
pytest
112115
```
113116

117+
Or you can optionally run:
118+
119+
```bash
120+
pip install -r test-requirements.txt
121+
python setup.py test
122+
```
123+
114124
If you're thinking of adding a new feature to the project, consider also contributing with a couple of tests. A well-tested codebase is a sane codebase. :)

VHostScan.py VHostScan/VHostScan.py

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
#!/usr/bin/python
22

3-
import os
43
import sys
54
import dns.resolver
65
from argparse import ArgumentParser
76
from socket import gethostbyaddr
8-
from lib.core.virtual_host_scanner import *
9-
from lib.helpers.output_helper import *
10-
from lib.helpers.file_helper import load_random_user_agents
11-
from lib.helpers.wordlist_helper import WordList
12-
from lib.core.__version__ import __version__
13-
from lib.input import cli_argument_parser
14-
15-
DEFAULT_WORDLIST_FILE = os.path.join(
16-
os.path.dirname(os.path.abspath(__file__)),
17-
'wordlists',
18-
'virtual-host-scanning.txt'
19-
)
7+
from pkg_resources import resource_filename
8+
from .lib.core.virtual_host_scanner import *
9+
from .lib.helpers.output_helper import *
10+
from .lib.helpers.file_helper import load_random_user_agents
11+
from .lib.helpers.wordlist_helper import WordList
12+
from .lib.core.__version__ import __version__
13+
from .lib.input import cli_argument_parser
14+
15+
DEFAULT_WORDLIST_FILE = resource_filename(
16+
'VHostScan', 'wordlists/virtual-host-scanning.txt')
2017

2118

2219
def print_banner():

VHostScan/__init__.py

Whitespace-only changes.
File renamed without changes.
File renamed without changes.

lib/core/__version__.py VHostScan/lib/core/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# |V|H|o|s|t|S|c|a|n| Developed by @codingo_ & @__timk
33
# +-+-+-+-+-+-+-+-+-+ https://github.com/codingo/VHostScan
44

5-
__version__ = '1.8.2'
5+
__version__ = '1.8.3'
File renamed without changes.

lib/core/virtual_host_scanner.py VHostScan/lib/core/virtual_host_scanner.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import hashlib
66
import pandas as pd
77
import time
8-
from lib.core.discovered_host import *
8+
from .discovered_host import *
99

1010
import urllib3
1111
urllib3.disable_warnings()
File renamed without changes.
File renamed without changes.

lib/helpers/output_helper.py VHostScan/lib/helpers/output_helper.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from lib.core.discovered_host import *
2-
from lib.helpers.file_helper import *
1+
from ..core.discovered_host import *
2+
from .file_helper import *
33
import time
44
from fuzzywuzzy import fuzz
55
import itertools

lib/helpers/wordlist_helper.py VHostScan/lib/helpers/wordlist_helper.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import sys
2-
import os
3-
from lib.helpers.file_helper import get_combined_word_lists
4-
5-
DEFAULT_WORDLIST_FILE = os.path.join(
6-
os.path.dirname(os.path.abspath(__file__)),
7-
'../..',
8-
'wordlists',
9-
'virtual-host-scanning.txt'
10-
)
2+
from .file_helper import get_combined_word_lists
3+
from pkg_resources import resource_filename
4+
5+
6+
DEFAULT_WORDLIST_FILE = resource_filename(
7+
'VHostScan', 'wordlists/virtual-host-scanning.txt')
118

129

1310
class WordList:
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

setup.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[aliases]
2+
test=pytest

setup.py

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from setuptools import find_packages, setup
2+
from VHostScan.lib.core.__version__ import __version__
3+
4+
5+
def dependencies(file):
6+
with open(file) as f:
7+
return f.read().splitlines()
8+
9+
10+
with open("README.md") as f:
11+
try:
12+
import numpy
13+
num_installed = True
14+
except ImportError:
15+
num_installed = False
16+
setup(
17+
name="VHostScan",
18+
license="GPLv3",
19+
description="A virtual host scanner that performs reverse lookups, "
20+
"can be used with pivot tools, detect catch-all"
21+
"scenarios, aliases and dynamic default pages.",
22+
long_description=f.read(),
23+
author="codingo",
24+
version=__version__,
25+
author_email="[email protected]",
26+
url="http://github.com/codingo/VHostScan",
27+
packages=find_packages(exclude=('tests')),
28+
package_data={'VHostScan': ['*.txt']},
29+
entry_points={
30+
'console_scripts': [
31+
'VHostScan = VHostScan.VHostScan:main'
32+
]
33+
},
34+
install_requires=dependencies('requirements.txt'),
35+
setup_requires=['pytest-runner',
36+
'' if num_installed else 'numpy==1.12.0'],
37+
tests_require=dependencies('test-requirements.txt'),
38+
include_package_data=True)

test-requirements.txt

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
-r requirements.txt
2-
31
pytest==3.2.3
42
pytest-mock==1.6.3
53
pep8==1.7.0

tests/helpers/test_file_helper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44

55
from collections import namedtuple
6-
from lib.helpers.file_helper import parse_word_list_argument, get_combined_word_lists
6+
from VHostScan.lib.helpers.file_helper import parse_word_list_argument, get_combined_word_lists
77

88
WORDLIST_FILES = {
99
'simpsons': ['marge', 'bart', 'homer', 'lisa', 'maggie'],

tests/helpers/test_wordlist_helper.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import pytest
33
from unittest.mock import patch
44

5-
from lib.helpers.wordlist_helper import WordList
6-
from lib.helpers.wordlist_helper import DEFAULT_WORDLIST_FILE
5+
from VHostScan.lib.helpers.wordlist_helper import WordList
6+
from VHostScan.lib.helpers.wordlist_helper import DEFAULT_WORDLIST_FILE
77

88

99
@pytest.fixture(scope='class')
@@ -28,7 +28,7 @@ def test_get_wordlist_from_stdin(self):
2828
stdin_wordlist = ['keyword1', 'keyword1']
2929
expected_wordlist = []
3030
expected_wordlist.extend(stdin_wordlist)
31-
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
31+
with patch('VHostScan.lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
3232
wordlist, wordlist_types = self.wordlist.get_wordlist()
3333
self.assertEqual(wordlist, expected_wordlist)
3434

@@ -37,59 +37,59 @@ def test_get_wordlist_from_stdin_and_wordlist(self):
3737
expected_wordlist = []
3838
expected_wordlist.extend(stdin_wordlist)
3939
expected_wordlist.extend(self.user_wordlist)
40-
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
40+
with patch('VHostScan.lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
4141
wordlist, wordlist_types = self.wordlist.get_wordlist(self.user_wordlist_file)
4242
self.assertEqual(wordlist, expected_wordlist)
4343

4444
def test_using_default_wordlist(self):
4545
stdin_wordlist = []
46-
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
46+
with patch('VHostScan.lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
4747
wordlist, wordlist_types = self.wordlist.get_wordlist()
4848
self.assertEqual(wordlist, self.default_wordlist)
4949

5050
def test_ip_using_prefix(self):
5151
stdin_wordlist = ['127.0.0.1']
5252
prefix = 'dev-'
53-
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
53+
with patch('VHostScan.lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
5454
wordlist, wordlist_types = self.wordlist.get_wordlist(None, prefix)
5555
self.assertEqual(wordlist, stdin_wordlist)
5656

5757
def test_ip_using_suffix(self):
5858
stdin_wordlist = ['127.0.0.1']
5959
suffix = 'test'
60-
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
60+
with patch('VHostScan.lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
6161
wordlist, wordlist_types = self.wordlist.get_wordlist(None,None,suffix)
6262
self.assertEqual(wordlist,stdin_wordlist)
6363

6464
def test_word_with_prefix(self):
6565
stdin_wordlist = ['www','www2','www3']
6666
expected_wordlist = stdin_wordlist + ['dev-www','dev-www2','dev-www3']
6767
prefix = 'dev-'
68-
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
68+
with patch('VHostScan.lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
6969
wordlist, wordlist_types = self.wordlist.get_wordlist(None,prefix)
7070
self.assertEqual(wordlist,expected_wordlist)
7171

7272
def test_words_with_suffix(self):
7373
stdin_wordlist = ['www','www2','www3']
7474
expected_wordlist = stdin_wordlist + ['wwwtest','www2test','www3test']
7575
suffix = 'test'
76-
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
76+
with patch('VHostScan.lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
7777
wordlist, wordlist_types = self.wordlist.get_wordlist(None,None,suffix)
7878
self.assertEqual(wordlist, expected_wordlist)
7979

8080
def test_words_with_host_and_prefix(self):
8181
stdin_wordlist = ['www.%s']
8282
expected_wordlist = stdin_wordlist + ['test-www.%s']
8383
prefix = 'test-'
84-
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
84+
with patch('VHostScan.lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
8585
wordlist, wordlist_types = self.wordlist.get_wordlist(None, prefix)
8686
self.assertEqual(wordlist, expected_wordlist)
8787

8888
def test_words_with_host_and_suffix(self):
8989
stdin_wordlist = ['www.%s']
9090
expected_wordlist = stdin_wordlist + ['wwwtest.%s']
9191
suffix = 'test'
92-
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
92+
with patch('VHostScan.lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
9393
wordlist, wordlist_types = self.wordlist.get_wordlist(None,None,suffix)
9494
self.assertEqual(wordlist, expected_wordlist)
9595

tests/test_input.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import argparse
22
import pytest
33

4-
from lib.input import cli_argument_parser
4+
from VHostScan.lib.input import cli_argument_parser
55

66
def test_parse_arguments_default_value(tmpdir):
77
words = ['word1', 'word2', 'word3']

0 commit comments

Comments
 (0)