當前位置: 首頁>>代碼示例>>Python>>正文


Python idaapi.set_processor_type方法代碼示例

本文整理匯總了Python中idaapi.set_processor_type方法的典型用法代碼示例。如果您正苦於以下問題:Python idaapi.set_processor_type方法的具體用法?Python idaapi.set_processor_type怎麽用?Python idaapi.set_processor_type使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在idaapi的用法示例。


在下文中一共展示了idaapi.set_processor_type方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: load_file

# 需要導入模塊: import idaapi [as 別名]
# 或者: from idaapi import set_processor_type [as 別名]
def load_file(li, neflags, format):
    
    # Select the PC processor module
    idaapi.set_processor_type("EVM", SETPROC_ALL|SETPROC_FATAL)
    
    # TODO: detect and emulate contract creation code
    li.seek(0)
    buf = li.read(li.size())
    if not buf:
        return 0

    if buf[0:2] == '0x':
        print "Detected hex"
        new_buf = buf[2:].strip().rstrip()
        buf_set = set()
        for c in new_buf:
            buf_set.update(c)
        hex_set = set(list('0123456789abcdef'))
        if buf_set <= hex_set: # subset
            print "Replacing original buffer with hex decoded version"
            buf = new_buf.decode('hex')

    # Load all shellcode into different segments
    start = 0x0
    seg = idaapi.segment_t()
    size = len(buf)
    end  = start + size
    
    # Create the segment
    seg.startEA = start
    seg.endEA   = end
    seg.bitness = 1 # 32-bit
    idaapi.add_segm_ex(seg, "evm", "CODE", 0)

    # TODO: make segments for stack, memory, storage

    # Copy the bytes
    idaapi.mem2base(buf, start, end)


    # check for swarm hash and make it data instead of code
    swarm_hash_address = buf.find('ebzzr0')
    if swarm_hash_address != -1:
        print "Swarm hash detected, making it data"
        for i in range(swarm_hash_address-1, swarm_hash_address+42):
            MakeByte(i)
        ida_bytes.set_cmt(swarm_hash_address-1, "swarm hash", True)
    # add entry point
    idaapi.add_entry(start, start, "start", 1) 

    # add comment to beginning of disassembly
    idaapi.describe(start, True, "EVM bytecode disassembly")

    # Mark for analysis
    AutoMark(start, AU_CODE)

    #setup_enums()
    return 1 
開發者ID:crytic,項目名稱:ida-evm,代碼行數:60,代碼來源:evm-loader.py

示例2: load_file

# 需要導入模塊: import idaapi [as 別名]
# 或者: from idaapi import set_processor_type [as 別名]
def load_file(f, neflags, format):
	f.seek(0)
	
	magic 		 	= f.read(4);
	version 	 	= struct.unpack("<I", f.read(4))[0];
	flags 		 	= struct.unpack("<I", f.read(4))[0];
	memType 	 	= struct.unpack("<I", f.read(4))[0];
	serviceType  	= struct.unpack("<I", f.read(4))[0];
	numInstances 	= struct.unpack("<I", f.read(4))[0];
	uuid 		 	= struct.unpack("<IIII", f.read(16));
	driverId 	 	= struct.unpack("<I", f.read(4))[0];
	numThreads 	 	= struct.unpack("<I", f.read(4))[0];
	textVA  	 	= struct.unpack("<I", f.read(4))[0];
	textLen 	 	= struct.unpack("<I", f.read(4))[0];
	dataVA  	 	= struct.unpack("<I", f.read(4))[0];
	dataLen 	 	= struct.unpack("<I", f.read(4))[0];
	bssLen 	 	 	= struct.unpack("<I", f.read(4))[0];
	entry 	 	 	= struct.unpack("<I", f.read(4))[0];

	f.seek(MCLF_TEXT_INFO_OFFSET)
	
	idaapi.set_processor_type("arm", ida_idp.SETPROC_LOADER)

	# Set VA for .text and add the segment
	f.file2base(0, textVA, textVA + textLen, True)
	idaapi.add_segm(0, textVA, textVA + textLen, ".text", "CODE")

	# Set VA for .data and add the segment
	f.file2base(textLen, dataVA, dataVA + dataLen, True)
	idaapi.add_segm(0, dataVA, dataVA + dataLen, ".data", "DATA")
	
	# Add BSS segment after .text and .data
	idaapi.add_segm(0, dataVA + dataLen, dataVA + dataLen + bssLen, ".bss", "BSS")

	if entry % 4 == 1: 
		#Thumb address is always +1 to set the T bit
		idaapi.add_entry(entry-1, entry-1, "_entry", 1)
		split_sreg_range(entry-1, "T", 0x1, ida_segregs.SR_user)
	else:
		idaapi.add_entry(entry, entry, "_entry", 1)
		split_sreg_range(entry, "T", 0x0, ida_segregs.SR_user)

	ida_bytes.create_data(tlApiLibEntry, FF_DWORD, 4, ida_idaapi.BADADDR)
	set_name(tlApiLibEntry,"tlApiLibEntry", SN_CHECK)
	return 1 
開發者ID:ghassani,項目名稱:mclf-ida-loader,代碼行數:47,代碼來源:mclf_loader.py

示例3: load_file

# 需要導入模塊: import idaapi [as 別名]
# 或者: from idaapi import set_processor_type [as 別名]
def load_file(f, neflags, format):
	f.seek(0)
	
	magic 		 	= f.read(4);
	version 	 	= struct.unpack("<I", f.read(4))[0];
	flags 		 	= struct.unpack("<I", f.read(4))[0];
	memType 	 	= struct.unpack("<I", f.read(4))[0];
	serviceType  	= struct.unpack("<I", f.read(4))[0];
	numInstances 	= struct.unpack("<I", f.read(4))[0];
	uuid 		 	= struct.unpack("<IIII", f.read(16));
	driverId 	 	= struct.unpack("<I", f.read(4))[0];
	numThreads 	 	= struct.unpack("<I", f.read(4))[0];
	textVA  	 	= struct.unpack("<I", f.read(4))[0];
	textLen 	 	= struct.unpack("<I", f.read(4))[0];
	dataVA  	 	= struct.unpack("<I", f.read(4))[0];
	dataLen 	 	= struct.unpack("<I", f.read(4))[0];
	bssLen 	 	 	= struct.unpack("<I", f.read(4))[0];
	entry 	 	 	= struct.unpack("<I", f.read(4))[0];

	f.seek(MCLF_TEXT_INFO_OFFSET)
	
	idaapi.set_processor_type("arm", SETPROC_ALL)

	# Set VA for .text and add the segment
	f.file2base(0, textVA, textVA + textLen, True)
	idaapi.add_segm(0, textVA, textVA + textLen, ".text", "CODE")

	# Set VA for .data and add the segment
	f.file2base(textLen, dataVA, dataVA + dataLen, True)
	idaapi.add_segm(0, dataVA, dataVA + dataLen, ".data", "DATA")
	
	# Add BSS segment after .text and .data
	idaapi.add_segm(0, dataVA + dataLen, dataVA + dataLen + bssLen, ".bss", "BSS")

	if entry % 4 == 1: 
		#Thumb address is always +1 to set the T bit
		idaapi.add_entry(entry-1, entry-1, "_entry", 1)
		SetRegEx(entry-1, "T", 0x1, SR_user);
	else:
		idaapi.add_entry(entry, entry, "_entry", 1)
		SetRegEx(entry, "T", 0x0, SR_user);

	MakeDword(tlApiLibEntry)
	MakeName(tlApiLibEntry,"tlApiLibEntry");
	return 1 
開發者ID:bkerler,項目名稱:tee_research,代碼行數:47,代碼來源:mclf_loader.py


注:本文中的idaapi.set_processor_type方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。