2021SC@SDUSC
os-sim/www原始碼分析之action.php
- 前言
- 一、php部分
- 二、html部分
- 2.1、head部分
- 2.2、body部分
- 總結
前言
在分析這個專案的原始碼時,我對php還不太了解,所以先了學習一些基礎知識,然后根據代碼自行理解遇到具體問題再去查閱,
PHP 是 PHP Hypertext Preprocessor(超文本與處理器)的首字母縮寫,
PHP有多種用途,特別是web網站開發,快速,靈活,實用使得php能夠更好的開發任何網站,
PHP 是一種 HTML 嵌入式的腳本語言,php檔案以.php結尾,它的很多語法來自 C,Java 和 Perl,并具有幾個 PHP 獨有的特點,該語言的主要目標是讓 Web 開發人員快速地書寫動態生成的網頁,
幾個基本常識:
- 指令分隔符 “;”
- 輸出陳述句:echo() 、 print()、 print_r()、var_dump()
- 變數是弱型別的,即不需要實作宣告型別、unset()函式釋放指定的變數
- 變數以$ 開始,常量不能加$
- 腳本以<?php開始 ,以 ?>結束
- 注釋 // /* … */
一、php部分
<?php
require_once 'av_init.php';
Session::logcheck("configuration-menu", "PolicyActions");
// load column layout
require_once '../conf/layout.php';
$category = "policy";
$name_layout = "actions_layout";
$layout = load_layout($name_layout, $category);
?>
1、require_once()是php檔案中作用是引入,此行為和require()陳述句類似,但區別是如果該檔案中的代碼已經被包含了,則不會再次包含,
2、Session::logcheck檢查登錄用戶的訪問權限
3、load_layout加載頁面
二、html部分
2.1、head部分
1)
<title> <?php echo gettext("OSSIM Framework"); ?> </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<link rel="stylesheet" type="text/css" href="../style/av_common.css?t=<?php echo Util::get_css_id() ?>"/>
<link rel="stylesheet" type="text/css" href="../style/flexigrid.css"/>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/jquery.flexigrid.js"></script>
<script type="text/javascript" src="../js/urlencode.js"></script>
- meta中的
http-equiv="X-UA-Compatible"是針對IE8新加的一個設定,避免制作出的頁面在IE8下面出現錯誤,將IE8使用IE7進行渲染,其余的資訊,可以參考meta的使用檔案, - link和script都是在引入.css檔案和.js檔案
2)style部分是頁面渲染的內容,我對此進行略過,重點分析script部分,
scipt部分有五個function,分別對應五個不同功能
function menu_action(com,id,fg,fp)
{
if (com=='modify')
{
if (typeof(id) != 'undefined')
{
document.location.href = 'actionform.php?id='+id;
}
else
{
alert('<?php echo Util::js_entities(_("Action unselected"))?>');
}
}
else if (com=='delete')
{
if (typeof(id) != 'undefined')
{
if (confirm("<?php echo Util::js_entities(_('Are you sure you want to delete the selected action?')) ?>"))
{
$("#flextable").changeStatus('<?=_("Deleting action")?>...',false);
$.ajax({
type: "GET",
url: "deleteaction.php?id="+urlencode(id),
data: "",
success: function(msg) {
$("#flextable").flexReload();
}
});
}
}
else
{
alert('<?php echo Util::js_entities(_("Action unselected"))?>');
}
}
else if (com == 'new')
{
document.location.href = 'actionform.php';
}
}
負責目錄修改和洗掉事件的回應,
function action(com,grid)
{
var items = $('.trSelected', grid);
if (com=='<?php echo _("Delete selected");?>')
{
//Delete host by ajax
if (typeof(items[0]) != 'undefined')
{
if (confirm("<?php echo Util::js_entities(_('Are you sure you want to delete the selected action?')) ?>"))
{
$("#flextable").changeStatus('<?=_("Deleting action")?>...',false);
$.ajax(
{
type: "GET",
url: "deleteaction.php?id="+urlencode(items[0].id.substr(3)),
data: "",
success: function(msg) {
$("#flextable").flexReload();
}
});
}
}
else
{
alert('<?php echo Util::js_entities(_("Action unselected"))?>');
}
}
else if (com=='<?php echo _("Modify");?>')
{
if (typeof(items[0]) != 'undefined')
{
document.location.href = 'actionform.php?id='+urlencode(items[0].id.substr(3))
}
else
{
alert('<?php echo Util::js_entities(_("Action unselected"))?>');
}
}
else if (com=='<?php echo _("New");?>')
{
document.location.href = 'actionform.php'
}
}
負責修改和洗掉的實作,
function apply_changes()
{
<?php $back = preg_replace ('/([&|\?]msg\=)(\w+)/', '\\1', $_SERVER["REQUEST_URI"]);?>
document.location.href = '../conf/reload.php?what=policies&back=<?php echo urlencode($back);?>';
}
切換到新的路由,且用 document.location.href切換后,可以退回到原頁面,
2.2、body部分
實作了一個按鈕
<?php
if (Web_indicator::is_on("Reload_policies"))
{
echo "<button class='button' οnclick='apply_changes()'>"._("Apply Changes")."</button>";
}
?>
對應前文的修改洗掉等操作目錄,
<ul id="myMenu" class="contextMenu" style="width:110px">
<li class="hostreport"><a href="#new" class="greybox" style="padding:3px"><img src="../pixmaps/tables/table_row_insert.png" align="absmiddle"/> <?=_("New Action")?></a></li>
<li class="hostreport"><a href="#modify" class="greybox" style="padding:3px"><img src="../pixmaps/tables/table_edit.png" align="absmiddle"/> <?=_("Modify")?></a></li>
<li class="hostreport"><a href="#delete" class="greybox" style="padding:3px"><img src="../pixmaps/tables/table_row_delete.png" align="absmiddle"/> <?=_("Delete")?></a></li>
</ul>
總結
OSSIM本質上通過對各種探測器和監控產生的告警進行格式化處理,再進行關聯分析,通過后期處理 ,通過圖形化界面展示給用戶,這里www目錄主要實作web界面的設計,同時系結了一些事件回應,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/374594.html
標籤:其他
上一篇:2021黑盾杯CTF部分WP
