반응형

x64dbg에서 Conditional Breakpoint나 Trace into/over 사용 시 작성하게 되는 Break Condition, Log Condition 에 대해 알아보자.

 

Conditional Breakpoint

Break Condition을 평가해서 True(1이나 0이 아닌 값)인 경우 break 한다. 기본값은 1(True)이다.

Log Condition을 평가해서 True(1이나 0이 아닌 값)인 경우 Log Text를 기록한다. 기본값은 1(True)이다.

Break 시 마다 Hit Count가 증가한다.

 

예)
절대 break하지 않는 Conditional Break. (디버거를 멈추지 않고 명령만 실행하거나 로그를 남기고 싶을때 유용)
break condition: 0

EAX와 ECX가 모두 1일 경우 break.
break condition: EAX==1 && ECX==1

첫 번째 매개변수가 1일 경우 break.
break condition: arg.get(0)==1

EAX가 유효한 주소값을 가질 경우 break.
break condition: mem.valid(EAX)

Break Point를 세 번째 만나면 break.
break condition: $breakpointcounter==3 or ($breakpointcounter%3)==0

ECX 값 위치의 utf-16 문자열이 "foo"를 포함하면 break.
break condition: strstr(utf16(ECX), "foo")

 

Trace over

Break Condition을 평가해서 True(1이나 0이 아닌 값)인 경우 break 한다. 기본값은 0(False)이다.
Log Condition을 평가해서 True(1이나 0이 아닌 값)인 경우 Log Text를 기록한다. 기본값은 1(True)이다.

Maximum trace count에 trace 할 최대 값을 지정할 수 있다.
Record trace를 선택하면 trace 내용이 파일에 기록되고 Trace 탭에서 확인 할 수 있다.

 

모든 숫자는 기본적으로 16진수로 인식된다. 10진수를 사용하고 싶다면 .123 처럼 숫자 앞에 . (dot) 을 사용한다.

예) .10 == a, .16 == 10, .18 == 12

 

Trace into/over는 step into/over를 Maximum trace count에 지정된 숫자만큼 자동으로 진행하는 것이다. 예를 들어 Log Text에 eax: {eax}를 입력하고 Maximum trace count에 2를 입력한 후 OK를 클릭하면 Log 창에 아래와 같은 기록이 남는다.

eax: 4E292C
eax: 22B1010
Trace finished after 2 steps!

 

Expressions

+, -, *, /, %, ~, >, <, =, ==, !=, ^, &, >>, <<, &&, || 등 대부분의 C 언어와 같은 문법으로 표현 가능하다. Help - Calculator 나 하단의 Command 창에서 연습해 볼 수 있다.

숫자, 변수, 레지스터(eax, ebx 등), 플래그(_zf = Zero Flag), 메모리 값(n:[00401238] = 00401238위치에서 n바이트를 읽어온다: n은 32비트에서 4, 64비트에서 8을 넘을 수 없다), 레이블/심볼 등이 표현에 사용 될 수 있다.

String Format

x64dbg에서 사용하는 기본적인 문자열 포맷은 {?:expression}이다. ?는 옵션이며 아래와 같은 type이 들어갈 수 있다.

기본 타입
d: signed decimal: -3
u: unsigned decimal: 57329171
p: zero prefixed pointer: 0000000410007683
s: string pointer (not recommended, use {utf8@address} instead)
x: hex: 3C28A (default for integer values)
a: address info: 00401010 <module.EntryPoint>
i: instruction text: jmp 0x77ac3c87

복합 타입
{ascii[;length]@address} will print the ASCII string at address with an optional length (in bytes).
{ansi[;length]@address} will print the ANSI (local codepage) string at address with an optional length (in bytes).
{utf8[;length]@address} will print the UTF-8 string at address with an optional length (in bytes).
{utf16[;length]@address} will print the UTF-16 string at address with an optional length (in words).
{disasm@address} will print the disassembly at address (equivalent to {i:address}).

예)
eax: {eax} => eax: 4C76
string: {utf16@4092a0} => string: Hello World!
password: {utf16@4*ecx+0x402000} => password: s3cret
return address: {a:[esp]} => return address: 6828371A

 

반응형
Posted by J-sean
: