Infrastructure Testing Training v1.0
Infrastructure Testing Training v1.0
Testing Training
November 2014
Information Protection, UK
Who am I?
INTERNAL USE ONLY
• Marc Wickenden
• Technical Director at 4ARMED
• @marcwickenden
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 2
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Agenda
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 3
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
What is an infrastructure penetration test?
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 4
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
What is an infrastructure penetration test?
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 5
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Penetration tests are cyclic
INTERNAL USE ONLY
Identify Exploit
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 6
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Not a Vulnerability Assessment
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 7
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Types of infrastructure penetration test
INTERNAL USE ONLY
• Black box
• Advantages:
• More like a real-world attack
• Disadvantages:
• Not really like a real-world attack
• White box
• Advantages:
• Deeper level of assurance, easier to achieve scope
• Disadvantages:
• Can "lead" the tester and actually be more time-consuming
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 8
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
What you need to test
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 9
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Methodology
INTERNAL USE ONLY
Methodology
Methodology
Methodology
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 10
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Phases of the Methodology
INTERNAL USE ONLY
1. Preparation
2. Mapping and Target Enumeration
3. Service Enumeration
4. Vulnerability Analysis
5. Exploitation
6. Post Exploitation
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 11
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Preparation
INTERNAL USE ONLY
• Update toolkit
• Make sure licenses are valid
• Equipment check
• Scope – (more to follow)
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 12
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Scope – Things to consider
INTERNAL USE ONLY
• Confirm the number of hosts within the test is still correct as per the scope.
• Are hosts firewalled? This will slow things down
• Are there any legacy / critical systems or slow network links that could be affected by
the testing?
• Are there Intrusion Prevention Systems (IPS)? This may require packet manipulation,
stealthy scans etc. again this will slow things down
• Example - Solaris hosts employ rate limiting on port scanning, this can significantly
slow things down, especially on UDP port scans
• What technologies underpin the network? Is it a big Windows domain, are there Linux
or Solaris hosts? Knowing this will help you focus and get ready the right tools
• Do you need to provide device MAC addresses of you laptop, does your laptop need to
be joined to the domain before network connectivity is granted?
• Check that you know who the technical contact is (often a network engineer) if things
go wrong on the day.
• Do you need to demonstrate AV/Patches before connecting to the network?
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 13
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
First things first…
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 14
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Network Layer – Mapping & Target Enumeration
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 15
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Enumerating Hosts & Routing (tcpdump / wireshark)
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 16
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Enumerating Hosts (Zone Transfers)
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 17
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Enumerating Hosts & Networks (SNMP)
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 18
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Enumerating Hosts & Networks (SNMP)…
INTERNAL USE ONLY
• A number of different tools exist for SNMP scanning and subsequent querying:
• Snscan (Windows) – can scan whole ranges or lists of IPs with a supplied dictionary of
community strings
• GetIF (Windows) – can query SNMP in detail: http://www.wtcs.org/snmp4tpc/getif.htm
(needs to be run in compatibility mode on Win7)
• Snmpcheck (PERL) - http://www.nothink.org/perl/snmpcheck/
• Snmpwalk (Unix) – common snmp library / client packages found in most Unix
distributions.
• OneSixtyOne – Linux community string bruteforcer
• How to determine whether a target has the public community string using snmpwalk on
Linux: -
• $ snmpwalk –Os –v 1 –c public <IP address>
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 19
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Enumerating Hosts and Networks (Windows Network)
INTERNAL USE ONLY
• Windows computers, workgroups and domains broadcast their presence on the network and
browse lists are automatically populated with Windows machines on the network. This can
provide an invaluable target list and can be used to identify significant components of the
network (e.g. Active Directory machines or SQL servers).
• It is possible to view the list of devices that your laptop can ‘see’ using the Windows ‘NET
VIEW’ command.
• It is also possible to see them via the GUI using the Windows Network Explorer application.
• Cain & Abel will also provide a list of machines on the network, including their role.
• To convert Windows hostnames to IP addresses, use nslookup or ping (which will also confirm
whether the device is up): -
C:\> PING LONADC1
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 20
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Enumerating Hosts & Networks (Windows Network)
INTERNAL USE ONLY
• Note: Cain & Abel will perform many of these tasks by default.
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 21
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Enumerating Hosts & Networks – Joining it all Together
INTERNAL USE ONLY
• Putting it all together you will likely have at least: -
• Local Subnet
• Local Gateway
• DHCP Servers
• DNS Servers
• Active Directory Servers
• MSSQL Servers
• Web Servers
• All of these hosts may reside on a local or remote subnet, so it is then possible to expand
on these and draw up a potential list of networks.
• Using traceroute and hping it is possible to map the network path between the source and
the destination, which may reveal further networks containing targets within the
environment.
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 22
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Mapping Routes
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 23
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Mapping Routes: Example Network
INTERNAL USE ONLY
ICMP Echo
Reply
ICMP ECHO
Request
(TTL=2)
ICMP Time
Exceeded
ICMP ECHO (TTL=2)
Request
(TTL=1)
ICMP Time
Exceeded
(TTL=1)
Src Laptop
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 24
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Mapping routes - traceroute
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 25
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Mapping routes – hping3
INTERNAL USE ONLY
• hping3 – This tool can perform traceroutes using any protocol by simply specifying a
port number. It should be noted that often using port TCP port 80 in hping traceroutes
enumerates more intermediate hops.
• The example below is a TCP traceroute using hping3:
• $ hping3 –T –S –p <port #> <IP address>
• Note that the output “stops” on a hop that does not respond with a TTL packet, use CTRL-
Z to restart…
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 26
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Mapping routes – Nmap
INTERNAL USE ONLY
• Nmap also has a traceroute option (--traceroute), this is very fast and useful on tests.
• On the windows or *nix command line ‘ping –r’ records IP addresses of intermediate
hops in the IP header. A maximum of 9 addresses can be recorded.
• Windows: ping –r 9 <host>
• *nix: ping –R <host>
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 27
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Host Discovery
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 28
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Host Discovery – Network Layers
INTERNAL USE ONLY
IP 3. Network 3. Network IP
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 29
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Host Discovery
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 30
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Host Discovery
INTERNAL USE ONLY
rt = 80)
ll)
)
a
PORT = 80
rew
firewall)
all)
Packet (SRC Po
by fi
fir ew
cked
y
acket (DST
y
db
(blocked b
(blo
t
o R ques
cke
(blo
uest
ly
e
TCP SYN/ACK
oR
ep
TCP SYN P
est
Req
ICM Ech
o Request
ch
equ
P
Echo
PE
ICM
R
ho
P
P Ec
ICM
ICMP Ech
ICM
Src Laptop
Arp Request
Arp Response
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 31
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Host Discovery
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 32
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Host Discovery
INTERNAL USE ONLY
The output from a sweep file might look like this: -
# Nmap 6.25 scan initiated Mon Jan 20 10:31:39 2014 as: Nmap -sP -PA -vv -oA pingsweep.192.168.100.0 192.168.100.0/24
<CUT>
Nmap scan report for 192.168.100.109 [host down]
Nmap scan report for ddpbk1.TARGET.local (192.168.100.110)
Host is up (0.00030s latency).
MAC Address: 00:50:56:B2:00:05 (VMware)
Nmap scan report for 192.168.100.111 [host down]
Nmap scan report for dp-manage01.TARGET.local (192.168.100.112)
Host is up (0.00025s latency).
MAC Address: 00:50:56:B2:00:0D (VMware)
Nmap scan report for 192.168.100.113 [host down]
Nmap scan report for 192.168.100.114 [host down]
Nmap scan report for 192.168.100.115 [host down]
Nmap scan report for 192.168.100.116 [host down]
Nmap scan report for 192.168.100.117 [host down]
Nmap scan report for 192.168.100.118 [host down]
Nmap scan report for ddpdc1.TARGET.local (192.168.100.119)
Host is up (0.00026s latency).
MAC Address: 00:0C:29:EE:BB:BB (VMware)
Nmap scan report for ddpdc2.TARGET.local (192.168.100.120)
Host is up (0.00025s latency).
MAC Address: 00:50:56:B2:00:00 (VMware)
<CUT>
As the example output is an ARP scan then the tool also shows the target MAC address. It is straightforward to
manipulate/grep the gNmap output file to create specific target lists.
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 33
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Exercise 1: Duration 45 minutes
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 34
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Enumerating Services
INTERNAL USE ONLY
• Now that we’ve roughly identified the layout of the network and live hosts, we look at what
services these hosts offer (open ports).
• This is the point at which port scanning is carried out – the main services are normally served
via TCP and UDP therefore we ideally need to perform both types of scan.
• It is important to make pragmatic choices on the time available to conduct infrastructure tests, to
ensure that enough coverage can be achieved in the given timescales.
• Perform a scan of one host to see how long this takes. Full port scans of all ports (65536) may
not be realistic – concentrate on Nmap’s default port range, or if time is short use --top-ports ‘X’
to scan the ‘X’ most common ports
• In time-critical situations, you can use other scanners, such as Masscan to complete large
networks in a short time.
• Note: UDP scanning can take a long time for a number of reasons:
• the protocol is connectionless
• there are no guarantees on sent/received UDP packets
• a number of IP stacks rate-limit on UDP connections (especially Solaris hosts)
• As such, often only a services scan is undertaken of UDP ports. However, other tools could be
considering in this scenario.
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 35
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Enumerating Services
INTERNAL USE ONLY
• Nmap again is the most common tool used for conducting port scans.
• It is important to fully understand how Nmap is operating with regard to its mode of port scanning to
ensure a reasonable coverage of hosts and ports is returned.
• Remember from the Nmap ping sweep usage the –P<type> flag specifies the protocol that is used for the
sweep?
• This flag is also used in port scans, but in this instance instructs Nmap how to identify the hosts to be
scanned.
• If this flag is omitted then the scanner will default to using a combination of ICMP ECHO and TCP port 80
to identify valid hosts.
• If a response is not received to the initial sweep requests within a given time then the target IP address will
NOT be port scanned.
• Using –P0 it is possible to instruct Nmap not to try to identify hosts to scan using ping, i.e. scan ALL IP
addresses.
• Once the target identification flag (-P<type>) has been set, then use the –s flag to specify the port scan
type. This defines the protocol (typically TCP or UDP but there are other types of malformed scans which
are commonly used to test firewall evasion) that is used for the scan.
• There are then other flags which can be used, including –p which specifies the port range (-p- specifies
ports 1-65535) as well as instructing Nmap to carry out additional supplementary functionality such as
Operating System fingerprinting (-O), network services banner grabbing (-sV) etc.
• The next slide provides more details on the various flags used in a port scan and the following slide
shows an example of conducting a portscan of a remote host using ICMP ECHO to identify the target
followed by a SYN scan on ports 80/TCP and 443/TCP.
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 36
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Enumerating Services
INTERNAL USE ONLY
-P<target id method> -s<portscan method) Other Common Options Output Type Targets
• -P0 – use nothing (portscan all) Most common scan types: - • -g <#> - source port of scans, • -oA <filename> - all • <TARGET IP,
• -PA – use ARP useful for fw evasion – try 20 output types range or list>
• -PI / -PE – use ICMP Echo • -sS – do a SYN scan and 53 (appends .gNmap / .
• -PM – use ICMP netmask • -sT – do a TCP full connect • -p – port range (e.g. 1-1024, Nmap and .xml) • -iL <text file of
• -PP – use ICMP Timestamp scan 21,22,23,53,80,443 or –p- for • -oN <filename> - targets>
• -PS80,443 – use TCP SYN on • -sU – do a UDP scan all) Nmap human
port 80 and 443 • -sL – don’t do a network scan • -O (Operating System fingerprint readable
• -PT80,443 – use full TCP at all, just list the targets to – careful on legacy systems can • -oG <filename> -
connect on port 80 and 443 the output (good for multiple cause crashes) Nmap machine
reverse DNS lookups or • -sV – poor choice of flag type by readable
generating target lists) Nmap author, but also conducts • -oX <filename> -
version fingerprinting of services XML output
More esoteric scan options – add to existing portscan • -oS <filename> -
(firewall testing): method script kiddy for lulz
• -sC – run additional scripts
• -sX – TCP XMAS scan (all • --reason – Nmap explains how it
flags set) came to determine the result in
• -sN – TCP Null scan (no flags the output
set) • --script – Nmap comes with lots
• -sA – TCP ACK scan (ACK of scripts that can enumerate
flag set) common info or identify
• -sF – TCP FIN scan (FIN flag vulnerabilities
set)
Also a number of timing options –
man Nmap
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 37
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Enumerating Services: Example Port Scanning with Nmap
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 38
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Enumerating Services: Understanding Nmap TCP Scan Output
INTERNAL USE ONLY
TCP is connection-orientated and therefore will provide responses in most cases to the
protocol opening sequence.
Nmap will report that each port on any given TCP scanned target is: -
• Open – received a TCP SYN/ACK response within the timeout interval.
• Closed – received a TCP RST response within the timeout interval.
• Filtered – Nmap did not receive a response in the timeout interval. This can mean: -
• The IP address is not being used at all or is completely protected by network security
firewall - particularly if all other ports are filtered (Filtered)
• The destination port is filtered by a firewall – if other ports on the target IP address are
open then this is likely to be the case (Filtered)
• Network conditions meant that a TCP response packet was not received prior to the
timeout – (WARNING! THE TESTER HAS MISSED SOMETHING!)
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 39
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Enumerating Services: Understanding Nmap UDP Scan Output
INTERNAL USE ONLY
Nmap will report that each port on any given UDP scanned target is: -
• Open – received a UDP packet back, the application protocol has responded, even to a likely mismatched
initial application protocol connection
• Closed – Nmap received an ICMP PORT_UNREACHABLE response.
• Open|Filtered – No response in the timeout interval. This can mean: -
• The UDP port is being used but the source did not send the correct application protocol sequence (Open)
• The IP address is not being used at all or is completely protected by network security firewall - particularly if
all other ports are filtered (Filtered)
• The destination port is filtered by a firewall (Filtered)
• Network conditions meant that a TCP response packet was not received prior to the timeout – (WARNING!
THE TESTER HAS MISSED SOMETHING! )
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 40
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Enumerating Services: Nmap Output
INTERNAL USE ONLY
The output from a TCP port scan Nmap output file might look like this: -
# Nmap 6.25 scan initiated Tue Feb 25 09:25:17 2014 as: Nmap -sS -v -oA portscan.tcp.services.europe -i europe.txt -sV -n
<CUT>
Nmap scan report for 192.168.204.2 Some ports are open but
remaining ports are closed
Host is up (0.068s latency). (more likely not behind a
All 1000 scanned ports on 192.168.204.2 are closed firewall)
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 41
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Enumerating Unknown Services: nc and ncat
INTERNAL USE ONLY
• Some ports are open, but do not respond with common protocol responses – Nmap
will not fingerprint them!
• nc and ncat are incredibly powerful tools – useful for:
• Port scanning (built-in scanning).
• Setting up network listeners (UDP and TCP) – with options to bind to program such as
cmd.exe.
• Probing unknown services or unusual ports and then try typing different commands and
inputting different text to elicit a response.
• It is important to probe all unknown/unusual ports
• When probing unknown service ports, send common protocol commands and other
sequences to the ports to determine whether they provide any further responses, as
demonstrated below.
• $ nc –nvv <IP address> <port>
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 42
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Poor man's nmap using netcat
INTERNAL USE ONLY
• Netcat is often installed on Linux boxes. Behold the poor man's port scanner:
tcp/21
tcp/53
tcp/80
tcp/135
tcp/139
tcp/445
tcp/3389
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 43
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Enumerating Hosts, Networks & Services – Joining it all Together
INTERNAL USE ONLY
• Enumeration progress so far: -
• Network maps.
• Multiple targets on different networks.
• Understanding of important online resources (name servers, active directory servers, file
servers, routers, firewalls, etc.).
• Available network application services (web servers, administrative login ports, databases) with
their vendors, versions and in some cases underlying Operating Systems and hostnames etc.
• This may be the stage at which to perform a vulnerability scan
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 44
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Enumerating Users - Windows
INTERNAL USE ONLY
• Always useful to enumerate user accounts of different services at this point – usually
easy to do and can come in useful – informs on username format (can then create
custom username dictionaries for brute-force attacks), and may have default or weak
credentials configured
• Windows-specific username enumeration:
• Null Connection / RID cycling (depending on registry settings of the servers – i.e.
RestrictAnonymous) tools include Getacct, sid2user/user2sid, Cain & Abel, enum4linux
• Misconfigured/open LDAP – multiple tools available for this
• SNMP – reveals users / groups on the box! (see earlier slides on SNMPwalk)
• Open SMB shares might reveal usernames (home directories)
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 45
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Enumerating Users - *nix
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 46
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Enumerating Users - Web
INTERNAL USE ONLY
• Web Servers:
• phpinfo() – PHP script that will return some information, sometimes usernames in paths /
processes
• Web server physical path leakage (sometimes within home directories containing a
username)
• Web content, can contain usernames in comments etc.
• Web application / management console logins – different responses for known / unknown
usernames
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 47
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Windows User Enumeration: Null/Anonymous and RID Cycling
INTERNAL USE ONLY
• Windows allows systems to legitimately make remote requests for users, groups and
other information from a remote device.
• In earlier versions of Windows this was enabled by default. In the latest versions of
Windows Server and Desktop software, the functionality is disabled by default.
• However, if the software is upgraded (rather than a fresh re-install) then the previous
setting (the RestrictAnonymous registry key) still applies.
• When RestrictAnonymous is set to 0, a great deal of information can be retrieved
including users, groups, password policy information, shares etc. This can be
enumerated via a null / anonymous connection to the device.
• When RestrictAnonymous is set to 1 then null connections are refused, however, a
method known as RID Cycling can be used to enumerate usernames from given User
ID formats. Incremental calls can be made to enumerate users on the system, though it
should be noted that users that are ‘deleted’ or disabled will still be provided.
• Local Administrator account (nearly) always has a RID value of 500 and the guest 501.
User / machine accounts then start from 1000.
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 48
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Windows User Enumeration: Null/Anonymous and RID Cycling
INTERNAL USE ONLY
• Enumeration tools:
• getacct
• enum
• enum4linux
• Cain & Abel
• Nessus
• Metasploit
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 49
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Enum4linux
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 50
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Unix Username Enumeration: Finger
INTERNAL USE ONLY
• Finger is a legacy Unix service, it was used when the network was a much ‘friendlier’ place. Its
function was used to determine when colleagues may be using remote workstations.
• Without the use of a username (finger @<IP address>) it responds with who is logged onto the
workstation.
• When a username is provided (finger <user>@<IP address>) it responds with useful information
such as whether that user exists, where they logged in from and their last login time. This is
useful for profiling targets and identifying IP addresses of administrative workstations or other
servers.
• Different uses of finger:
• $ finger @ip-address (might return all the logged in users)
• $ finger "a b c d e f g h"@ip-address (Solaris bug that returned all users ( < Early Solaris 8))
• $ finger "1 2 3 4 5 6 7 8 9 0"@ip-address (Solaris)
• $ finger 0@ip-address (returns users with blank GECOS entries - Solaris)
• $ finger -l .@ip-address
• $ finger -l **@ip-address
• $ finger -l user@ip-address
• The perl script fist.pl automates this and often finds multiple users.
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 51
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Unix Username Enumeration: Rusers / RWho
INTERNAL USE ONLY
• Similar to finger, these (below) are legacy Unix RPC services.
• Rusers displays a list of logged in users
• $ rusers –la <IP address>
• Rwho collects broadcast information from other machines on the network and collates
who is logged in. This is functionality is very rarely in use, but if you have
compromised a remote legacy machine in a cluster then it may be worth attempting:
• $ rwho
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 52
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Unix Username Enumeration: Sendmail SMTP Enumeration
INTERNAL USE ONLY
• By default, the Sendmail service (commonly on 25/TCP) will allow remote guessing of
usernames on the system using a variety of verbs.
• Depending on the response from the server to the guessing attempts, it may be
possible to identify whether the username is valid or not, by comparing the responses.
• Try these commands on Sendmail (and other) SMTP services (use Netcat or Telnet): -
■ VRFY <username>
■ EXPN <username>
■ HELO localhost
■ MAIL FROM: <root>
■ RCPT TO: <username>
• Many tools and scripts exist to automate the process, including Hydra (see following
slides).
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 53
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Exercise 2: Duration 20 minutes
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 54
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Exercise 3: Duration 15 minutes
INTERNAL USE ONLY
• Enumerate all hosts on the 10.0.2.0/24 network. Identify any domains and enumerate
those.
• Enumerate users and password policies.
• Explore the tools (and any others) from the previous slides.
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 55
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Vulnerability Enumeration Automated…
INTERNAL USE ONLY
• Nessus is a great tool to baseline vulnerabilities and to supplement the test findings.
• You should run Nessus against prioritised, known, live hosts only. It’s good practice to
input only lists of ‘up’ hosts enumerated during host discovery phase.
• Nessus scan policy – It is important to define this depending on the network.
• Care should be taken to configure a default policy that works for you and is tailored on a
per-test basis, to be specific to the environment (ensure verbose reporting is enabled!).
• This phase isn’t just about interpreting Nessus output, as Nessus lacks the context of a
network and people. This is where we need to provide insight and make connections
between the findings. For example;
• Anonymous FTP – Nessus won’t know if an excel spreadsheet served via anonymous FTP
contains domain usernames and passwords. Nessus would mark this a medium-level finding.
• Unknown software – Nessus only knows about common software. A bespoke telnet
application may be running for example, which has a number of vulnerabilities, however,
Nessus cannot evaluate this.
• It’s also worth noting that Nessus is very limited in what it can detect within Web Applications.
• Useful: Nessus can filter by ‘has exploit’ and can cross-reference this with Metasploit.
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 56
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Vulnerability Scans – Be careful!
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 57
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Vulnerability Enumeration MANUAL!
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 58
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Vulnerability Enumeration MANUAL!
INTERNAL USE ONLY
• Often, there are many reasons why a scanner will not find a vulnerability or weakness:
• The service is running on a non-standard port.
• Network / Server / Client performance conditions lead to a timeout.
• The scanner is buggy (believe it or not).
• Intrusion Detection and Prevention identified the scanner and blocked all subsequent attempts.
• Smart system administrators change the configuration of targets during the test.
• Misconfigured scanner configuration or policy.
• A vulnerability that exists on the network is complex or multi-staged and cannot be identified by
a scanner.
• The scanner is not conducting password guessing / dictionary / brute force attacks
• The scanner does not interpret Web / FTP / Telnet site content
• The scanner does not try combinations of input to a network application based on the context of
the environment.
• Ultimately a penetration tester is smarter than Nessus!
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 59
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Vulnerability Enumeration - MANUAL!
INTERNAL USE ONLY
• Find your own vulnerabilities – firstly, investigate the applications and versions that
were identified from the previous phases.
• Don’t forget to look at information from web servers, e.g. SAP, ColdFusion, .NET, PHP
server applications as well as off the shelf web content (lots of content is vulnerable).
• Appliances can also be vulnerable to specific weaknesses and exploits.
• Check common information security vulnerability sources (Securityfocus, exploit-db,
CVE/NVD et al) and use search engines.
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 60
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Vulnerability Enumeration - MANUAL!...
INTERNAL USE ONLY
• Be thorough, do not give up if the answer is not on the first page of results!
• Determine whether some weaknesses lead to information leakage that could assist
with other exploits, e.g. anonymous connections, RID cycling, SNMP on a Windows
system, finger, SMTP VRFY/EXPN / RUSERS et al on a *nix box, or PHPINFO, physical
path revelation issues, Apache server-status on web servers.
• Piece together all of the elements of the ‘jigsaw’ and hopefully it will solve the puzzle!
Use information from one finding and feed it into another exploit attempt. For example,
take a username identified from an information leak and try and login to all open SSH
ports using that username and common passwords.
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 61
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Exercise 4: Vulnerability Enumeration: Duration 20 minutes
INTERNAL USE ONLY
• How many critical and high risk vulnerabilities exist for each host?
• How many Metasploit exploits exist for each host?
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 62
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Automated Password Guessing
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 63
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Password Bruteforcing – Be careful!
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 64
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Automated Password Guessing (medusa)
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 65
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Automated Password Guessing (hydra)
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 66
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Windows Remote Exploitation
INTERNAL USE ONLY
• It is also possible to attempt the exploitation of specific flaws in the software, setup
and configuration of the target system.
• Different types of Windows exploitation include:
• Exploiting actual software flaws in the Operating System or additional software
installed (many Windows Backup software remote listeners became targets) -
Metasploit is your friend- ensure your copy is working and up-to-date. Spend time learning
how to use it – it is an invaluable framework for infrastructure penetration testing
• Metasploit is an advanced tool that could have a training course to itself, but for further
reading, an excellent resource:
http://www.offensive-security.com/metasploit-unleashed/Introduction
• Remote shares are often open to abuse:
• >net view \\<host>
• >net use \\<host>\<sharename> (or just connect to \\<host> in an explorer window)
• Misconfiguration of services – e.g. anonymous FTP, default passwords
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 67
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
*nix Remote Exploitation
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 68
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Application Layer Remote Exploitation
INTERNAL USE ONLY
• It is also possible to exploit additional applications that are installed on the system.
• Common quick wins with a high degree of confidence and low risk are:
• JBOSS and Tomcat manager (without credentials or with default username / password)
• Anything PHP can be a good bet
• Look out for Heartbleed and Shellshock too
• Investigate other web servers running on target systems to determine whether they
have default credentials, poorly configured scripts or leak useful information that might
be used to gain access to other elements of the service.
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 69
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Using Metasploit (carefully!)
INTERNAL USE ONLY
./msfupdate (or similar depending on how you use Metasploit)
> search <term*>
> use <exploit>
> show options
> info <module name> give info on the exploit, including rating on performance of exploit
> set PAYLOAD <payload>
• Good PAYLOAD for windows is: windows/meterpreter/reverse_tcp
> check (for some exploits, you can check if host is vulnerable)
> exploit
If exploit works:
>getsystem
>hashdump
>search <term> is useful to search for exploits relating to different services or products
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 70
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Windows Local Privilege Escalation
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 71
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Windows Local Privilege Escalation
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 72
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Windows Local Privilege Escalation
INTERNAL USE ONLY
• More…
• Kon-boot
• Metasploit Browser autopwn
• Unquoted Service Paths
• E.g. Service that runs as SYSTEM and is defined using an unquoted path of:
• C:\SomeApp\Program Folder\bin\servicebinary.exe
• If your user can create a file Program.exe in C:\SomeApp\ this will be used and Folder\
bin\servicebinary.exe will be interpreted as arguments to the binary
• Create binary, place in location and reboot the box
• SYSTEM access
• Metasploit also has lots of post modules that collect data or attempt escalation
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 73
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Post local privilege escalation – what next?
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 74
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Mimikatz
INTERNAL USE ONLY
Wouldn't it be great if we could just read the plaintext password instead of cracking the
hash?
• Windows caches user passwords in the memory in order to handle WDIGEST
authentication
• Mimikatz can extract these passwords
• Available as standalone EXE (will get detected by AV)
• Meterpreter has it built in these days
• > use mimikatz
• > wdigest
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 75
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Aside: Effective Password Cracking
INTERNAL USE ONLY
• Rainbow tables are the best option for fast password cracking - ophcrack is a great
tool with good free tables. The downside is that rainbow tables take up disk space, so
it’s worth working out how you’re going to do your cracking in advance, make sure you
consider protective marking restrictions also.
• John the Ripper (JTR) – supports many hash types, and it is possible to automate
cracking with the MSF. In cases where the hashes are not salted, such as some MD5 or
SHA256 deployments, you can use Google as a cracking engine, as lots of indexed
sites have collision data on them.
• Ensure that you know what the password policy is on a host!
• It is a waste of time brute-forcing with inaccurate dictionary word-lengths, you should
customise your dictionary or JTR rules to crack against the relevant password policy.
More information can be found here: http://www.openwall.com/john/doc/RULES.shtml
• Lab or cloud cracking may also be an option. Think!
• KPMG’s Dutch team have a big password cracking capability, maybe we can become
friends
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 76
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Aside: Pass-the-Hash/Windows Credential Editor (WCE)
INTERNAL USE ONLY
• Windows Credentials Editor (WCE) allows listing of logon sessions and adding,
changing, and deleting associated credentials (ex.: LM/NT hashes).
• This can be used for example, to perform pass-the-hash on Windows and also obtain
NT/LM hashes from memory (from interactive logons, services, remote desktop
connections, etc.) which can be used in further attacks.
• WCE v1.2 supports obtaining logon sessions and NTLM credentials just by reading
memory without performing code injection.
• Windows Credentials Editor supports Windows XP, 2003, Vista, 7 and 2008.
• Note: This tool requires administrator privileges and currently doesn’t run on 64-bit
• Pass the hash functionality is available in Metasploit using Incognito
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 77
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Exercise 5: Duration 30 minutes
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 78
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Anti-virus
INTERNAL USE ONLY
Only trouble with Metasploit is most Anti-virus detects and blocks many of its payloads
• Even its default evasion techniques are detected!
• If you see something like this:
[*] Fingerprint: Windows 2003 - Service Pack 1 - lang:Unknown
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 79
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Evading Anti-virus
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 80
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Veil Evasion
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 81
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Veil Evasion Command Line
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 82
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Veil Catapult
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 83
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Veil Catapult Command Line
INTERNAL USE ONLY
Other options can be used which are passed to veil-evasion for payload generation.
An example command line:
• veil-catapult –t somehost –exe /tmp/VEIL.exe –winexe –U administrator –P password –act upexec
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 84
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Exercise 6: Duration 20 minutes
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 85
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
*nix Local Privilege Escalation
INTERNAL USE ONLY
In *nix – think of EVERYTHING as a file. All *nix privilege escalations therefore relate to
examination and manipulation of file permissions. Common escalation techniques
include:
■ Cron - allows tasks to be automatically run in the background at regular intervals by the cron
daemon – recorded in crontab.
■ suid/guid/ and world-writeable files and services/scripts / permission manipulation
■ .bash_history – if accessible, often leak information
■ search for files containing *pass*, *.bak etc.
■ Searching in /tmp directory often reveals interesting content
■ Local exploits – exploit-db
■ sudo - allows users to run programs with the security privileges of another user. If root then
win! Check sudoers file if accessible or just try sudo bash
■ Always be aware of ‘<element>.allow’ and ‘<element>.deny’ files, these can assist or prohibit
escalation.
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 86
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Crontab
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 87
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
File permission abuse
INTERNAL USE ONLY
To find all SUID files find / -xdev -type f -perm +u=s –print
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 88
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
sudo
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 89
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
*nix local package checking and automating escalation vectors
INTERNAL USE ONLY
Debian dpkg -l
If your permissions allow upload, a host audit script can be executed to speed up the process of
finding potential security issues.
Unix-privesc-checker:
Unix-privesc-checker is a script that runs on Unix systems (tested on Solaris 9, HPUX 11, Various
Linuxes, FreeBSD 6.2). It tries to find misconfigurations that could allow local unprivileged users
to escalate privileges to other users or to access local apps (e.g. databases). More information
and download can be found here: http://code.google.com/p/unix-privesc-check/
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 90
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Unix shells
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 91
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
SSH
INTERNAL USE ONLY
• SSH is an awesome tool.
• TCP Port forward and Dynamic SOCKS proxying alone are worth using it for
• Fantastic for pivoting through Unix/Linux hosts
• Most important command lines to remember:
• ssh –L <local port number>:<remote IP address>:<remote port number> host
• ssh –R <remote port number>:<local IP address>:<local port number> host
Examples:
We can now connect to localhost:80 which will in turn connect us to 192.168.1.1 on tcp/80 via the host
192.168.1.5.
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 92
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Exercise 8: Exploiting NFS and SSH configurations
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 93
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Reflection. Key Learning Points
INTERNAL USE ONLY
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 94
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
Useful Guides/Lists/Tools
INTERNAL USE ONLY
http://www.vulnerabilityassessment.co.uk/Penetration%20Test.html
http://www.mindcert.com/resources/
© 2011 KPMG LLP, a UK limited liability partnership, a subsidiary of KPMG Europe LLP and a member firm of the KPMG network of independent 95
member firms affiliated with KPMG International Cooperative ('KPMG International'), a Swiss entity. All rights reserved.
© 2014 KPMG LLP, a UK limited liability partnership, a
subsidiary of KPMG Europe LLP and a member firm
of the KPMG network of independent member firms
affiliated with KPMG International Cooperative
('KPMG International'), a Swiss entity. All rights
reserved.