Articoli con tag spam

Come agire se il proprio sito/blog viene compromesso

Negli ultimi giorni ho avuto a che fare con un attacco combinato di spammer che, sfruttando falle in WordPress o nella configurazione del server ospitante il blog, beneficiano del Pagerank dei blog colpiti per apparire nelle prime pagine dei risultati di ricerca.

A parte questo mi sono trovato nella situazione al limite del ridicolo in cui i gestori o proprietari dei blog ignorano i miei messaggi, o peggio mi rispondono che per loro è tutto a posto. Uno mi ha detto addirittura che il problema l’ha risolto settimane fa.

Il codice malevolo inserito nei blog è congegnato in modo da nascondersi a chi è visitatore abituale del blog. Quindi il proprietario ed i suoi amici e frequentatori non notano niente di strano. E se trovano strani link in ricerche su Google, quando li seguono non accade nulla, ma questa è un’altra storia. Ho avvertito tutti, qualcuno anche più volte, ho scritto al team di WordPress ed a Google. Staremo a vedere.

Ma la cosa che mi è saltata agli occhi è la mancanza di regole da seguire nel malaugurato caso che il proprio blog, o il proprio sito, venga compromesso da qualcuno che riesce a sfruttare un bug o un errore di configurazione.

Se l’intruso ha sfruttato la falla per motivi poco etici ma, per fortuna si è limitato a fare spam, come in questo caso, possiamo soprassedere e limitarci alle regole che seguono poco sotto. Se invece abbiamo il dubbio che possano essere stati commessi reati più gravi, non esitiamo a contattare le Forze dell’Ordine, senza toccare nulla. E’ fondamentale che le prove restino al loro posto. Qualsiasi intervento da parte nostra potrebbe cancellare indizi importanti per risalire al responsabile.

E’ un attimo, trovarsi coinvolti in indagini per truffa o peggio, senza averne colpa alcuna se non quella di usare un software vulnerabile e cadere vittima di un predone.

Se invece le cose sono meno gravi, come appunto in questo caso, possiamo seguire alcune semplici regole, mutuate dall’Informatica Forense:

  1. Non cancellare il codice del sito. Sia esso in PHP, ASP o altro, se ne deve fare un backup completo, usando ftp o un altro metodo, includendo eventuali temi, plugin o estensioni. Se l’intruso è riuscito a modificare il codice, il poter vedere quali siano le modifiche e gli eventuali file creati al momento dell’attacco è di grandissimo aiuto nel trovare il punto di ingresso, ed eventualmente turare una falla.
  2. Se il sito ha un’area di upload, salvarne tutto il contenuto. L’intruso potrebbe essere riuscito a infilare qualcosa in mezzo agli altri file, ed averlo usato per l’attacco.
  3. Se si ha accesso ai log del web server, salvarne una copia, possibilmente a partire dal giorno in cui potrebbe essere successo il fatto. Per questo ci può aiutare la data sui file modificati dall’intruso nel sito. Alcune vulnerabilità vengono sfruttate usando particolari URL, forgiati in modo da attivare un bug nel codice. Avere a disposizione i log del web server aiuta ad identificare la forma usata nell’URL per iniettare il codice dannoso.
  4. Se il sito usa un database, farne un backup, o un dump completo. Alcune intrusioni iniettano dati nell’archivio, o aggiungono tabelle al database. Averne una copia è un aiuto preziosissimo, sempre allo scopo di individuare il punto d’ingresso.
  5. Nel caso, raro in verità, in cui il server sia “in casa”, la cosa migliore sarebbe una immagine del disco bit a bit, una pratica da fare con strumenti tipici dell’Informatica Forense, ma questo richiede competenze specifiche.

La pratica comune è di reinstallare, o fare un upgrade. Questo va bene, ma in ogni caso conviene prima salvare tutto il materiale utile alle indagini, poi si procede ad una installazione pulita.

Non basta il solo aggiornamento del software: se l’intruso ha inserito codice nelle tabelle del database, fra i file di supporto o gli upload, questo verrà ereditato dal software aggiornato, vanificando l’operazione.

Tags: , , ,

Attention: your WordPress blog may be compromised.

Post updated after publish, see bottom

If you came to this article because you got an e-mail or a comment in your blog that ask to read it, please do not go away. Read the rest.

I’m an independent Information Security researcher. I’m investigating about an attack to some WordPress based blogs that involves spam and exploiting Google pagerank mechanism.

First of all, check yourself that your blog may be compromised. To do that, you need to do two different checks. First requires a little utility called “wget”, that is widely used in Linux, but it is available for Windows, too. Use this command:


wget -U googlebot -O home.html http://yourblogurl/

Note that -O and -U are both capital, and http://yourblogurl/ is the address of your blog homepage.
After command execution you will get a single file called home.html, that contains the HTML of your blog homepage. This is how your blog appears to the Google spider. Open it with a text editor, not from web browser. Examine the code, and you can see a block of code in a <div> block, that contains links that don’t belongs to your site. Usually it is shortly after the opening <body> tag, or near the end of page.
These links are about pills, ring tones, loan, and so on, like normal spam mails. You can compare with your homepage as appears on your browser source viewer, or you can get another copy with wget, without the -U option, so you get the “regular” homepage.

For the second check, open your browser and go to Google search. Type this query string:
buy valium inurl:yourblogurl
where yourblogurl is a part of the site name that is unique for your blog. I.e. if I want to check my blog I will type:
buy valium inurl:ismprofessional
Change text according to your website, and try other well-known drugs name, like the “blue pills”, named in every mail spam message.

The result of the query can be something like this:


Buy Valium from Sunrise Movies
All the information and advice you'll need to find the best
Buy Valium with the lowest Vicodin price, even if you're a first-time buyer.
www.yourblogurl/?item=137

The query part of the url string can change. This is an incomplete list:


?google-approved=number
?coupon_number=number
?item=number
?order_id=number
?certified=number
?pharma-certified=number

If you click on the link in the search results, apparently nothing special happens: you will go in your blog.

But try this: open cookie management of your browser, search for all cookies of your site and delete them. Then return to Google result page and click again on the link with your blog. This time something different happens: your browser will redirected to an online pharmacy.

How this is possible? I don’t know exactly, but I can do some hypotheses: If someone was able to crack something in your WordPress installation, the index.php file may contain malicious code that checks if you visited the blog in the past, through the cookie. If you have the cookie, the code do not activate itself, so you see your blog. If you do not visited blog before, and you come from a search engine, the malicious code redirect your browser to pharmacy site.

It is a sort of hiding mechanism to protect malicious code being discovered by regular blog visitor, or by blog owner.

If you do not understand terms I used, please ask to someone more skilled to explain in other words.

I wrote this message because I tried to warn blog owners of the problem, but my message got no replies, and I suspect that gets catch by spam filters. It is quite difficult to write about drugs spam without use same terms used by spammers.

If you get persuaded that my warning is true, please DO NOT delete your WordPress installation files on server. Save them on a zip file and, if you can, send the zipfile to me, so I can figure how malicious code was injected in your blog. After that you can delete all the file and reinstall WordPress. Check also the database, because some malicious code put extraneous data in WordPress tables.

For what I see, upgrading to WordPress 2.5 DO NOT solve the problem. Some of the hacked blogs already use version 2.5, but the problem persist.

Why I do all this work? Because I think that someone exploiting a bug or a flaw in WordPress, or in the web server configuration, to do dirty business. These people knows perfectly how Google Pagerank works, and are able to use it very well.

I earn nothing from that. I do only for ethical reason.

So, if you think that I am in error, please apologize, and you can forget any message I send to you.

In other case, you can contact me using this page.

At the moment I get more information, I will update this post, so stay tuned.

First information available

Thanks to Jay, we have first data about malicious code. There are some symptoms:

  • An extraneous file uploaded to the /tmp/ directory on the server, added as a WP add-on. Warning: It didn’t show up on the list, so it was only visible by looking at the actual database using phpMyAdmin.
  • New admin account in WordPress as well, called “WordPress”. Warning: invisible in the administration interface of WordPress.
  • Other PHP scripts placed around in various directory of server. Jay do not send me a sample, but he looked into the code, and these scripts allow remote shell and command execution.

Note that: WordPress was updated to last release, but the redirect code were still in place and active. Only after direct database editing the redirect stops working.

A different cracking scheme

During the analysis of a different blog, I found another type of penetration scheme:

  • The cracker targets old WordPress releases, known to be highly vulnerable, i.e. 2.0.3, 2.0.5 and so on.
  • It inject one or two files in unused directories, like wp-content/themes/classic, or in uploads directory.
  • These files are: a remote shell coded in PHP, and the “spam injector/redirector”.
  • It uses something called “doorgen”, but the name can be other

So, checks your WordPress installation for modified or extraneous files.

Update

I arranged an automated test to check for this problem. The page is called WordPress Autotest. Read instructions carefully.

Tags: , ,