Share
## https://sploitus.com/exploit?id=223B7991-AEA3-53D7-8CE6-EC207C15BDFF
# AI-Powered Smart Contract Security Scanner
An automated blockchain security tool that continuously monitors Ethereum and Arbitrum for newly deployed contracts, scans them for vulnerabilities using AI, and generates professional audit reports.
## ๐ฏ What It Does
- **Discovers** newly deployed contracts on ETH/ARB blockchain in real-time
- **Batch scans** hundreds of contracts automatically with rate limiting
- **Uses AI** (GPT-4 or Claude) to analyze contracts for 15+ vulnerability types
- **Tracks everything** in a SQLite database to avoid re-scanning
- **Generates reports** in Markdown and JSON formats
- **Continuous monitoring** mode for 24/7 blockchain surveillance
- Identifies critical issues like reentrancy, access control flaws, oracle manipulation, etc.
## โ ๏ธ Important Disclaimers
This tool is for **educational and preliminary assessment purposes only**:
- AI analysis may produce false positives or miss certain vulnerabilities
- **NOT a replacement** for professional security audits
- Always get contracts audited by firms like Trail of Bits, OpenZeppelin, or Certora before mainnet deployment
- Use responsibly and ethically - only scan contracts you have permission to analyze
## ๐ Quick Start
### 1. Install Dependencies
```bash
pip install -r requirements.txt
```
### 2. Set Up API Keys
Copy the example environment file and add your API keys:
```bash
cp .env.example .env
```
Edit `.env` and add your keys:
```bash
# Get free API keys from:
# - Etherscan: https://etherscan.io/myapikey
# - Arbiscan: https://arbiscan.io/myapikey
ETHERSCAN_API_KEY=your_etherscan_api_key_here
ARBISCAN_API_KEY=your_arbiscan_api_key_here
# Choose one AI provider:
# Option 1: OpenAI (https://platform.openai.com/api-keys)
OPENAI_API_KEY=your_openai_key_here
AI_PROVIDER=openai
# Option 2: Anthropic (https://console.anthropic.com/)
ANTHROPIC_API_KEY=your_anthropic_key_here
AI_PROVIDER=anthropic
```
### 3. Run the Scanner
**Single Contract Scan:**
```bash
python main.py 0xdAC17F958D2ee523a2206206994597C13D831ec7
```
**Discover New Contracts (last 24 hours):**
```bash
python main.py --discover --hours 24 --network ethereum
```
**Batch Scan (scan all new contracts from last week):**
```bash
python main.py --batch --hours 168 --verified-only
```
**Continuous Monitoring (scan every hour indefinitely):**
```bash
python main.py --monitor --hours 1 --interval 60
```
**View Statistics:**
```bash
python main.py --stats
```
## ๐ Vulnerability Types Detected
The scanner checks for 15+ common vulnerability patterns:
- โ
**Reentrancy** - Recursive call exploits
- โ
**Access Control** - Unauthorized function access
- โ
**Intege & Database
### SQLite Database (`scan_results.db`)
All scan results are stored in a database with:
- **Contracts table** - Tracks all scanned contracts
- **Scans table** - Scan history with timestamps
- **Vulnerabilities table** - Detailed vulnerability records
Query the database:
```python
from database import ScanDatabase
db = ScanDatabase()
high_risk = db.get_high_risk_contracts(min_risk_score=7.0)
stats = db.get_statistics()
```
### Report Files- โ
**Unchecked External Calls** - Failed call handling
- โ
**Delegatecall Vulnerabilities** - Malicious delegate execution
- โ
**Unprotected Ether Withdrawal** - Funds drainage
- โ
**Timestamp Dependence** - Block timestamp manipulation
- โ
**Front-Running** - Transaction ordering exploits
- โ
**Denial of Service** - Contract blocking attacks
- โ
**Oracle Manipulation** - Price feed exploits
- โ
**Flash Loan Attacks** - Uncollateralized loan exploits
- โ
**Signature Replay** - Signature reuse attacks
- โ
**Gas Griefing** - Gas limit exploits
- โ
**Storage Pointers** - Uninitialized storage bugs
- โ
**Array Deletion Issues** - Improper cleanup
## ๐ Output
The scaUsage Modes
### 1. Discovery Mode
Find new contracts without scanning:
```bash
# Find all verified contracts from last 7 days
python main.py --discover --hours 168 --verified-only
# Find all contracts (verified + unverified) from last 24h
python main.py --discover --hours 24 --network arbitrum
```
### 2. Batch Scan Mode
Automatically discover and scan multiple contracts:
```bash
# Scan all new verified contracts from last 24 hours
python main.py --batch --hours 24 --verified-only
# Scan last week on Arbitrum
python main.py --batch --hours 168 --network arbitrum
```
Features:
- Automatic rate limiting (respects Etherscan API limits)
- Skips already-scanned contracts (checks database)
- Progress tracking with ETA
- Saves all results to database
### 3. Continuous Monitoring Mode
Run 24/7 to catch new deployments:
```bash
# Check every hour for new contracts (last 1 hour)
python main.py --monitor --hours 1 --interval 60
# Check every 30 minutes
python main.py --monitor --hours 1 --interval 30
```
Perfect for:
- Finding zero-day vulnerabilities before others
- Monitoring trending protocols
- Building a vulnerability database
### 4. Statistics Mode
View your scanning history:
```bash
python main.py --stats
```
Shows:
- Total contracts scanned
- High-risk contracts found
- Most common vulnerabilities
- Average risk scores JSON Report (`ContractName_TIMESTAMP.json`)
- Structured data for automation
- Programmatic integration
- CI/CD pipeline compatible
## ๐ ๏ธ Advanced Usage
### Scan Multiple Contracts
```bash
# Create a batch scan script
for address in "0xAddr1" "0xAddr2" "0xAddr3"; do
python main.py $address --network ethereum
done
```
## ๐ก Recommended Workflow
### For Bug Bounty Hunters:
1. **Start continuous monitoring:**
```bash
python main.py --monitor --hours 1 --interval 60 --verified-only
```
2. **Let it run 24/7** - it will discover and scan new contracts automatically
3. **Check high-risk findings:**
```bash
python main.py --stats
```
4. **Review the database** for contracts with critical vulnerabilities:
```python
from database import ScanDatabase
db = ScanDatabase()
high_risk = db.get_high_risk_contracts(min_risk_score=8.0)
for contract in high_risk:
print(f"{contract['name']}: {contract['address']}")
```
5. **Manually verify** AI findings (crucial - avoid false positives!)
6. **Check for active bounties** on Immunefi/HackerOne
7. **Submit responsible disclosure** and collect rewards
### For One-Time Audits:
1. **Batch scan recent contracts:**
```bash
python main.py --batch --hours 168 --verified-only
```
2. **Review findings** in the `reports/` directory
3. **Focus on high-risk** contracts (risk score โฅ 7)
### For Researchers:
1. **Build a vulnerability database** by running monitoring mode for weeks
2. **Analyze patterns** with database queries:
```python
db = ScanDatabase()
stats = db.get_statistics()
print(stats['top_vulnerabilities']) # Most common issues
```
3. **Export data** for research:
```python
db.export_high_risk_report("research_data.json")
```
## ๏ฟฝ Performance & Scalability
### API Rate Limits
- **Etherscan Free Tier:** 5 calls/second, 100k calls/day
- Scanner uses conservative 4 calls/sec to avoid limits
- Can scan ~14,000 contracts per hour
- ~336,000 contracts per day
### Resource Usage
- Minimal CPU (mostly waiting for API responses)
- ~50MB RAM for scanner
- SQLite database grows ~1KB per scanned contract
- AI API costs: ~$0.01-0.05 per contract (depending on provider/model)
### Cost Estimates
Scanning 1000 contracts/day:
- Etherscan API: Free
- AI API (Claude/GPT-4): ~$10-50/day
- Total: **~$300-1500/month** for continuous monitoring
๐ก **Tip:** Focus on verified contracts only to reduce costs (~10-20% of all deployments)
## ๐ก Tips for Success
1. **Start with monitoring mode** - Let it run and build a database
2. **Focus on verified contracts** - Higher quality, fewer false alarms
3. **Verify AI findings manually** - Always understand the code before reporting
4. **Check for active bug bounties** - Use Immunefi, HackerOne
5. **Target new/trending protocols** - Less likely to be thoroughly audited
6. **Learn Solidity deeply** - AI is a tool, not a replacement for knowledge
7. **Track high-value contracts** - Prioritize protocols with significant TVL
8. **Run 24/7 monitoring** - Be first to find vulnerabilities in new deployments
9. **Analyze patterns** - Use database statistics to improve detection
10. **Stay updated** - Follow [@samczsun](https://twitter.com/samczsun), [@officer_cia](https://twitter.com/officer_cia)
## ๐ง Configuration
Edit [config.py](config.py) to customize:
- Add more vulnerability patterns
- Change AI model parameters
- Modify network configurations
- Adjust analysis depth
## ๐จ Ethical Guidelines
- โ
Only scan contracts on public testnets or mainnets
- โ
Follow responsible disclosure practices
- โ
Respect bug bounty program rules
- โ
Never exploit vulnerabilities for personal gain
- โ Don't perform unauthorized testing on private contracts
- โ Don't use findings for malicious purposes
- โ Don't claim AI findings as deep manual audits
## ๐ Learning Resources
- [Smart Contract Security Best Practices](https://consensys.github.io/smart-contract-best-practices/)
- [SWC Registry](https://swcregistry.io/) - Known vulnerabilities
- [Ethernaut](https://ethernaut.openzeppelin.com/) - Security challenges
- [Damn Vulnerable DeFi](https://www.damnvulnerabledefi.xyz/) - Practice platform
## ๐ค Contributing
Improvements welcome:
- Add more EVM chains (Polygon, Base, BSC, Optimism, etc.)
- Improve AI prompts for better detection
- Add automated exploit PoC generation
- Build a web dashboard for monitoring
- Integrate with GitHub Actions for CI/CD
- Add Telegram/Discord notifications for high-risk findings
- Implement parallel processing for faster scanning
## ๐ License
MIT License - Use at your own risk
## ๐ Acknowledgments
Built for aspiring security researchers and bug bounty hunters. Remember: with great power comes great responsibility.
---
**Questions?** Check existing contracts first, read the code, and start scanning! ๐