MagicDot: Exploiting Windows Paths for Rootkit Power
MagicDot
A set of rootkit-like abilities for unprivileged users, and vulnerabilities based on the DOT-to-NT path conversion known issue.

MagicDot Python Package
Implements MagicDot’s rootkit-like techniques:
- Files/Directories named with dots only
- Bonus – Such Directories prevent any shadow copy restoration of any parent directory of the inoperable directory
- Inoperable Files/Directories
- Impersonated Files/Directories
- Impersonated Process
- Process Explorer DoS Vulnerability – CVE-2023-42757
- Hidden files in ZIP archives
Install
git clone https://github.com/SafeBreach-Labs/MagicDot.git
pip install -r requirements.txt
Use
Inside the tools folder, you’ll find the magic_dot_cli tool (dependent on the MagicDot Python package) along with 3 different solo scripts that implement the exploits for vulnerabilities CVE-2023-36396, CVE-2023-32054, and a third unfixed Deletion EoP vulnerability. During the installation of the MagicDot Python package, the requirements for these scripts are installed as well.
For convenience purposes, it is recommended to pack magic_dot_cli into an executable using Pyinstaller:
[pastacode lang=”markup” manual=”cd%20tools%5Cmagic_dot_cli%5C%0Apyinstaller%20–onefile%20magic_dot_cli.py” message=”” highlight=”” provider=”manual”/]
magic_dot_cli
[pastacode lang=”markup” manual=”python%20.%5Cmagic_dot_cli.py%20-h%0Ausage%3A%20magic_dot_cli.py%20%5B-h%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7BCREATE_IMPERSONATED_PROCESS%2CCREATE_INOPERABLE_FILE%2CCREATE_INOPERABLE_DIR%2CCREATE_DOTS_FILE%2CCREATE_DOTS_DIR%2CCREATE_IMPERSONATED_FILE%2CCREATE_IMPERSONATED_DIR%2CADD_INVISIBLE_FILE_INTO_ZIP%2CDISABLE_PROCEXP%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20…%0A%0AAn%20unprivileged%20rootkit-like%20tool%0A%0Aoptional%20arguments%3A%0A%20%20-h%2C%20–help%20%20%20%20%20%20%20%20%20%20%20%20show%20this%20help%20message%20and%20exit%0A%0Acommand%3A%0A%20%20%7BCREATE_IMPERSONATED_PROCESS%2CCREATE_INOPERABLE_FILE%2CCREATE_INOPERABLE_DIR%2CCREATE_DOTS_FILE%2CCREATE_DOTS_DIR%2CCREATE_IMPERSONATED_FILE%2CCREATE_IMPERSONATED_DIR%2CADD_INVISIBLE_FILE_INTO_ZIP%2CDISABLE_PROCEXP%7D%0A%20%20%20%20CREATE_IMPERSONATED_PROCESS%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Create%20a%20process%20that%20impersonates%20a%20different%20process.%20Both%20Task%20Manager%20and%20Process%20Explorer%20will%20display%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20information%20about%20the%20target%20process%20to%20impersonate%20to%0A%20%20%20%20CREATE_INOPERABLE_FILE%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Create%20an%20inoperable%20file%0A%20%20%20%20CREATE_INOPERABLE_DIR%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Create%20an%20inoperable%20directory%0A%20%20%20%20CREATE_DOTS_FILE%20%20%20%20Create%20a%20dots%20file%0A%20%20%20%20CREATE_DOTS_DIR%20%20%20%20%20Create%20a%20dots%20directory%0A%20%20%20%20CREATE_IMPERSONATED_FILE%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Create%20a%20file%20that%20impersonates%20a%20different%20file%0A%20%20%20%20CREATE_IMPERSONATED_DIR%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Create%20a%20directory%20that%20impersonates%20a%20different%20directory%0A%20%20%20%20ADD_INVISIBLE_FILE_INTO_ZIP%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Inserts%20a%20file%20into%20a%20zip.%20The%20file%20is%20inserted%20with%20a%20name%20that%20prevents%20Windows’%20ZIP%20archiver%20from%20being%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20able%20to%20list%20it%20in%20the%20ZIP.%0A%20%20%20%20DISABLE_PROCEXP%20%20%20%20%20Exploits%20a%20DOS%20vulnerability%20in%20ProcExp.%20Creates%20a%20process%20that%20runs%20forever%20and%20does%20nothing.%20The%20process%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20has%20a%20certain%20name%20that%20crashes%20ProcExp%20whenever%20it%20runs.%20Valid%20against%20all%20ProcExp%20versions%20under%20version%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2017.04%20(released%20in%20April%203rd%202023).” message=”” highlight=”” provider=”manual”/]
For more help per each command use -h for the specific command. For Example:
python magic_dot_cli.py CREATE_IMPERSONATED_PROCESS -h
prepare_archive_rce_exploit (CVE-2023-36396)
[pastacode lang=”markup” manual=”python%20prepare_archive_rce_exploit.py%20-h%0Ausage%3A%20prepare_archive_rce_exploit.py%20%5B-h%5D%20%5B–target-dir-relative%20TARGET_DIR_RELATIVE%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20files_to_write_paths%20%5Bfiles_to_write_paths%20…%5D%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20out_archive_path%0A%0AExploits%20CVE-2023-36396.%20Crafts%20a%20malicious%20archive%20that%20exploits%20Windows%20File%20Explorer%20%20%20%0Ato%20extract%20a%20file%20to%20an%20arbitrary%20relative%20path.%20The%20default%20relative%20path%20is%20set%20to%20%20%20%20%20%20%0Apoint%20from%20the%20Downloads%20directory%20to%20the%20user’s%20Startup%20folder%0A%0Apositional%20arguments%3A%0A%20%20files_to_write_paths%20%20File%20paths%20separated%20by%20spaces.%20These%20files%20are%20the%20files%20which%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20will%20be%20written%20to%20the%20chosen%20victim’s%20directory%0A%20%20out_archive_path%20%20%20%20%20%20Path%20to%20the%20archive%20to%20be%20created%20that%20will%20contain%20the%20exploit.%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20the%20type%20of%20the%20archive%20will%20be%20determined%20based%20on%20the%20file%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20extension%20provided.%20Supported%20types%3A%20.tar%7C.tar.gz%7C.tar.gzip%7C.tar%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20.xz%7C.tar.bz2%7C.tar.bzip2%7C.tar.zst%7C.tar.zstd%7C.7z%7C.7zip%0A%0Aoptional%20arguments%3A%0A%20%20-h%2C%20–help%20%20%20%20%20%20%20%20%20%20%20%20show%20this%20help%20message%20and%20exit%0A%20%20–target-dir-relative%20TARGET_DIR_RELATIVE%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20A%20relative%20path%20from%20the%20victim’s%20estimated%20extraction%20folder%20to%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20the%20destination%20folder%20of%20the%20executables” message=”” highlight=”” provider=”manual”/]
prepare_shadow_copy_restoration_write_exploit (CVE-2023-32054)
[pastacode lang=”markup” manual=”python%20.%5Cprepare_shadow_copy_restoration_write_exploit.py%20-h%0Ausage%3A%20prepare_shadow_copy_restoration_write_exploit.py%20%5B-h%5D%20-target-dir%20TARGET_DIR%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20(-replacing-dir%20REPLACING_DIR%20%7C%20-remove-dir)%0A%0AExploits%20CVE-2023-32054%0A%0Aoptional%20arguments%3A%0A%20%20-h%2C%20–help%20%20%20%20%20%20%20%20%20%20%20%20show%20this%20help%20message%20and%20exit%0A%20%20-target-dir%20TARGET_DIR%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20The%20target%20directory%20to%20try%20to%20overwrite%20its%20files.%20The%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20directory%20is%20vulnerable%20if%20an%20unprivileged%20user%20is%20allowed%20to%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20create%20a%20new%20directory%20its%20parent%20directory%0A%20%20-replacing-dir%20REPLACING_DIR%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20The%20directory%20that%20contains%20files%20with%20the%20same%20names%20in%20the%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20same%20structure%20of%20the%20target%20dir%20but%20with%20the%20new%20desired%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20content%0A%20%20-remove-dir%20%20%20%20%20%20%20%20%20%20%20Delete%20the%20directory%20created%20a%20part%20of%20the%20exploit%20in%20an%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20earlier%20point%20in%20time.%20This%20is%20recommended%20to%20be%20done%20after%20a%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20shadow%20copy%20was%20taken%20by%20an%20admin%2C%20while%20the%20directory%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20existed” message=”” highlight=”” provider=”manual”/]
prepare_delete_dir_exploit
[pastacode lang=”markup” manual=”python%20prepare_delete_dir_exploit.py%20-h%0Ausage%3A%20prepare_delete_dir_exploit.py%20%5B-h%5D%20target_dir%0A%0AExploits%20a%20%22won’t%20fixed%22%20deletion%20EoP%20vulnerability%20triggered%20by%20a%20privileged%20user%0Ainteraction.%20Creates%20a%20directory%20called%20%22…%20%22%20in%20a%20target%20directory%20to%20delete.%20When%20%20%20%20%20%20%0A%22…%20%22%20is%20deleted%2C%20then%20its%20parent%20directory%20is%20deleted%20too.%0A%0Apositional%20arguments%3A%0A%20%20target_dir%20%20The%20target%20directory%20to%20try%20to%20delete.%20It%20is%20vulnerable%20only%20if%20you%20can%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20create%20a%20directory%20inside%20it.%0A%0Aoptional%20arguments%3A%0A%20%20-h%2C%20–help%20%20show%20this%20help%20message%20and%20exit” message=”” highlight=”” provider=”manual”/]
Presented at Black Hat Asia 2024 under the title – MagicDot: A Hacker’s Magic Show of Disappearing Dots and Spaces
For a deeper understanding of the research, read this blog post – MagicDot: A Hacker’s Magic Show of Disappearing Dots and Spaces
Copyright (c) 2022, SafeBreach Labs
All rights reserved.
Source: https://github.com/SafeBreach-Labs/
Support Our Threat Intelligence
If you find our technology report and cybersecurity news helpful, consider supporting our work.