..we are going to create a new app for the hacksuite. We're not going to do anything fancy here, we will make a simple app to get familiar how to write compatible scripts for the..
Creates a blueprint/map of a server folder
<?php
/* Determines whether log files contain proper data and find interesting log entries
Author: Remco Kouw
Site: http://www.hacksuite.com
Last Edit: 05-02-2015
*/
if(!defined('IN_SCRIPT')){
exit;
}
if($_CONTEXT['allow_logfileanalyze']){
$_CONTEXT['scanlabel']['log_analyze'] = "logfile analyze";
$_CONTEXT['log_analyze'] = "";
// load the data directory file that contains all core functions or throw a fatal error
$aRequire = array($_PATHS['data_root']."/logsdata.php",$_PATHS['functions_root']."/raw_to_array.php");
for($x=0;$x<count($aRequire);$x++){
(!IsThere($aRequire[$x]) ? include_once($_PATHS['end']) : include_once($aRequire[$x]));
}
for($x=0;$x<count($_CONTEXT['l_formats']);$x++){
// create log file location
$sDest = $_PATHS['log_root']."/".ExploitFilter($_CONTEXT['l_formats'][$x]['file'],1,1);
if(!file_exists($sDest)){
$_CONTEXT['log_analyze'] .= " <div>missing ".$sDest."</div>\n";
}
else{
// some logs need to have content
$iSize = filesize($sDest);
if(isset($_CONTEXT['l_formats'][$x]['format']['notempty'])){
if(!$iSize){
$_CONTEXT['log_analyze'] .= " <div>expecting content in ".$sDest."</div>\n";
continue;
}
}
// if we have content in the logfile make sure that we have a valid structure
if($iSize>0){
if($_CONTEXT['l_formats'][$x]['format']['type']=="plain"){
// plain text file like bla[separate_character]bla\n
$aFile = RawToArray($sDest,$_CONTEXT['l_formats'][$x]['format']['separate']);
for($y=0;$y<count($aFile);$y++){
// make sure the structure is ok
if(count($aFile[$y])!=$_CONTEXT['l_formats'][$x]['format']['items']){
$_CONTEXT['log_analyze'] .= " <div>expecting ".$_CONTEXT['l_formats'][$x]['format']['items']." items on line ".$y." in ".$sDest."</div>\n";
}
}
}
else{
// array based file
include_once($sDest);
if(isset($_CONTEXT[$_CONTEXT['l_formats'][$x]['format']['root']])){
// check all keys on existence
for($y=0;$y<count($_CONTEXT['l_formats'][$x]['format']['keys']);$y++){
if(!isset($_CONTEXT[$_CONTEXT['l_formats'][$x]['format']['root']][$_CONTEXT['l_formats'][$x]['format']['keys'][$y][0]])){
$_CONTEXT['log_analyze'] .= " <div>expecting variable \$_CONTEXT['".$_CONTEXT['l_formats'][$x]['format']['root']."']['".$_CONTEXT['l_formats'][$x]['format']['keys'][$y][0]."'] in ".$sDest."</div>\n";
}
else{
$sType = $_CONTEXT['l_formats'][$x]['format']['keys'][$y][1];
// simple type check
switch($sType){
case"string":
if(!is_string($_CONTEXT[$_CONTEXT['l_formats'][$x]['format']['root']][$_CONTEXT['l_formats'][$x]['format']['keys'][$y][0]])){
$_CONTEXT['log_analyze'] .= " <div>expecting string value for variable \$_CONTEXT['".$_CONTEXT['l_formats'][$x]['format']['root']."']['".$_CONTEXT['l_formats'][$x]['format']['keys'][$y][0]."'] in ".$sDest."</div>\n";
}
break;
case"integer":
if(!is_int($_CONTEXT[$_CONTEXT['l_formats'][$x]['format']['root']][$_CONTEXT['l_formats'][$x]['format']['keys'][$y][0]])){
$_CONTEXT['log_analyze'] .= " <div>expecting integer value for variable \$_CONTEXT['".$_CONTEXT['l_formats'][$x]['format']['root']."']['".$_CONTEXT['l_formats'][$x]['format']['keys'][$y][0]."'] in ".$sDest."</div>\n";
}
break;
case"array":
if(!is_array($_CONTEXT[$_CONTEXT['l_formats'][$x]['format']['root']][$_CONTEXT['l_formats'][$x]['format']['keys'][$y][0]])){
$_CONTEXT['log_analyze'] .= " <div>expecting array value for variable \$_CONTEXT['".$_CONTEXT['l_formats'][$x]['format']['root']."']['".$_CONTEXT['l_formats'][$x]['format']['keys'][$y][0]."'] in ".$sDest."</div>\n";
}
break;
}
}
}
}
else{
$_CONTEXT['log_analyze'] .= " <div>expecting variable \$_CONTEXT['".$_CONTEXT['l_formats'][$x]['format']['root']."'] in ".$sDest."</div>\n";
}
}
}
}
}
$_CONTEXT['scandata']['log_analyze'] = $_CONTEXT['log_analyze'];
}
?>