Created
June 25, 2025 01:08
-
-
Save marz-hunter/4169a7be0f5006a35ba10aec5d48a7f2 to your computer and use it in GitHub Desktop.
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 | |
| import json | |
| # Step 1: Get the initial buildId from the first request | |
| print("Fetching buildId...") | |
| response1 = requests.get('https://immunefi.com/bug-bounty/') | |
| response1.raise_for_status() # Ensure we got a successful response | |
| # Find the buildId in the response body | |
| start_index = response1.text.find('"buildId":"') + len('"buildId":"') | |
| end_index = response1.text.find('"', start_index) | |
| build_id = response1.text[start_index:end_index] | |
| print(f"Build ID: {build_id}") | |
| # Step 2: Use the buildId to get the list of bug bounty ids | |
| print("\nFetching bug bounty list...") | |
| url2 = f'https://immunefi.com/_next/data/{build_id}/bug-bounty.json' | |
| response2 = requests.get(url2) | |
| response2.raise_for_status() | |
| bounties_data = response2.json() | |
| # Extract the ids and names from the response | |
| bounties = [(bounty['id'], bounty.get('name', 'Unknown')) for bounty in bounties_data['pageProps']['bounties']] | |
| print(f"Found {len(bounties)} bug bounty programs") | |
| # Step 3: For each id, get smart contract addresses | |
| print("\nFetching smart contract details...") | |
| smart_contracts = [] | |
| for bounty_id, bounty_name in bounties: | |
| try: | |
| # Get the scope data for this bounty | |
| url3 = f'https://immunefi.com/_next/data/{build_id}/bug-bounty/{bounty_id}/scope.json?slug={bounty_id}' | |
| response3 = requests.get(url3) | |
| response3.raise_for_status() | |
| scope_data = response3.json() | |
| # Get the program URL | |
| program_url = f'https://immunefi.com/bug-bounty/{bounty_id}' | |
| # Look for smart contract assets | |
| if 'bounty' in scope_data['pageProps'] and 'assets' in scope_data['pageProps']['bounty']: | |
| for asset in scope_data['pageProps']['bounty']['assets']: | |
| if asset['type'] == 'smart_contract': | |
| contract_info = { | |
| 'program_name': bounty_name, | |
| 'program_url': program_url, | |
| 'address': asset.get('url', 'N/A'), | |
| 'chain': asset.get('chain', 'Unknown'), | |
| 'name': asset.get('name', 'Unnamed Contract'), | |
| 'severity': asset.get('severity', 'N/A') | |
| } | |
| smart_contracts.append(contract_info) | |
| except Exception as e: | |
| print(f"Error processing {bounty_id}: {str(e)}") | |
| continue | |
| # Print the collected smart contracts with formatting | |
| print(f"\n{'='*100}") | |
| print(f"Found {len(smart_contracts)} smart contracts across all programs") | |
| print(f"{'='*100}\n") | |
| # Group by program for better readability | |
| current_program = None | |
| for contract in smart_contracts: | |
| if contract['program_name'] != current_program: | |
| current_program = contract['program_name'] | |
| print(f"\n๐ Program: {current_program}") | |
| print(f"๐ URL: {contract['program_url']}") | |
| print(f"{'-'*80}") | |
| print(f" ๐ธ Contract: {contract['name']}") | |
| print(f" Chain: {contract['chain']}") | |
| print(f" Address: {contract['address']}") | |
| print(f" Severity: {contract['severity']}") | |
| # Optional: Save to JSON file | |
| with open('immunefi_smart_contracts.json', 'w') as f: | |
| json.dump(smart_contracts, f, indent=2) | |
| print(f"\nโ Data saved to immunefi_smart_contracts.json") | |
| # Summary statistics | |
| chains = {} | |
| for contract in smart_contracts: | |
| chain = contract['chain'] | |
| chains[chain] = chains.get(chain, 0) + 1 | |
| print(f"\n๐ Smart Contracts by Chain:") | |
| for chain, count in sorted(chains.items(), key=lambda x: x[1], reverse=True): | |
| print(f" {chain}: {count}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment