Skip to content
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

added new features #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
101 changes: 58 additions & 43 deletions ctfr.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,77 +2,92 @@
# -*- coding: utf-8 -*-
"""
------------------------------------------------------------------------------
CTFR - 04.03.18.02.10.00 - Sheila A. Berta (UnaPibaGeek)
CTFR - 04.03.18.02.10.00 - Sheila A. Berta (UnaPibaGeek)
------------------------------------------------------------------------------
"""

## # LIBRARIES # ##
import re
import requests
import sys

## # CONTEXT VARIABLES # ##
version = 1.2

## # MAIN FUNCTIONS # ##

def parse_args():
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--domain', type=str, required=True, help="Target domain.")
parser.add_argument('-o', '--output', type=str, help="Output file.")
return parser.parse_args()
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--domain', type=str, help="Target domain.")
parser.add_argument('-o', '--output', type=str, help="Output file.")
parser.add_argument('-s', '--silent', default=False, action='store_true', help="Don't show banner")
return parser.parse_args()

def banner():
global version
b = '''
global version
b = '''
____ _____ _____ ____
/ ___|_ _| ___| _ \
| | | | | |_ | |_) |
| |___ | | | _| | _ <
\____| |_| |_| |_| \_\\
Version {v} - Hey don't miss AXFR!
Made by Sheila A. Berta (UnaPibaGeek)
'''.format(v=version)
print(b)
'''.format(v=version)
print(b)
def clear_url(target):
return re.sub('.*www\.','',target,1).split('/')[0].strip()
return re.sub('.*www\.','',target,1).split('/')[0].strip()

def save_subdomains(subdomain,output_file):
with open(output_file,"a") as f:
f.write(subdomain + '\n')
f.close()
with open(output_file,"a") as f:
f.write(subdomain + '\n')
f.close()

def main():
banner()
args = parse_args()

subdomains = []
target = clear_url(args.domain)
output = args.output

req = requests.get("https://crt.sh/?q=%.{d}&output=json".format(d=target))

if req.status_code != 200:
print("[X] Information not available!")
exit(1)
def get_subdomain(target, subdomains, silent):
req = requests.get("https://crt.sh/?q=%.{d}&output=json".format(d=target))

for (key,value) in enumerate(req.json()):
subdomains.append(value['name_value'])
if req.status_code != 200:
if not silent: print("[X] Information not available!")
return

print("\n[!] ---- TARGET: {d} ---- [!] \n".format(d=target))
for (key,value) in enumerate(req.json()):
subdomains.append(value['name_value'])

subdomains = sorted(set(subdomains))
if not silent: print("\n[!] ---- TARGET: {d} ---- [!] \n".format(d=target))

for subdomain in subdomains:
print("[-] {s}".format(s=subdomain))
if output is not None:
save_subdomains(subdomain,output)
subdomains = sorted(set(subdomains))
return subdomains

print("\n\n[!] Done. Have a nice day! ;).")


main()

def main():
args = parse_args()
silent = args.silent
if not silent: banner()
subdomains = []

stdin = not sys.stdin.isatty()
output = args.output
if args.domain:
target = clear_url(args.domain)
subdomains = get_subdomain(target, subdomains, silent)
elif stdin:
for line in sys.stdin:
target = clear_url(line.rstrip())
subdomains = get_subdomain(target, subdomains, silent)
else:
print("No domain given. either use stdin or -d flag")
exit(1)

for subdomain in subdomains:
print("{s}".format(s=subdomain))
if output is not None:
save_subdomains(subdomain,output)

if not silent: print("\n\n[!] Done. Have a nice day! ;).")


if __name__ == '__main__':
main()