本文整理汇总了Python中ptypes.setsource函数的典型用法代码示例。如果您正苦于以下问题:Python setsource函数的具体用法?Python setsource怎么用?Python setsource使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setsource函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_abc
def test_abc():
data = '\xbf\x14\xe5\x03\x00\x00\x01\x00\x00\x00\x00\x10\x00.\x00\x00\x00\x00"\x00\x04void\x07mx.core\nIFlexAsset\x0eByteArrayAsset\x0bflash.utils\tByteArray\x16mx.core:ByteArrayAsset\x08test_fla\x1aMainTimeline_Testinputsets#test_fla:MainTimeline_Testinputsets\x0cMainTimeline\rflash.display\tMovieClip\x15test_fla:MainTimeline\rTestinputsets\x05Class\x07loadres\x06frame1*http://www.adobe.com/2006/flex/mx/internal\x07VERSION\x06String\x073.0.0.0\x0bmx_internal\x06Object\tshareable\x0eaddFrameScript\x0cflash.events\x0fEventDispatcher\rDisplayObject\x11InteractiveObject\x16DisplayObjectContainer\x06Sprite\x0c\x16\x01\x16\x03\x16\x06\x18\x08\x16\t\x18\x0b\x16\r\x18\x0f\x17\t\x08\x14\x16\x1c\x03\x01\x02\x01\x05\x1a\x07\x01\x02\x07\x02\x04\x07\x02\x05\x07\x03\x07\t\x04\x01\x07\x05\n\x07\x05\x0c\x07\x07\x0e\x07\x01\x10\x07\x01\x11\x07\x01\x12\x07\t\x13\x07\n\x15\x07\x01\x16\x07\x02\x18\t\x05\x01\x07\x01\x19\t\n\x02\x07\x01\x1a\x07\x01\x1b\x07\x0b\x1d\x07\x07\x1e\x07\x07\x1f\x07\x07 \x07\x07!\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x02\x00\x05\x00\x02\x00\x03\x04\t\x04\x01\x05\x05\x00\x06\x03\t\x06\x00\x08\x00\x07\x08\x08\x08\x00\r\x03\t\x00\x00\n\x00\x0b\x01\x00\x0b\x0c\x01\x00\x0c\x01\x00\x04\x01\r\x06\x01\x0e\x17\x01\x07\x00\n\x00\x05\x00\x01\x0f\x06\x00\x00\n\x08\x03\x01\x02\x04\x00\x00\x06\x01\x03\x04\x00\x01\t\x01\x06\x04\x00\x02\x0e\x01\x07\x04\x01\x03\x0e\x00\x01\x01\x01\x02\x03\xd00G\x00\x00\x01\x00\x01\x03\x03\x01G\x00\x00\x03\x02\x01\x01\x02\n\xd00]\x05 X\x00h\x02G\x00\x00\x04\x02\x01\x04\x05\t\xd00^\r,\x17h\rG\x00\x00\x05\x01\x01\x05\x06\x06\xd00\xd0I\x00G\x00\x00\x06\x02\x01\x01\x04\x13\xd00]\x10`\x110`\x040`\x04X\x01\x1d\x1dh\x03G\x00\x00\x07\x01\x01\x05\x06\x03\xd00G\x00\x00\x08\x01\x01\x06\x07\x06\xd00\xd0I\x00G\x00\x00\t\x02\x01\x01\x05\x17\xd00]\x12`\x110`\x040`\x030`\x03X\x02\x1d\x1d\x1dh\x06G\x00\x00\n\x01\x01\t\n\x03\xd00G\x00\x00\x0b\x02\x02\n\x0b\x0e\xd00\xd0J\t\x00\x80\x04\xd5\xd1&a\x13G\x00\x00\x0c\x01\x01\n\x0b\x07\xd00\xd0O\x0b\x00G\x00\x00\r\x03\x01\n\x0b\x15\xd00\xd0`\x06h\t\xd0I\x00]\x14$\x00\xd0f\x0cO\x14\x02G\x00\x00\x0e\x02\x01\x01\t\'\xd00e\x00`\x110`\x150`\x160`\x170`\x180`\x190`\x080`\x08X\x03\x1d\x1d\x1d\x1d\x1d\x1d\x1dh\x07G\x00\x00'
ptypes.setsource( prov.string(data) )
a = tags.Tag()
a = a.l
print a['data']['ABCData']
示例2: test_DefineShape_load
def test_DefineShape_load():
s = '\xbf\x00$\x00\x00\x00\x01\x00`\x002\x00\x00\r\xc0\x01\x00\xff\xff\xff\x01\x01\x00\x00\x00\x00\x115\x8c\x807\x1fD\xe0p\xc9\x1d\x0c\x81\xc2\xdc\x00'
ptypes.setsource( prov.string(s) )
a = tags.Tag()
a = a.l
b = a['data']
print b
print b['shapeid']
print b['shapebounds']
print b['shapes']
示例3: test_SHAPEWITHSTYLE_load
def test_SHAPEWITHSTYLE_load():
global a
s = '\x01\x00\xff\xff\xff\x01\x01\x00\x00\x00\x00\x115\x8c\x807\x1fD\xe0p\xc9\x1d\x0c\x81\xc2\xdc\x00'
print repr(s[0xc:])
ptypes.setsource( prov.string(s) )
a = stypes.SHAPEWITHSTYLE()
a = a.l
print a.v
#print a['fillstyles']['fillstyles'][0]
#print a['linestyles']['linestyles'][0]
#print a['numbits']
print a['ShapeRecords'][0]
print a['shaperecords']
print a['shaperecords'][0]
print a['shaperecords'][0]['Shape']
示例4:
if __name__ == '__main__':
import ptypes,pecoff
from ptypes import *
ptypes.setsource(ptypes.file('./chewbacca.exe.infected'))
a = pecoff.Executable.File()
a=a.l
b = a['next']['header']
#print b['header']
c = b['FileHeader']['pointertosymboltable'].d
c = c.l
print c['Symbols'][1]
print c['Symbols'][1].details()
print c['Symbols']
print c.names()
print c.walk().next()
print c.getSymbol('_main')
print c.getAuxiliary('_main')
print c.fetch('_main')
示例5: DpxMainHeader
(float, 'white_level'),
(float, 'integration_times'),
(dyn.block(76), 'reserved'),
]
class DpxMainHeader(pstruct.type):
_fields_ = [
(DpxFileHeader, 'fileHeader'),
(DpxImageHeader, 'imageHeader'),
(DpxOrientationHeader, 'orientationHeader'),
(DpxFilmHeader, 'filmHeader'),
(DpxTelevisionHeader, 'televisionHeader'),
]
class File(pstruct.type):
_fields_ = [
(DpxMainHeader, 'header'),
]
if __name__ == '__main__':
import sys
import ptypes, image.dpx
if len(sys.argv) != 2:
print "Usage: {:s} file".format(sys.argv[0] if len(sys.argv) else __file__)
sys.exit(0)
ptypes.setsource(ptypes.prov.file(sys.argv[1]))
a = image.dpx.File()
a = a.l
示例6: section_entry_extension
class section_entry_extension(pstruct.type):
class __field(pbinary.struct):
_fields_ = [(4,'unused'),(1,'record_follows'),(2,'unused2'),(1,'wtf')]
_fields_ = [
(uchar, 'indicator'),
(uchar, 'field'),
(dyn.block(30), 'vendor_criteria'),
]
if __name__ == '__main__':
import ptypes,iso9660
reload(iso9660)
reload(ptypes.provider)
ptypes.setsource(ptypes.provider.WindowsFile('~/downloads/6euj41uc.iso', 'r'))
z = iso9660.File()
z = z.l
boot_sector = z['desc'][1]['data']['boot_catalog']
if False:
a = iso9660.sector(offset=boot_sector*2048).l
print a.cast(iso9660.section_validation_entry)
# print z['iso']
# print [x for x in z['unused'] if not x.is_empty()]
# date = z['primary']['root_directory_record']['date']
# print date
# print date['year'].summary()
a = z['desc'][1]['data']['boot_catalog']
print a.cast(iso9660.sectorpointer)
示例7:
(_row(method_info, 'method_count'), 'method'),
(u30, 'metadata_count'),
(_row(metadata_info, 'metadata_count'), 'metadata'),
(u30, 'class_count'),
(_row(instance_info, 'class_count'), 'instance'),
(_row(class_info, 'class_count'), 'class'),
(u30, 'script_count'),
(_row(script_info, 'script_count'), 'script'),
(u30, 'method_body_count'),
(_row(method_body_info, 'method_body_count'), 'method_body'),
]
if __name__ == '__main__':
import ptypes,as3,stypes
from ptypes import *
ptypes.setsource(prov.file('./tag-abcfile.bin','r'))
#0000000: 0100 0000 0010 002e 00
#0000000 00 0000 2200 0476 ............"..v
b = as3.abcFile(offset=5)
b=b.l
# print b['minor_version'].l
# print b['major_version'].l
# c = b['constant_pool'].l
# print c.keys()
# for k,v in c.items():
# print k
# print v
# print c
示例8: File
(UINT32, 'packet_count_for_this_packet'),
]
###
class File(parray.terminated):
_object_ = RealMedia_Header
def isTerminator(self, value):
l = len(self.value)
if l > 0:
return l > self.value[0]['object']['num_headers'].int() + 1
return False
if __name__ == '__main__':
import sys
import ptypes,rmff
ptypes.setsource( ptypes.file(sys.argv[1], mode='rb') )
self = rmff.File()
z = self.l
print len(self.value)
# offset = 0x16f
# print self.at(offset)
# typespecific = self[3]['object']['type_specific_data']
mdpr = [x for x in self.traverse(filter=lambda x: type(x) == rmff.RealMedia_Header) if x['object_id'].serialize() == 'MDPR']
for x in mdpr:
print x.__name__, x['object']['mime_type']
示例9: pieces
import sys, user
import ptypes,pecoff
ptypes.setsource(ptypes.prov.file(sys.argv[1], mode='r'))
z=pecoff.Executable.File()
print >>sys.stdout, 'Filename: {:s}\n'.format(z.source.file.name)
z=z.l
p = z['next']['header']
#lc = p['datadirectory']['loadconfig']['address'].d.li
dn = p['datadirectory']['clr']['address'].d.li
#dnv = dn['vtablefixups']['address'].d.li
dnm = dn['metadata']['address'].d.li
root = dnm['StreamHeaders'].Get('#~')['Offset'].d
root = root.l
print >>sys.stderr, 'Loading strings...'
names = dnm['StreamHeaders'].Get('#Strings')['Offset'].d.l
print >>sys.stderr, 'Loading blobs...'
blobs = dnm['StreamHeaders'].Get('#Blob')['Offset'].d.l
class pieces(ptypes.pbinary.struct):
_fields_ = [
(8, 'table'),
(24, 'index'),
]
e = dn['EntryPoint'].cast(pieces)
if e['table'] != pecoff.portable.clr.TMethodDef.type:
print >>sys.stderr, 'No CLR entrypoint found!'
示例10: ImageData_Chunk
class ImageData_Chunk(pstruct.type):
_fields_ = [
(pint.uint8_t, 'Block Size'),
(lambda s: dyn.block(int(s['Block Size'].li)), 'Data Values')
]
class ImageData( parray.type ):
length = 1
_object_ = ImageData_Chunk
def isTerminator(self, v):
if int(v['Block Size']) == 0:
return True
return False
class File(pstruct.type):
_fields_ = [
(Header, 'header'),
(LogicalScreenDescriptor, 'screen'),
(ImageDescriptor, 'image'),
(ImageData, 'data')
]
if __name__ == '__main__':
import ptypes,gif
reload(gif)
ptypes.setsource( ptypes.provider.file('./poc.gif') )
z = gif.File()
print z.l
示例11: min
sig = header['Signature'].str()
# if it's compressed then use the 'zlib' structure
t = EncodedDataType.withdefault(sig, type=sig)
length = min(header['FileLength'].int(), self.source.size()) - header.size()
return dyn.clone(t, _value_=dyn.clone(t._value_, length=length))
_fields_ = [
(Header, 'header'),
(__data, 'data')
]
if __name__ == '__main__':
import sys
import ptypes,__init__ as swf
ptypes.setsource(ptypes.file('./test.swf', mode='r'))
z = File
# z = ptypes.debugrecurse(z)
z = z()
z = z.l
for x in z['data']['tags']:
print '-'*32
print x
a = z['data']['tags'][0]
print a.hexdump()
print a.li.hexdump()
print repr(a.l['Header'].serialize())
correct='\x44\x11\x08\x00\x00\x00'
示例12: int
_fields_ = [
(dyn.block(4), 'SettingSig'),
(uInt32Number, 'SettingSize'),
(verify_bitsize(uInt32Number, 8), 'numSettings'),
(lambda s: dyn.array(uInt32Number, int(s['numSettings'].li)), 'Setting')
]
class TextDescStruct(pstruct.type, TagStruct):
signature = 'desc'
_fields_ = [
(pstr.szstring, 'IsoStr'),
(uInt32Number, 'UniLangCode'),
(pstr.szwstring, 'UniStr'),
(uInt16Number, 'MacScriptCode'),
(uInt8Number, 'MacCount'),
(dyn.clone(pstr.string, length=67), 'MacStr')
]
if __name__ == '__main__':
import ptypes
from ptypes import *
ptypes.setsource( provider.file('./poc.pf') )
self = ProfileFile()
# print self.l
self.l
z = ptype.debugrecurse(DevStruct)()
z.setoffset(self['tags'][0]['offset'].__int__())
示例13: USER
class USER(ptype.block): type = 0x0007
@Viewport.define
class CAMERA(ptype.block): type = 0x0008
@Viewport.define
class LIGHT(ptype.block): type = 0x0009
@Viewport.define
class DISABLED(ptype.block): type = 0x0010
@Viewport.define
class BOGUS(ptype.block): type = 0x0011
## File chunk
class File(Chunk): pass
if __name__ == '__main__':
import ptypes, max
ptypes.setsource(ptypes.prov.file('./samples/3ds/boletus.3ds', mode='rb'))
z = max.File()
z=z.l
print z['data']
print z['data'][1]['data'][0]['data']
print z['data'][1]['data'][1]
print z['data'][1]['data'][2]['data'][0]['data']
print z['data'][1]['data'][3]['data']['chunk']['data'][0]['data'] # TRI_VERTEXL
print z['data'][1]['data'][3]['data']['chunk']['data'][1]['data'] # TRI_LOCAL
print z['data'][1]['data'][3]['data']['chunk']['data'][2]['data'] # TRI_MAPPINGCOORS
print z['data'][1]['data'][3]['data']['chunk']['data'][3]
print z['data'][1]['data'][3]['data']['chunk']['data'][3]['data']
print z['data'][1]['data'][3]['data']['chunk']['data'][3]['data']['face']
print z['data'][1]['data'][3]['data']['chunk']['data'][3]['data']['facedata'][0]['data']['face']
print z['data'][1]['data'][3]['data']['chunk']['data'][3]['data']['facedata'][1]['data']
示例14: File
_fields_ = [
(Signature, 'signature'),
(Attributes, 'attributes'),
(__extended, 'extended'),
(__padding_header, 'padding'),
]
class File(pstruct.type):
def __data(self):
res = self['header'].li
return dyn.block(res['attributes']['compressed-size'].int())
_fields_ = [
(Header, 'header'),
(__data, 'data'),
]
if __name__ == '__main__':
import ptypes, archive.lha
reload(archive.lha)
ptypes.setsource(ptypes.prov.file('c:/users/user/Downloads/fcgb2.lzh', mode='r'))
z = archive.lha.File()
z = z.l
print z.source.size()
print z['header']['signature']
print z['header']['attributes']
print z['header']
print z['header']['filename']
示例15: ProcessBasicInformation
('UniqueProcessId', ctypes.c_uint32),
('Reserved3', ctypes.c_uint32)]
pbi = ProcessBasicInformation()
res = nt.NtQueryInformationProcess(handle, 0, ctypes.byref(pbi), ctypes.sizeof(pbi), None)
return pbi
# grab process handle
if len(sys.argv) > 1:
pid = int(sys.argv[1])
print 'opening process %d'% pid
handle = openprocess(pid)
else:
handle = getcurrentprocess()
print 'using current process'
ptypes.setsource(ptypes.provider.WindowsProcessHandle(handle))
# grab peb
import ndk
pebaddress = getPBIObj(handle).PebBaseAddress
z = ndk.PEB(offset=pebaddress).l
# grab heap
if len(sys.argv) > 2:
heaphandle = eval(sys.argv[2])
for x in z['ProcessHeaps'].d.l:
print hex(x.int()),hex(heaphandle)
if x.int() == heaphandle:
b = x
break
continue