Log formats and general improvements by initstring · Pull Request #47 · initstring/cloud_enum · GitHub
Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .gitignore
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,19 @@ optional arguments:
-m MUTATIONS, --mutations MUTATIONS
Mutations. Default: enum_tools/fuzz.txt
-b BRUTE, --brute BRUTE
List to brute-force Azure container names. Default:
enum_tools/fuzz.txt
List to brute-force Azure container names. Default: enum_tools/fuzz.txt
-t THREADS, --threads THREADS
Threads for HTTP brute-force. Default = 5
-ns NAMESERVER, --nameserver NAMESERVER
DNS server to use in brute-force.
-l LOGFILE, --logfile LOGFILE
Will APPEND found items to specified file.
-f FORMAT, --format FORMAT
Format for log file (text,json,csv - defaults to text)
--disable-aws Disable Amazon checks.
--disable-azure Disable Azure checks.
--disable-gcp Disable Google checks.
-qs, --quickscan Disable all mutations and second-level scans

```

# Thanks
Expand Down
46 changes: 29 additions & 17 deletions cloud_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

'''

LOGFILE = False

def parse_arguments():
"""
Expand Down Expand Up @@ -68,7 +67,11 @@ def parse_arguments():
help='DNS server to use in brute-force.')

parser.add_argument('-l', '--logfile', type=str, action='store',
help='Will APPEND found items to specified file.')
help='Appends found items to specified file.')
parser.add_argument('-f', '--format', type=str, action='store',
default='text',
help='Format for log file (text,json,csv)'
' - default: text')

parser.add_argument('--disable-aws', action='store_true',
help='Disable Amazon checks.')
Expand All @@ -86,8 +89,7 @@ def parse_arguments():

# Ensure mutations file is readable
if not os.access(args.mutations, os.R_OK):
print("[!] Cannot access mutations file: {}"
.format(args.mutations))
print(f"[!] Cannot access mutations file: {args.mutations}")
sys.exit()

# Ensure brute file is readable
Expand All @@ -102,7 +104,7 @@ def parse_arguments():
sys.exit()

# Parse keywords from input file
with open(args.keyfile) as infile:
with open(args.keyfile, encoding='utf-8') as infile:
args.keyword = [keyword.strip() for keyword in infile]

# Ensure log file is writeable
Expand All @@ -121,23 +123,29 @@ def parse_arguments():
print("[!] Cannot write to log file, exiting")
sys.exit()

# Set up logging format
if args.format not in ('text', 'json', 'csv'):
print("[!] Sorry! Allowed log formats: 'text', 'json', or 'csv'")
sys.exit()
# Set the global in the utils file, where logging needs to happen
utils.init_logfile(args.logfile)
utils.init_logfile(args.logfile, args.format)

return args


def print_status(args):
"""
Print a short pre-run status message
"""
print("Keywords: {}".format(', '.join(args.keyword)))
print(f"Keywords: {', '.join(args.keyword)}")
if args.quickscan:
print("Mutations: NONE! (Using quickscan)")
else:
print("Mutations: {}".format(args.mutations))
print("Brute-list: {}".format(args.brute))
print(f"Mutations: {args.mutations}")
print(f"Brute-list: {args.brute}")
print("")


def check_windows():
"""
Fixes pretty color printing for Windows users. Keeping out of
Expand All @@ -151,16 +159,18 @@ def check_windows():
print("[!] Yo, Windows user - if you want pretty colors, you can"
" install the colorama python package.")


def read_mutations(mutations_file):
"""
Read mutations file into memory for processing.
"""
with open(mutations_file, encoding="utf8", errors="ignore") as infile:
mutations = infile.read().splitlines()

print("[+] Mutations list imported: {} items".format(len(mutations)))
print(f"[+] Mutations list imported: {len(mutations)} items")
return mutations


def clean_text(text):
"""
Clean text to be RFC compliant for hostnames / DNS
Expand All @@ -171,6 +181,7 @@ def clean_text(text):

return text_clean


def build_names(base_list, mutations):
"""
Combine base and mutations for processing by individual modules.
Expand All @@ -189,19 +200,20 @@ def build_names(base_list, mutations):
mutation = clean_text(mutation)

# Then, do appends
names.append("{}{}".format(base, mutation))
names.append("{}.{}".format(base, mutation))
names.append("{}-{}".format(base, mutation))
names.append(f"{base}{mutation}")
names.append(f"{base}.{mutation}")
names.append(f"{base}-{mutation}")

# Then, do prepends
names.append("{}{}".format(mutation, base))
names.append("{}.{}".format(mutation, base))
names.append("{}-{}".format(mutation, base))
names.append(f"{mutation}{base}")
names.append(f"{mutation}.{base}")
names.append(f"{mutation}-{base}")

print("[+] Mutated results: {} items".format(len(names)))
print(f"[+] Mutated results: {len(names)} items")

return names


def main():
"""
Main program function.
Expand Down
37 changes: 26 additions & 11 deletions enum_tools/aws_checks.py
Loading