Beispiel #1
0
if ($data['status'] == 'error') {
    $data['status'] = 'error';
    $data['data'] = _('We found the followings errors:') . "<div style='padding-left: 15px; text-align:left;'>" . $data['data'] . '</div>';
    echo json_encode($data);
    exit;
}
if (!Ossec::is_editable($file)) {
    $data['status'] = 'error';
    $data['data'] = _('Error! File not editable');
    echo json_encode($data);
    exit;
}
$_SESSION['_current_file'] = $file;
$lk_name = $_SESSION['lk_name'];
$new_xml_data = html_entity_decode(base64_decode($new_xml_data), ENT_QUOTES, 'UTF-8');
$xml_obj = new Xml_parser($lk_name);
$xml_obj->load_string($new_xml_data);
if ($xml_obj->errors['status'] == FALSE) {
    $data['status'] = 'error';
    $data['data'] = "<div id='parse_errors'>\n                        <span style='font-weight: bold;'>" . _('Data in XML file with wrong format') . "&nbsp;<a onclick=\"\$('#msg_errors').toggle();\"> [" . _('View errors') . "]</a></span>\n                        <br/><div id='msg_errors'>" . implode('', $xml_obj->errors['msg']) . "</div>\n                   </div>";
} else {
    try {
        Ossec::set_rule_file($sensor_id, $file, $new_xml_data);
        $array_xml = $xml_obj->xml2array();
        $tree_json = Ossec_utilities::array2json($array_xml, $file);
        $_SESSION['_tree_json'] = $tree_json;
        $_SESSION['_tree'] = $array_xml;
        $data['data'] = _("{$file} updated successfully") . '###' . base64_encode($tree_json);
    } catch (Exception $e) {
        $data['status'] = 'error';
        $data['data'] = $e->getMessage();
Beispiel #2
0
*
* 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
*
*/
require_once dirname(__FILE__) . '/../../conf/config.inc';
Session::logcheck('environment-menu', 'EventsHidsConfig');
//Get XML node
$lk_value = POST('lk_value');
$lk_name = $_SESSION['lk_name'];
$tree_lr = $_SESSION['_tree'];
$child = Ossec::get_child($tree_lr, $lk_name, $lk_value);
$rule = array('@attributes' => array($lk_name => '1'), '0' => array('rule' => $child['tree']));
if (!empty($child)) {
    $xml_obj = new Xml_parser($lk_name);
    $output = $xml_obj->array2xml($rule);
    $data['status'] = 'success';
    $data['data'] = Ossec_utilities::formatOutput($output, $lk_name);
} else {
    $data['status'] = 'error';
    $data['data'] = _('Error! Information not available');
}
echo json_encode($data);
            $data['data'] = _('Invalid branch value');
            echo json_encode($data);
        } else {
            if (!empty($nodes) && is_array($nodes)) {
                $ok = @eval("\$tree{$branch}=\$nodes;");
            }
        }
        break;
}
if ($data['status'] != 'error') {
    if ($ok === FALSE) {
        $data['status'] = 'error';
        $data['data'] = _('Error! XML file not updated (1)');
        echo json_encode($data);
    } else {
        $xml = new Xml_parser($lk_name);
        $output = $xml->array2xml($tree);
        $output = Ossec_utilities::formatOutput($output, $lk_name);
        $output = utf8_decode($output);
        try {
            Ossec::set_rule_file($sensor_id, $file, $output);
            $tree = Ossec::get_tree($sensor_id, $file);
            $tree_json = Ossec_utilities::array2json($tree, $file);
            $_SESSION['_tree_json'] = $tree_json;
            $_SESSION['_tree'] = $tree;
        } catch (Exception $e) {
            $data['status'] = 'error';
            $data['data'] = $e->getMessage();
        }
    }
}
Beispiel #4
0
                    $(nRow).find('a').off('click');
                    $(nRow).find('a').click(function() {
                        var id = $(this).attr("id");
                        get_action(id);
                    });
                }
            });
    </script>
    <?php 
} else {
    if ($tab == '#tab2') {
        $ac_key = empty($_POST['ac_key']) ? 0 : $_POST['ac_key'];
        try {
            // Agent.conf
            $conf_data = Ossec_agent::get_configuration_file($sensor_id);
            $xml_obj = new Xml_parser('key');
            $xml_obj->load_string($conf_data['data']);
            $array_oss_cnf = $xml_obj->xml2array();
            $agent_config = Ossec::get_nodes($array_oss_cnf, 'agent_config');
            $ac_keys[] = array();
            if (is_array($agent_config) && !empty($agent_config)) {
                foreach ($agent_config as $k => $ac_data) {
                    unset($ac_data['@attributes']['key']);
                    $keys = array_keys($ac_data['@attributes']);
                    $ac_keys[$k] = $keys[0] . ' = "' . $ac_data['@attributes'][$keys[0]] . '"';
                }
            }
            $syscheck = Ossec::get_nodes($array_oss_cnf, 'syscheck');
            $syscheck = $syscheck[$ac_key];
            $directories = Ossec::get_nodes($syscheck, 'directories');
            $wentries = Ossec::get_nodes($syscheck, 'windows_registry');