Hacking Steps
Hacking Steps
❖ Hacking steps
❖ System hacking
❖ Web application hacking
Hacking Steps
1 2
❖ Network
❖ Sniffer
❖ Spoofing
❖ Flooding / DDoS
❖ Applications
❖ Data
❖ Operation
3 4
Risk Information Security Principles
X"
Vulnerabili*es, Threats(
Loss$,$Damage$
5 6
PART 0
Preparing before Pentest
7 8
General Attack Lifecycle Attack Methodology
Footprinting Gathering broad publiclyavailable information, ARIN, IANA, web sites
Scanning Using info from above, see what services run, ports opened, OS used
Profiling
Use specific OS/ service enumeration techniques to gather user
Enumeration account/ shared/ exported info
Entering
Penetration First real attack phase
Concealing Penetration Failed Penetration Success
Compromising
Either:
Pilfering of Data Altering & copying data
Empowering •Tactics of last resort, an action of
desperation (good job on your
part)
•Relatively unskilled attacker
Cover Tracks Edit / erase audit logs
9 10
11 12
Overall PenTest Process Public Pentest Methodologies
Preparation • Various organizations have released free network scanning and
• If applicable, sign Non-Disclosure Agreement (NDA) penetration testing methodologies
• Discuss the nature of test with target personnel (business concern, rules • They can provide useful source documentation for formalizing your own
of engagement, test scope) customized test plan
• Sign off on the permission (free out-of-jail card) • Some of notable references
• Assign the team • Open Source Security Testing Methodology Manual (OSSTMM) from
ISECOM
Testing
• NIST Special Publication 800-42: Guideline to Network Security Testing
• Perform detailed testing (internal & external) - depend on the scope
• Open Web Application Security Project (OWASP)
Conclusion
• Penetration Testing Framework from Toggmeister
• Analyze test results & retest (with documentations)
• Prepare a thorough report & presentation
13 14
Activities
❖ Footprinting
❖ Scanning
❖ Exploitation
❖ Post Exploitation
❖ Password
❖ Backdoor / Trojan
PART 1
Footprinting
15 16
Footprinting - Google Dorks Search people
❖ Some of common Google keyword searches:
❖ intitle: index of “parent directory”
❖ inurl:.go.th
❖ filetype: or ext:
❖ site: operator
❖ admin login page
❖ intranet | help.desk
johny.ihackstuff
17 18
19 20
IP Address What can we know more about IP?
❖ Dotted Decimal ❖ IP Owner’s name or Provider
❖ 192.168.20.59 ❖ Contact point
❖ Binary ❖ Email address
❖ 11000000.10101000.00010100.00111011 ❖ Telephone number
❖ Decimal ❖ Route
❖ 3232240699 ❖ Active or not?
❖ Hexadecimal ❖ Opened ports
❖ 0xC0.0xA8.0x14.0x3B ❖ Vulnerabilities
21 22
23 24
Whois result Tracert / Traceroute
25 26
Ping nslookup
27 28
Dig Exercises
❖ Use google dorks keyword
❖ Check your server’s IP address and other
information
❖ Discuss what you found
29 30
Scanning
• Scanning is meant to know live machines, open & closed ports, service
versions, OS used.
PART 2
Scanning
31 32
Goal of Scanning Scan using Nmap
❖ Overall: Learning more about the target and find
openings by interacting with the target
❖ Determine network addresses of live hosts, firewall,
routers, etc, in the network
❖ Determine network topology of the target environment
❖ Determine the operating system types of discovered
hosts
❖ Determine the open ports & services (with versions, if
possible - via banner grabbing/test)
❖ Determine the list of potential vulnerabilities
33 34
35 36
Nmap Nmap (Windows)
❖ Port scanning tools
❖ Both GUI and Command line
❖ Free download at http://www.nmap.org
❖ Compatible with Windows, Linux and MacOS
❖ Last version is 5.6x
37 38
Nessus Nessus
❖ Free download at http://www.nessus.org
❖ Vulnerabilities Scanner
❖ Last version is 5
❖ Compatible with Linux, MacOS and Windows
❖ 2 Softwares
❖ Nessus Server
❖ Nessus Client
39 40
Exercises
❖ Use Nessus to scan my server
❖ Use Nmap
❖ nmap -sn 192.168.100.0
❖ nmap -sS 192.168.100.20
❖ Use MBSA
❖ try your machine
❖ try 172.17.50.130
PART 3
Exploitation
41 42
43 44
Metasploit Features Metasploit Framework Components
❖Runs on various OS platform (Windows, Linux, BSD &
MacOS X) User interface
❖ Also able to run on Linux-based PDA, iPhone (Jail-broken) Exploit Development
Support Tools
❖ Support wide-range of exploits & updated on regular Exploit 1 Payload 1
basis Payload
injection tools
Vuln finding
tools
❖ Current version (3.x) use ‘svn update’ Exploit 2 Payload 2
Armoring
❖ Not only home of Windows OS & services exploits but also Memory region
tools (to dodge
size, location &
include client-side attacks & appliance vulnerabilities Exploit n Payload n detection &
offset helper
filter)
❖Developer-friendly & ready for use payload
❖ Many features built-in (Windows SP independence, retrieving
stack pointer, various encoders, converter from exe to vbs, etc)
Exploit Payload Tgt Info Launcher Send to target
45 46
47 48
List of exploits List of Payloads
❖Common Windows OS vulnerabilities & services exploit ❖Customized payload to suit OS platform
❖ Windows Plug and Play Overflow ❖ Windows/ Linux/ Solaris/ AIX/ BSD/ OSX
❖ Microsoft ASN.1 attack against LSASS
❖ RPC DCOM (several)
❖Some of payload types
❖Other OSes vulnerabilities (UNIX, Linux, Mac OS X, BSD) ❖ singles: stand-alone (everything bundled)
❖ HP Openview connectedNodes.ovpl Remote Command Execution ❖ stagers: piece-parts which load first to allow stage to
❖ AIX Calendar Manager Service Daemon (rpc.cmsd) Opcode 21 Buffer communicate later
Overflow ❖ stages: piece-parts which implement the function through
❖Client-side components
stager
❖ AOL Instant Messenger goaway Overflow
❖ stagers (comm) + stages (function) = full payload
❖ Microsoft Excel Malformed FEATHEADER Record Vulnerability
❖Back-up solutions ❖Windows Singles
❖ VERITAS NetBackup Remote Command Execution ❖ adduser, exec, download_exec, shell_bind_tcp,
❖ Arkeia Backup Client Type 77 Overflow shell_bind_tcp_xpfw
49 50
51 52
Meterpreter
❖ Meterpreter = Metasploit Interpreter
❖ Most of hard-core development done by Skape
❖ Consist of a series of DLLs injected into process memory
❖ Meterpreter (for Linux & Mac OS X) also available
❖ Extensive modules
❖ Core: sysinfo, shutdown, reboot, reg
❖ Stdapi: file system (cd, cat, download, mkdir, edit), process (getpid, ps,
kill, migrate), network (ipconfig, portfwd, route)
❖ Additional module, Priv: timestomp, hashdump, Incognito: token
stealing
❖ Ready-made scripts for various functionalities
❖ Why Meterpreter?
❖ Does not create separate process (run inside exploited process) PART 4
❖
❖
Pure manipulation of memory, does not touch hard drive
Does not need any system-provided command executables (all built-in)
Post Exploitation - Password
53 54
to the case.
55 56
Windows password Obtaining windows password
❖ Locally, in SAM database, Windows store password as: ❖ Pull hashes from local SAM as well as AD database
❖ LANMAN hash (Extremely weak) ❖ DLL injection into LSASS process (to extract hashes)
❖ NT Hash (Stronger) ❖ using Windows CreateRemoteThread API
❖ When complete, tools delete artifacts left on the target’s file
Both are not salted! system
❖ Default: Both hashes stored in NT, 2000, XP & 2003. ❖Pwdump family
Only NT Hash stored in Vista & 2008 (although can be ❖ pwdump2 to pwdump3 (may crash LSASS due to Windows DEP,
force to reboot)
altered). ❖ pwdump3e to pwdump6 (low chance of crash - marking injected
❖ With AD, domain controllers store account information, code as executable, encrypt hashes as they move across network)
including both hashes, in %systemroot%\ntds\ntds.dit ❖Fgdump (from Fizzgig, Foofus hacking group)
❖ Typically quite large (more than 50MB although for a few ❖ Addresses problem with AV tools deleting pwdump programs and
accounts) DLLs copied to the target file system for extraction
❖ Before moving files, fgdump remotely disables AV tools and then
❖ No parsing tool publicly released
moves files to dump password hashes
57 58
59 60
Obtaining Linux password Cain & Abel
❖ Grab a copy of /etc/passwd ❖ Written by Massimiliano Montoro (free at www.oxid.it)
❖ Mainly focus on password cracking (but can do more!)
❖ Contains login names, UID numbers and possibly ❖ Windows-type passwords (LANMAN, NT, LANMAN challenge/response,
password representation (if not shadowed) NTLMv1, NTLMv2, MS Kerberos5 PreAuth)
❖ Readable by any account on system ❖ Non Windows password (Cisco IOS Type 5 enable, Cisco PIX enable,
APOP-MD5, VNC-3DES, RADUS Pre-Shared Secret, IKE Pre-Shared Key,
❖ Grab a copy of /etc/shadow Oracle, MySQL and many more)
❖ Contains password representations, security settings, etc. ❖ NOT SUPPORT: DES and MD5 Linux/ UNIX password (since it is salted)
❖ It also can sniff password (or password hashes) directly from the
❖ Readable only by accounts with UID 0
network
❖ Combined the two together with script ❖ Other features:
❖ John the Ripper’s unshadow script pulls account info ❖ SIP/ RTP-to-WAV file converter
❖ SecureID Token Generator
from /etc/passwd and password info from /etc/shadow, ❖ Box Revealer (reveal what’s behind ******* in password box via DLL
creating one resulting file suitable for cracking injection)
❖ Hash calculator
61 62
63 64
Planting Malware
❖ Trojan: malicious, security breaking program that disgise as
useful program, mainly allow one to control a user’s system
❖ Like virus, trojans do not distribute itself from one system to another
❖ Back Orifice (port 31337 or 31338), Netbus (port 12345 or 12346),
Netcat, Tini
❖ Commonly distributed via peer-to-peer sharing, IRC, warez sites,
pornography sites
❖ Bots: software programs that perform some action on behalf of
human (with little or no human intervention)
❖ Used to control large numbers of systems (so-called bot-nets)
❖ Attacker usually control all infected machines (zombies) via
command & control center (C&C)
PART 4B ❖ Bot communication channels: IRC on standard port (TCP 6667), IRC
Post Exploitation - Backdoor / Trojan non standard port, distributed P2P communications, social
networking sites (Twitter, YouTubes, Google documents, etc)
65 66
67 68
Thank You
69
72
What is an OWASP? Open Web Application Security Project
! Open Web Application Security Project
! http://www.owasp.org
! Open group focused on understanding and improving
the security of web applications and web services!
! Hundreds of volunteer experts from around the world
74
Problems Goals
Attack type Description Mitigation
• Theft of service
• Warez or pornography uploads Any of the network, web-server,
• Pirate servers and applications or application-based attacks Prepare for attacks.
System integrity
• Password sniffing that result in denial of service, a Inspect the application to
• Rootkit and Trojan program installation Denial of service
condition in which a system is remove application-based
• Distributed Denial of Service participation overloaded and can no longer attack points.
respond normally.
• Vandalism, data tampering, or site defacement
• Inadvertent file deletion or modification Data integrity
Human Resources
Application Layer
Legacy Systems
Web Services
Apache problems in the Apache web Patch promptly.
Databases
Directories
Custom Developed Application
Billing
vulnerabilities server. Code
APPLICATION
ATTACK
Web Server
Network Layer
Hardened OS
Firewall
all other unmitigated problems
Firewall
on the same network as the Do not expose unneeded
Attacks through
web server. For example, a services, and
other services
vulnerable MySQL database compartmentalize.
You can’t use network layer protection (firewall, SSL, IDS, hardening)
server running on the same to stop or detect application layer attacks
machine and open to the public.
78
79
OWASP Top 10 Application Security Risks - 2010 What is WebGoat ?
1. Injection ! Deliberately insecure J2EE web application
2. Cross Site Scripting (XSS) ! Maintained by OWASP
3. Broken Authentication and Session Management
4. Insecure Direct Object References ! Designed to teach web application security lessons
5. Cross Site Request Forgery (CSRF) ! For example, in one of the lessons the user must use SQL
6. Security Misconfiguration injection to steal fake credit card numbers. The application
7. Insecure Cryptographic Storage is a realistic teaching environment, providing users with
8. Failure to Restrict URL Access hints and code to further explain the lesson.
9. Insufficient Transport Layer Protection ! Why the name "WebGoat"?
10.Unvalidated Redirects and Forwards ! Developers should not feel bad about not knowing security.
Even the best programmers make security errors. What they
https://www.owasp.org/index.php/Top_10_2010-Main need is a scapegoat, right? Just blame it on the 'Goat!
82
83
Weak Session Cookies
65432ubphcfx
DVWA DVWA
! Damn Vulnerable Web Application
! http://www.dvwa.co.uk
! PHP/MySQL
! Vulnerable web for security testing
! Freeware
Username : admin
Password : password
DVWA Configure
! Setup -> Create/Reset Database
! DVWA Security -> Low -> Submit
93
99
SQL Injection Try these commands and explain
! a' OR '1'='1
http://www.securiteam.com/securityreviews/5DP0N1P76E.html
http://en.wikipedia.org/wiki/SQL_injection
http://www.unixwiz.net/techtips/sql-injection.html
! Find the current version of MySQL ! Find the current version of MySQL
a’ UNION ALL SELECT 1, @@version;#
! List the password hashed ! List the password hashed
1′ UNION ALL SELECT user, password FROM mysql.user;
— priv;#’
! Find the database name
! Find the database name
a’ OR database() LIKE ‘%A%’;#
! Find the table name
! Find the table name
a’ UNION SELECT table_schema, table_name FROM
information_schema.tables WHERE table_schema LIKE
‘%dv%
How to fix Cross Site Scripting (XSS)
! Check all input
! type
! size
! mysql_real_escape_string()
abc’ or ’1′=’1
abc\’ or \’1\’=\’1
107
Preventing XSS - Continued Ex.2 Cross-Site Scripting
❖ Learn to do XSS on DVWA
❖ Ensure your filter uses a white list approach
❖ Understand how weak web application is
❖ Filters based on blacklisting have historically been flawed
❖ E.g. Ruby on Rails sanitize method ❖ Learn how to prevent this attack
❖ New encoding schemes can easily bypass filters that use a ❖ Know how to program securely
blacklist approach
❖ Do not accept and reflect unsolicited input
❖ Reflecting every parameter for confirmation pages
❖ Printing out the session/request parameters in error pages
❖ Great XSS resource: http://ha.ckers.org/xss.html
110
! <script>alert(“XXX”); </script>
! <img src=”http://www.aaa.com/a.jpg”>
How to fix Input filtering
! htmlspecialchars() ! Input sanitizing
! FILTER_SANITIZE_SPECIAL_CHARS
cut HTML escape character (e.g. ‘ ” < > &)
! FILTER_SANITIZE_URL
cut non-alphabet, non-number and non $-_.+!*’(),{}|\
\^~[]`<>#%”;/?:@&=
! Logical filtering
! FILTER_VALIDATE_EMAIL
! FILTER_VALIDATE_INT
Follow me
Email : [email protected]
[email protected]
Weblog : http://foh9.blogspot.com
Twitter : @kitisak