Panda Recon
Panda Recon
Panda Recon
Architecture
Neutral
Dynamic
Analysis
What is PANDA?
You can write plugins
Platform for
Architecture
Neutral
Dynamic
Analysis
What is PANDA?
You can write plugins
Platform for
Supports x86, ARM!
Architecture and MIPS
Neutral
Dynamic
Analysis
What is PANDA?
You can write plugins
Platform for
Supports x86, ARM!
Architecture and MIPS
Neutral
Dynamic
Static analysis is hard
Analysis
What is PANDA?
You can write plugins
Platform for
Supports x86, ARM!
Architecture and MIPS
Neutral
Dynamic
Static analysis is hard
Analysis (and often imprecise,!
slow, hard to scale)
Features
Based on QEMU 1.0.1
Deterministic record/replay
==
Friday?
==
0x45?
>=
0x80?
Record/Replay
CPU Outside World
==
0x45?
>=
0x80?
Record/Replay
CPU Outside World
==
0x45?
>=
0x80?
Record/Replay
CPU Outside World
>=
0x80?
Record/Replay
CPU Outside World
>=
0x80?
Record/Replay
CPU Outside World
>=
0x80?
Record/Replay
CPU Outside World
Record Log
>=
0x80?
Sharing is Caring
LLVM Translation
0x8260a634: push esp
0x8260a635: push ebp
0x8260a636: push ebx
0x8260a637: push esi
0x8260a638: push edi
0x8260a639: sub esp,0x54
0x8260a63c: mov ebp,esp
0x8260a63e: mov DWORD PTR [ebp+0x44],eax
0x8260a641: mov DWORD PTR [ebp+0x40],ecx
0x8260a644: mov DWORD PTR [ebp+0x3c],edx
0x8260a647: test DWORD PTR [ebp+0x70],0x20000
0x8260a64e: jne 0x8260a60c
LLVM Translation
movi_i64 tmp4,$0x8260a634
st_i64 tmp4,env,$0x80
---- 0x8260a634
movi_i64 tmp12,$0x8260a634
st_i64 tmp12,env,$0xdae0
ld_i64 tmp12,env,$0xdad0
movi_i64 tmp13,$0x1
add_i64 tmp12,tmp12,tmp13
st_i64 tmp12,env,$0xdad0
mov_i64 tmp0,rsp
mov_i64 tmp2,rsp
movi_i64 tmp12,$0xfffffffffffffffc
add_i64 tmp2,tmp2,tmp12
movi_i64 tmp12,$0xffffffff
and_i64 tmp2,tmp2,tmp12
[ ]
LLVM Translation
define private i64 @tcg-llvm-tb-0-8260a634(i64*) {
entry:
%1 = getelementptr i64* %0, i32 0
%env_v = load i64* %1
%2 = add i64 %env_v, 128
%3 = inttoptr i64 %2 to i64*
store i64 2187372084, i64* %3
store volatile i64 2, i64* inttoptr
(i64 29543856 to i64*)
store volatile i64 2187372084, i64* inttoptr
(i64 29543864 to i64*)
%4 = add i64 %env_v, 56032
%5 = inttoptr i64 %4 to i64*
store i64 2187372084, i64* %5
%6 = add i64 %env_v, 56016
[ ]
Android Emulation
Supports Android 2.x 4.2
Record/replay
System-level introspection
supported on all Android
versions
Plugin Architecture
LLVM IR
!
%2 = add i64 %env_v, 128
%3 = inttoptr i64 %2 to i64*
store i64 2187372084, i64* %3
!
Basic Block
!
Basic Block
Translation Execution
PANDA_CB_BEFORE_BLOCK_TRANSLATE
LLVM IR
!
%2 = add i64 %env_v, 128
%3 = inttoptr i64 %2 to i64*
store i64 2187372084, i64* %3
!
Basic Block
!
Basic Block
Translation Execution
PANDA_CB_BEFORE_BLOCK_TRANSLATE
LLVM IR
!
%2 = add i64 %env_v, 128
%3 = inttoptr i64 %2 to i64*
store i64 2187372084, i64* %3
!
PANDA_CB_INSN_TRANSLATE
Basic Block
!
Basic Block
Translation Execution
PANDA_CB_BEFORE_BLOCK_TRANSLATE
LLVM IR
!
%2 = add i64 %env_v, 128
%3 = inttoptr i64 %2 to i64*
store i64 2187372084, i64* %3
!
PANDA_CB_INSN_TRANSLATE
Basic Block
PANDA_CB_AFTER_BLOCK_TRANSLATE
!
Basic Block
Translation Execution
PANDA_CB_BEFORE_BLOCK_TRANSLATE PANDA_CB_BEFORE_BLOCK_EXEC
LLVM IR
!
%2 = add i64 %env_v, 128
%3 = inttoptr i64 %2 to i64*
store i64 2187372084, i64* %3
!
PANDA_CB_INSN_TRANSLATE
Basic Block
PANDA_CB_AFTER_BLOCK_TRANSLATE
!
Basic Block
Translation Execution
PANDA_CB_BEFORE_BLOCK_TRANSLATE PANDA_CB_BEFORE_BLOCK_EXEC
LLVM IR PANDA_CB_AFTER_BLOCK_EXEC
!
%2 = add i64 %env_v, 128
%3 = inttoptr i64 %2 to i64*
store i64 2187372084, i64* %3
!
PANDA_CB_INSN_TRANSLATE
Basic Block
PANDA_CB_AFTER_BLOCK_TRANSLATE
!
Basic Block
Translation Execution
PANDA_CB_BEFORE_BLOCK_TRANSLATE PANDA_CB_BEFORE_BLOCK_EXEC
LLVM IR PANDA_CB_AFTER_BLOCK_EXEC
!
%2 = add i64 %env_v, 128
%3 = inttoptr i64 %2 to i64*
store i64 2187372084, i64* %3
!
PANDA_CB_INSN_TRANSLATE
Basic Block
PANDA_CB_AFTER_BLOCK_TRANSLATE
PANDA_CB_VIRT_MEM_READ
PANDA_CB_VIRT_MEM_WRITE
PANDA_CB_PHYS_MEM_READ
PANDA_CB_PHYS_MEM_WRITE !
Basic Block
Translation Execution
PANDA_CB_BEFORE_BLOCK_TRANSLATE PANDA_CB_BEFORE_BLOCK_EXEC
LLVM IR PANDA_CB_AFTER_BLOCK_EXEC
!
%2 = add i64 %env_v, 128
%3 = inttoptr i64 %2 to i64*
store i64 2187372084, i64* %3
!
PANDA_CB_INSN_TRANSLATE
Basic Block
PANDA_CB_AFTER_BLOCK_TRANSLATE
PANDA_CB_VIRT_MEM_READ
PANDA_CB_VIRT_MEM_WRITE
PANDA_CB_PHYS_MEM_READ
PANDA_CB_PHYS_MEM_WRITE !
Basic Block
PANDA_CB_GUEST_HYPERCALL
And many more
x86_64-softmmu/qemu-system-x86_64 \
-replay sshb32 \
-panda-plugin panda_callstack_instr.so \
-panda-plugin panda_syscalls.so \
-panda-plugin panda_stringsearch.so \
-panda-plugin panda_tstringsearch.so \
-panda-plugin panda_taint.so
Five Plugins, One Replay
Keep track of calls/returns
x86_64-softmmu/qemu-system-x86_64 \
-replay sshb32 \
-panda-plugin panda_callstack_instr.so \
-panda-plugin panda_syscalls.so \
-panda-plugin panda_stringsearch.so \
-panda-plugin panda_tstringsearch.so \
-panda-plugin panda_taint.so
Five Plugins, One Replay
Track syscalls
x86_64-softmmu/qemu-system-x86_64 \
-replay sshb32 \
-panda-plugin panda_callstack_instr.so \
-panda-plugin panda_syscalls.so \
-panda-plugin panda_stringsearch.so \
-panda-plugin panda_tstringsearch.so \
-panda-plugin panda_taint.so
Five Plugins, One Replay
Find!
x86_64-softmmu/qemu-system-x86_64 passphrase \
-replay sshb32 \
-panda-plugin panda_callstack_instr.so \
-panda-plugin panda_syscalls.so \
-panda-plugin panda_stringsearch.so \
-panda-plugin panda_tstringsearch.so \
-panda-plugin panda_taint.so
Five Plugins, One Replay
x86_64-softmmu/qemu-system-x86_64 \
-replay sshb32 Enables taint! \
engine
-panda-plugin panda_callstack_instr.so \
-panda-plugin panda_syscalls.so \
-panda-plugin panda_stringsearch.so \
-panda-plugin panda_tstringsearch.so \
-panda-plugin panda_taint.so
Five Plugins, One Replay
x86_64-softmmu/qemu-system-x86_64 \
-replay sshb32 \
-panda-plugin panda_callstack_instr.so \
-panda-plugin panda_syscalls.so \
-panda-plugin panda_stringsearch.so \
-panda-plugin panda_tstringsearch.so \
-panda-plugin panda_taint.so
Mining Memory Accesses
Goal: Find places in system where data of
interest (e.g., ssh passphrase) is handled
More details: Tappan Zee (North) Bridge: Mining Memory Accesses for
Introspection. B. Dolan-Gavitt, T. Leek, J. Hodosh, W. Lee. ACM CCS. Berlin,
Germany, November 2013.
Sample Tap Points
Content
Tap Code
Read Write
! 00FFABED! 00646517 0064A423 Kernel! 0064A423 push ebx!
00123456! 00123456! 00646517 0064A424 Kernel! 0064A424 push [ebp+var_28]!
! 00ABCDEF! 00646517 0064A427 Kernel! 0064A427 push esi!
! 0064A42D! 00646517 0064A428 Kernel! 0064A428 call _memcpy!
! ! ! !
! ! ! _memcpy:!
! ! ! [...]!
! ! ! 00430E08 shr ecx, 2!
! ! ! 00430E0B and edx, 3!
! ! ! 00430E0E cmp ecx, 8!
! ! ! 00430E11 jb short loc_430E3C!
\Device\Harddisk! \Device\Harddisk! 0064A42D 00430E13 Kernel! 00430E13 rep movsd!
00430F3C 0064A42D 00430E15 Kernel 00430E15 jmp off_430F2C[edx*4]
Sample Tap Points
Content
Tap Code
Read Write
! 00FFABED! 00646517 0064A423 Kernel! 0064A423 push ebx!
00123456! 00123456! 00646517 0064A424 Kernel! 0064A424 push [ebp+var_28]!
! 00ABCDEF! 00646517 0064A427 Kernel! 0064A427 push esi!
! 0064A42D! 00646517 0064A428 Kernel! 0064A428 call _memcpy!
! ! ! !
! ! ! _memcpy:!
! ! ! [...]!
! ! ! 00430E08 shr ecx, 2!
! ! ! 00430E0B and edx, 3!
! ! ! 00430E0E cmp ecx, 8!
! ! ! 00430E11 jb short loc_430E3C!
\Device\Harddisk! \Device\Harddisk! 0064A42D 00430E13 Kernel! 00430E13 rep movsd!
00430F3C 0064A42D 00430E15 Kernel 00430E15 jmp off_430F2C[edx*4]
Sample Tap Points
Content
Tap Code
Read Write
! 00FFABED! 00646517 0064A423 Kernel! 0064A423 push ebx!
00123456! 00123456! 00646517 0064A424 Kernel! 0064A424 push [ebp+var_28]!
! 00ABCDEF! 00646517 0064A427 Kernel! 0064A427 push esi!
! 0064A42D! 00646517 0064A428 Kernel! 0064A428 call _memcpy!
! ! ! !
! ! ! _memcpy:!
! ! ! [...]!
! ! ! 00430E08 shr ecx, 2!
! ! ! 00430E0B and edx, 3!
! ! ! 00430E0E cmp ecx, 8!
! ! ! 00430E11 jb short loc_430E3C!
\Device\Harddisk! \Device\Harddisk! 0064A42D 00430E13 Kernel! 00430E13 rep movsd!
00430F3C 0064A42D 00430E15 Kernel 00430E15 jmp off_430F2C[edx*4]
Sample Tap Points
Content
Tap Code
Read Write
! 00FFABED! 00646517 0064A423 Kernel! 0064A423 push ebx!
00123456! 00123456! 00646517 0064A424 Kernel! 0064A424 push [ebp+var_28]!
! 00ABCDEF! 00646517 0064A427 Kernel! 0064A427 push esi!
! 0064A42D! 00646517 0064A428 Kernel! 0064A428 call _memcpy!
! ! ! !
! ! ! _memcpy:!
! ! ! [...]!
! ! ! 00430E08 shr ecx, 2!
! ! ! 00430E0B and edx, 3!
! ! ! 00430E0E cmp ecx, 8!
! ! ! 00430E11 jb short loc_430E3C!
\Device\Harddisk! \Device\Harddisk! 0064A42D 00430E13 Kernel! 00430E13 rep movsd!
00430F3C 0064A42D 00430E15 Kernel 00430E15 jmp off_430F2C[edx*4]
Sample Tap Points
Content
Tap Code
Read Write
! 00FFABED! 00646517 0064A423 Kernel! 0064A423 push ebx!
00123456! 00123456! 00646517 0064A424 Kernel! 0064A424 push [ebp+var_28]!
! 00ABCDEF! 00646517 0064A427 Kernel! 0064A427 push esi!
! 0064A42D! 00646517 0064A428 Kernel! 0064A428 call _memcpy!
! ! ! !
! ! ! _memcpy:!
! ! ! [...]!
! ! ! 00430E08 shr ecx, 2!
! ! ! 00430E0B and edx, 3!
! ! ! 00430E0E cmp ecx, 8!
! ! ! 00430E11 jb short loc_430E3C!
\Device\Harddisk! \Device\Harddisk! 0064A42D 00430E13 Kernel! 00430E13 rep movsd!
00430F3C 0064A42D 00430E15 Kernel 00430E15 jmp off_430F2C[edx*4]
Sample Tap Points
Content
Tap Code
Read Write
! 00FFABED! 00646517 0064A423 Kernel! 0064A423 push ebx!
00123456! 00123456! 00646517 0064A424 Kernel! 0064A424 push [ebp+var_28]!
! 00ABCDEF! 00646517 0064A427 Kernel! 0064A427 push esi!
! 0064A42D! 00646517 0064A428 Kernel! 0064A428 call _memcpy!
! ! ! !
! ! ! _memcpy:!
! ! ! [...]!
! ! ! 00430E08 shr ecx, 2!
! ! ! 00430E0B and edx, 3!
! ! ! 00430E0E cmp ecx, 8!
! ! ! 00430E11 jb short loc_430E3C!
\Device\Harddisk! \Device\Harddisk! 0064A42D 00430E13 Kernel! 00430E13 rep movsd!
00430F3C 0064A42D 00430E15 Kernel 00430E15 jmp off_430F2C[edx*4]
Sample Tap Points
Content
Tap Code
Read Write
! 00FFABED! 00646517 0064A423 Kernel! 0064A423 push ebx!
00123456! 00123456! 00646517 0064A424 Kernel! 0064A424 push [ebp+var_28]!
! 00ABCDEF! 00646517 0064A427 Kernel! 0064A427 push esi!
! 0064A42D! 00646517 0064A428 Kernel! 0064A428 call _memcpy!
! ! ! !
! ! ! _memcpy:!
! ! ! [...]!
! ! ! 00430E08 shr ecx, 2!
! ! ! 00430E0B and edx, 3!
! ! ! 00430E0E cmp ecx, 8!
! ! ! 00430E11 jb short loc_430E3C!
\Device\Harddisk! \Device\Harddisk! 0064A42D 00430E13 Kernel! 00430E13 rep movsd!
00430F3C 0064A42D 00430E15 Kernel 00430E15 jmp off_430F2C[edx*4]
Sample Tap Points
Content
Tap Code
Read Write
! 00FFABED! 00646517 0064A423 Kernel! 0064A423 push ebx!
00123456! 00123456! 00646517 0064A424 Kernel! 0064A424 push [ebp+var_28]!
! 00ABCDEF! 00646517 0064A427 Kernel! 0064A427 push esi!
! 0064A42D! 00646517 0064A428 Kernel! 0064A428 call _memcpy!
! ! ! !
! ! ! _memcpy:!
! ! ! [...]!
! ! ! 00430E08 shr ecx, 2!
! ! ! 00430E0B and edx, 3!
! ! ! 00430E0E cmp ecx, 8!
! ! ! 00430E11 jb short loc_430E3C!
\Device\Harddisk! \Device\Harddisk! 0064A42D 00430E13 Kernel! 00430E13 rep movsd!
00430F3C 0064A42D 00430E15 Kernel 00430E15 jmp off_430F2C[edx*4]
Sample Tap Points
Content
Tap Code
Read Write
! 00FFABED! 00646517 0064A423 Kernel! 0064A423 push ebx!
00123456! 00123456! 00646517 0064A424 Kernel! 0064A424 push [ebp+var_28]!
! 00ABCDEF! 00646517 0064A427 Kernel! 0064A427 push esi!
! 0064A42D! 00646517 0064A428 Kernel! 0064A428 call _memcpy!
! ! ! !
! ! ! _memcpy:!
! ! ! [...]!
! ! ! 00430E08 shr ecx, 2!
! ! ! 00430E0B and edx, 3!
! ! ! 00430E0E cmp ecx, 8!
! ! ! 00430E11 jb short loc_430E3C!
\Device\Harddisk! \Device\Harddisk! 0064A42D 00430E13 Kernel! 00430E13 rep movsd!
00430F3C 0064A42D 00430E15 Kernel 00430E15 jmp off_430F2C[edx*4]
Sample Tap Points
Content
Tap Code
Read Write
! 00FFABED! 00646517 0064A423 Kernel! 0064A423 push ebx!
00123456! 00123456! 00646517 0064A424 Kernel! 0064A424 push [ebp+var_28]!
! 00ABCDEF! 00646517 0064A427 Kernel! 0064A427 push esi!
! 0064A42D! 00646517 0064A428 Kernel! 0064A428 call _memcpy!
! ! ! !
! ! ! _memcpy:!
! ! ! [...]!
! ! ! 00430E08 shr ecx, 2!
! ! ! 00430E0B and edx, 3!
! ! ! 00430E0E cmp ecx, 8!
! ! ! 00430E11 jb short loc_430E3C!
\Device\Harddisk! \Device\Harddisk! 0064A42D 00430E13 Kernel! 00430E13 rep movsd!
00430F3C 0064A42D 00430E15 Kernel 00430E15 jmp off_430F2C[edx*4]
TZB Implementation
Track calling context with callstack_instr plugin
Native Code
LLVM IR
! Dynamic
%2 = add i64 %env_v, 128
%3 = inttoptr i64 %2 to i64* Values
store i64 2187372084, i64* %3
LLVM IR
!
%2 = add i64 %env_v, 128
%3 = inttoptr i64 %2 to i64*
store i64 2187372084, i64* %3
Taint
[emit taint operations] Processor
DEMO:
ssh-keygen backdoor
Breaking Spotify DRM
DRM has a strong signature
Contribute code:
https://github.com/moyix/panda