当前位置: 首页>>代码示例>>PHP>>正文


PHP Util::execute_command方法代码示例

本文整理汇总了PHP中Util::execute_command方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::execute_command方法的具体用法?PHP Util::execute_command怎么用?PHP Util::execute_command使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Util的用法示例。


在下文中一共展示了Util::execute_command方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: server_get_servers

function server_get_servers($server_list)
{
    $active_servers = 0;
    $total_servers = 0;
    if ($server_list) {
        $total_servers = count($server_list);
        foreach ($server_list as $server) {
            $ip = $server->get_ip();
            $port = $server->get_port();
            try {
                $output = Util::execute_command("echo 'connect id=\"1\" type=\"web\"' | nc ? ? -w1", array($ip, $port), 'array');
                if (strncmp('ok id="1"', $output[0], 9) == FALSE) {
                    $active_servers++;
                }
            } catch (Exception $e) {
            }
        }
    }
    return array($total_servers, $active_servers);
}
开发者ID:jackpf,项目名称:ossim-arc,代码行数:20,代码来源:server_get_servers.php

示例2: execute_sql

function execute_sql($path_file_log, $sql_file, $upgrade)
{
    if (preg_match("/\\.gz\$/", $sql_file)) {
        // Gzipped .sql.gz
        $cmd = "zcat ? | ossim-db > ? 2>&1";
    } else {
        // Normal .sql
        $cmd = "ossim-db < ? > ? 2>&1";
    }
    try {
        Util::execute_command($cmd, array($sql_file, $path_file_log), 'array');
        // Array mode to catch errors
        $php_file = str_replace("_mysql.sql", ".php", $sql_file);
        $php_file = preg_replace("/\\.gz\$/", "", $php_file);
        // Clean .gz
        if (file_exists($php_file)) {
            echo "\t Done\nExecuting: " . $sql_file . "...";
            return execute_php($php_file, $upgrade, $path_file_log);
        }
        return 0;
    } catch (Exception $e) {
        return 1;
    }
}
开发者ID:alienfault,项目名称:ossim,代码行数:24,代码来源:update_db.php

示例3: set_include_path

* You should have received a copy of the GNU General Public License
* along with this package; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA  02110-1301  USA
*
*
* On Debian GNU/Linux systems, the complete text of the GNU General
* Public License can be found in `/usr/share/common-licenses/GPL-2'.
*
* Otherwise you can read it here: http://www.gnu.org/licenses/gpl-2.0.txt
*
*/
set_include_path('/usr/share/ossim/include');
require_once 'av_init.php';
$user = $argv[1];
$file = $argv[2];
$db = new ossim_db();
$conn = $db->connect();
$config = new User_config($conn);
if (!preg_match("/^\\/var\\/tmp\\//", $file) && !preg_match("/^\\/tmp\\//", $file)) {
    echo "Error: 'file' parameter must be a valid /tmp file\n";
    exit;
}
if (!file_exists($file)) {
    echo "Error: '{$file}' file does not exist\n";
    exit;
}
$cmd = "(cat ? | ossim-db; rm -f ?; echo 'flush_all' | /bin/nc -q 2 127.0.0.1 11211; sleep 3) > /var/tmp/alarm_bg_result 2>&1 & echo \$!";
$pid = Util::execute_command($cmd, array($file, $file), 'string');
$config->set($user, 'background_task', $pid, 'simple', 'alarm');
$db->close($conn);
开发者ID:jackpf,项目名称:ossim-arc,代码行数:31,代码来源:bg_alarms.php

示例4: ossim_query

     // generate PDF
     $query = ossim_query("SELECT scantime, report_key FROM vuln_nessus_reports WHERE report_id={$report_id}");
     $rs = $dbconn->Execute($query);
     if (!$rs) {
         print $dbconn->ErrorMsg();
     } else {
         if (!$rs->EOF) {
             $scan_END = $rs->fields['scantime'];
             $report_key = $rs->fields['report_key'];
         }
     }
     $file_path = "/usr/share/ossim/www/tmp/" . $result->fields["name"] . "_" . $scan_END . ".pdf";
     $file_path = str_replace(" ", "", $file_path);
     $file_name = $result->fields["name"] . "_" . $scan_END . ".pdf";
     $params = array($report_id, $file_path);
     Util::execute_command("/usr/bin/php /usr/share/ossim/scripts/vulnmeter/respdf.php ? > ?", $params);
     if (file_exists($file_path) && filesize($file_path) <= 5242880) {
         $attachments[] = array("path" => $file_path, "name" => $file_name);
     }
 }
 if (!valid_hex32($username)) {
     $body = get_timestamps($dbconn, $username, $result->fields['scan_START'], $result->fields['scan_SUBMIT'], $body);
     $email = get_email($dbconn, $username);
     Util::send_email($dbconn, $email, $subject, $body, $attachments);
 } else {
     // username is a entity
     $entity_data = Acl::get_entity($dbconn, $username, FALSE, FALSE);
     if ($entity_data["admin_user"] != "") {
         $body = get_timestamps($dbconn, $entity_data["admin_user"], $result->fields['scan_START'], $result->fields['scan_SUBMIT'], $body);
         $email = get_email($dbconn, $entity_data["admin_user"]);
         Util::send_email($dbconn, $email, $subject, $body, $attachments);
开发者ID:jackpf,项目名称:ossim-arc,代码行数:31,代码来源:send_notification.php

示例5: newFolder

function newFolder($name)
{
    if (file_exists($name)) {
        return false;
    } else {
        @mkdir($name, 0755, true);
        Util::execute_command("chown www-data:www-data ?", array(dirname($name)));
        Util::execute_command("chown www-data:www-data ?", array($name));
        return true;
    }
}
开发者ID:jackpf,项目名称:ossim-arc,代码行数:11,代码来源:launcher.php

示例6: array

    $result_server = $dbconn->Execute("SELECT meth_Wcheck FROM vuln_jobs WHERE id = ?", array($job_id));
    preg_match("/.*\\s(\\d+\\.\\d+\\.\\d+\\.\\d+)<.*/", $result_server->fields['meth_Wcheck'], $found);
    $sensor_id = Av_sensor::get_id_by_ip($dbconn, $found[1]);
    $sensor_object = new Av_sensor($sensor_id);
    $sensor_object->load_from_db($dbconn);
    $ov_credentials = $sensor_object->get_vs_credentials($dbconn);
    $port = $ov_credentials['port'];
    $user = $ov_credentials['user'];
    $password = $ov_credentials['password'];
    $omp = new Omp($sensor_object->get_ip(), $port, $user, $password);
}
switch ($disp) {
    case "kill":
        $schedid = intval($schedid);
        if ($schedid > 0) {
            Util::execute_command("sudo /usr/share/ossim/scripts/vulnmeter/cancel_scan.pl ?", array($schedid));
        }
        break;
    case "playTask":
        $omp->play_task($job_id);
        break;
    case "pauseTask":
        $omp->pause_task($job_id);
        break;
    case "stopTask":
        $omp->stop_task($job_id);
        break;
    case "resumeTask":
        $omp->resume_task($job_id);
        break;
    case "deleteTask":
开发者ID:jackpf,项目名称:ossim-arc,代码行数:31,代码来源:manage_jobs.php

示例7: run_ip2cc

/**
 * Second method how to lookup the country corresponding to an ip address:
 * Makes use of the perl module IP::Country
 * http://search.cpan.org/dist/IP-Country/
 * The web server needs permission to execute "ip2cc".
 * Quoting from the php manual:
 * "Note: When safe mode is enabled, you can only execute executables within the safe_mode_exec_dir. For practical reasons it is currently not allowed to have .. components in the path to the executable."
 *
 * $IP2CC must contain the absolute path to this executable.
 *
 *
 */
function run_ip2cc($address_with_dots, &$country)
{
    global $db, $debug_mode, $IP2CC, $iso_3166;
    if (empty($address_with_dots)) {
        ErrorMessage("ERROR: \$address_with_dots is empty<BR>\n");
        return 0;
    }
    if (!is_file($IP2CC) || !is_executable($IP2CC)) {
        ErrorMessage("ERROR: with \$IP2CC = \"" . $IP2CC . "\"<BR>\n");
        return 0;
    }
    $cmd = $IP2CC . " ?";
    unset($output);
    try {
        $output = Util::execute_command($cmd, array($address_with_dots), 'array');
    } catch (Exception $e) {
        ErrorMessage("ERROR with " . $cmd . "<BR>\n");
        print_r($output);
        return 0;
    }
    $result = explode(" ", $output[6]);
    $max = count($result);
    $country = "";
    for ($i = 3; $i < $max; $i++) {
        $country .= $result[$i] . " ";
    }
    // if ($debug_mode > 0) {
    // print "Found: " . $address_with_dots . " belongs to " . $country . "<BR>\n";
    // }
    return 1;
}
开发者ID:alienfault,项目名称:ossim,代码行数:43,代码来源:base_graph_common.php

示例8: device

        $conn->Execute("BEGIN");
        $conn->Execute("TRUNCATE acid_event");
        $conn->Execute("TRUNCATE ac_acid_event");
        $conn->Execute("TRUNCATE po_acid_event");
        $conn->Execute("TRUNCATE device");
        $conn->Execute("REPLACE INTO device (id, device_ip, interface, sensor_id) VALUES (999999, 0x0, '', 0x0)");
        $conn->Execute("UPDATE device SET id = 0 WHERE id = 999999");
        $conn->Execute("TRUNCATE extra_data");
        $conn->Execute("TRUNCATE reputation_data");
        $conn->Execute("TRUNCATE idm_data");
        $conn->Execute("TRUNCATE otx_data");
        $conn->Execute("COMMIT");
        $conn->Execute("SET AUTOCOMMIT=1");
        Util::memcacheFlush();
        session_write_close();
        Util::execute_command('sudo /etc/init.d/ossim-server restart > /dev/null 2>&1 &');
    }
}
$run_data = Backup::is_running($conn_ossim);
$run = $run_data[0];
$db->close($conn);
$db->close($conn_ossim);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <title><?php 
echo _('Backup');
?>
</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
开发者ID:jackpf,项目名称:ossim-arc,代码行数:31,代码来源:index.php

示例9: GET

*/
require_once 'av_init.php';
Session::logcheck("analysis-menu", "EventsForensics");
require_once 'classes/Util.inc';
$id = GET('id');
ossim_valid($id, OSS_HEX, 'illegal:' . _("id"));
if (ossim_error()) {
    die(ossim_error());
}
//Labels
$tl_error = utf8_encode(_("Error in pcap format!"));
$pcapfile = "/var/tmp/base_packet_" . $id . ".pcap";
$pdmlfile = "/var/tmp/base_packet_" . $id . ".pdml";
// TSAHRK: show packet in web page
$cmd = "tshark -V -r ? -T pdml > ?";
Util::execute_command($cmd, array($pcapfile, $pdmlfile));
?>
<ul style="display:none"><li id="key1" data="isFolder:true, icon:'../../images/any.png'">
<?php 
if (file_exists($pdmlfile) && filesize($pdmlfile) > 0) {
    $i = 1;
    if ($xml = @simplexml_load_file($pdmlfile)) {
        foreach ($xml->packet->proto as $key => $xml_entry) {
            $atr_tit = $xml_entry->attributes();
            if ($atr_tit['name'] == "geninfo") {
                $img = "information.png";
            } elseif ($atr_tit['name'] == "tcp" || $atr_tit['name'] == "udp") {
                $img = "proto.png";
            } elseif ($atr_tit['name'] == "ip") {
                $img = "flow_chart.png";
            } elseif ($atr_tit['name'] == "frame") {
开发者ID:jackpf,项目名称:ossim-arc,代码行数:31,代码来源:base_payload_tshark_tree.php

示例10: check_bg_tasks

function check_bg_tasks($conn)
{
    $user = Session::get_session_user();
    $config = new User_config($conn);
    //Getting the pid of the operation running in background
    $pid = $config->get($user, 'background_task', 'simple', "alarm");
    $bg = FALSE;
    //If the pid is not empty, then we check if the process is still running
    if ($pid != '') {
        //Launching a ps with the pid stored
        $process_state = Util::execute_command('ps ?', array(intval($pid)), 'array');
        $bg = count($process_state) >= 2;
        //If the count is >= 2 then there is a process running
        //If the process is not running any longer, then we delete the pid from db
        if (!$bg) {
            $config->set($user, 'background_task', '', 'simple', 'alarm');
        }
    }
    $return['error'] = FALSE;
    $return['msg'] = '';
    $return['bg'] = $bg;
    Util::memcacheFlush(FALSE);
    return $return;
}
开发者ID:jackpf,项目名称:ossim-arc,代码行数:24,代码来源:alarm_actions.php

示例11: ossim_set_error

    if (!Ossec_utilities::is_sensor_allowed($conn, $sensor_id)) {
        ossim_set_error(_('Error! Sensor not allowed'));
    }
    $db->close();
}
if (ossim_error()) {
    echo '2###' . _('We found the followings errors') . ": <div style='padding-left: 15px; text-align:left;'>" . ossim_get_error_clean() . '</div>';
    exit;
}
//Current sensor
$_SESSION['ossec_sensor'] = $sensor_id;
if ($tab == '#tab1') {
    try {
        $conf_data = Ossec::get_configuration_file($sensor_id);
        $command = 'egrep "<[[:space:]]*include[[:space:]]*>.*xml<[[:space:]]*/[[:space:]]*include[[:space:]]*>" ?';
        $output = Util::execute_command($command, array($conf_data['path']), 'array');
        $rules_enabled = array();
        foreach ($output as $k => $v) {
            if (preg_match("/^<\\s*include\\s*>(.*)<\\s*\\/include\\s*>/", trim($v), $match)) {
                $rules_enabled[] = $match[1];
            }
        }
        sort($rules_enabled);
        $all_rules = Ossec::get_rule_files($sensor_id);
        $no_added_rules = array_diff($all_rules, $rules_enabled);
        echo "1###";
        ?>
        <div id='cnf_rules_cont'>
            <table class='cnf_rules_table'>
                <tr>
                    <td style='padding: 8px 0px 6px 0px;'><?php 
开发者ID:jackpf,项目名称:ossim-arc,代码行数:31,代码来源:load_tabs.php

示例12: str_replace

    for ($i = 1; $i < $total; $i++) {
        $l = $lines[$i];
        $l = str_replace("host=", "<b><font color = \"red\">host=</font></b>", $l);
        $l = str_replace("port=", "<b><font color = \"red\">port=</font></b>", $l);
        foreach ($types as $t) {
            $l = str_replace($t, "<b><font color = \"blue\">" . $t . "</font></b>", $l);
        }
        print $l . "<br>";
    }
    if ($total == $maxlines) {
        print "[...]<br>";
    }
    print "</pre></div></p>";
    $output_file = '/tmp/shellcode.png';
    $tmp2 = tempnam("/tmp", "dot");
    @unlink($output_file);
    Util::execute_command('sctest -Sgs 1000000 -G ? < ?', array($tmp2, $tmp));
    Util::execute_command('dot -Tpng -Gcharset=latin1 -Gsize="400,300" ? -o ?', array($tmp2, $output_file));
    if (file_exists($output_file)) {
        $img = 'data:image/png;base64,' . base64_encode(file_get_contents($output_file));
        echo '<img src="' . $img . '" style="border: 1px solid #333333; padding:5px;width:99%"/>';
    }
    @unlink($tmp2);
    @unlink($output_file);
}
@unlink($tmp);
@unlink($tmpout);
?>
</body>
</html>
开发者ID:jackpf,项目名称:ossim-arc,代码行数:30,代码来源:shellcode.php

示例13: array

 *  $Id: nfsen.php 22 2007-11-20 12:27:38Z phaag $
 *
 *  $LastChangedRevision: 22 $
 *
 */
// The very first function to call
require_once 'av_init.php';
Session::logcheck("environment-menu", "MonitorsNetflows");
require 'conf.php';
require 'nfsenutil.php';
require 'navigator.php';
/*
We need to use the timezone of the box in orther to keep synchronized the PHP and the NfSen.
This is needed after upgrading to PHP 5.4 (The PHP timezone is UTC by default and it might not match with the machine's timezone)
*/
$machine_tz = Util::execute_command("head -1 /etc/timezone | tr -d '\n'", FALSE, 'string');
if ($machine_tz != '') {
    date_default_timezone_set($machine_tz);
}
$expected_version = "1.3.6p1";
if ($_REQUEST["login"] != "") {
    $_POST["process"] = "Process";
}
// Session check
if (!array_key_exists('backend_version', $_SESSION) || $_SESSION['backend_version'] != $expected_version) {
    //session_destroy();
    //session_start();
    $_SESSION['version'] = $expected_version;
    //print "<h1>Frontend - Backend version missmatch!</h1>\n";
}
$TabList = array('Home', 'Graphs', 'Details');
开发者ID:jackpf,项目名称:ossim-arc,代码行数:31,代码来源:nfsen.php

示例14: array

             $xml_rules[] = "<include>{$rule}</include>";
         } else {
             $xml_rules[] = "<!--<include>{$rule}</include>-->";
         }
     } else {
         if (array_key_exists($rule, $rules_enabled)) {
             $xml_rules[$rule_order[$rule]] = "<include>{$rule}</include>";
         } else {
             $xml_rules[$rule_order[$rule]] = "<!--<include>{$rule}</include>-->";
         }
     }
 }
 $rule_xml = Util::execute_command("egrep \"<[[:space:]]*rule[[:space:]]*>.*<[[:space:]]*/[[:space:]]*rule[[:space:]]*>\" ?", array($conf_data['path']), 'array');
 $rule_dir_xml = Util::execute_command("egrep \"<[[:space:]]*rule_dir[[:space:]]*>.*<[[:space:]]*/[[:space:]]*rule_dir[[:space:]]*>\" ?", array($conf_data['path']), 'array');
 $decode_xml = Util::execute_command("egrep \"<[[:space:]]*decode[[:space:]]*>.*<[[:space:]]*/[[:space:]]*decode[[:space:]]*>\" ?", array($conf_data['path']), 'array');
 $decode_dir_xml = Util::execute_command("egrep \"<[[:space:]]*decode_dir[[:space:]]*>.*<[[:space:]]*/[[:space:]]*decode_dir[[:space:]]*>\" ?", array($conf_data['path']), 'array');
 if (is_array($rule_xml) && !empty($rule_xml)) {
     foreach ($rule_xml as $k => $v) {
         $xml_rules[] = trim($v);
     }
 }
 if (is_array($rule_dir_xml) && !empty($rule_dir_xml)) {
     foreach ($rule_dir_xml as $k => $v) {
         $xml_rules[] = trim($v);
     }
 }
 if (is_array($decode_xml) && !empty($decode_xml)) {
     foreach ($decode_xml as $k => $v) {
         $xml_rules[] = trim($v);
     }
 }
开发者ID:jackpf,项目名称:ossim-arc,代码行数:31,代码来源:save_tabs.php

示例15: while

        $fsearch = Util::execute_command("sudo ps ax |grep 'fetch_all'| grep -v grep", FALSE, 'array');
    } else {
        $exit = true;
    }
}
// to alienvault_search process
$exit = false;
$fsearch = Util::execute_command("sudo ps ax |grep 'alienvault_search'| grep -v grep", FALSE, 'array');
while (count($fsearch) > 0 && !$exit) {
    $pids_to_kill = array();
    foreach ($fsearch as $result) {
        if ($debug) {
            echo $result . "\n";
        }
        if (preg_match("/^\\s*(\\d+)\\s.*/", $result, $match)) {
            $pids_to_kill[] = $match[1];
        }
    }
    $fsearch = array();
    if (count($pids_to_kill) > 0) {
        $all_pids = implode(" ", $pids_to_kill);
        if ($debug) {
            echo "sudo kill -9 {$all_pids}\n";
        }
        Util::execute_command("sudo kill -9 ?", array($all_pids));
        sleep(2);
        $fsearch = Util::execute_command("sudo ps ax |grep 'alienvault_search'| grep -v grep", FALSE, 'array');
    } else {
        $exit = true;
    }
}
开发者ID:jackpf,项目名称:ossim-arc,代码行数:31,代码来源:kill_scheduled_report.php


注:本文中的Util::execute_command方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。