403Webshell
Server IP : 103.119.228.120  /  Your IP : 13.58.45.238
Web Server : Apache
System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User : nobody ( 99)
PHP Version : 5.6.40
Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime
MySQL : ON |  cURL : ON |  WGET : ON |  Perl : ON |  Python : ON |  Sudo : ON |  Pkexec : ON
Directory :  /usr/local/ssl/local/ssl/local/ssl/local/ssl/libexec/grubby/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /usr/local/ssl/local/ssl/local/ssl/local/ssl/libexec/grubby/prune_debug
#!/bin/sh

######################################################################
# Prune undesired systemd.debug entries in kernels that are not
# marked for debugging. See Red Hat bugzilla 1285601.
######################################################################

PATH=/usr/bin:/usr/sbin
EPOCH_DATE=$(date +"%s")
LOG_DIR="/var/log"
LOG_FILE="${LOG_DIR}/grubby_prune_debug"

display_event()
{
    EVENT_LABEL="$1"
    EVENT_DATA="$2"
    JUSTIFIED_LABEL=$(printf "%-12s" "${EVENT_LABEL}")
    LOG_TIMESTAMP=$(date +"%s")
    echo "[${LOG_TIMESTAMP}] ${JUSTIFIED_LABEL}: ${EVENT_DATA}" >> "${LOG_FILE}"
}

exit_event()
{
    display_event "Exit" "Exiting script"
    exit $1
}

find_entry_by_title()
{
    SEARCH_TITLE=$1

    display_event "Examine" "Searching for entry title - ${SEARCH_TITLE}"

    for current_index in $(grubby --info=ALL|grep "^index="| sed 's/^index=//') ; do
        CURRENT_TITLE=$(grubby --info="${current_index}" 2> /dev/null |grep "^title=" | sed 's/^title=//')

        # do not do anything if this was empty
        [ -z "${CURRENT_TITLE}" ] && continue

        if [ "${CURRENT_TITLE}" = "${SEARCH_TITLE}" ]; then
            echo "${current_index}"
            break;
        fi
    done
}

[ -d "${LOG_DIR}" ] || mkdir -p -m 0755 "${LOG_DIR}"

display_event "Start" "Begin search for extraneous debug arguments"

if [ "$(id -u)" -ne 0 ]; then
    display_event "Error" "This script may only run as root."
    exit_event 0
fi

######################################################################
# Back up the grub.cfg for sanity
######################################################################
BOOTLOADER_CFG=
BOOTLOADER_CFG_BK=

if [ -f "/etc/grub2.cfg" ]; then
    BOOTLOADER_CFG=$(realpath "/etc/grub2.cfg")
    BOOTLOADER_CFG_BK="${BOOTLOADER_CFG}.${EPOCH_DATE}.rpmsave"
elif [ -f "/etc/grub2-efi.cfg" ]; then
    BOOTLOADER_CFG=$(realpath "/etc/grub2-efi.cfg")
    BOOTLOADER_CFG_BK="${BOOTLOADER_CFG}.${EPOCH_DATE}.rpmsave"
elif [ -f "/etc/zipl.conf" ]; then
    BOOTLOADER_CFG=$(realpath "/etc/zipl.conf")
    BOOTLOADER_CFG_BK="${BOOTLOADER_CFG}.${EPOCH_DATE}.rpmsave"
elif [ -f "/etc/yaboot.conf" ]; then
    BOOTLOADER_CFG=$(realpath "/etc/yaboot.conf")
    BOOTLOADER_CFG_BK="${BOOTLOADER_CFG}.${EPOCH_DATE}.rpmsave"
fi

if [ -z "${BOOTLOADER_CFG}" ]; then
    display_event "Error" "Could not find a bootloader configuration to back up"
    exit_event 0
fi

if [ -f "${BOOTLOADER_CFG}" ]; then
    if cp -a "${BOOTLOADER_CFG}" "${BOOTLOADER_CFG_BK}" 2> /dev/null; then
        display_event "Copied" \
            "Current configuration backed up to ${BOOTLOADER_CFG_BK}"
    else
        display_event "Error" "Could not write ${BOOTLOADER_CFG_BK}"
        exit_event 0
    fi
fi

######################################################################
#  Figure out what the debugging tag will look like
######################################################################
ARCH=$(uname -m)
if [ $ARCH = 's390' -o $ARCH = 's390x' ]; then
    DEBUGGING_TAG="_with_debugging"
else
    DEBUGGING_TAG=" with debugging"
fi

######################################################################
# Remove the systemd.debug kernel arguments from standard non-debug
# kernel entries only
######################################################################
display_event "Examine" "Searching for distribution provided debugging entries"
for entry_index in $(grubby --info=ALL|grep "^index="| sed 's/^index=//') ; do
    INDEX_TITLE=$(grubby --info="${entry_index}" 2> /dev/null |grep "^title=" | sed 's/^title=//')

    # do not do anything if this was empty
    [ -z "${INDEX_TITLE}" ] && continue

    if echo "${INDEX_TITLE}" | grep -q "${DEBUGGING_TAG}$"; then
        display_event "Found" "Found distribution provided debugging entry - ${INDEX_TITLE}"
        NON_DEBUG_TITLE=$(echo "${INDEX_TITLE}" | sed "s/${DEBUGGING_TAG}$//")
        NON_DEBUG_INDEX=$(find_entry_by_title "${NON_DEBUG_TITLE}")

        if [ -n "${NON_DEBUG_INDEX}" ]; then
            display_event "Found" "Found matching non-debugging entry - ${NON_DEBUG_TITLE}"
            KERNEL_ARGS=$(grubby --info="${NON_DEBUG_INDEX}" 2> /dev/null |grep "^args=")
            if echo "${KERNEL_ARGS}" | grep -E -q 'systemd.debug|systemd.log_level=debug|systemd.log_target=kmsg'; then
                if grubby --update-kernel="${NON_DEBUG_INDEX}" --remove-args="systemd.debug systemd.log_level=debug systemd.log_target=kmsg"; then
                    display_event "Update" "Removed debugging arguments for ${NON_DEBUG_TITLE}"
                else
                    display_event "Error" "grubby failed to remove debug argument from ${NON_DEBUG_TITLE}"
                fi
            else
                display_event "Skip" "No debugging arguments to remove for ${NON_DEBUG_TITLE}"
            fi
        else
            display_event "Error" "Could not find the matching non-debugging entry - ${NON_DEBUG_TITLE}"
        fi
    fi
done

######################################################################
# The default entry should not have debugging statements
######################################################################

# source of ALLOW_DEBUGGING_DEFAULT
[ -f /etc/sysconfig/kernel ] && . /etc/sysconfig/kernel

CURRENT_DEFAULT_INDEX=$(grubby --default-index)
CURRENT_TITLE=$(grubby --info="${CURRENT_DEFAULT_INDEX}" 2> /dev/null |grep "^title=" | sed 's/^title=//')
if echo "${CURRENT_TITLE}" | grep -q "${DEBUGGING_TAG}$"; then
    case "${ALLOW_DEBUGGING_DEFAULT}" in
        [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1)
            display_event "Examine" "Detected user preference to allow debugging default entries if present"
            exit_event 0
            ;;
    esac

    display_event "Examine" "Search for entry without debugging to replace default entry - ${CURRENT_TITLE}"

    unset NON_DEBUG_INDEX
    unset NON_DEBUG_TITLE

    ARCH=$(uname -m)
    NON_DEBUG_TITLE=$(echo "${CURRENT_TITLE}" | sed "s/${DEBUGGING_TAG}$//")

    NON_DEBUG_INDEX=$(find_entry_by_title "${NON_DEBUG_TITLE}")

    if [ -n "${NON_DEBUG_INDEX}" ]; then
        if grubby --set-default-index="${NON_DEBUG_INDEX}"; then
            display_event "Update" "Selected ${NON_DEBUG_TITLE} as the new default entry"
        else
            display_event "Error" "Could not set ${NON_DEBUG_TITLE} as default"
        fi
    else
        display_event "Error" "Could not find the matching non-debugging entry"
    fi
fi

exit_event 0

Youez - 2016 - github.com/yon3zu
LinuXploit