Cатсн²² (in)sесuяitу / ChrisJohnRiley

Because we're damned if we do, and we're damned if we don't!

Category Archives: Study

SANS SEC710: Advanced Exploit Development

SANS_Logo_REVAfter spending the week doing the Advanced Web App Penetration Testing class, what could be better than spending a couple of day doing exploit dev! Yeah, nobody said I was smart, but I am a sucker for punishment.

Day 1 – Linux

The class kicked off with a discussion of the dynamic Linux memory, followed quickly by a couple of interesting (albeit similar) heap exploit exercises. The class moved quickly (lots of content, little time) into overwriting function pointers (BSS segment exploitation). As usual the exercises (labs) that follow each section helped reinforce the information from the previous section. Although the exercise programs are simple (and often simple purposed) they do a good job of easing you into the exploit type your working on without distracting you with huge monolithic programs.

After lunch we started in on format string attacks, which left the class a little confused I think. So many characters that we’re not accustomed to in exploitation. Still, things sorted themselves out, and surprisingly I was even able to get the exploit working using direct parameter access techniques.

To finish up the day there were 2 exercises: The first was a proftpd exploit (that for some reason didn’t like working on my version of VMware Fusion). The second was the bootcamp portion of the class, and was based on a challenge from the DefCon 18 CTF pre-quals.

Unfortunately we didn’t get too much time on the bootcamp as we spent more time on format strings and fighting with proftpd than planned.

Day 1 was mostly performed using older (Gutsy/Edgy Linux) so very little (if any) ASLR or other advanced protections in place. That’s not to say the information in day 1 isn’t worthwhile… it’s just like everything else, it’s a starting point!

Day 2 – Windows

Monday morning kicked things off with an overview of patch diffing (using BinDiff, PatchDiff2, and turbodiff) with IDA Pro. For people who don’t know how IDA works, the class went through some basics on using IDA for diffing. I found this a bit of a shame personally. I have no intention of buying IDA Pro (as I’m not an exploit dev) and the demo version used in class doesn’t support diffing (which is the primary use for SEC710). I’d have liked to have seen the class stick to open-source or free versions to keep the playing field flat for everybody in class. Still, BinDiff and IDA Pro are the de-facto standard, so I can see where the class is coming from. Using free or open-source alternatives may have made the examples so complex as to be unusable.

Some background info was a little fluffy for my liking. For example, the section on Microsoft patches started off with a discussion on how Microsoft releases patches and how to get patches from the MS website. Good info, but mostly known and not really something that warrants more than a 60 second refresher.

The real meat of day 2 was working through the old ms07-17 ANI exploit. Taking it from patch diffing with IDA (free or pro) through to a working exploit on a Vista host. The final exploitation used heap spraying to get code execution. Unfortunately the walkthrough of the exploit on a Windows Vista system was trickier than first thought and didn’t run as smoothly as it could have. Exploitation isn’t easy though, else we’d all be doing it…

Although the appendix talks about ROP gadgets and touches on Windows 7 x64 and Windows 8, these weren’t covered in the class itself. There is an exercise at the end of the book however that touches on Win7 exploitation.

Conclusion

A Lot of topics the class covered were a bit over my head as I don’t do this stuff on a daily basis, and unfortunately spent most of day 2 fighting with VMware fusion issues. SEC710 is not an easy class and tries to cram a LOT of information into the 2 days without going too long despite the bootcamp section. At the end of the class there is still a lot of content that needs to be reviewed to solidify things however, as well as the additional appendix content that’s not really covered in normal class. Exploit development isn’t for the faint of heart though, and anybody who thinks they can walk out of a 2 day class as a reverse engineer or exploit developer is fooling themselves.

People seem to want to compare SEC710 with Corelan’s Win32 Bootcamp. Although they both cover exploitation, SANS SEC710 covers different topics from the Corelan Live bootcamp (Linux being the biggest example) and the classes with SANS don’t run as long ;) (Corelan likes to run 12 hour sessions both days… which is exhausting, but fun!).

Realistically there is no comparison between the two classes. SEC710 covers topics that are not covered in the Corelan class, and vice versa. As a result you end up with a broader knowledge from SEC710, but a much more detailed view from the Corelan class. Neither is better, they are simply different! Having said that, I found the explanations of the techniques are not as clear in SEC710 as they are in the Corelan Live – Win32 Exploit Development Bootcamp. Then again, having 2 days to focus on Windows means less setup, and more time to really deep dive without the confusion of describing different operating systems and how they differ.

Overall I enjoyed the class (despite not really being an exploit developer myself)… Everytime I sit in on one of these classes I learn a little more. Maybe one day I’ll actually have time to do the after class work to actually understand things fully!

Personally I hope they make some changes to SEC710 to make it deeper. To manage that I think they’d need to split the class into a 2 day Linux exploitation and a 2 day Windows exploitation class. Covering all the information in a single 2 day class just isn’t really feasible and leaves the student wanting more!

Links:

SANS SEC642: Advanced Web App Penetration Testing and Ethical Hacking (review)

After taking a year off from SANS London (a trip to Colombia was too much to resist last year), I flew back over to sunny London (ha) to attend the new SEC642: Advanced Web App Penetration Testing class with Justin Searle. As I’ve had a few people ask about the class I thought I’d write-up some thoughts as I go through the class… Hope they come in handy for people interested in the class content!

Day 1

Day 1 kicked off with a quick refresher on the testing methodology to ease people into things. SEC642 is strongly focused on the discovery and exploitation of vulnerabilities, but the importance of recon and mapping was emphasised during the process, as well as the process used to work through an application from initial recon through to the exploitation phase. One key point raised, and one that most people ignore, was the requirement to finish discovery of flaws (or potential flaws) in an application, BEFORE starting to exploit them. Although the exploitation phase is where we all have the most fun, it’s important for our clients to ensure we have as much coverage of the application as possible.

Jumping straight in, we discussed the more abstract and oft mis-used or unknown features of Burp Suite. It’s amazing the features that you never notice or use simply because you didn’t know they were there. Things like the Burp web interface (http://burp) and the ability to output log files (yes, even in the free version). We also touched on Burp scripting, although briefly. I’d loved to have dived into some more detailed scripting, but I get the feeling this process will be changing slightly with the 1.5 pro release, so maybe it’s better to wait anyhow ;)

With everybody on the same page with Burp, we moved into LFI (Local File Inclusion) and RFI (Remote File Inclusion). Alongside the simple examples there were some advanced methods exploiting LFI issues on various target platforms. Particularly interesting was the PHPINFO trick for using LFI to gain remote code execution on a system, as well as some interesting php://filter tricks to read the content of PHP files without them executing. It was good to have a test lab to try out the intricacies of these tricks and get the chance to get them running well and truly understand the ins and outs of the techniques.

To finish of day 1 we talked SQL Injection, with a short refresher in the basics before jumping into more advanced exploitation (including timing based and heuristic and binary search trees). We finished up day 1 with a couple of  SQLi labs to try out some of the more common SQL Injection tools (Havij, SQLmap)…

Day 2

Moving into the second day we shifted focus to “discovery and exploitation for specific applications”. We kicked things off with coverage of DOM based XSS, which is something that is often discussed, but seldom tested. Although the theory is simple enough, detection (and in particular automated testing tools) to discover DOM based XSS is not always an easy task. No discussion of XSS would be complete without looking at how it can be leveraged to attack clients, and as expected a number of possible payloads were discussed. It’s nice to see some examples of keylogging and geolocation payloads present, but the addition of scriptless attacks was particularly interesting. It was one of those “Oh yeah, that’s obvious… why didn’t I think about that sooner” moments. Sometimes you just can’t inject JavaScript, so having a few useful non-JavaScript attack payloads will certainly come in handy for those tricky apps.

web-app-security-imgMoving on from XSS, the class discussed more advanced XSRF attacks focusing more on the use of AJAX to perform attacks that are invisible to users. After some bad JavaScript coding (I’m no coder) we discussed CSRF protections and methods to bypass them by combining XSRF and XSS vulnerabilities within an application. The discussion of XSRF culminated in the creation of a simple self replicating XSRF attack (ala sammy).

To finish off the day we focused on application specific attacks against Sharepoint and WordPress systems. Personally I’d rather have spent the time discussing more in-depth workings of Sharepoint (or other enterprise grade systems such as Lotus Domino, SAP, etc…) than WordPress. Then again, you can’t please everybody all the time, and it was good to see @ethicalhack3r‘s wpscan mentioned in the WordPress section.

Overall day 2 was a little slow for my liking. Although it was nice to get some refresher on some points, it would have been cool to play with more varied XSS payload tricks, and maybe even look at some non-JavaScript injection (VBscript,…) and XSS via CSS, Flash files etc… Maybe SEC742 ;)

Day 3

Of all the content, the crypto day was the one I was looking forward to most out of the class. Crypto is often something people skim over on a penetration test, so it’s nice to get some practical exercises in more advanced crypto based attacks.

The day started off with a quick grounding in common ciphers and hash algorithms, and moved on to methods for identifying encryption within web applications. The meat of the day was spent discussing attacks against CBC and ECB encryption modes (including bit flipping, CBC chosen plaintext, padding oracles and ECB shuffling attacks). With a good mix of theory and practical examples/exercises the class really helped to give a good understanding of how things work in the background, and how the can be exploited to attack or extract data from a web application.

Day 3 was a theory heavy day, and certainly a departure from days 1 and 2… I would have liked to have spent more time looking at crypto flaws, but there’s more gold in them their web applications than crypto alone!

Day 4

No advanced class would be complete without talking about bypassing web application firewalls and filters. Day 4 covered some of the more common ways to detect and enumerate WAF’s and other protections, and how to work around some of the protections they offer. Some interesting techniques such as DATAURI and CDATA blocks were touched on, as well as the more common comment and onerror/onload style bypass techniques. We also covered some groundwork on HTML5 and it’s use in injection and bypassing common filters. The day finished up with a quick look at sqlmap tamper scripts and the little used evasion techniques built into sqlmap itself.

I felt that day 4 was a little basic for an advanced class. With so many options for evading detection or active filtering, I think the coverage was a little light.

Day 5

Day 5 stepped away from the world of Web Applications for a while to venture into mobile security. Although it seems at first blush to be a bit of a strange thing to include in a web app class, a lot of mobile application testing crosses over into the web app realm. Things like SOAP and REST are common to mobile applications and web application testing, providing the perfect chance to cover some mobile security alongside the standard web application testing.

Some of the background information on mobile platforms was a little too detailed for my liking (interesting, but not really relevant to web application testing), the exercises proved interesting and allowed people to play with capturing web traffic from mobile emulators.

Day 6

As with a lot of the SANS penetration testing classes, the final day of the class was a capture the flag style challenge to enforce some of the topics covered in the class. A majority of the keys were pretty simple to find, and I won’t spoil it for you by giving you too much info. I’d have like to have seen some more of the crypto content in the CTF, but I guess in a small timeframe you can’t do everything!

Overall the CTF was a fun experience… and as usual, I did terribly! Somehow I just can’t get into CTFs

Conclusion

The SEC 642 is a very young course, and isn’t without its flaws and issues. Saying that, the foundation is there for a good followup to the SEC542 class. With a few tweaks and changes (that I’m sure are already in the works) the SEC642 class should provide a good addition to the SANS penetration testing range of classes. If you’re doing penetration testing and found the SEC542 class a little too light for you, then SEC642 is definitely something you should look at in the future.

I would have liked to have seen even a passing mention to Metasploit as it pertains to Web Application testing, perhaps even replacing some of the less advanced sections with a few useful examples and labs. Still, you can’t have your cake AND eat it… and most people don’t see Metasploit as a useful tool in their web application testing arsenal (mores the pity!).

Some days may spend a little too long reviewing basic principles (sometimes for good reason), as well as a little too much focus on defense sometimes (defense is good, but this IS an exploitation course). You can’t please everyone though, and I think the class strikes a reasonable balance.

Links:

Setting up your own SAP Netweaver test lab

One of the main issues I came across when starting research in SAP security (and SAP in general) was the seeming lack of demo software available and the difficulty getting what demo versions there were up and running. This has also been the number 1 question I’ve received over the last few months… “How do I get a trial version for my lab”!

With that in mind I’ve collected up the links I’ve used over the past few months into a single post for those that are interested in setting up an SAP test lab and playing about with it.

These trial versions are slightly limited as they don’t offer the ability to update them to the latest build (which is an issue when it comes to security research). They also rely on MaxDB (formerly SAP DB) by default (although I believe one uses IBM DB/2 just for fun). They might be able to be configured to use external databases (Oracle etc…) but with this you’re on your own! I’m as far from a SAP expert as you could probably find.

I’ve tried to break things down by platform as one of my aims was to get and install a few different versions for tool testing. These trials are memory hungry, CPU hungry at times, and need a lot of disk space (>42GB for a single VM).

Note: SAP isn’t for the faint of heart, and getting things running 100% is never going to be easy! Don’t say I didn’t warn you ;)

You’ll need to sign-up for a free SAP Community Network (SCN) user account to download most of these files. This will also give you access to the forums.

Linux

SAP NetWeaver 7.0 – Trial Version on Linux –> DOWNLOAD

(N4S) SAP NETWEAVER 7.0 – SAP WEB APPLICATION SERVER ON LINUX (DVD) –> REQUEST DVD

Windows

SAP NetWeaver AS ABAP 7.02 SP6 32-bit Trial –> DOWNLOAD

Step by Step Installation of SAP NetWeaver 7.01 SR1 SP3 ABAP Trial Version in Oracle VirtualBox Part 1/3 –> GUIDE

SAP NETWEAVER 2004S ABAP TRIAL VERSION – TROUBLESHOOTING GUIDE  –> GUIDE

Notes: A few points you might want to check before beginning with the install.

  • RAM
    • I got away with running this on 1.5GB of RAM, but it really needs >2GB to run smoothly
  • SWAP
    • Don’t even bother starting your install without >4GB of swapfile initialized. The installer will only complain about the lack of swap after you’ve configured the whole install… you’ve been warned!
  • Disk Space
    • Lots…. I made a VM with a 50GB second disk purely for the MaxDB
  • JRE
    • It might look like things are all working fine with 1.6.x but I only had issues with the system afterwards or during install (crashed my vmware fusion). Stick to JRE 1.4.x  latest (worked fine for me).

VMWARE (LINUX SLES)

(CTB) SAP NetWeaver 7.0 – Java Trial Version on Linux – VMware Edition –> DOWNLOAD

Novell Link to CTB SLES images –> DOWNLOAD

GETTING STARTED SAP NETWEAVER 7.0-JAVA-VMWARE-TRIAL –> GUIDE

SAP ON LINUX: TEST DRIVES – TIPS AND TRICKS –> GUIDE

Notes: This VM is meant to be a sealed unit where you access it from a second system for management etc. I had issues getting the Visual Administrator to connect, and also getting the config tool running on the local system.

Some guides reference the n4sadm user (these guides are written for the pure Linux version of SAP and not the VM version). You might find you have more luck using the ctbadm when the guide says n4sadm.

Oh and the root password is “sap123″

Licensing

This page seems to be the main hub for what SAP now call “minisap” (originally TRIAL version).

You’ll need to run some commands on the SAP install and extract the resulting codes to request a key through this link.

http://www.sap.com/minisap/

LINKS:

SANS SEC580: Metasploit Kung Fu for Enterprise Pen Testing – Post Mortem

At the end of my time in London I had the chance to sit in on the new SANS SEC580 class (Metasploit Kung Fu for Enterprise Pen  Testing).

This 2-day class is designed to “show students how to apply the incredible capabilities of the Metasploit Framework in a comprehensive penetration testing and vulnerability assessment regimen, according to a thorough methodology for performing effective tests”. With Ed Skoudis and John Strand behind the class I had high hopes for something that really goes into the depths of Metasploit.

Day One

NewImage.jpg

The first day started off with a gentle introduction to Metasploit and the MSF project in general, before diving into msfconsole and covering the required commands and options. Even though I’ve taught a few Metasploit workshops, there were a few gems here that I’ve not played with before. Small things (like the connect feature for example), but still gems non the less.

After covering the “basics” the class focuses on using Metasploit in a 4-phase penetration test (Recon, Scanning, Exploitation, and Post-Exploitation).

By using the Recon phase as the basis for the afternoons labs, a number of the Metasploit auxiliary modules are discussed, with labs on dns_enum, port scanning, databases and db_autopwn.

The obligatory meterpreter overview was given, as well as some more detailed discussion about meterpreter scripts and their uses.

Day Two

Day two concluded the scanning section from the previous day (demo of netxpose scan and import), before moving on to the exploitation phase.

To provide an complete overview of exploitation, everything some client-side (file format, and browser_autopwn) through to Social Engineering Toolkit (SET) and remote network exploitation was covered in varying detail. Coverage of some of the additional Metasploit command-line tools (msfpayload, msfencode) was included, but wasn’t explored in too much detail outside of a few specific examples.

The labs in this section of the book are well written and really give a good feel as to how specific protections can be bypassed. It was also good to play with SET and sqlmap using MSF payloads. Surprisingly the File Format lab wasn’t on Adobe PDF exploitation, but on Office macros… which makes a change ;)

Moving into the final stages of the class we covered some of the inner workings of Post-Exploitation with meterpreter scripts and some irb scripting. Although the labs gave the chance to write a simple meterpreter script and interact with the irb shell, I would have liked to spend some more time covering Ruby basics and going a little more in-depth. Still, you can’t have it all!

To finish things off a number of sniffer and database modules were used to demonstrate Metasploit’s password sniffing/extracting capabilities.

Wrapping things up was a short discussion of Karmetasploit and the Metasploit web integration.

Conclusion

Overall I really enjoyed this class, even if it wasn’t quite at the “kung-fu” level the name hints at. I was a little disappointed that the Metasploit version used for the class (3.4.0) was so outdated, but I understand the problems keeping a course like this up to date, so fully understand the choices.

This class is certainly a winner if Metasploit isn’t your daily driver! If you get up everyday and pentest using Metasploit, then you’re not going to get the full effect of this class. Then again, there are some real gems in here if you take the time to look for them. I’ve taken a few hints and tips that I’ll be using in the future, so I’m sure there’s something for almost everybody here.

If I had my way, I’d slim down some of the “introduction to…” stuff, and spend a little more time covering Ruby basics and bring in some of the more advanced topics, like module writing (simple modules naturally) and maybe something on Railgun / Racket.

This class certainly motivated me to get moving on some of my (long standing) Metasploit projects. Since getting back I’ve finished up my adduser payload modifications as well as a number of SAP auxiliary modules I had waiting to be finished. So I guess that makes it a resounding success!

If you attend the class in 2011 please let me know what you think… I’m interested to see the transformation of the class over time, as Metasploit is ever changing!

Quote of the class: “Shine on you crazy diamond!”

Follow

Get every new post delivered to your Inbox.

Join 132 other followers