ROOTPLOIT
Server: Apache
System: Linux node6122.myfcloud.com 6.14.3-x86_64-linode168 #1 SMP PREEMPT_DYNAMIC Mon Apr 21 19:47:55 EDT 2025 x86_64
User: bashacomputer (1004)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib64/nagios/plugins/check_a2_grub.sh.all
#!/bin/bash

# exit if
if ! grep -q Supermicro /sys/class/dmi/id/chassis_vendor 2>/dev/null; then
  exit 0
fi

if [ -e /dev/xvda1 ]; then
  exit 0
else
  if [ -d /boot/efi/EFI ]; then
    # check for EFI grub
    BLCOUNT=$(find /boot/efi/EFI -name grubx64.efi | wc -l)
    if [ ${BLCOUNT} -gt 0 ]; then
      # EFI GRUB loader found!
      echo "Grub status - OK"
      exit 0
    fi
  fi


  DEVICES=$(mdadm --detail $(df / | grep md | awk '{print $1}') | grep -o [hs]d[a-z] | awk '{print $NF}' | tr -d '1$')
  for DEVICE in ${DEVICES};   do
  #Exclude by vendor
  if egrep -q "Areca" /sys/block/$DEVICE/device/vendor; then
    continue;
  fi

  #Exclude removables
  if [ $(cat /sys/block/$DEVICE/removable) -eq 1 ]; then
    continue;
  fi

  #Exclude by model
  if egrep -q "COMSTAR|iSCSI|NEXENTASTOR" /sys/block/$DEVICE/device/model; then
    continue;
  fi

  #Examine MBR header
  dd if=/dev/$DEVICE bs=512 count=1 2>/dev/null | strings | grep -q GRUB
  RET=$?

  if [ $RET -eq 0 ]; then
    # MBR GRUB found
    echo "Grub status - OK"
    exit 0
  else
    # MBR GRUB needs re-installation
    # Warn now and do not continue to next device
    # MBR grub should be on every device
    echo "Grub status - NOT OK"
    exit 2
  fi
  done
fi