Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # [Sample Information]
- # source : blog.alyac.co.kr/2086?category=957259 (일요일 수행된 APT 변종 공격, 오퍼레이션 페이크 캡슐(Operation Fake Capsule) 주의
- # hash(md5) : d64e4acd81152d90f0ac28db49ab290a
- # 리소스 영역 내부에 존재하는 DLL 파일에서 사용하는 인코딩을 IDAPython을 이용해 풀어보기
- import idautils
- import idaapi
- import idc
- encoded_func = 0x10001010
- def decode(str_):
- en_array = map(ord, str_)
- result = len(str_)
- count = 0
- if result > 0:
- if result > 0x40:
- pass
- else:
- if count < result:
- while(result > 0):
- en_array[count] -= 3
- result-=1
- count+=1
- return "".join(map(chr, en_array))
- def get_string(addr):
- out = ""
- while True:
- if Byte(addr) != 0:
- out += chr(Byte(addr))
- else:
- break
- addr += 1
- return out
- def find_function_arg(addr):
- while True:
- addr = idc.PrevHead(addr)
- if GetMnem(addr) == "mov" and "ecx" in GetOpnd(addr, 0):
- return GetOperandValue(addr, 1)
- return False
- for addr in XrefsTo(encoded_func, flags=0):
- ret_ffa = find_function_arg(addr.frm)
- if ret_ffa != False:
- string = get_string(ret_ffa)
- print "Ref Addr: 0x%x | Decoded: %s" % (addr.frm, decode(string))
Advertisement
Add Comment
Please, Sign In to add comment