Skip to content

Commit

Permalink
Merge pull request #53 from xuvez/master
Browse files Browse the repository at this point in the history
Closes #52 - Added command line flags for JSON output
  • Loading branch information
codingo authored Oct 4, 2017
2 parents 5d383d6 + 10b43c6 commit ad43e52
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/core/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# |V|H|o|s|t|S|c|a|n| Developed by @codingo_ & @__timk
# +-+-+-+-+-+-+-+-+-+ https://github.com/codingo/VHostScan

__version__ = '1.5.1'
__version__ = '1.5.2'

12 changes: 8 additions & 4 deletions lib/helpers/file_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ def __init__(self, output_file):
self.output_file = output_file

def check_directory(self):
directory = self.output_file
directory = os.path.dirname(self.output_file)

try:
os.stat(self.directory)
os.stat(directory)
except:
os.mkdir(self.directory)
print("[!] %s didn't exist and has been created." % output_directory)
os.mkdir(directory)
print("[!] %s didn't exist and has been created." % directory)

# placeholder for error checking on -oJ implementation
def is_json(json_file):
Expand All @@ -24,6 +25,9 @@ def is_json(json_file):
return True

def write_file(self, contents):
# check if host directory exists, if not create it
self.check_directory()

with open(self.output_file, "w") as o:
o.write(contents)

Expand Down
20 changes: 16 additions & 4 deletions lib/helpers/output_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,28 @@ def output_normal_likely(self):

def output_json(self, filename):
file = file_helper(filename)
list = dict()
output = dict()
output['Start Time'] = '{} {}'.format(time.strftime("%d/%m/%Y"), time.strftime("%H:%M:%S"))
output['Target'] = self.scanner.target
output['Base Host'] = self.scanner.base_host
output['Port'] = self.scanner.port
output['Real Port'] = self.scanner.real_port
output['Ignore HTTP Codes'] = self.scanner.ignore_http_codes
output['Ignore Content Length'] = self.scanner.ignore_content_length
output['Wordlist'] = self.scanner.wordlist
output['Unique Depth'] = self.scanner.unique_depth
output['SSL'] = self.scanner.ssl
result = dict()
for host in self.scanner.hosts:
headers = {}
headers = dict()
for header in host.keys:
headers[header.split(':')[0]] = header.split(':')[1].strip()

list[host.hostname] = {'Code': host.response_code,
result[host.hostname] = {'Code': host.response_code,
'Hash': host.hash,
'Headers': headers}
file.write_file(json.dumps(list))
output['Result'] = result
file.write_file(json.dumps(output))


def output_fuzzy(self):
Expand Down

0 comments on commit ad43e52

Please sign in to comment.