Created
February 4, 2015 00:37
-
-
Save averagesecurityguy/ca3b7376473c98e0666f to your computer and use it in GitHub Desktop.
Generate a masscan configuration file for the EC2 IP address ranges.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
resp = requests.get('https://ip-ranges.amazonaws.com/ip-ranges.json') | |
ranges = resp.json() | |
sync = ranges['syncToken'] | |
ec2 = [r['ip_prefix'] for r in ranges['prefixes'] if r['service'] == 'EC2'] | |
with open('ec2.conf', 'wb') as f: | |
f.write('EC2 Masscan Configuration.\n'.encode('utf-8')) | |
f.write('rate = 5000.00\n'.encode('utf-8')) | |
f.write('output-format = list\n'.encode('utf-8')) | |
f.write('output-filename = ec2_{0}.list\n'.format(sync).encode('utf-8')) | |
for r in ec2: | |
f.write('range = {0}\n'.format(r).encode('utf-8')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment