Skip to content

Instantly share code, notes, and snippets.

@heyibrahimkhan
Created September 12, 2020 18:29
Show Gist options
  • Select an option

  • Save heyibrahimkhan/74a75236b61b391367a0ffa950f39632 to your computer and use it in GitHub Desktop.

Select an option

Save heyibrahimkhan/74a75236b61b391367a0ffa950f39632 to your computer and use it in GitHub Desktop.
Crawl EC2 Instance Metadata
import requests
from pprint import pprint
def r_get(url):
res = requests.get(url)
print(url)
print(res.text)
if res.status_code == 404:
return
else:
for uri in res.text.split('\n'):
r_get('{0}/{1}'.format(url, uri))
init_url = 'http://169.254.169.254'
r_get(init_url)
# res = requests.get(init_url)
# print(res.text)
# print(res.text.split('\n'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment