Skip to content

Instantly share code, notes, and snippets.

@averagesecurityguy
Created February 4, 2015 00:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save averagesecurityguy/ca3b7376473c98e0666f to your computer and use it in GitHub Desktop.
Save averagesecurityguy/ca3b7376473c98e0666f to your computer and use it in GitHub Desktop.
Generate a masscan configuration file for the EC2 IP address ranges.
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