Reveal API Redirect on Themida
PyCommand 디렉토리 아래에 스크립트 파일을 저장한 후, eip가 call 문에 있을 때 커맨드라인에서 다음과 같이 입력하면 실행이 됩니다.
!revealapi
이 스크립트는 call 문을 직접 실행하지 않고 Themida에서 리다이렉트된 API를 찾아서 comment로 알려줍니다. 스크립트가 완성된 게 아니라서 70%의 정확도를 가집니다.
revealapi.py
# -*- coding:utf-8 -*-
'''
* =====================================================================================
*
* Filename: revealapi.py
*
* Description: The script to reveal the redirected Windows API in the Themida.
*
* Version: 1.0
* Created: 2010.09.12. 15:58:44
* Revision: none
* Compiler: Python
*
* Author: Yeonjae Kim (https://hisjournal.net/blog), 6l4ck3y3 (at) gmail.com
* Company: CERT-IS (http://www.cert-is.com)
*
* =====================================================================================
'''
from immlib import *
def main (args):
imm = Debugger ()
eip = orig_eip = imm.getRegs ()['EIP']
if not imm.Disasm (eip).isCall ():
return "Call instruction is NOT here."
imm.Log ("", 0)
imm.Log ("", 0)
imm.Log ("==================================================================", 0)
imm.Log ("", 0)
imm.Log ("[+] Revealing the redirected Windows API of %08X" % orig_eip, 0, True)
imm.Log ("[+] This script was written by 6l4ck3y3 (@6l4ck3y3)", 0, True)
imm.Log ("", 0)
imm.Log ("==================================================================", 0)
imm.Log ("", 0)
limit = 1000
while (eip < 0x10000000 and limit):
try:
opcode = imm.Disasm (eip)
except:
imm.Log ("[*] %s" % opcode.getDisasm (), eip)
return "What is hidden? Go into."
if (opcode.isJmp () or opcode.isConditionalJmp () or opcode.isCall ()):
eip = opcode.getJmpAddr ()
elif opcode.isRet ():
return "API was NOT found. Maybe here is a local func."
else:
imm.Log ("[*] %s" % opcode.getDisasm (), eip)
eip = eip + int (opcode.getSize ())
limit = limit - 1
if not limit:
return "API was NOT found"
msg = "".join (["%s " % m for m in opcode.getDisasm ().split (' ')[1:]])
imm.Log ("[*] %s" % msg, eip)
imm.setComment (orig_eip, "%s" % msg)
return "%s was FOUND." % msg
하하하… 파이썬 금방 배웁니다. 쉬워요.. ^^;
python 잘쓰시는분들 보면 참 부러워요. (특히 immunitydbg가 제공하는 정보 잘쓰시는분들..ㅋㅋ)