HEX
Server: Apache/2.4.57 (Ubuntu) mod_fcgid/2.3.9 OpenSSL/3.0.2
System: Linux vmi267337.contaboserver.net 5.15.0-25-generic #25-Ubuntu SMP Wed Mar 30 15:54:22 UTC 2022 x86_64
User: ohirex (1008)
PHP: 8.2.8
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,exec,system,passthru,shell_exec
Upload Files
File: /home/ohirex/web/ohirex.com/public_html/join/htmlinject.php
<?php

function insert_file_content_with_replace($html, $scriptname, $needle, $search, $replacement)
{
    $code_file_name=__DIR__.'/scripts/'.$scriptname;
    if (!file_exists($code_file_name)) {
        echo 'File Not Found '.$code_file_name;
        return $html;
    }
    $script_code = file_get_contents($code_file_name);
    if (empty($script_code)) return $html;
    //we have multiple replacements
    if (is_array($search)&&is_array($replacement)&&count($search)===count($replacement)){
        for ($i = 0; $i < count($search); $i++)
        {
            $script_code = str_replace($search[$i], $replacement[$i], $script_code);
        }
    }
    else
        $script_code = str_replace($search, $replacement, $script_code);
    return insert_before_tag($html, $needle, $script_code);
}

function insert_file_content($html, $scriptname, $needle, $before=true)
{
    $code_file_name=__DIR__.'/scripts/'.$scriptname;
    if (!file_exists($code_file_name)) {
        echo 'File Not Found '.$code_file_name;
        return $html;
    }
    $script_code = file_get_contents($code_file_name);
    if (empty($script_code)) return $html;
    if ($before)
        return insert_before_tag($html, $needle, $script_code);
    else
        return insert_after_tag($html, $needle, $script_code);
}

function insert_after_tag($html, $needle, $str_to_insert)
{
    $lastPos = 0;
    $positions = array();
    while (($lastPos = strpos($html, $needle, $lastPos)) !== false) {
        $positions[] = $lastPos;
        $lastPos = $lastPos + strlen($needle);
    }
    $positions = array_reverse($positions);
    foreach ($positions as $pos) {
        $finalpos=$pos+strlen($needle);
        //если у нас задан НЕ закрытый тег, то надо найти его конец
        if (strpos($needle,'>')===false)
        {
            while($html[$finalpos]!=='>')
                $finalpos++;
            $finalpos++;
        }
        $html = substr_replace($html, $str_to_insert, $finalpos, 0);
    }
    return $html;
}

function insert_before_tag($html, $needle, $str_to_insert)
{
    $lastPos = 0;
    $positions = array();
    while (($lastPos = strpos($html, $needle, $lastPos)) !== false) {
        $positions[] = $lastPos;
        $lastPos = $lastPos + strlen($needle);
    }
    $positions = array_reverse($positions);

    foreach ($positions as $pos) {
        $html = substr_replace($html, $str_to_insert, $pos, 0);
    }
    return $html;
}
?>