파이썬
cuckoo api를 활용해 프로세스 실행
삼전동해커
2022. 4. 10. 21:19
cuckoo sandbox를 활용해 멀웨어 분석에 필요한 프로세스를 실행해야 한다. 이를 위한 패키지를 만들어봤다.
먼저 cuckoo github의 다음 경로의 process를 주로 활용한다.
https://github.com/cuckoosandbox/cuckoo/tree/master/cuckoo/data/analyzer/windows/lib/api
GitHub - cuckoosandbox/cuckoo: Cuckoo Sandbox is an automated dynamic malware analysis system
Cuckoo Sandbox is an automated dynamic malware analysis system - GitHub - cuckoosandbox/cuckoo: Cuckoo Sandbox is an automated dynamic malware analysis system
github.com
from lib.api.process import Process
from lib.common.exceptions import CuckooPackageError
from lib.common.abstracts import Package
import os
class Pin(Package):
def start(self):
raise NotImplementedError
def check(self):
return True
def start(self,path):
p = Process() #__init__으로 pid 생성
print(p.pid)
pin = os.path.join("pin 프로그램 경로","pin.exe") #pin을 실행시키기위한 경로 설정
dll = os.path.join("dll 경로","getop_li.dll") #pin에서 사용할 dll의 경로 설정
root = "Z:\\" #결과를 저장하기 위해 공유폴더 root 설정
filename = path.strip(".exe_") #멀웨어 이름에서 .exe_를 제거
filename = filename + ".out" #멀웨어 opcode를 저장하기 위한 텍스트 파일 설정
out = os.path.join(root,filename) #out 파일 경로 설정
argv = "-t %s -o %s -- %s" % (dll,out,path) #pin 실행 옵션들 설정
if not p.execute(path=pin,args=argv):
raise CuckooPackageError(
"Unable to execute pin."
)
return p.pid