Skip to content

Instantly share code, notes, and snippets.

@glen-testing
Created September 11, 2022 18:13
Show Gist options
  • Save glen-testing/de4099f962b665d82d5a492aa82cc055 to your computer and use it in GitHub Desktop.
Save glen-testing/de4099f962b665d82d5a492aa82cc055 to your computer and use it in GitHub Desktop.
This got me 6th place with 4 blocks in ipv4.games
import requests
# From https://github.com/Ge0rg3/requests-ip-rotator
from requests_ip_rotator import ApiGateway
import time
"""
I got to 6th on the board as 'fiasco' with 4 blocks on 9/11/2022 of ipv4.games
You can do better. Adapt this to choose different regions and do 5-10k
request runs per-api-gateway and you'll chew through whatever blocks
AWS had api gateways in. They're supposedly free for the first 1million
requests.
By default, I was getting 9 different /8 blocks this was submitting to,
so you might be able to do 9 blocks without tinkering. Adding more regions will help.
Using this was quite resilient with cleaning up the ApiGateway resources in AWS.
Give it a not-overly-excessive IAM permission in case it leaks somehow.
Configure your env with `aws configure` after installing the awscli.
If everything FUBARs and you can't hunt down your many apigateways, you can
turn to https://github.com/rebuy-de/aws-nuke to blow it all away.
If you don't want to give me more points, you should probably switch out the claim?name value to yours.
"""
iplist = []
with ApiGateway("http://ipv4.games") as g:
session = requests.Session()
session.mount("http://ipv4.games", g)
for _ in range (10000):
response = session.get("http://ipv4.games/claim?name=fiasco")
# IP address happens to be the 5th token if you're splitting by space. Handy
# This breaks in some error conditions. Happened after ~15k responses for me.
# 15k responses got me 5800ish unique IPs. Running in range(10000) runs is probably best.
ip = response.text.split()[5]
#print(ip)
iplist.append(ip)
# Dump results to a file periodically
if len(iplist) > 50:
with open("apigateway-ips-claimed.txt", 'a') as ipfile:
for ip in iplist:
ipfile.writelines(ip+'\n')
iplist = []
print("wrote to file")
# Probably unnecessary, but I didn't want to overload anything/hit rate-limits.
time.sleep(.2)
print("done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment