Skip to content

Commit 2409436

Browse files
author
HackTricks News Bot
committed
Add content from: Evolving Tactics of SLOW#TEMPEST: A Deep Dive Into Advanced ...
1 parent 1403e5b commit 2409436

4 files changed

Lines changed: 99 additions & 8 deletions

File tree

src/generic-methodologies-and-resources/basic-forensic-methodology/malware-analysis.md

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,98 @@ If the files of a folder **shouldn't have been modified**, you can calculate the
169169

170170
When the information is saved in logs you can **check statistics like how many times each file of a web server was accessed as a web shell might be one of the most**.
171171

172-
{{#include ../../banners/hacktricks-training.md}}
172+
---
173+
174+
## Deobfuscating Dynamic Control-Flow (JMP/CALL RAX Dispatchers)
175+
176+
Modern malware families heavily abuse Control-Flow Graph (CFG) obfuscation: instead of a direct jump/call they compute the destination at run-time and execute a `jmp rax` or `call rax`. A small *dispatcher* (typically nine instructions) sets the final target depending on the CPU `ZF`/`CF` flags, completely breaking static CFG recovery.
177+
178+
The technique – showcased by the SLOW#TEMPEST loader – can be defeated with a three-step workflow that only relies on IDAPython and the Unicorn CPU emulator.
179+
180+
### 1. Locate every indirect jump / call
181+
182+
```python
183+
import idautils, idc
184+
185+
for ea in idautils.FunctionItems(idc.here()):
186+
mnem = idc.print_insn_mnem(ea)
187+
if mnem in ("jmp", "call") and idc.print_operand(ea, 0) == "rax":
188+
print(f"[+] Dispatcher found @ {ea:X}")
189+
```
190+
191+
### 2. Extract the dispatcher byte-code
192+
193+
```python
194+
import idc
195+
196+
def get_dispatcher_start(jmp_ea, count=9):
197+
s = jmp_ea
198+
for _ in range(count):
199+
s = idc.prev_head(s, 0)
200+
return s
201+
202+
start = get_dispatcher_start(jmp_ea)
203+
size = jmp_ea + idc.get_item_size(jmp_ea) - start
204+
code = idc.get_bytes(start, size)
205+
open(f"{start:X}.bin", "wb").write(code)
206+
```
207+
208+
### 3. Emulate it twice with Unicorn
209+
210+
```python
211+
from unicorn import *
212+
from unicorn.x86_const import *
213+
import struct
214+
215+
def run(code, zf=0, cf=0):
216+
BASE = 0x1000
217+
mu = Uc(UC_ARCH_X86, UC_MODE_64)
218+
mu.mem_map(BASE, 0x1000)
219+
mu.mem_write(BASE, code)
220+
mu.reg_write(UC_X86_REG_RFLAGS, (zf << 6) | cf)
221+
mu.reg_write(UC_X86_REG_RAX, 0)
222+
mu.emu_start(BASE, BASE+len(code))
223+
return mu.reg_read(UC_X86_REG_RAX)
224+
```
225+
226+
Run `run(code,0,0)` and `run(code,1,1)` to obtain the *false* and *true* branch targets.
227+
228+
### 4. Patch back a direct jump / call
229+
230+
```python
231+
import struct, ida_bytes
232+
233+
def patch_direct(ea, target, is_call=False):
234+
op = 0xE8 if is_call else 0xE9 # CALL rel32 or JMP rel32
235+
disp = target - (ea + 5) & 0xFFFFFFFF
236+
ida_bytes.patch_bytes(ea, bytes([op]) + struct.pack('<I', disp))
237+
```
238+
239+
After patching, force IDA to re-analyse the function so the full CFG and Hex-Rays output are restored:
240+
241+
```python
242+
import ida_auto, idaapi
243+
idaapi.reanalyze_function(idc.get_func_attr(ea, idc.FUNCATTR_START))
244+
```
245+
246+
### 5. Label indirect API calls
247+
248+
Once the real destination of every `call rax` is known you can tell IDA what it is so parameter types & variable names are recovered automatically:
249+
250+
```python
251+
idc.set_callee_name(call_ea, resolved_addr, 0) # IDA 8.3+
252+
```
253+
254+
### Practical benefits
255+
256+
* Restores the real CFG → decompilation goes from *10* lines to thousands.
257+
* Enables string-cross-reference & xrefs, making behaviour reconstruction trivial.
258+
* Scripts are reusable: drop them into any loader protected by the same trick.
259+
260+
---
173261

262+
## References
174263

264+
- [Unit42 – Evolving Tactics of SLOW#TEMPEST: A Deep Dive Into Advanced Malware Techniques](https://unit42.paloaltonetworks.com/slow-tempest-malware-obfuscation/)
175265

266+
{{#include ../../banners/hacktricks-training.md}}

src/mobile-pentesting/android-app-pentesting/reversing-native-libraries.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ Java.perform(function () {
6161
});
6262
});
6363
```
64-
Frida will work out of the box on PAC/BTI-enabled devices (Pixel 8/Android 14+) as long as you use frida-server 16.2 or later – earlier versions failed to locate padding for inline hooks. citeturn5search2turn5search0
64+
Frida will work out of the box on PAC/BTI-enabled devices (Pixel 8/Android 14+) as long as you use frida-server 16.2 or later – earlier versions failed to locate padding for inline hooks.
6565

6666
---
6767

6868
### Recent vulnerabilities worth hunting for in APKs
6969

7070
| Year | CVE | Affected library | Notes |
7171
|------|-----|------------------|-------|
72-
|2023|CVE-2023-4863|`libwebp` ≤ 1.3.1|Heap buffer overflow reachable from native code that decodes WebP images. Several Android apps bundle vulnerable versions. When you see a `libwebp.so` inside an APK, check its version and attempt exploitation or patching.| citeturn2search0|
72+
|2023|CVE-2023-4863|`libwebp` ≤ 1.3.1|Heap buffer overflow reachable from native code that decodes WebP images. Several Android apps bundle vulnerable versions. When you see a `libwebp.so` inside an APK, check its version and attempt exploitation or patching.| |
7373
|2024|Multiple|OpenSSL 3.x series|Several memory-safety and padding-oracle issues. Many Flutter & ReactNative bundles ship their own `libcrypto.so`.|
7474

7575
When you spot *third-party* `.so` files inside an APK, always cross-check their hash against upstream advisories. SCA (Software Composition Analysis) is uncommon on mobile, so outdated vulnerable builds are rampant.
@@ -92,7 +92,7 @@ When you spot *third-party* `.so` files inside an APK, always cross-check their
9292

9393
### References
9494

95-
- Frida 16.x change-log (Android hooking, tiny-function relocation) – [frida.re/news](https://frida.re/news/) citeturn5search0
96-
- NVD advisory for `libwebp` overflow CVE-2023-4863 – [nvd.nist.gov](https://nvd.nist.gov/vuln/detail/CVE-2023-4863) citeturn2search0
95+
- Frida 16.x change-log (Android hooking, tiny-function relocation) – [frida.re/news](https://frida.re/news/)
96+
- NVD advisory for `libwebp` overflow CVE-2023-4863 – [nvd.nist.gov](https://nvd.nist.gov/vuln/detail/CVE-2023-4863)
9797

9898
{{#include ../../banners/hacktricks-training.md}}

src/mobile-pentesting/ios-pentesting/ios-pentesting-without-jailbreak.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Recent Frida releases (>=16) automatically handle pointer authentication and oth
106106

107107
### Automated dynamic analysis with MobSF (no jailbreak)
108108

109-
[MobSF](https://mobsf.github.io/Mobile-Security-Framework-MobSF/) can instrument a dev-signed IPA on a real device using the same technique (`get_task_allow`) and provides a web UI with filesystem browser, traffic capture and Frida console【turn6view0†L2-L3】. The quickest way is to run MobSF in Docker and then plug your iPhone via USB:
109+
[MobSF](https://mobsf.github.io/Mobile-Security-Framework-MobSF/) can instrument a dev-signed IPA on a real device using the same technique (`get_task_allow`) and provides a web UI with filesystem browser, traffic capture and Frida console【†L2-L3】. The quickest way is to run MobSF in Docker and then plug your iPhone via USB:
110110

111111
```bash
112112
docker pull opensecurity/mobile-security-framework-mobsf:latest

src/pentesting-web/sql-injection/ms-access-sql-injection.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Point the UNC path to:
141141
* a host that drops the TCP handshake after `SYN-ACK`
142142
* a firewall sinkhole
143143

144-
The extra seconds introduced by the remote lookup can be used as an **out-of-band timing oracle** for boolean conditions (e.g. pick a slow path only when the injected predicate is true). Microsoft documents the remote database behaviour and the associated registry kill-switch in KB5002984. citeturn1search0
144+
The extra seconds introduced by the remote lookup can be used as an **out-of-band timing oracle** for boolean conditions (e.g. pick a slow path only when the injected predicate is true). Microsoft documents the remote database behaviour and the associated registry kill-switch in KB5002984.
145145

146146
### Other Interesting functions
147147

@@ -229,7 +229,7 @@ Mitigations (recommended even for legacy Classic ASP apps):
229229
* Block outbound SMB/WebDAV at the network boundary.
230230
* Sanitize / parameterise any part of a query that may end up inside an `IN` clause.
231231
232-
The forced-authentication vector was revisited by Check Point Research in 2023, proving it is still exploitable on fully patched Windows Server when the registry key is absent. citeturn0search0
232+
The forced-authentication vector was revisited by Check Point Research in 2023, proving it is still exploitable on fully patched Windows Server when the registry key is absent.
233233
234234
### .mdb Password Cracker
235235

0 commit comments

Comments
 (0)