mardi 29 août 2017

From Onliner Spambot to millions of email's lists and credentials

Hey! It's time for another writeup about spambot.
Here I will explain how I have found millions of emails and credentials on a spambot server and why your creds can be in these databases.

I have written a lot about spambot on this blog for many reason. Spambots are often ignored by researchers and I don't understand why.
In a successful cybercrime campaign there are different parts, the final payload is important but the spam process is very critical too.
Some malware campaigns like Locky are successful also because the spamming process works well.
This case is a good example :).

Spam the world


As introduction, we will have a look at what is a spambot, why crooks use them and why they need huge list of credentials.
In the past, it used to be easier for attackers to send mass spams: they just had to scan the Internet to find vulnerable SMTP server (with weak passwords or in Open Relay mode) and use them to send Spams.
However, nowadays, it's more complicated. There are a lot of anti spam companies, products or firewalls. Most of the open relays are blacklisted and the attackers have to find another way to send mass spams.
Among the available options, I have seen 2 very common behaviour:

PHP Mailer

The most used tricks I have seen is to use compromised websites. For instance, this kind of spamming campaign has been used for a big Andromeda campaign.
The principle is simple:
  • The spammer hacks a lot (10k/20k) of websites (via well known vulnerabilities on Wordpress, Joomla, OpenCart or FTP/SSH bruteforce etc) or buy access to a lot of websites on a random shop
  • He uses these websites for hosting a PHP script in charge of sending emails.
  • He controls all the websites via a software or a web panel and uses them to send spam
Due to the almost infinite number of out-of-date websites on the Internet, it's difficult to blacklist every websites and it's really easy to use them for the spammer.

Malware spammer

The other common way to send spam is more brutal. Here, the attacker creates or buys a specifique malware used to infects people and send spams.
The more the attacker infects people, the more he can distribute spams through different IPs.
However, a random pwned Windows machine is not enought to send spam. For that, the attacker needs some email server (SMTP) credentials. This is where you can be concerned by Spambot :)

Indeed, to send spam, the attacker needs a huge list of SMTP credentials. To do so, there are only two options: create it or buy it :D
And it's the same as for the IPs: the more SMTP servers he can find, the more he can distribute the campaign.
Lets go through an example to see how attackers create SMTP credentials lists:

Credentials: Spambots gasoline

I will take as an example the Onliner spambot. This spambot is used since at least 2016 to spread a banking trojan called Ursnif. I have seen this spambot targeting specific countries like Italy, or specific business like Hotels.
Some emails example:
DHL notification:

Email targeting Hotel business:

If you're curious about this case, I have tried to give some details in 3 blog posts:
TL;DR: this malware, after infecting your machine, uses 2 modules:
  • A module in charge of sending spam
  • A module in charge of creating a huge list of SMTP credentials

To create the list, the attacker provides to the second module a list of emails and credentials like foo@bar.com:123456.
Then, the module tries to send an email using this combinaison. If it works, credential are added to the SMTP list. Else, credentials are ignored.
Thanks to free email services like outlook, gmail or your ISP, the attacker can suppose that a lot of people reuse the same password and use your outlook adress to send spam :)

It's difficult to know where those lists of credentials came from. I have obviously seen a lot of public leaks (like Linkedin, Baidu or with every passwords in clear text) but credentials can also came from phishing campaigns, credentials stealer malwares like Pony, or they can also be found in a shop. Somebody even show me a spambot with a SQL injection scanner which scan Internet, looks for SQLi, retrieves SQL tables with names like "user" or "admin".

Thanks to an open directory on the web server of the Onliner Spambot CNC, I was able to grab all the spamming data
It's composed of ~40GB of emails, credentials or SMTP configuration.
These data are composed of:
  • Huge lists of credentials like email:password (in clear text)
  • Huge lists of Emails to spam
  • Spambot configuration files
I have found around 80 millions credentials (unsorted, it's an estimation, I cannot deal with so big txt files).
One part (~2 millions) seems to come from a Facebook phishing campaign, those I have tested seems to be working and were not on HIBP.
Therefore, it's difficult to say where did your credentials come from.

Making emails lists like a pro

Inside all these data, we can see a lot of emails (used for sending spam to).
Because I have been following these guys for almost a year I'm able to explain how they built these lists.

After looking at the spambot logs, I have seen that it was used to send fingerprinting spam. What does this mean?.
Before starting a new malware campaign, the attacker used the spambot to send this kind of emails:
If you look at the email you will see that inside this random spam, there is a hidden 1x1 gif. This method is well known in the marketing industry.
Indeed, when you open this random spam, a request with your IP and your User-Agent will be sent to the server that hosts the gif. With these information, the spammer is able to know when you have opened the email, from where and on which device (Iphone ? Outlook?...).
At the same time, the request also allows the attacker to know that the email is valid and people actually open spams :).
This is an example of a classification script found on one Onliner spambot server:

Example of output :


As a reminder: DON'T OPEN SPAM!

Conclusion

If you're a malware researcher, it's time to look deeper in the spambot business. It's a creative market which interracts with a lot of other cybercrime business.
Around Spambot you will often found phisher, password stealer botmaster, website scanners, malware developers, dropper developers, payload hosters, and so on.
The way is maybe short between the lame Pony you have received last month in a stupid .ace archive and a spambot that spread Ursnif.


Annexe


Some urls found in spam configuration files:
  • hxxp://119.28.18.104/IMG_8026.zip
  • hxxp://21emb.com/IMG_0557.zip
  • hxxp://cielitodrive.com/2.docm
  • hxxp://cielitodrive.com/IMG_0557.zip
  • hxxp://dcipostdoc.com/3.docm
  • hxxp://fondazioneprogenies.com/1.docm
  • hxxp://fondazioneprogenies.com/IMG_7339.zip
  • hxxp://intesols.com/IMG_8026.zip
  • hxxp://jltl.net/IMG_8026.zip
  • hxxp://liyuesheng.com/Report_Bill_ID20039421.zip
  • hxxp://lopezdelaisidra.com/107490427.zip
  • hxxp://maikaandfriends.com/Report_Bill_ID20593601.zip
  • hxxp://mc-keishikai.com/Report_Bill_ID73086492.zip
  • hxxp://pacific-centre.com/IMG_8026.zip
  • hxxp://reliancemct.com/IMG_9647.zip
  • hxxp://resital.net/IMG_0557.zip
  • hxxp://speaklifegreetings.com/IMG_9647.zip
  • hxxp://tspars.com/087578952.zip
  • hxxp://usedtextilemachinerylive.com/IMG_9647.zip
  • hxxp://webtoaster.net/IMG_0273.zip
  • hxxp://whatisaxapta.com/5.docm
  • hxxp://womenepic.com/4.docm
  • hxxp://www.loidietxarri.com/Report_Bill_ID87793518.zip

Thanks to Hydraze for reviewing \o/

dimanche 20 août 2017

A third look at JSDropper/ursnif campaign - Proxy Statistics

Hey

I've already talk a lot about the Ursnif campaigns against EU and mainly Italy spreaded by a JScript (you know, the jscript that contacts /r6.php?cmd=p&id= / /l2.php?cmd=p&id= / /re.php?cmd=p&id= etc) but 6 months after my last blogpost, crooks are still working and I have enough data for some cool statistics.
For the last 6 months I've collected access.log logs of one proxy used by this botnet. I'll try to details that here.
There is no magic, I've just use Splunk :D


As reminding, this campaign is used to spread Ursnif like that:

In the same "Proxy server", you can found further "proxy scripts" (usually 1 script / campaign) and those scripts looks like :
So, I've retrieve access.log of one of these proxies and I've extract traffic relative to our case.

Global

Some global statistics for 1 proxy:
From February 2017 to August 2017
  • Total number of hits on all the proxy scripts: 924 021
  • From 108 367 unique IPs
  • on 16 different PHP proxy scripts
Filename Hits First seen url Malware
/3E2s4R.php 610787 June http://194.247.13.196/asus/ Onliner
/re.php 137352 June http://94.177.196.246/loadere/gate.php JSDropper
term.php 121669 February http://94.177.196.246/loader/gate.php JSDropper
l2.php 52288 February http://109.120.142.156/loader2/gate.php JSDropper
r4.php 1848 February http://109.120.142.156/loader4/gate.php JSDropper
/0iSP0c.php 7 June http://194.247.13.222/tess/ Onliner
/130D0G.php 7 June http://194.247.13.222/tess/ Onliner
/1AtJai.php 7 June http://194.247.13.222/tess/ Onliner
/HTsGeg.php 7 June http://194.247.13.222/tess/ Onliner
/J65oH1.php 7 June http://194.247.13.222/tess/ Onliner
/PaD8qo.php 7 June http://194.247.13.222/tess/ Onliner
/XI2jHR.php 7 June http://194.247.13.222/tess/ Onliner
/8QE2UX.php 6 June http://194.247.13.222/tess/ Onliner
/Xou0HC.php 6 June http://194.247.13.222/tess/ Onliner
/19pYvo.php 5 June http://194.247.13.222/tess/ Onliner
/LPQQLc.php 5 June http://194.247.13.222/tess/ Onliner
We can see 2 different cases:
  • Some PHP proxies are used in production
  • Some PHP proxies seems used for tests only.

Tests proxies

I'll start with the "tests proxies". I call them like that because they have only a few hits (~5) and all the hits on those pages are done by the same IP :]
66.180.197.197
This IP is not new in this game :), do you remember the white listing feature set in the spam bot panel ?
This IP was in list of allowed IP in the Spambot panel:


Proxy scripts are configured to forward traffic to hxxp://194.247.13.222/tess/, it's Onliner Spambot, proably the testing instance.

Production proxies

Some details about each proxy scripts:

3E2s4R.php

This one is my favourite.
The proxy records 610 787 hits on this file, from ~ 100 000 unique IPs and I'm unable to find any sample on public sandox.
This is a lot of hits if we think that these statistics concern only 1 proxy! It was used to forward the Spambot traffic to 194.247.13.196

re.php

This one was hit 137 352 times by 1335 uniques IPs. It is used to forward JSDropper traffic to 94.177.196.246.
This Proxy was used for the JSDropper campaign "NEWIT" (Ursnif)
Interesting fact of this one: 51.28% of hits are done by the IP 2.228.128.141 (Italy).
Some IOCs:
urls:
samples:
  • d5291865ff80cd7cc9f425a145351bb7234383f1
  • 67e1c342f6b41d163a6208b3ccebb991c0650473

term.php

Used to forward JSDropper traffic to 94.177.196.246
121 669 hits from 2259 unique IPs.
It was used for campaigns "WASP","iphone","summer","old", "u1", "NEWIT" and "404" (Ursnif)

Some IOCs:
urls:
  • hxxp://www.volf.de/term.php?cmd=e
  • hxxp://pajaje.borec.cz/term.php?cmd=e
  • hxxp://hotelsantantonio.com/term.php?cmd=e
  • hxxp://46.163.110.45/css/term.php?cmd=e
  • hxxp://fb-arredamenti.it/term.php?cmd=e
  • hxxp://psymaster.wz.cz/term.php?cmd=e
  • hxxp://getting-reconnected.de/term.php?cmd=e
  • hxxp://ebkk.nl/term.php?cmd=e
  • hxxp://supercondmat.org/term.php?cmd=e
samples:
  • 2016dfb44f452adcdd96b7781fdfb581ac72b0f7392404805f08d57210d16ad9
  • a1bd385b59efe1be13da9e8a008e06a6fb6cc07acd2727be22d076c7a2b27155
  • 01853d1552ca4032e5fdc251cc92d57dffd5912411666c7842106d730ada09f4

l2.php

Used to forward JSDropper traffic to 109.120.142.156 52 288 hits from 716 unique IPs.
This one is very old. I've logs from November 2016 for this scripts.
At this time they was not using campaign or group name, and they was using ... Ursnif.

Some IOCs:
urls:
  • http://151.236.13.49/l2.php
  • http://191860.webhosting63.1blu.de/l2.php
  • http://454391.webx04.mmc.at/l2.php
  • http://46.163.110.45/css/l2.php
  • http://ballettschule-nottuln.de/l2.php
  • http://edle-steine.at/l2.php
  • http://enmoto.com/l2.php
  • http://evastrutzmann.at/l2.php
  • http://evi-verein.at/l2.php
  • http://fioravanti-production.org/l2.php
  • http://friesl-keramik.at/l2.php
  • http://ftp.dimensionevideo.it/l2.php
  • http://ftp.italiabrowsergame.com/l2.php
  • http://getting-reconnected.de/l2.php
  • http://gunnebo.eniac.it/l2.php
  • http://hobbygartenteich.at/l2.php
  • http://hotelsantantonio.com/l2.php
  • http://humanitas-gbr.de/l2.php
  • http://jambasket.com.hk/l2.php
  • http://juwelier-hohenberger.de/l2.php
  • http://katstones.de/l2.php
  • http://lklv.wz.cz/l2.php
  • http://mauriz.at/l2.php
  • http://meindl-edv.eu/l2.php
  • http://nr11303.vhost-enzo.sil.at/l2.php
  • http://pajaje.borec.cz/l2.php
  • http://patrickhess.de/l2.php
  • http://pferdemedizin-stanek.at/l2.php
  • http://portoverde.it/l2.php
  • http://positivemindstates.com/l2.php
  • http://psymaster.wz.cz/l2.php
  • http://reimer-wulf.de/l2.php
  • http://sca.homelinux.com/l2.php
  • http://spatialpourtous.com/l2.php
  • http://supercondmat.org/l2.php
  • http://tennis-arnfels.at/l2.php
  • http://tischlerei-kreiner.at/l2.php
  • http://umzuegeberlin.com/l2.php
  • http://www.diamondfitness.hu/l2.php
  • http://www.drogenhilfezentrum.de/l2.php
  • http://www.dtk-brandenburg.de/l2.php
  • http://www.elektro-morjan.de/l2.php
  • http://www.kurzhaarteckel-trakehner.de/l2.php
  • http://www.midnightlady2006.de/l2.php
  • http://www.msinformatica.it/l2.php
  • http://www.seelackenmuseum-sbg.at/l2.php
  • http://www.skyways-ragdolls-zwergspitze.de/l2.php
  • http://www.teeversand24.net/l2.php
  • http://www.valentinavalsania.it/mdb-databases/cgi-bin/l2.php
  • http://www.webstream.at/l2.php
samples:
  • a10cd296e3f58fe329bbff6edaf0bdbb1f9099a088b7a5cede583dda09dd7cf2
  • 5add967a8dc9d7669e7d8da9882329600874b3a35d2a8f087820438ae112cecd
  • fbfe6048514c7fc944c0f56a480d8c4963fce9018b5d3ae8cf39c5840979930c
  • 9a44ff53471012328a3b167c149ed71c2e82b117de8f9463f5773b5b4f5cc7b6
  • 0bf1c1b457818bf7acb6eda33b0f8eb6e9ce026aee620707f6b4e4b58a2e77d0

r4.php

And the last one: r4.php.
1884 hits by 302 IPs. Used during the campaigns "mk1" "mk2" "bomber" and one with no name ""
Some IOCs:
urls:
  • hxxp://191860.webhosting63.1blu.de/r4.php?cmd=e
  • hxxp://werbekalender-werbenotebooks.de/r4.php?cmd=e
  • http://positivemindstates.com/r4.php?cmd=e
  • di000240.host.inode.at/r4.php?cmd=e
  • http://patrickhess.de/r4.php?cmd=e
samples:
  • c827511b425cbc91faf947f1c3d309db3dde7419fe8c892380a03c71b5196e0e

Résumé


This threat start to be very noisy, they continue to spread malware always in the same way.
If somebody who's reading this works on the Ursnif part, don't hesitate to ping me I'll share my data :]

I hope that this example can help you to better understand cybercrime threats. Happy hunting \o/

mercredi 16 août 2017

Quick look at another Alina fork: XBOT-POS

Hi, it's time for a new post. Today I'll try to have a look at the "Team NZMR"
I've found this funny team by hazard on Twitter via the bot @ScumBots I would like to write this little blog post because I think that this is interesting to see an Alina panel behind a .onion domain and as you can see later, I like look at some weird panels :D.
Let's have a look on this server.
As we know, we have an Alina (Well known POS malware) panel at thzsmrjqqzpaz2mz.onion.link/al/loading.php.
Samples: 26aa9709d0402157d9d36e4849b1f9bacecd8875169c7f26d7d40c5c0c3de298 (http://thzsmrjqqzpaz2mz.onion.link/al/Spark.exe)


In the same boring way, we can found:
  • a Fareit/Pony panel at https://thzsmrjqqzpaz2mz.onion.link/pn/admin.php (I don't have sample)
  • an Atmos at https://thzsmrjqqzpaz2mz.onion.link/at/cp.php :
    Sample e34720cc8ab3718413064f19af5cc704e95661e743293a19f218d3b675147525 (https://thzsmrjqqzpaz2mz.onion.link/at/files/us.exe)

    Thanks to CCAM we can get 2 new servers used by this team:
    • http://netco1000.ddns.net/at/file.php
    • http://22klzn6kzjlwlmt2.onion.link/at/file.php
Those guys really want your creds and your credit card numbers :D


They also try to deal with ransomware (NZMR Ransomware) at https://thzsmrjqqzpaz2mz.onion.link/ed2/ without success...


But I've write this quick blog post for the last panel,
Let me introduce you XBOT panel \o/: https://thzsmrjqqzpaz2mz.onion.link/panel/
(click to enlarge)

The bot ad:
Selling xbot ,new bank trojan -- Modules -- Webinject -- Formgrabber -- Socket4/5 -- Hidden VNC
New bot bank xbot is available for rent (800$/monthly) -- server on tornetwork/clearnet
Customized programming service and web developer/c/c++/Python/NET/others
Team Coder/NZMR
xbot costs 3k $ modules available >webinject -- formgrabber -- Socket4/5 -- Hidden VNC
When buying xbot what do you get?
You will get the builder,bin/exe+socket.exe/server.exe hvnc
[+] - Free installation on your server in tornetwork or clearnet, you choose
[+] - monthly support paid 100 $ (you choose,with or without support)
[+] - Update bot for new version 400 $
[+] Rent xbot
Panel access (Clearnet/Tornetwork)
Bin (exe)
Socket.exe/hvnc.exe
Priçe
800 $ monthly (First 6 customers, others 1k $)
Support monthly 100 $ (btc)
I don't have any sample yet but if you have one, i'm REALLY interrested :D.
Thanks to Xylitol this panel looks like a mix between Alina and Dexter. For example the URI scheme "/front/stats.php", the successstatuscode 666 or this page "Version Control":

This panel looks designed for Banking stuff (webinjects) and POS malware.
From XBOT panel you can DL/Exec, Start VNC sessions, socks sessions and update bots:


We can also found some strange "webinjects" stuff:

where "view content" leads to these kinds of data:


Some settings (look at the Alinas 666 status code):


You can also add some bins in the panel database. Currently, they have 8472 Bins in the database.
And finally the bot lists (~600 bots if I trust the bots list).

I've uploaded the whole list of bots on this album. Ping me if you're on the list :D I'm really curious to see the binary part
And finally the database structure reminds again Alina: By this way we will find soon more Alina forks than Zeus forks \o/

So, NOPE! it's not a super new next gen POS malware, it's just another Alina Fork :D but this webinjects part looks curious :) and the team seems very active.
But come one, 3k$ for open sourced malware haha...

Thanks for your time, thanks to Xylitol and happy hunting :)

IOCs:

http://thzsmrjqqzpaz2mz.onion.link/al/Spark.exe (Alina) http://thzsmrjqqzpaz2mz.onion.link/payload.exe (Neutrino) http://thzsmrjqqzpaz2mz.onion.link/at/files/us.exe (Atmos) http://22klzn6kzjlwlmt2.onion.link/al/Spark.exe (Alina) http://22klzn6kzjlwlmt2.onion.link/al/payload.exe (Neutrino http://22klzn6kzjlwlmt2.onion.link/al/files/us.exe (Atmos) http://netco1000.ddns.net http://netco400.ddns.net/Dia (Gorynch) http://netco400.ddns.net/at/(Atmos) e34720cc8ab3718413064f19af5cc704e95661e743293a19f218d3b675147525 (atmos) 26aa9709d0402157d9d36e4849b1f9bacecd8875169c7f26d7d40c5c0c3de298 (Alina) 8a62f61c4d11d83550ab4baceb9b18d980a4c590723f549f97661a32c1731aff (neutrino)

dimanche 28 mai 2017

Feedback on how build SMB Honeypot

Hey,

During the painful "Wannacry weekend" I've received a lot of message asking for help to create a SMB Honeypot.
I'll try here to explain how I've create mine.
It's 2017 but it looks like it's useful to remind that Honeypot are really useful.
I've read a lot of papers about Wannacry variants during the wannacry crisis, but I've never saw them in the wild. A lot of trolls has uploaded patched versions of the w0rm in Virustotal and has waited for the first paper about a new variante....

This post will not explain all the steps for building a Honeypot but it will try to give some tips and ideas.

Exposing port 445

So, we need to create a honeypot for monitoring SMB network and catching Wannacry in the more automatical way possible.
First of all let's try to expose port 445. In many countries, it's really complicated to expose SMB over the Internet \o/!

My first try was to install a Windows VM with a shared directory (Windows 7 x64 because it's a very used OS in corporations, and hey we're in 2017, people uses 64bits OSs), and configure NAT rules in my home router:
                                          
+--------+          +----------+          +----------+
|Internet|---445--->|homerouter|---445--->|Windows VM|
+--------+          +----------+          +----------+
I've obviously disable Windows Firewall and Windows Defender but when I've try to nmap the 445 port the port was always filtered:
Host is up.
PORT    STATE    SERVICE      VERSION
445/tcp filtered microsoft-ds
After some tests with Wireshark it apears that my home router allows incomming packets on port 445 but blocks outcomming packets.
I've reproduce this behaviour on French ISPs (SFR, Numericable, Orange), French hoster OVH, UK ISPs and some Digital Ocean VPSs
Due to this, we have to bypass this hard coded Firewall rules. It's realy easy, we just have to forward SMB packets to another port than 445. But for that we need 2 other machine. One for forwarding incomming SMB packets to another port and the other for forwarding outcomming packets:
+--------+         
|Internet|-445-+
+--------+     |  
               |
              +---+         +----------+
              |VPS|--5555-->|homerouter|
              +---+         +----------+
                                |
                                |       +---+        +----------+
                                +-5555->|Rpi|--445-->|Windows VM|
                                        +---+        +----------+
                             
You need a few iptables rules (sorry in advance, I'm not an iptables Jedi \o/).
In the exposed VPS:

iptables -t nat -A PREROUTING -p tcp --dport 445 -j DNAT --to-destination HOME_ROUTER_IP:5555
iptables -A FORWARD -p tcp --dport 445 -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward


and for the RaspberryPi config:

iptables -t nat -A PREROUTING -p tcp --dport 5555 -j DNAT --to-destination WINDOWS_VM:445
iptables -A FORWARD -p tcp --dport 5555 -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward


By this way, the 445 port of our Windows VM is ready to be pwned.
To accelerate the pwning rate, I use many cheap VPSs around the world (I've used DigitalOcean, 1&1, HostAfrika...)
+--------+         
|Internet|-445-+
+--------+     |  
               |
              +---+         
              |VPS|--5555---------+
              +---+               |
              +---+               |
              |VPS|--5555---------+
              +---+               |
              +---+               |
              |VPS|--5555---------+
              +---+               |
              +---+               |
              |VPS|--5555---------+     
              +---+               |
              +---+               |
              |VPS|--5555---------+
              +---+               |
              +---+               |
              |VPS|--5555---------+
              +---+               |
                                  |
                            +----------+
                            |homerouter|
                            +----------+
                                |
                                |       +---+        +----------+
                                +-5555->|Rpi|--445-->|Windows VM|
                                        +---+        +----------+                           
The big limit of this configuration is when the packet is into our Windows VM, the source IP is losted due to the iptables forwarding.
In my case I capture traffic on VPSs and retrieve pcaps via this trick (thanks to Kafeine :D)

Monitoring the endpoint

Because there is a lot of other malware than Wannacry it's important to monitor our Windows.
For that, you have a lot of tools available; ProcMon is a good candidate, it's easy to run it and collect pmon trace automatially with the command line, for example here, you can launch it and save a pml trace:
pmon.exe /AcceptEula /Backingfile C:\pmon.pml
To stop procmon, run it like:
pmon.exe /Terminate
There is a lot of solution for the behaviour part, you can use etw traces, Event viewer...
The hardest part is to collect files dropped into our Honeypot.
I think that the better way is to use Minifilter, you can intercept writed PE files and save them in a specific location. There is an almost ready to use example in the WDK.
You can also hook WriteFile API in userland but it's easily bypassable.

Just for fun you can even retrive writted files and a lot of cool information without developping tool, just with the very painfull powerfull debugger Windbg \o/.
The idea is to use Windbg as kernel debugger, break on each nt!ntWritefile, and save Buffer parameter :D.
But you can do more! Dumping lsass memory on each attack for example :) Oh, yes, forget about perf here :D it's for fun
You have 2 options: the native diabolic scripting language of Windbg or the awesome python interface pykd
Here I'll use pykd :)
Download VirtualKd and install it into the VM (copy the "target" directory and run vminstall)
Run vmmon before restarting the VM, on the next boot Windbg will pop.


Press f5 and let Windows boots. When Windows is ready, break into Windbg (ctrl+pause).
Now we can do everything we want. For example let's try to dump the memory of lsass (usefull for fileless attack :) ) By dumping lsass memory you can even easily extract the payload binary :).

For that, load pykd extension into Windbg via:
.load pykd
And create your python script as you want.
A dirty example here:
Finally, choose on wich action you want to break on Windbg, here we'll dump lsass each time it try to write a file:
bp nt!ntWriteFile "!py C:\smbhoneypot\dumper.py;g"
Here we go, you are abble to collect a memory dump of lsass eatch time it was exploited to drop someting!

From now you can extract just the buffer of ntWriteFile, you can break on the vulnerability itself and trace execution etc. Plug your brain and be creative !

It's quick to do, it's easy and it allow you to collect a lot of useful data.

Cleaning your honeypot

Another important point is to manipulate Virtual machine. For that you have a lot of tools availaible.
In my case, I use VMWare on Windows. VMWare has a useful tools called vmrun, with it you can power on ,power off,revert snapshot, retrieves files from VM (like a pmon trace), run command in VM, list files... etc
Some command line example:
create snapshot:
vmrun.exe-T ws snapshot c:\VMs\honeypot.vmx snapshot_name
revert snapshot:
vmrun.exe-T ws snapshot revertToSnapshot c:\VMs\honeypot.vmx snapshot_name
run program in guest:
vmrun.exe -gu windows_user -gp windows_pwd runProgramInGuest \
                              c:\VMs\honeypot.vmx -activeWindow \
                                 -interactive -noWait program.exe
get data from guest:
vmrun.exe -gu windows_user -gp windows_pwd copyFileFromGuestToHost \
                              c:\VMs\honeypot.vmx -activeWindow \
                                c:\guest\auto_run.txt c:\host\auto_run.txt
There is similare tools for every hypervizor.

PROFIT

Last point: don't forget store all the data. Store everything you can, even if you don't know yet what to do with these data.
Date, IPs source, memory dump, sample etc These data are gold mine.
You can found a lot of python lib for parsing pcap, you can export windbg output, you can graph your pmon traces with tools like ProcDot, forward your data in Kibana dashbords etc.

Conclusion

This kind of infrastructure cost me around 30€/months for VPSs + 30€ for a RaspberryPi so less than 500€ by year for having a look at what happening in the wild, Having data, making stats, start some investigation etc :)

This kind of project are awesome because you have to deals with network, system, a little bit a dev, databases etc. You can even use this kind of honeypot for learning forensic for example!
I strongly recommand to every people who want to learn malware hunting to build honeypots, on many services and on different countries.
Of course you cannot catch advanced attacks with honeypot, but you can catch interresting malware with RDP or VNC honeypots for example

Links

Some link that can help you:
Tracing API call in Python: Fibratus
Example of how deal with pcap in Python
memdump tools from CCT
File System Filter Driver Tutorial
WinDbg cheat sheet
Using vmrun to Control Virtual Machines
Make ETW Great Again. - Ruxcon 2016
HONEY ? Where is my POS - Botconf

jeudi 16 mars 2017

Hancitor panel overview

Hey!

These weeks I've read a lot of tweets about hancitor. Hancitor is even in the CheckPoint "top 5 Most Wanted malware" (¯\_(ツ)_/¯).
You can read a lot of good stuff about the Hancitor/Fareit/Vawtrack/H1N1 gang, binaries reverse, proxy infra... but nothing about Hancitor web panels. So, I've write this (very) quick blogpost to show the attacker point of view :]


Since admin has activated White-listing, it seems that it's not possible to access to the web panel via the Nginx Proxy. When you try to access to a page admin.php or panel.php etc, proxy returns a 403 error. For accessing the panel, you have to find the real IP behind proxies.

Before the white-listing system, it was possible to access to Hancitor CNC due to a lot of vulns. Because these vuln are patched today, it's time to disclose some stuff. Let's have a look at this dropper C&C.

Bypassing authentication


When you want to access to a page, the panel developer checks if the user is authenticated with this kind of code:
This is an old school kind of vulnerability \o/. They don't use an "exit()" after the header function.
When you browse the page with a browser like Firefox, you are correctly redirected to google.com, however if you grab the page with CURL or WGET the header function is ignored and... all the PHP code is executed :).


Here we go, the panel is composed of 4 parts:

Panel.php


This is the main page, with some data about infected hosts.

commands.php

This page is used for sending commands to the bots. You can send commands to a specific group of bots or to a specific location.
The available commands are:
  • Download and Run
  • BOT Start
  • DLL Load
  • EXE Load
  • Uninstall
  • Load Config
  • Update
Two interesting facts: There is an "uninstall" command and if you send the correct POST request to the page commands.php, without authent', it works :)

passwords.php

This page is used for the password stealer module. I've never seen this feature used. It's maybe due to the fact that this gang use Fareit for stealing passwords...

statistics.php

And finally the statistics page, you can found online/Online in the last 12 hours/offline and create a new group of bots.
Thanks to a SQLi we can see that the database structure is:


As you can see, this super evil malware has a very basic CNC.
Some articles about this threat:
I hope that this quick post can be useful for somebody






lundi 27 février 2017

Spambot safari #2 - Online Mail System

Hey !
today I'll present some research around a spambot named "Onliner". This spambot is actually used for spreading Ursnif.
I've already talk about Onliner in another blogpost but because the spambot quickly evolve, and the botmaster seems to tries to avoid pwning attempst, I'll try to explain everything here :].

Original sample

The first sample that I've grab come from email, dropped by JSDropper.
A quick dynamic analysis allow us to understand that it's a spambot (a lot of SMTP connections from the malicious process).
Before reversing it, let's look a the CNC communication.

Malware communicates over HTTP. An interesting thing is that the process doesn't contacts directly the CNC, it try to contact some proxy web page (PHP script uploaded on compromised websites).

Proxy - Good idea - Bad realization

Using proxy websites is a good idea only if you don't use poor pwned CMS. With poor pwned CMS it take around 3 minutes to anybody to retrieves your real CNC. Example:
I can make some supposition:
  • It's pretty sure that the bot master uses a script for updating all the proxies scripts
  • All the compromised websites are old: most probable infection vectors are FTP Bruteforce or CMS exploits
  • They have leave a php backdoor somewhere on the compromised website
I have try to found the PHP backdoor for using it to read the PHP proxy code. After some guessing I have saw that the PHP backdoor is a WSO webshell, uploaded always in the same locations:
  • /cgi-bin/terms.php
  • /cgi-bin/useterms.php
  • /css/terms.php
  • /css/useterms.php
the WSO webshell is protected by a poor password -> I can read the PHP proxy code :). The commented version below:

The real CNC is http://194.247.13.8/img/. I'll come back later on the $GET_['99'] / $_POST['99'] parameters, those parameters are really interesting in the pwning process :D.

Panel - Good idea - Bad realization


Funny, the authentication is not like in others panels.
I don't want to directly use brute force here because like in almost all panels it must have a vulnerability somewhere.
Come back to the malware communication. As you can see here, the malware download some dll (ssl and 7zip) from the CNC.

I'm not a good pentester but when you saw a full dll name ssleay32.dll in a GET parameter, it's smell something bad \o/.


Thanks to that LFI we have access to all the panel (click on image bellow for the full album)

After looking around, I've found a reference to another IP: 194.247.13.178. This server host another onliner web panel: hxxp://194.247.13.178/naomi/login.php (click on image bellow for the full album)



By looking at the IP addresses (194.247.13.18 and 194.247.13.178) it seems that those guys really like "DELTA-X" hoster (Ukraine).
You know, for science, I've try to scan 194.247.13.0-255 with Nmap on port 80 + some directory guessing with Patator.
And you know what? It works haha!

I've found another panel at hxxp://194.247.13.196/asus/login.php .

Panel V2 - Good idea - Bad realization

After releasing the first blogpost about onliner, the botmaster change some stuff. They start to use IP White listing for accessing the panel, they update some code, they don't patch the LFI, they add some others vulns x].

Now, due to IP White listing, when you try to access the web panel, you are kicked by the PHP script:

The LFI is still here so we can look at the code. We can see 4 IPs white listed (Please don't spoil yourself, ignore the 2 first foreach haha I'll discuss that below):

It looks bad. I can read the PHP code but I can't access the admin panel. It's time to understand the authentication process. Take a seat, it's wonderfull. This is a big picture of the process:

admin.php:

I cannot explain yet what the hell is that
if ($_GET['pass']=='Lm7%Dv)ko4q') {
include('login.php');
}
Anyway, the big picture show us that the situation looks bad, the IP White listing is done early. But the function for IP White listing is in fact... a backdoor \o/:

Remember the $_GET['99'] in the PHP proxy script ? Look at the script. For bypassing IP White listing when an infected bot try to contacts the CNC, they use this parameters $_GET['99'] and $_POST['99'].
I just need the code (in config.php) + set the POST and GET variables and I can access to the CNC from any IPs.

curl --data "code=70183619&99=backdoor" "http://194.247.13.178/naomi/admin.php?99=backdoor&mailer=true" > onliner.html



Bonus

To finish, I just want to show you without comment 2 security features used in the Onliner panel.
Anti-SQLi:

Anti-... I don't know what:


Malware binary

The malware himself is in fact a dropper. When you run it, it copy itself in C:\windows\ and re-run as services.

The dropper try to drop 2 dlls:
  • http://cnc.com/MailerSMTP/dll.dll : the Spam module
  • http://cnc.com/CheckerSMTP/dll.dll : the SMTP credentials checker module
Those 2 dll are xored with the key
[0x37, 0x32, 0x44, 0x45, 0x34, 0x45, 0x35, 0x33, 0x36, 0x46, 0x35, 0x42, 0x32, 0x37, 0x39, 0x36, 0x31, 0x43, 0x43, 0x44, 0x41, 0x37, 0x30, 0x43, 0x32, 0x30, 0x39, 0x37, 0x38, 0x32, 0x46, 0x44, 0x44, 0x35, 0x31, 0x34, 0x43, 0x34, 0x36, 0x37, 0x44, 0x37, 0x39, 0x44, 0x30, 0x39, 0x39, 0x33, 0x38, 0x30, 0x33, 0x35, 0x31, 0x39, 0x43, 0x33, 0x32, 0x41, 0x46, 0x37, 0x33, 0x30, 0x34, 0x30, 0x00]

A little schema of the malware communication initialization: (the communication is encoded with base64 with $_GET parameters)

All the modules needed are copied in c:\windows\ too.
After installation, the malware wait for command from the CNC. Here, an example with the CheckerSMTP Module:
  • The CNC send the "control account", this account (mail+password+smtpserver) is used to be sure that the spamming process works. Valid SMTP credentials can be sends to this control account to
  • The CNC send a file a list of SMTP server + a list of compromised account in 2 zip files. mask.zip and 3746000.zip
  • The CNC wait until the bot finish his job and send another list of SMTP+Credentials

The sample is pretty good detected by AV industry (maybe due to the lot of debug strings present in the binary).

Conclusion

As reminded, this spam bot is used to spread Ursnif in Italy and Canada.
Onliner has around 1000 infected bots, they don't spread to much sample of the spambot.

I look forward the next update of the panel.

Annexe

Onliner known IPs:
  • 194.247.13.8
  • 194.247.13.178
  • 194.247.13.196
  • 91.210.165.163

Spambot sample:
Module samples:

lundi 30 janvier 2017

БОМБИЛА - БОТНЕТ

Spambot safari #1 - Bombila

Hey!

Let's go for a Spambot safari.
There is a lot of malware analysis on the Internet but a very small number about malware used for Spamming (Necurs is a rare exception). But behind every big spam campaign, there is a spambot. And this part of the campaign is often technically weak.

It's easy to find a spambot. Most of the time, botmatsers's do the error of spreading the spambot's binary via the spam botnet itself. Due to the malware's communication, this mistake expose the spambot architecture and allow us to analyze the CNC part.
Looking for malware with SMTP communication on public sandboxes is a another good way to find spambot samples.

Here, I'll try to describe "Bombila" Spambot (БОМБИЛА).
This malware was used for spreading Teslacrypt in 2016 (if you want to understand how weak are spamming campaigns, take a look at: https://thisissecurity.net/2016/03/02/lets-ride-with-teslacrypt/)

I'll try to give an overview of this malware.
Sample: 6aa5fd384fbfe271a5000397e2e0c9d9e06dd5d041488e4f2de7ae3a4eb1589d

Silent_SMTP_Bruter.exe

The malware itself (Silent_SMTP_Bruter) is not really interresting and seems in developpment;
A lot of bugs, poor strings obfuscation, OutputDebugStrings, a log file created in C:\log.txt...
Persistance is done via CurrentVersionRun, there is no self replication or hidden feature (the malware stay where you launch it), after some connection checks, the malware contact the CNC (HTTP). If you kill the process with the task manager, the malware stop working.


Wow! So much obfuscation...


"Silent_SMTP_Bruter" string is present in the PACKAGEINFO


As usual the malware is composed of a SMTP bruteforce module and a SMTP spam module.
The main module try to contacts a gate "cmd.php" in 2 different ways:
  • A POST request $_POST['status'] every 5 minutes for sending bot status
  • a GET request whitout parameter for retrieving new order.

Not so boring malware

But, the best part is not in the malware itself; it's the icon of the malware \o/. You can observe a funny behaviour; when you rename the binary, the binary's icon changes. It take icons already present in system icon cache. The hash is still the same (works on Windows 10 up to date :]).
It can be used to fool victims because the malware takes icon like directory or Word, txt etc


If we extract the icon from resources binary, I reproduce the bug with the .ico icon:


It's a very small icon file (78bytes)


In red, it's the Ico header composed of 2 structures: ICONDIR and ICONDIRENTRY
In green, it's the bitmap header, in the structure BITMAPINFOHEADER
In blue it's the color data RGB

It seems that, after a MapViewOfFile, user32 misparse bitmap data and choose a "random" icon in the icon Cache (C:\Users\login\AppData\Local\Microsoft\Windows\Explorer).
I'm still working on that; I'll try to write a post about how reverse these kinds of UI tricks without getting suicidal tendencies \o/.
Thanks a lot to @Antelox for his precious help :]

Crack the bot

During Teslacrypt analysis I was abble to dump the web panel. So, why not try to patch the bot with my CNC for playing with all the features ?
For that, we have to understand were is stored the CNC in the binary and patch it.
There is a good resource about that on Xylibox But in this case I'll use a easier way :]. In the binary we can see that the CNC is "obfuscated" (loc_4480D3)


It's now easy to make a dirty python script for encoding our CNC and patch the binary (Offset 0x58488)
Due to a stupid parsing error, the CNC must look like "http://domain.com/folder" without the last slash.



You can now control the bot and explore all the features \o/.


Panel Overview



The source code is a real mess. It looks like the panel is a compilation of 2 panels
For example there is 3 footers in index.php:

Some comments refer to other projects:


It's time for a quick overview (I've try to do a quick and dirty english version (thanks @KodaES :D), put your cursor on the image for the translated version):
The home page:

From this page, you can:
  • Upload emails lists
  • Upload subject, messages, "from", header etc
  • retrives statistics about the spam campaign
  • retrives some statistics about infected bots
  • configure the campaing


I cannot found any bot lists or campaigns details directly form the webpanel.
Some page are only accessible by reading the source code.
In fact, index.php is a big switch case:



For example: the bots list (index.php?act=work):


Search engine:

there is no dropping or backdoor feature. This malware is only about spam purpose.

After Teslacrypt ?


I've try to found other sample of this malware after the end of Teslacrypt.
I've found a another panel but nothing else.


I think it can be easy to retrives new sample via VTi.

Some numbers to conclude (based on webstat files found on the CNC):
From December 2015 to February 2016, Bombila :
  • was composed of ~10 000 bots
  • has sent at least 10 millions emails


Thanks for reading :]