PDA

View Full Version : |Tutorial| Deixando sua Web+segura // MuSite // Effectweb // Shop v3



ValterHernandes
15/08/2017, 10:43 PM
- Olá pessoal pouco tempo atras eu mexendo no meu servidor reparei em uma coisa que MuSite // EffectWeb Gerar login e senha em uma determinada pasta sendo assim pessoas com más intenções,prejudicando seu servidor essa falha esta localizada na área de logs , Então aconselho sempre estar limpando os logs dentro dessa pasta o caminho para a pasta são os seguintes




Effect Web : modules/Logs/CTM_MSSQL.htm




MuSite : /logs/injects.txt







Esses dois diretórios podem as vezes exibir senhas de administradores e mesmo de usuários segui as imagem a baixo




Imagem EffectWeb

1615

MuSite

1616



BEM AVISO ESTA DADO , POSTEI ISSO POR QUE MUITOS ADMINISTRADORES DE MU ESTÃO SENDO VITIMAS DESSE DETALHE E ESTÃO PENSANDO QUE O TAL FULANDO ESTA EDITANDO POR SQL INJECTON ETC .










Solução MuSite





Vai até a pasta modules do seu site em settings.php ([Only registered and activated users can see links]) procure pela seguinte linha de comando pelo Ctrl+F desative o sistema de logs





/*
[Only registered and activated users can see links]
[Only registered and activated users can see links]
*/
$PANELUSER_MODULE['LOG']['Active'] = true; //Ativa os logs do painel.
$PANELUSER_MODULE['LOG']['DirLog'] = "logs/paneluser"; //Pasta para gravação dos logs, a pasta deve ficar na raiz do site
(OBS: Coloque uma pasta que ninguem saiba e essa pasta deve conter permissão de escrita.).


/*
[Only registered and activated users can see links]
[Only registered and activated users can see links]
*/
$PANELADMIN_MODULE['LOG']['Active'] = true; //Ativa os logs do painel.
$PANELADMIN_MODULE['LOG']['DirLog'] = "logs/paneladmin"; //Pasta para gravação dos logs, a pasta deve ficar na raiz do site
(OBS: Coloque uma pasta que ninguem saiba e essa pasta deve conter permissão de escrita.).






Solução : EffectWeb






define("MSSQL_Security_Log", FALSE); // -- Salvar Logs de Erros na tarefas do MSSQL (Padrão -> true)





Solução Secundaria


Em sua hospedagem,procura pelos seguintes caminho , achando eles de um chmod nos arquivos contendo os arquivos citados a baixo

MuSite : seusite/logs/injects.txt
Effectweb : seusite/modules/Logs/CTM_MSSQL.htm
Shop v3 : seushop/logs/injects.txt




Explicando as permissões mais comuns:




P ermissão
Usuário
Grupo
Mundo


644
L / G
L
L


755
L / G /E
L / E
L / E


777
L / G /E
L / G /E
L / G /E





Siglas: L = Leitura , G = Gravação e E =Execução



IMPLEMENTAÇÃO

A maioria das invasões feitas através de sites são injects, recomendo que você faça os passos abaixo.
1º Desativar o servidor ftp


( ftp://ftp.seudominio.com.br/ )


2º A maioria dos inject são feitos através dos upload de imagens, recomendo que desative o upload de imagem.

3º Caso você for usar Effect Web (que na minha opinião é a melhor web pra mu.) recomendo que você corrija um erro da ranking class, existe uma falha de sqli, xssl isso é grave, com um exploit é possível executar as query no site.
Link correção:


[Only registered and activated users can see links] ([Only registered and activated users can see links])



4º Recomendo pesquisar no google uma proteção contra inject, parecida com essa que eu uso [Only registered and activated users can see links]



Proteção contra Brute Force para Effect-Web


Não garanto que a Effect-Web tem essa falha, mas é melhorar prevenir do que remediar. Não é atoa que até o MuSite tem esse fix.
Por isso quem utiliza Effect-Web, sugiro que aplique o fix.

Se não sabe o que é Brute Force, confira aqui: [Only registered and activated users can see links] ([Only registered and activated users can see links])

O que o fix vai fazer é bem simples, ele vai bloquear por 5 minutos o login que um determinado usuário errar a senha por 3 vezes em menos de 5 minutos.

1627


Para aplicar o fix, faça os procedimentos abaixo

1° Rode em seu SQL, para criar a tabela onde ficará armazenada as tentativas incorretas de login.




GO
/****** Object: Table [dbo].[BRUTE_FORCE] Script Date: 10/13/2015 16:38:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[BRUTE_FORCE](
[login] [nvarchar](10) COLLATE Latin1_General_CI_AS NULL,
[tentativas] [int] NOT NULL CONSTRAINT [DF_BRUTE_FORCE_tentativas] DEFAULT ((0)),
[block] [int] NOT NULL CONSTRAINT [DF_BRUTE_FORCE_block] DEFAULT ((0))
) ON [PRIMARY]

2° Rode em seu SQL, para criar a job que irá determinar o tempo de bloqueio.


USE [msdb]
GO
/****** Object: Job [Proteção contra Brute - EffectWeb] Script Date: 10/13/2015 16:46:09 ******/
BEGIN TRANSACTION
[Only registered and activated users can see links]
[Only registered and activated users can see links]
/****** Object: JobCategory [[Uncategorized (Local)]]] Script Date: 10/13/2015 16:46:09 ******/
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'[Uncategorized (Local)]' AND category_class=1)
BEGIN
[Only registered and activated users can see links]
[Only registered and activated users can see links]

END

[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
/****** Object: Step [1] Script Date: 10/13/2015 16:46:09 ******/
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
COMMIT TRANSACTION
GOTO EndSave
QuitWithRollback:
[Only registered and activated users can see links]


Crie um arquivo php com nome CTM_Ajax.class.php e copie o codigo dentro do arquivo logo em seguida copie o arquivos para pasta /modules/classes/


<?php
//**********************************************//
// -> Effect Web //
// -> Powered By: Erick-Master //
// -> CTM TeaM Softwares //
// -> [Only registered and activated users can see links] //
//**********************************************//
$Page_Request = strtolower(basename($_SERVER['REQUEST_URI']));
$Page_File = strtolower(basename(__FILE__));
if ($Page_Request == $Page_File)
{
exit("<span style=\"border:1px dashed #c00; color:#c00; padding:6px; background-color:#ffebe8;\"><strong>CTM-Error: N&atilde;o &eacute; permitido acessar o arquivo diretamente.</strong></span>");
}
if(IN_EFFECTWEB != "47e5098c88cc5f67543414ff1af32efc")
exit("<!-- CTM.Error(x); -->");
if(!class_exists("CTM_Ajax")) :
class CTM_Ajax extends CTM_MSSQL
{
public function Set_Panel()
{
global $CTM_General;

if($CTM_General->Check_Logged(false) == FALSE)
{
$this->Login_Command();
$this->Login_Form(false);
}
else
{
$this->Panel($_SESSION["Hash_Account"]);
}
}
private function Login_Form($Message)
{
global $CTM_Template;

$CTM_Template->Set("Account", $_POST["Log_Account"]);
$CTM_Template->Set("Password", $_POST["Log_Password"]);
$CTM_Template->Set("Message", $Message);

$CTM_Template->Load("templates/".$CTM_Template->Open()."/pages/panel[LOGIN].ajax.php");
}
private function Panel($Account)
{
global $CTM_General, $CTM_Template, $CTM, $_PmSystem;

if(isset($_SESSION["Hash_Account"]) == FALSE && isset($_SESSION["Hash_Password"]) == FALSE)
{
echo("<script>CTM_Load('?ajax=panel','Panel','GET');</script>
<script>CTM_Load('?pag=home','conteudo','GET');</script>");
}
else
{
$Query = $this->Query("SELECT * FROM ".MuAcc_DB.".dbo.MEMB_INFO WHERE memb___id='{$Account}'");
$Staff = $this->FetchQuery("SELECT type FROM {$CTM[0]} WHERE account='{$Account}'");
$Type_Acc = $this->FetchQuery("SELECT ".VIP_Column." FROM ".VIP_DB.".dbo.".VIP_Table." WHERE ".VIP_Login."='{$Account}'");
$Golds = $this->FetchQuery("SELECT ".GL_Column_1.",".GL_Column_2.",".GL_Column_3." FROM ".GL_DB.".dbo.".GL_Table." WHERE ".GL_Login."='{$Account}'");
$Load_Acc = $this->FetchArray($Query);
$VIP_Type = $CTM_General->Memb_Type($Type_Acc[0]);

/*************************************
[Only registered and activated users can see links]
[Only registered and activated users can see links]
[Only registered and activated users can see links]
**************************************/
/*if($_PmSystem["Enable"] == TRUE)
{
if($_PmSystem["Mode"] == 0)
{
$Query_Chars = $this->Query("SELECT Name FROM ".MuGen_DB.".dbo.Character WHERE AccountID='".$_SESSION["Hash_Account"]."'");
while($PM_Chars = $this->Fetch($Query_Chars))
{
$Check_PM = $this->NumQuery("SELECT * FROM ".MuGen_DB.".dbo.".$_PmSystem["Main"]." WHERE Name='{$PM_Chars[0]}'");
if($Check_PM > 0)
{
$GUID = $this->FetchQuery("SELECT GUID FROM ".MuGen_DB.".dbo.".$_PmSystem["Main"]." WHERE Name='{$PM_Chars[0]}'");
$Count_PM = $this->FetchQuery("SELECT count(*) FROM ".MuGen_DB.".dbo.".$_PmSystem["Table"]." WHERE GUID={$GUID[0]} and bRead=0");
}
}
}
}*/

/*if($_PmSystem["Enable"] == TRUE)
{
if($_PmSystem["Mode"] == 0)
{
if($Count_PM[0] > 0)
{
$PM_Panel = "<li><a href=\"javascript: void(EffectWeb);\" onclick=\"CTM_Load('?pag=paneluser&option=PM_ENTER','conteudo','GET');\"><b>&raquo; Notifica&ccedil;&otilde;es <span class=\"colr\">(".$Count_PM[0].")</span></b></a></li>";
}
else
{
$PM_Panel = "<li><a href=\"javascript: void(EffectWeb);\" onclick=\"CTM_Load('?pag=paneluser&option=PM_ENTER','conteudo','GET');\">&raquo; Notifica&ccedil;&otilde;es (0)</a></li>";
}
}
}*/
$CTM_Template->Set("Memb_Name", $Load_Acc["memb_name"]);
$CTM_Template->Set("Memb_Type", $VIP_Type);
$CTM_Template->Set("Memb_Amount[1]", $Golds[0]);
$CTM_Template->Set("Memb_Amount[2]", $Golds[1]);
$CTM_Template->Set("Memb_Amount[3]", $Golds[2]);
$CTM_Template->Set("PanelAdmin_Link", $Staff[0] > 0 ? "<li><a href=\"javascript: void(EffectWeb);\" onclick=\"CTM_Load('?pag=paneladmin','conteudo','GET');\">&raquo; Painel Administrativo</a></li>" : NULL);
//$CTM_Template->Set("PM_System#Notifications", $PM_Panel == TRUE ? $PM_Panel : NULL);

$CTM_Template->Load("templates/".$CTM_Template->Open()."/pages/panel[LOGGED].ajax.php");

}
}
private function Login_Command()
{
global $CTM_Crypt;

if($_GET["cmd"] == "login")
{
$Account = $_POST["Log_Account"];
$Password = $_POST["Log_Password"];
$Check = $this->FetchQuery("exec dbo.CTM_CheckLogin '".$Account."','".$Password."',".USE_MD5."");
$Find = $this->FetchQuery("SELECT bloc_code,mail_chek FROM ".MuAcc_DB.".dbo.MEMB_INFO WHERE memb___id='{$Account}'");
$Findd = $this->FetchQuery("SELECT login,block FROM ".MuAcc_DB.".dbo.brute_force WHERE login='{$Account}'");

if(empty($Account))
{
$this->Login_Form("<div class=\"min-warning\">Digite seu Login</div>");
}
elseif(empty($Password))
{
$this->Login_Form("<div class=\"min-warning\">Digite sua Senha</div>");
}
elseif($Findd[1] == 1)
{
$this->Login_Form('<div class=\"min-error\">Login bloqueado por 5 minutos devido a 3 tentativas incorretas!</div>');
}
elseif($Check[0] !== 1)
{
$this->Login_Form('<div class=\"min-error\">Login ou senha incorretos!</div>');
if ($Findd[0] != $Account)
{
$this->Query("insert into MuOnline.dbo.brute_force (login,tentativas) values ('{$Account}',1)");
}
else
{
$this->Query("update MuOnline.dbo.brute_force set tentativas=tentativas+1 where login='{$Account}'");
$this->Query("update MuOnline.dbo.brute_force set block=1 where tentativas > 2 and login='{$Account}'");
}

}
elseif($Find[0] == 1)
{
$this->Login_Form("<div class=\"min-error\">Sua conta est&aacute; Bloqueada</div>");
}
elseif($Find[1] == 0)
{
$this->Login_Form("<div class=\"min-error\">Sua conta n&atilde;o esta confirmada.</div>");
}
else
{
$_SESSION["Hash_Account"] = utf8_encode($Account);
$_SESSION["Hash_Password"] = $CTM_Crypt->Pwd($Password);

$this->Login_Form("<script>setTimeout(\"count()\", 1000);</script>
<div class=\"min-success\">&raquo; Logado com Sucesso.&raquo; Aguarde...</div>
<span id=\"time\" style=\"display: none;\">2</span>");
}
}
}
public function ServerList()
{
if(constant("Server_List") == TRUE)
{
global $_ServerList;
$CTM_ConnectServer = new CTM_ConnectServer(true);

for($GS = 0; $GS < count($_ServerList); $GS++)
{
$Count = ceil($CTM_ConnectServer->ServerCount(true, $_ServerList[$GS][1]) * 100 / $_ServerList[$GS][2]);
echo("<li>&raquo; ".$_ServerList[$GS][0]." : <a href=\"javascript: void(EffectWeb);\" onclick=\"CTM_Load('?pag=online&gs=".urlencode($_ServerList[$GS][1])."','conteudo','GET');\"><strong id=\"".$_ServerList[$GS][1]."_ID\">".$Count."%</strong></a>
<div class=\"OnlineCount\" id=\"ServerID".$_ServerList[$GS][1]."\">
<div class=\"ServerCount\" style=\"width: ".$Count."%\"></div>
</div></li>");
}
echo("<li>Total: <strong id=\"TotalServers\"><a href=\"javascript: void(EffectWeb);\" onclick=\"CTM_Load('?pag=online','conteudo','GET');\">".$CTM_ConnectServer->ServerCount(false, false)."</a></strong> <a href=\"javascript: void(EffectWeb);\" onClick=\"CTM_Load('?ajax=check&cmd=servers', 'ServerRefresh', 'GET');\"><img src=\"images/icons/refresh.png\" width=\"10\" height=\"10\" border=\"0\"></a></li>");
}
else
{
$CTM_ConnectServer = new CTM_ConnectServer(false);
echo("<li>Total: <strong id=\"TotalServers\"><a href=\"javascript: void(EffectWeb);\" onclick=\"CTM_Load('?pag=online','conteudo','GET')\">".$CTM_ConnectServer->ServerCount(false, false)."</a></strong> <a href=\"javascript: void(EffectWeb);\" onClick=\"CTM_Load('?ajax=check&cmd=servers', 'ServerRefresh', 'GET');\"><img src=\"images/icons/refresh.png\" width=\"10\" height=\"10\" border=\"0\"></a></li>");
}
}
public function StaffList($Code)
{
$Query = $this->Query("SELECT Name,AccountID FROM ".MuGen_DB.".dbo.Character WHERE CtlCode={$Code} ORDER BY Name");
$Check = $this->NumRow($Query);

if($Check < 1)
{
exit("<div class=\"min-info\">Nenhum ADM/GM Cadastrados</div>");
}
for($WzAG = 0; $WzAG < $this->NumRow($Query); $WzAG++)
{
$Member = $this->Fetch($Query);
$Status = $this->FetchQuery("SELECT ConnectStat FROM ".MuGen_DB.".dbo.MEMB_STAT WHERE memb___id='{$Member[1]}'");
switch($Status[0])
{
case 0 : $Stat = "<span style=\"color: red;\">Offline</span>"; break;
case 1 : $Stat = "<span style=\"color: green;\">Online</span>"; break;
}
echo("<li>&raquo; {$Member[0]} - {$Stat}</li>");
}
}
public function RefreshServers()
{
global $_ServerList;
$CTM_ConnectServer = new CTM_ConnectServer(true);

echo "<script>document.getElementById('TotalServers').innerHTML = '<a href=\"javascript: void(EffectWeb);\" onclick=\"CTM_Load(\'?pag=online\',\'conteudo\',\'GET\');\">".$CTM_ConnectServer->ServerCount(false, false)."</a>';</script>";
for($GS = 0; $GS < count($_ServerList); $GS++)
{
$Count = ceil($CTM_ConnectServer->ServerCount(true, $_ServerList[$GS][1]) * 100 / $_ServerList[$GS][2]);
echo "<script>document.getElementById('".$_ServerList[$GS][1]."_ID').innerHTML = '{$Count}%';
document.getElementById('ServerID".$_ServerList[$GS][1]."').innerHTML = '<div class=\"ServerCount\" style=\"width: {$Count}%\"></div>';</script>";
}
exit();
}
}
endif;
?>



Créditos Tutorial : Script
Implementação : Rick Barbosa
Implementação : Guilherme Souza


Duvidas ou mais dicas para implementação ou algum Ant Sql Inject manda via MP que irei implementando ao post !

Rick Barbosa
16/08/2017, 11:25 AM
Show, muitas coisas ai eu aprendi contigo. :D

Marco_Aurélio
16/08/2017, 01:11 PM
Me falaram esses dias que existe uma falha no musite bem grave no meu ponto de vista, que faz com que consigam acesso ao arquivo Settings.ini, teria alguma solução para este problema?

s00x
16/08/2017, 02:48 PM
Me falaram esses dias que existe uma falha no musite bem grave no meu ponto de vista, que faz com que consigam acesso ao arquivo Settings.ini, teria alguma solução para este problema?

Explore a falha, e concretize se é verdade, porque não estou sabendo disso não, claro que as permissões no arquivo inibe muita coisa, mas essa do acesso ao Settings, eu desconheço.
Recomendo simular ela, e postar o resultado para todos ficarmos cientes.

ValterHernandes
17/08/2017, 01:08 AM
Me falaram esses dias que existe uma falha no musite bem grave no meu ponto de vista, que faz com que consigam acesso ao arquivo Settings.ini, teria alguma solução para este problema?

Colega , como o s00x ([Only registered and activated users can see links])
disse não estou sabendo dessa falha não procure saber mais sobre isso por que tentei de todas formas que eu conheço acessar diretamente o arquivo Settings pelo navegador e não tive sucesso em nem uma das tentativa !

cri0
17/08/2017, 06:51 AM
4º Recomendo pesquisar no google uma proteção contra inject, parecida com essa que eu uso [Only registered and activated users can see links]
Tutorial sobre, poderia acrescentar ?

SeeKeerS
17/08/2017, 03:00 PM
nunca ouvi falar sobre essa falha no musite de acessar diretamente o modules/settings.php e não modules/settings.ini

ValterHernandes
17/08/2017, 03:16 PM
Tutorial sobre, poderia acrescentar ?


[Only registered and activated users can see links]
mais quando eu tiver um tempinho faço um tutorial acrescentando isso

8 Dias 21 Horas:------- Atualizado -------

Post . update implementação de proteção contra BruteForce ( Simples ) Créditos : Guilherme

Tenente-BK
26/08/2017, 01:17 PM
Sobre o erro da musite que ele fala é uma forma de PESCAR ela! Ou seja puxar ela pra fora do site assim pegando os dados dela!