| Current Path : /home/jeromecohp/www/aesecure/tools/pentest/ |
| Current File : /home/jeromecohp/www/aesecure/tools/pentest/pentest.php |
<?php
// @file : /tools/pentest/pentest.php
// @version : 2.0.2
// @author : AVONTURE Christophe - christophe@aesecure.com
// @copyright : (C) 2013-2015 - Christophe Avonture - all right reserved.
// @url : http://www.aesecure.com/
// @package : 2015-02-14 13:37:55
// @license : This program is a commercial software. You CAN'T redistribute it and/or modify it.
// Source code is the property of Christophe Avonture and can't be reused, in whole or in part, in any programs.
?>
<?php
require_once ('../aesecure.php');if(!defined('_AESECURE')) define('_AESECURE',1);
class aecPT{
var $root = null;var $template = null;var $json = null;var $jsonfile=null;var $aesC=null;var $aesL=null;var $aesS=null;var $aeSt=null;
function __construct(){
$this->root = dirname(dirname(dirname(__FILE__)));$this->jsonfile = dirname(__FILE__).'/pentest.json';$this->template = dirname(__FILE__);if(is_readable($this->jsonfile)){
require_once($this->root.'/helpers/session.php');$this->aesS = aecS::getInstance();require_once ($this->root.'/helpers/configuration.php');$this->aesC = aeSecureConfiguration::getInstance();if($this->aesC->dbu()===true){error_reporting(E_ALL);}
require_once($this->root.'/helpers/language.php');$this->aesL = aecLa::getInstance($this->aesS->get('language'));require_once ($this->root.'/helpers/settings.php');$this->aeSt = aecSt::getInstance();$this->json = json_decode(file_get_contents($this->jsonfile), true);} else{
die('pentest.json not found');} return true;} private function Display(){
$lines='';
$i=0;
$select='<span class="actionbtn smallbtn glyphicon glyphicon-ok" data-task="select_all" data-restrict="%s" title="'.$this->aesL->getValue('main','select_all','Select all').'"></span>';
$unselect='<span class="actionbtn smallbtn glyphicon glyphicon-remove" data-task="unselect_all" data-restrict="%s" title="'.$this->aesL->getValue('main','unselect_all','Unselect all').'"></span>';
$toggle='<span class="actionbtn smallbtn glyphicon glyphicon-refresh" data-task="select_toggle" data-restrict="%s" title="'.$this->aesL->getValue('main','toggle','Toggle').'"></span>';
$run='<span class="actionbtn smallbtn glyphicon glyphicon-play" data-task="doit" data-restrict="%s" title="'.$this->aesL->getValue('pentest','run','Run the test').'"></span>';
ksort($this->json['urls'], SORT_ASC);foreach ($this->json['urls'] as $code=>$arr){
if($arr['enabled']=="0") continue;
list($msg,$ban,$mail)=$this->aeSt->getCode($code);
$info=($code!='other'?'Code '.$code.':':'').$msg;if(isset($arr['info'])) $info.=(trim($info)!=''?'<br/><em><small>'.$arr['info'].'</small></em>':$arr['info']);
$toolbar='<span class="smallbtn btn-info">'.sprintf($select,$code);
$toolbar.=sprintf($unselect,$code);
$toolbar.=sprintf($toggle,$code).'</span> ';
$toolbar.='<span class="smallbtn btn-primary ">'.sprintf($run,$code).'</span>';
$lines.=
'<tr>'.'<td class="info" colspan="6">'.$info.'<span class="itemtoolbar">'.$toolbar.'</span>'. '</tr>';
ksort($arr['samples'], SORT_ASC);
$arrTmp = array();foreach ($arr['samples'] as $key => $row) $arrTmp[$key] =key($row);
array_multisort($arrTmp, SORT_ASC,$arr['samples'] );foreach ($arr['samples'] as $entry){
foreach ($entry as $url=>$enabled){
if($enabled==0) continue;
$url=ltrim($url,'/');if(trim($url)=='') continue;
$url=str_replace('$ROOT/',$this->aeSt->siUl(),$url);
$i++;
$lines.=
'<tr id="row'.$i.'">'.'<td class="chk"><input type="checkbox" id="chk'.$i.'" data-parent="'.$code.'"/></td>'.'<td class="nbr">'.$i.'</td>'.'<td class="code">'.$code.'</td>'.'<td class="action"><span class="actionbtn glyphicon glyphicon-new-window" data-task="open" data-id="'.$i.'"></span></td>'.'<td class="url" id="url'.$i.'">'.htmlentities($url).'</td>'.'<td id="result'.$i.'"> </td>'.'</tr>';}}}
require_once ($this->root.'/helpers/third/aes.php'); require_once ($this->root.'/helpers/third/aesctr.php');
$timer = microtime(true);
$pwd='dtHWqdjtlxHHRrz1k70M';
$url=AesCtr::encrypt($this->aeSt->siUl().'aesecure/tools/pentest/tests/',$pwd,256);
$url='{"url":"'.$url.'"}';
$fname=str_replace('pentest.json','settings.json',$this->jsonfile);
$fp = fopen($fname,"wb");
fwrite($fp,$url);
fclose($fp);$html=file_get_contents($this->template.'/pentest.default.aec');$html=str_replace('%PENTEST_TITLE%',$this->aesL->getValue('pentest','title','PenTest'),$html);$html=str_replace('%PENTEST_INTRO%',$this->aesL->getValue('pentest','intro',''),$html);$html=str_replace('%RUNTEST%',$this->aesL->getValue('pentest','run','Run the test'),$html);$html=str_replace('%SELECTALL%',$this->aesL->getValue('main','select_all','Select all'),$html);$html=str_replace('%UNSELECTALL%',$this->aesL->getValue('main','unselect_all','Unselect all'),$html);$html=str_replace('%TOGGLE%',$this->aesL->getValue('main','toggle','Toggle'),$html);$html=str_replace('%RESULT%',$this->aesL->getValue('main','result','Result'),$html);$html=str_replace('%SUCCESS%',str_replace("'","\'",$this->aesL->getValue('pentest','finished','Tests done')),$html);$html=str_replace('%AESECUREKEY%',$this->aesC->get('key'),$html);$html=str_replace('%AESECUREDEMO%',$this->aesC->mo()?'true':'false',$html);$html=str_replace('%AESECURETOKEN%',$this->aesS->get('token',NULL),$html);$html=str_replace('%TOKEN%',$this->aesS->get('token_value',NULL),$html);$html=str_replace('%LINES%',$lines,$html);echo $html;}
private function GetJSON(){
$jsonfile = dirname(__FILE__).'/settings.json';if(is_readable($jsonfile)){
echo file_get_contents($jsonfile);} else{
echo "";}} public function Process(){
$task=aecFt::gRvl($param='task',$default='display',$maxlen='10',$type='string',$where='POST');if($task=='display'){
self::Display();} elseif($task=='json'){
self::GetJSON();} else{
aecFt::SeAD('Invalid call');}}}
$aesPT = new aecPT();
$aesPT->Process();
unset($aesPT);