ShellShock exploited in the wild: kernel exploit with CnC component
gist.github.com
gist.github.com
I ran the "nginx" binary thru strace in a vagrant vm and got some connection attempts to a clouldflare IP
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("108.162.197.26")}, 16) = 0
but didn't see anything interesting being sent there... My tcpdump output showed it connects to a http server at 89.238.150.154:5 and exchanges some data there
sent >>> BUILD X86
recv >>> !* HTTP
recv >>> 190.93.240.15,190.93.241.15,141.101.112.16,190.93.243.15,190.93.242.15 pastebin.com /4HQ2w4AZ 80 2
recv >>> PING
sent >>> PONG
then it just goes to do ping/pong with the same server. At one point the process forks a separate process of itself and dies...
The pastebin link leads to an uploadcash.org file named hermoine_granger_jpg.jpg which I can assume is a payload of somekind...
FWIW, it doesn't appear to be a new bit of malware - the same strings match this pastebin from March - http://pastebin.com/xa87Gh7q
Anyhow, doesn't seem like it sends anything to Cloudflare. I think it just checks if the IP is alive (perhaps this is how it tests connectivity to the internet). It also checks my routing table and extracts the MAC address.
P.S as of now, the CC server at 89.238.150.154:5 is not accessible.
A get request is sent to the server with additional commands added to the content, which creates the file ./tmp/besh whose content comes from the ngix file from http://162.253.66.76/nginx. The executable flag is set and then the file gets executed.
The next three commands show information about the downloaded nginx file (check sums, file command info). For what reason? Is the file really an nginx server or is it just named like this to show that nginx is exploitable? I know that this is basically about the bash exploit, right?
Thanks
The title/description of the gist claims it is a kernel exploit with CnC (Command and Control) capabilities. So yeah, the file is only named nginx; it doesn't have anything to do with the popular web server software of the same name. Probably named that way to avoid suspicion
Correct, it is usually done to conceal the process in process listings (top / ps aux).
Discovering a case where wget shells out to bash while setting some env vars based on received headers. And then anonymously posting a supposed shellshock payload just begging to be downloaded with wget.
Why oh why would this ever happen?
This hole bug is way overblown. Not every small program on the planet "shells out to bash", and if they do, thats one seriously messed up program.
If you run a web server that generates its own CAPTCHA using something like ImageMagick, or call system() to gzip something, you could possibly be vulnerable.
Never underestimate vulnerabilities and the way people can use them, or even combine them, to exploit systems.
Are you serious, who the hell does that!?
Any half-assed language has a zip implementation, use that. Any non-boring language has image-magick binding to that library.
This bug affects complete idiots.
Consider how many people touch an enterprise system, or even a system at a smaller shop. Consider how many people touch shared hosting servers or even dedicated boxes.
Do /you/ trust all of them, along with all the authors of all the software exposed to the web (or touched by something exposed to the web) on that system?
Seriously, if you're on shared hosting, it's almost certain that at least one person on the server is compromised/malicious
This information is, frankly, more interesting than the fact that ShellShock is being exploited in the wild. Really, it was only a matter of time.
The most obvious answer is no.
Somone is going to make a fortune mining bitcoin in the coming weeks.
The far more likely way for this bug resulting in someone exfiltrating lots of bitcoins is them hitting every Bitcoin exchange looking for e.g. cPanel on a development box, Wordpress hosted on Nginx with fastcgi, etc etc. If they find one, they've got the hot wallet inside of five minutes later if it is on the same box, a bit more if it is somewhere else on the local network.
(I've got to admit, the first thing I did after patching my boxes, to relax about the stress, was grepping Bitcoin Core for system calls. No obvious ones that I could see, for what it is worth.)
If I can emphasize again, though: just because you don't engage in risky behaviors like e.g. transacting in bitcoins, doesn't mean your boxes are safe. Every. Server. On. The. Internet. Will be probed for a variety of exploits enabled by this vulnerability. There will be dozens of independently administered for loops probing for it within 24 hours.
https://launchpad.net/ubuntu/+source/bash/4.2-2ubuntu2.2
> -- Marc Deslauriers <email address hidden> Mon, 22 Sep 2014 15:31:07 -0400
Also, very amusing: > bash (4.2-2ubuntu2.2) precise-security; urgency=medium
urgency=medium? Shouldn't it be: urgency="don't even finish your lunch; run"
CVE-2014-7169 has not been yet been patched.
The fix right now is to mv bash ohhellnobarsh && ln -s dash sh
Or such.
# ls -l /bin/*sh
lrwxrwxrwx 1 root root 12 Feb 9 2014 /bin/ash -> /bin/busybox
lrwxrwxrwx 1 root root 12 Feb 9 2014 /bin/sh -> /bin/busybox
http://www.kernelmode.info/forum/viewtopic.php?f=16&t=3505#p...
One can, of course, envision numerous ways to get data in and out without it being an IRC channel, but that is easy to implement, works across a wide variety of target environments, and plays well with the existing ratware ecosystem.
https://www.pcisecuritystandards.org/documents/PCI_DSS_v3.pd...
I wrote unix exploits for a living for years (All legit, in a pentest company) and for payloads I would normally use echo or printf to upload a binary and execute it. And those are built-in commands in the shell.
http://blog.sucuri.net/2014/09/bash-vulnerability-shell-shoc...
env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
This should be displayed: bash: warning: x: ignoring function definition attempt
bash: error importing function definition for `x'
this is a testNOPE
This bug only affects people who dont care about security.
Now you say, but you really really have to run this "utility" with subprocessing or whatever. Well, then its outside of python program and instead of relying on subprocessing Id consider exposing that utility as an interface and writing a small protocl through which the python and utility can exchange data. You most probably have to parse output of utility anyway, better do it right straight away. And if you dont have to parse output of utility - then you send a signal/request/messaging-bus to a listerner which will do what you want - but now with cleaned environment.
https://docs.python.org/3.4/library/subprocess.html#security...
All you're doing is hiding the call to system/execve behind deeper layers of abstraction.
Plus if people actually went ahead and reproduced all of the GNU/busybox toolchain inside of Python then everyone would be queuing up to criticise them, particularly if they introduced more security issues (e.g. reproducing rsync fully within a Python library).
Realistically using execve instead of system is a step forward. It is more efficient for non-scripts and you aren't potentially picking up poisoned environmental variables. But if you NEED to run utilities then all you can really do is pre-parse all the parameters carefully and hope for the best.
Suggesting never using either execve or system is just highly unrealistic. There is just too much useful code available via it and aren't nearly enough libraries to reproduce all of that code within whatever language you're working.
Thats the point, layers where environment variables do not pass - since they in that abstraction do not make sense.
> Plus if people actually went ahead and reproduced all of the GNU/busybox toolchain inside of Python
Basically all of gnu coreutils/busybox, is already inside python, its called import os.
For your rsync example, python-librsync exists. C library, with python binding/interface. No need to run a bash to use the algorithm. If you still want to exec it, then use pythons binding to exceve system call or similar, not to system.
I didnt suggest never to use execve and/or system, I said do not ever use system, sometimes highly questionably use execve.
And those running code written by people who don't know any better...
If you are an admin for servers running third part code that you have not verified every line of, you need to be concerned about anything like this just in case said code does something that isn't considered best practise.
Also if the CGI code path uses affected functions, you are not going to be protected by avoiding using them in the code that is eventually called.
Even if the CGI script is in some other language, think of how many .sh wrapper scripts there are out there.
EDIT: http://lcamtuf.blogspot.com/2014/09/quick-notes-about-bash-b... explains it better