\x20\40\x20\40
<?php
require_once "/usr/local/cpanel/php/cpanel.php";
$cpanel = new CPANEL();
print $cpanel->header( "MalSSH Scanner", "malssh_scanner_cpanel" );
//check if registration is done
$content = file('/usr/bin/malssh');
foreach ($content as $v){
if(strpos($v,'LICENSE') !== false){
eval($v);
break;
}
}
if(strpos(LICENSE,'{LICENSE_KEY}') !== false)
{
MalSSH_ShowErrorMessage('Administrator has not registered MalSSH scanner. Сontact your hosting provider.', 'MalSSH license issue');
}
else {
if(isset($_REQUEST['path']) && !empty($_REQUEST['path']) && isset($_REQUEST['report_path']) && !empty($_REQUEST['report_path']))
{
$status = exec("/usr/bin/malssh --scan='".$_REQUEST['path']."' --report='".$_REQUEST['report_path']."' -o='file'", $output);
if ($status === false)
{
MalSSH_ShowErrorMessage(implode("<br>", $output), 'PHP exec returned false');
}
else {
$output = implode("<br>", $output);
if (strpos($output, "Error:") !== false) MalSSH_ShowErrorMessage($output, 'MalSSH module returned error status');
}
}
$variables = $cpanel->uapi(
'Variables', 'get_user_information',
array(
'name-1' => 'home',
)
);
$homedir = $variables["cpanelresult"]["result"]["data"]["home"];
$report_path = $variables["cpanelresult"]["result"]["data"]["home"] . '/malssh_report.txt'
?>
<script>
function ShowLoader()
{
document.getElementById("container_main").style.display = "none";
document.getElementById("container_loader").style.display = "inline";
document.getElementById("container_loader").innerHTML = '<p style="text-align:center;"><span class="lds-dual-ring"></span><br><b>Scan is in progress. Please wait.</b></p>';
}
</script>
<style>
.lds-dual-ring {
display: inline-block;
width: 80px;
height: 80px;
}
.lds-dual-ring:after {
content: " ";
display: block;
width: 64px;
height: 64px;
margin: 8px;
border-radius: 50%;
border: 6px solid #21ba45;
border-color: #21ba45 transparent #21ba45 transparent;
animation: lds-dual-ring 1.2s linear infinite;
}
@keyframes lds-dual-ring {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
<div class="section">
<h2>Scan</h2>
<br>
<div style="display:none" id="container_loader"></div>
<div id="container_main">
<form method="POST" action="<?php echo $_SERVER["PHP_SELF"];?>">
<input type="hidden" name="path" value="<?php echo $homedir;?>">
<input type="hidden" name="report_path" value="<?php echo $report_path;?>">
<button class="btn btn-primary" type="submit" onclick="ShowLoader()">Start Scanner</button>
</form>
<br>
<hr>
<h2>Latest Scan Report</h2>
<br>
<?php
if(file_exists($report_path)){ ?>
<pre><?php echo file_get_contents($report_path); ?></pre>
<?php
$report_text = file_get_contents($report_path);
$search_string_line = strlen('Infected files : ');
$start_search_position = stripos($report_text,'Infected files : ') + $search_string_line;
$end_search_position = strpos($report_text,' ',$start_search_position) - 5;
$number_inf_files = substr($report_text, $start_search_position, $end_search_position - $start_search_position);
if((int) $number_inf_files > 0 ){
?>
<br>
<a class="btn" style="background-color:red;color:white;" target="_blank" href="https://www.siteguarding.com/en/services/malware-removal-service">Clean</a>
<?php
}
} else {
echo 'Report file is not exists. Scan your website.';
}
?>
</div>
</div>
<?php
}
print $cpanel->footer();
$cpanel->end();
function MalSSH_ShowErrorMessage($text, $header = '')
{
?>
<section class="panel panel-danger">
<div class="panel-heading">
<span class="widget-title"><?php echo $header; ?></span>
</div>
<div class="panel-body">
<div><?php echo $text; ?></div>
</div>
</section>
<?php
}
?>