Files
wevads-platform/scripts/scan-joomla-hosts.py
2026-02-26 04:53:11 +01:00

175 lines
5.2 KiB
Python
Executable File

#!/usr/bin/env python3
"""
SCAN JOOMLA CMS HOSTS
Trouve des sites Joomla avec media manager accessible
Pour héberger des images avec bonne réputation
"""
import psycopg2
import requests
import re
from urllib.parse import urlparse
import sys
DB_CONFIG = {
'host': 'localhost',
'database': 'adx_system',
'user': 'admin',
'password': 'admin123'
}
# Google dork patterns pour trouver des Joomla
JOOMLA_PATTERNS = [
'index.php?option=com_media&view=media',
'administrator/index.php?option=com_media',
]
# Sites connus (à tester)
KNOWN_JOOMLA_SITES = [
'https://hoiquanphidung.com/echo/index.php?option=com_media&view=media&tmpl=component',
'https://usibo.org/index.php?option=com_media&view=media&tmpl=component',
'https://www.gov.sz/index.php?option=com_media&view=media&tmpl=component',
'https://www.immigration-vanuatu.com/index.php?option=com_media&view=media&tmpl=component',
'https://www.nutkrimpen.nl/',
]
def get_db():
return psycopg2.connect(**DB_CONFIG)
def get_country_from_tld(url):
"""Extract country from TLD"""
domain = urlparse(url).netloc
tld = domain.split('.')[-1].upper()
tld_map = {
'COM': 'US', 'NET': 'US', 'ORG': 'US',
'CA': 'CA', 'UK': 'GB', 'CO': 'GB',
'FR': 'FR', 'DE': 'DE', 'ES': 'ES', 'IT': 'IT',
'NL': 'NL', 'BE': 'BE', 'CH': 'CH',
'SZ': 'SZ', 'VU': 'VU',
'AU': 'AU', 'NZ': 'NZ',
'JP': 'JP', 'CN': 'CN', 'KR': 'KR',
'BR': 'BR', 'MX': 'MX', 'AR': 'AR',
}
return tld_map.get(tld, 'US')
def check_joomla_media(url, timeout=10):
"""Check if Joomla media manager is accessible"""
try:
# Add required params if not present
if 'option=com_media' not in url:
url += '/index.php?option=com_media&view=media&tmpl=component'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
}
response = requests.get(url, headers=headers, timeout=timeout, allow_redirects=True)
# Check for Joomla media manager indicators
content = response.text.lower()
indicators = [
'com_media',
'media manager',
'joomla',
'upload',
'local-images'
]
score = sum(1 for ind in indicators if ind in content)
return {
'accessible': response.status_code == 200,
'status_code': response.status_code,
'score': score,
'has_upload': 'upload' in content or 'input type="file"' in content
}
except Exception as e:
return {'accessible': False, 'error': str(e)}
def add_host_to_db(url, country, host_type='cms_joomla', reputation=70):
"""Add host to database"""
conn = get_db()
cur = conn.cursor()
domain = urlparse(url).netloc
try:
cur.execute("""
INSERT INTO admin.country_image_hosts
(country_code, host_name, host_url, host_type, reputation_score, upload_method)
VALUES (%s, %s, %s, %s, %s, 'form')
ON CONFLICT (country_code, host_url) DO UPDATE SET
last_check = NOW(),
is_active = true
""", (country, domain, url, host_type, reputation))
conn.commit()
return True
except Exception as e:
print(f"DB Error: {e}")
return False
finally:
conn.close()
def scan_known_sites():
"""Scan known Joomla sites"""
print("=" * 60)
print("SCANNING KNOWN JOOMLA SITES")
print("=" * 60)
results = []
for url in KNOWN_JOOMLA_SITES:
print(f"\n🔍 Checking: {url[:50]}...")
result = check_joomla_media(url)
country = get_country_from_tld(url)
if result.get('accessible'):
print(f" ✅ Accessible (score: {result.get('score', 0)})")
print(f" 📍 Country: {country}")
print(f" 📤 Has Upload: {result.get('has_upload', False)}")
# Calculate reputation
reputation = 60
if result.get('score', 0) >= 3:
reputation = 75
if '.gov' in url or '.edu' in url:
reputation = 90
# Add to DB
if add_host_to_db(url, country, 'cms_joomla', reputation):
print(f" 💾 Added to database")
results.append({
'url': url,
'country': country,
'score': result.get('score', 0),
'has_upload': result.get('has_upload', False)
})
else:
print(f" ❌ Not accessible: {result.get('error', 'Unknown')}")
return results
def main():
results = scan_known_sites()
print("\n" + "=" * 60)
print("SUMMARY")
print("=" * 60)
print(f"Total checked: {len(KNOWN_JOOMLA_SITES)}")
print(f"Accessible: {len(results)}")
if results:
print("\n📋 Available Hosts:")
for r in results:
upload = "📤" if r['has_upload'] else ""
print(f" [{r['country']}] {urlparse(r['url']).netloc} {upload}")
if __name__ == '__main__':
main()