8000 Setup JSON output for domains scripts by Edznux · Pull Request #184 · DataSploit/datasploit · GitHub
[go: up one dir, main page]

Skip to content

Setup JSON output for domains scripts #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add domain_whois json output
  • Loading branch information
Edznux committed Oct 27, 2017
commit c62084b6cd914d198022d7328f93d633aa7d3300
34 changes: 26 additions & 8 deletions domain/domain_whois.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,58 @@
#!/usr/bin/env python

import json
import base
import sys
import whois
from termcolor import colored
import time
import datetime

ENABLED = True

OUTPUT_TYPE = "console"

class style:
BOLD = '\033[1m'
END = '\033[0m'


def whoisnew(domain):
w = whois.whois(domain)
return dict(w)


def banner():
print colored(style.BOLD + '---> Finding Whois Information.' + style.END, 'blue')

if(OUTPUT_TYPE == "console"):
print colored(style.BOLD + '---> Finding Whois Information.' + style.END, 'blue')

def main(domain):
return whoisnew(domain)


def output(data, domain=""):
print data
print "\n-----------------------------\n"

if(OUTPUT_TYPE == "console"):
print data
print "\n-----------------------------\n"

if(OUTPUT_TYPE == "json"):
js = {}
for i in data:
# convert iterables to json list
if(hasattr(data[i], '__iter__')):
js[i] = list()
for j in data[i]:
js[i].append(j)
# convert datetime to string
elif (isinstance(data[i], datetime.datetime)):
js[i] = data[i].strftime("%s")
else:
js[i] = str(data[i])

print json.dumps(js)

if __name__ == "__main__":
try:
domain = sys.argv[1]
if(len(sys.argv) > 2):
OUTPUT_TYPE=sys.argv[2]
banner()
result = main(domain)
output(result, domain)
Expand Down
0