﻿WEBVTT

00:00:00.000 --> 00:00:03.486
[RHYTHMIC ELECTRONIC MUSIC]

00:00:14.940 --> 00:00:17.928
[MELODIC ELECTRONIC MUSIC]

00:00:27.400 --> 00:00:29.710
Hello, and welcome to
the Hacker House Hands

00:00:29.710 --> 00:00:34.330
On Hacking practical module for
the NAS module of our course.

00:00:34.330 --> 00:00:37.030
So I've got here on my screen
my VirtualBox environment.

00:00:37.030 --> 00:00:39.610
I'm currently running
my Kali Linux install,

00:00:39.610 --> 00:00:44.650
and I've got here my lab set
up to use the file server ISO.

00:00:44.650 --> 00:00:46.360
I double checked my
host only adapter

00:00:46.360 --> 00:00:48.230
to make sure we're
running in a sandbox,

00:00:48.230 --> 00:00:50.740
so that we don't impact any
other resources on our network

00:00:50.740 --> 00:00:55.710
and we can test our attacks
and systems exploits out.

00:00:55.710 --> 00:00:57.950
So I'm going to boot
this nice appliance now--

00:00:57.950 --> 00:01:00.610
and remember, if you don't get
an IP address straight away,

00:01:00.610 --> 00:01:02.470
simply hitting
return a few times

00:01:02.470 --> 00:01:04.989
is often sufficient to
give you the IP address.

00:01:04.989 --> 00:01:06.780
But we can see here,
once again, I've

00:01:06.780 --> 00:01:10.293
been given the IP
address 192.168.56.3,

00:01:10.293 --> 00:01:11.710
and that's because
I'm continually

00:01:11.710 --> 00:01:14.550
reusing the same lab and
swapping over the CD.

00:01:14.550 --> 00:01:17.050
However, if you do that, it's
important to remember that you

00:01:17.050 --> 00:01:20.468
might need to clear your browser
cache after each adventure,

00:01:20.468 --> 00:01:22.510
because otherwise, you
may find that your caching

00:01:22.510 --> 00:01:26.080
some information on your local
machine, which will be reused,

00:01:26.080 --> 00:01:28.300
and you may not get the same--

00:01:28.300 --> 00:01:31.180
the same output or experiences
you're seeing on the screen,

00:01:31.180 --> 00:01:31.880
here.

00:01:31.880 --> 00:01:33.838
So ensure that you clear
your browsing history.

00:01:33.838 --> 00:01:36.190
Make sure you've got no kind
of lingering data lingering

00:01:36.190 --> 00:01:37.180
around in there.

00:01:37.180 --> 00:01:42.160
And then we can ping that IP
address, and we are good to go.

00:01:42.160 --> 00:01:44.060
We're good to start
scanning that server.

00:01:44.060 --> 00:01:45.518
So the first thing
we do when we're

00:01:45.518 --> 00:01:48.222
trying to scan a server is
initially review its footprint,

00:01:48.222 --> 00:01:49.930
have a look at what
kind of service ports

00:01:49.930 --> 00:01:50.923
it might have open.

00:01:50.923 --> 00:01:52.840
I'm just running a
standardized Nmap Remember,

00:01:52.840 --> 00:01:54.368
this isn't a comprehensive scan.

00:01:54.368 --> 00:01:56.410
It will just find a couple
of common ports for me

00:01:56.410 --> 00:01:58.220
and show me what
they are all about.

00:01:58.220 --> 00:02:00.760
Because we're now on an
internal network perspective,

00:02:00.760 --> 00:02:03.920
and we're somehow situated
inside the internal network,

00:02:03.920 --> 00:02:05.920
we're perhaps not as
worried about firewalls,

00:02:05.920 --> 00:02:08.410
so we could now try out maybe
some of those buying payloads

00:02:08.410 --> 00:02:10.030
or all those-- because
the firewall is

00:02:10.030 --> 00:02:11.697
less likely to be in our way.

00:02:11.697 --> 00:02:13.780
But we can see here that
we've got a standard what

00:02:13.780 --> 00:02:16.090
looks like a network
appliance of some sort,

00:02:16.090 --> 00:02:18.460
we've got FTP, Telnet, RPC--

00:02:18.460 --> 00:02:20.620
common kind of Windows
sharing services,

00:02:20.620 --> 00:02:22.520
all this-- common
internet file system.

00:02:22.520 --> 00:02:25.780
Into ipp-- some kind of printer
sharing-- rsync and something

00:02:25.780 --> 00:02:26.637
called NFS.

00:02:26.637 --> 00:02:28.720
So we've got a number of
different services there.

00:02:28.720 --> 00:02:30.895
We would begin with our
banner grabbing process,

00:02:30.895 --> 00:02:33.195
we connect to each of
those ports on port 21.

00:02:33.195 --> 00:02:35.320
You can see there we've
got a welcoming banner that

00:02:35.320 --> 00:02:37.370
tells us some information.

00:02:37.370 --> 00:02:40.480
So if I was to connect to this
service and try, OK, USER FTP,

00:02:40.480 --> 00:02:41.500
PASS FTP--

00:02:41.500 --> 00:02:44.020
ah, we can see here that this
one's actually successful.

00:02:44.020 --> 00:02:47.920
And if I type stat, we can see
that it says here that this

00:02:47.920 --> 00:02:51.337
is version 2.3.4 of the vsftpd.

00:02:51.337 --> 00:02:53.170
So we can actually find
the version number--

00:02:53.170 --> 00:02:55.480
not from the welcoming
banner, but from querying it

00:02:55.480 --> 00:02:59.120
from the stacked command or
status on the remote server.

00:02:59.120 --> 00:03:02.470
It says client count was 1, and
it gives me some information

00:03:02.470 --> 00:03:04.260
about that system.

00:03:04.260 --> 00:03:05.320
It gives you the status--

00:03:05.320 --> 00:03:07.295
the status of what
I'm connected to.

00:03:07.295 --> 00:03:08.920
So if I was to come
out of that system,

00:03:08.920 --> 00:03:10.720
could I just type
that by itself?

00:03:10.720 --> 00:03:11.620
It says no.

00:03:11.620 --> 00:03:14.730
If I was to try USER
anonymous, PASS anonymous--

00:03:17.810 --> 00:03:20.270
we can see that we can
log into that FTP server.

00:03:20.270 --> 00:03:23.510
So I'll now log into that FTP
server using an FPT client,

00:03:23.510 --> 00:03:26.810
and I'll try FTP FTP, and
I'll list the files in there--

00:03:26.810 --> 00:03:29.210
and what we can do is we
can now explore the contents

00:03:29.210 --> 00:03:30.808
of that FTP server.

00:03:30.808 --> 00:03:33.350
I'm going to also have a look
at some of the other ports that

00:03:33.350 --> 00:03:35.090
are out there, but
before I do so,

00:03:35.090 --> 00:03:37.700
I'm going to kick off a
more comprehensive scan.

00:03:37.700 --> 00:03:42.970
I'm going to do Nmap minus sT
-P, disable pings, disable DNS,

00:03:42.970 --> 00:03:45.950
and then I will do default
scripts, do aggressive mode,

00:03:45.950 --> 00:03:48.480
vv, and then disable--

00:03:48.480 --> 00:03:54.530
then once I've got those
in, do a full 65K handshake.

00:03:54.530 --> 00:03:57.470
So, connect scan,
disable pings, disable

00:03:57.470 --> 00:03:59.240
DNS-- to increase the
speed of my scans.

00:03:59.240 --> 00:04:00.740
You don't need to
disable these two,

00:04:00.740 --> 00:04:02.870
but you'll get faster
responses when you do.

00:04:02.870 --> 00:04:05.837
-sC, especially if you
know the host is alive.

00:04:05.837 --> 00:04:07.670
If you don't know whether
the host is alive,

00:04:07.670 --> 00:04:09.170
you might want to
leave these on.

00:04:09.170 --> 00:04:13.550
-sC will then do
default scripts.

00:04:13.550 --> 00:04:15.950
-A for be aggressive--
do some fingerprinting,

00:04:15.950 --> 00:04:18.470
be verbose, tell me what's
going on on the screen.

00:04:18.470 --> 00:04:23.030
-p- And then I want to run the
probes against this server.

00:04:23.030 --> 00:04:25.730
And then I'm going to make sure
that I dump it out to a file

00:04:25.730 --> 00:04:27.710
called Nmap.txt and Nmap.xml.

00:04:37.265 --> 00:04:39.890
Now, we can see here we've got
a number of other open services,

00:04:39.890 --> 00:04:41.060
including things like Telnet.

00:04:41.060 --> 00:04:42.685
So if we were to
Telnet to that server,

00:04:42.685 --> 00:04:45.140
we can see now Telnet into
that server has given us

00:04:45.140 --> 00:04:46.320
Linux welcoming banner.

00:04:46.320 --> 00:04:48.320
It's giving us the kernel
version of the server,

00:04:48.320 --> 00:04:50.510
and we can see that that is
in fact an out of date kernel

00:04:50.510 --> 00:04:52.802
version, we should recognize
that it's a version that's

00:04:52.802 --> 00:04:54.290
vulnerable to Dirty COW.

00:04:54.290 --> 00:04:56.630
So we know that this server
has privilege escalations,

00:04:56.630 --> 00:04:58.880
we know that it's running
out of date software-- just

00:04:58.880 --> 00:05:00.590
by connecting to the
welcoming banner.

00:05:00.590 --> 00:05:02.570
But if we were on
the FTP service

00:05:02.570 --> 00:05:04.822
now, if we go in to
see the backup ls,

00:05:04.822 --> 00:05:06.530
we can see there's a
file called Read Me.

00:05:06.530 --> 00:05:08.360
If we go into
incoming ls, we can

00:05:08.360 --> 00:05:09.600
see there's nothing in there.

00:05:09.600 --> 00:05:12.260
So I'm going to go to the backup
directory on the FTP server,

00:05:12.260 --> 00:05:14.100
and I'm going to
type get Read Me.

00:05:14.100 --> 00:05:16.970
So I've downloaded that Read Me
file into my local directory,

00:05:16.970 --> 00:05:18.710
and if I open that
Read Me file, you

00:05:18.710 --> 00:05:21.170
can see here it says, "the
system backup account is

00:05:21.170 --> 00:05:23.810
configured to run under
the user backupserv,

00:05:23.810 --> 00:05:25.715
and it uses rsync to
access remote files

00:05:25.715 --> 00:05:28.640
and install them in the FTP
server for nightly collection.

00:05:28.640 --> 00:05:31.100
Speak to Dave for help
with this application."

00:05:31.100 --> 00:05:33.740
So this is a kind of a
backup account or some kind

00:05:33.740 --> 00:05:36.320
of backup service that's
using this storage account,

00:05:36.320 --> 00:05:38.497
and it says here the
user is backupserv.

00:05:38.497 --> 00:05:40.080
So if I see something
like backupserv,

00:05:40.080 --> 00:05:42.710
I perhaps create some
passwords, maybe.

00:05:42.710 --> 00:05:45.800
If I go to Word Lists , have
a look at weak passwords,

00:05:45.800 --> 00:05:48.950
maybe I'll add the password
backup into weak passwords,

00:05:48.950 --> 00:05:52.230
I'll add the userbackupserv
into weak passwords.

00:05:52.230 --> 00:05:55.040
And then, perhaps I could do
with hydra, and say well, OK.

00:05:55.040 --> 00:05:56.270
Hydra, minus, minus, help.

00:05:56.270 --> 00:05:57.770
Let's see if I can
try a brute force

00:05:57.770 --> 00:06:01.430
attack against that Telnet
interface, do Hydra minus L,

00:06:01.430 --> 00:06:03.650
and then we'll give
it just a user--

00:06:03.650 --> 00:06:05.960
and I'll give it
the backupserv user.

00:06:05.960 --> 00:06:09.080
And then I'll say,
OK, well P, pass list.

00:06:09.080 --> 00:06:12.515
I'll try word lists--
you know, weak passwords.

00:06:12.515 --> 00:06:14.990
And we could try a brute
force against this server

00:06:14.990 --> 00:06:18.325
and see whether or not that
would actually let us in.

00:06:18.325 --> 00:06:20.200
Remember, you're not
allowed to use this tool

00:06:20.200 --> 00:06:21.760
if you're a member
of the military

00:06:21.760 --> 00:06:24.490
or if you're involved in a
Secret Service organization,

00:06:24.490 --> 00:06:27.640
as it would be against the
license restrictions designated

00:06:27.640 --> 00:06:28.500
by its author--

00:06:28.500 --> 00:06:29.695
van Hauser from THC.

00:06:34.760 --> 00:06:37.555
Now we can see the Telnet
attempt, we tried to log in--

00:06:37.555 --> 00:06:40.180
but we'll see whether we get any
success with those brute force

00:06:40.180 --> 00:06:40.830
attacks.

00:06:40.830 --> 00:06:43.240
But looking through here,
we can actually see now--

00:06:43.240 --> 00:06:44.740
we look at our
Nmap output, we can

00:06:44.740 --> 00:06:47.500
see that Nmap has run a
number of default scripts.

00:06:47.500 --> 00:06:49.510
It's identified some
other open services,

00:06:49.510 --> 00:06:51.755
it's got some network
filing services up there,

00:06:51.755 --> 00:06:54.130
and we can have a look at some
of those in just a second,

00:06:54.130 --> 00:06:54.760
as well.

00:06:54.760 --> 00:06:58.180
So we've got NAS, I think?

00:06:58.180 --> 00:06:59.470
Did we just save that file?

00:06:59.470 --> 00:07:00.580
Nmap.txt.

00:07:00.580 --> 00:07:03.790
So I'm going to do
xsltproc, Nmap.xml.

00:07:03.790 --> 00:07:07.230
I'm going to convert that
file now to NAS.html.

00:07:07.230 --> 00:07:08.860
And then I'm going
to open that file

00:07:08.860 --> 00:07:11.350
and just look at it in
a human, readable way.

00:07:14.420 --> 00:07:16.490
Deal with this nice,
pretty, formatted table--

00:07:16.490 --> 00:07:18.290
so I can actually see
what information I've

00:07:18.290 --> 00:07:20.838
got from my port scans in a
very clear and concise way.

00:07:20.838 --> 00:07:22.880
And in fact, we can see
all these various scripts

00:07:22.880 --> 00:07:25.400
that have run, giving us
extra information from things

00:07:25.400 --> 00:07:26.300
like the SMB--

00:07:26.300 --> 00:07:27.838
or Server Message
Block service--

00:07:27.838 --> 00:07:29.630
and we'll look at that
slightly afterwards.

00:07:29.630 --> 00:07:31.370
But for the moment, we're going
to concentrate on these lower

00:07:31.370 --> 00:07:32.510
ports down here.

00:07:32.510 --> 00:07:35.220
We've done this FTP service,
we found these files in here,

00:07:35.220 --> 00:07:37.220
we found that there's a--
running an out of date

00:07:37.220 --> 00:07:39.560
version of vsftp, perhaps.

00:07:39.560 --> 00:07:41.390
We've also seen there's
a Telnet service--

00:07:41.390 --> 00:07:43.927
but above that, we can see
there's an RPC info service.

00:07:43.927 --> 00:07:46.010
So we're not having much
luck with our brute force

00:07:46.010 --> 00:07:47.750
attack for the
moment, but what we'll

00:07:47.750 --> 00:07:51.730
do is, we'll try RPC info and
query that remote service.

00:07:51.730 --> 00:07:53.450
And as you can
see, with RPC info,

00:07:53.450 --> 00:07:57.110
we can see port mapper, NFS,
and lock manager mountd.

00:07:57.110 --> 00:08:01.380
We can see these various options
that might be available there.

00:08:01.380 --> 00:08:03.500
So you can see it's
[INAUDIBLE] 16 tries a minute.

00:08:03.500 --> 00:08:06.020
Doesn't seem to be successfully
doing a brute force

00:08:06.020 --> 00:08:07.250
attack against there.

00:08:07.250 --> 00:08:11.882
You could also perhaps try
it against the FTP service--

00:08:11.882 --> 00:08:14.450
I'll do rm minus
rf hydra restore--

00:08:14.450 --> 00:08:17.330
and try to do a brute force
attack against the FTP service

00:08:17.330 --> 00:08:19.080
and see if that works.

00:08:19.080 --> 00:08:21.890
Oh, and in fact here, we
now see the FTP service

00:08:21.890 --> 00:08:23.390
was successfully brute forced.

00:08:23.390 --> 00:08:25.943
The backup service user
account password was backup.

00:08:25.943 --> 00:08:27.860
So we want you to get
into the habit of that--

00:08:27.860 --> 00:08:29.180
same user, same password.

00:08:29.180 --> 00:08:30.350
Maybe some variation.

00:08:30.350 --> 00:08:32.539
So not a very-- not a
very difficult password.

00:08:32.539 --> 00:08:33.659
So that was backup.

00:08:33.659 --> 00:08:36.630
So if I was to Telnet
to that server now,

00:08:36.630 --> 00:08:39.770
can I log in as backupserv,
and the password of backup?

00:08:39.770 --> 00:08:41.280
And as you can see,
we're now logged

00:08:41.280 --> 00:08:44.700
into that computer using a
low privileged backup service

00:08:44.700 --> 00:08:45.510
account.

00:08:45.510 --> 00:08:47.880
So we've got some limited
access to command shells,

00:08:47.880 --> 00:08:51.005
we've got some ability to
look around the file system.

00:08:51.005 --> 00:08:53.130
However, there are other
things on this server that

00:08:53.130 --> 00:08:58.140
are of interest, and when we've
run RPCinfo, we do RPCinfo -p,

00:08:58.140 --> 00:09:01.680
we can actually see that
we've got RPC information.

00:09:01.680 --> 00:09:04.470
So when that port scan
was returned there,

00:09:04.470 --> 00:09:06.680
you saw that it was
an open port 111.

00:09:06.680 --> 00:09:12.300
This RPC buying service or
RPC program number 100,000

00:09:12.300 --> 00:09:15.030
is the RPC port mapper
service, and its job

00:09:15.030 --> 00:09:18.570
is to map remote procedural
programs to port numbers.

00:09:18.570 --> 00:09:20.190
We're going to do a
lot of a deep dive

00:09:20.190 --> 00:09:22.338
through some RPC and
RPC vulnerabilities,

00:09:22.338 --> 00:09:23.880
so I don't want you
to panic too much

00:09:23.880 --> 00:09:25.830
about what all of this
stuff means for the moment.

00:09:25.830 --> 00:09:28.120
Just know that here on the
left is the program number--

00:09:28.120 --> 00:09:30.037
that's the RPC, or the
remote procedure called

00:09:30.037 --> 00:09:31.920
the application
that we can talk to,

00:09:31.920 --> 00:09:34.080
the version of the
protocol it supports,

00:09:34.080 --> 00:09:36.930
and whether it's UDP or
TCP, and the port number

00:09:36.930 --> 00:09:37.980
that it relates to.

00:09:37.980 --> 00:09:39.865
And here we can see
we've got mountd in NFS--

00:09:39.865 --> 00:09:41.490
these are some of
the requirements that

00:09:41.490 --> 00:09:45.278
are necessary for us to be able
to mount a remote file system.

00:09:45.278 --> 00:09:47.070
So how can we interrogate
that file system?

00:09:47.070 --> 00:09:50.230
When you see it's got 2-0-4-9,
is an Open Service port.

00:09:50.230 --> 00:09:52.440
So we need to check--
can we see 2-0-4-9?

00:09:52.440 --> 00:09:52.980
Yes, we can.

00:09:52.980 --> 00:09:54.570
We've got access
to the NFC service,

00:09:54.570 --> 00:09:56.430
and some of these
higher ports down here

00:09:56.430 --> 00:10:00.340
appear to be NFS
related and RPC related.

00:10:00.340 --> 00:10:02.080
You even have the
program numbers there.

00:10:02.080 --> 00:10:03.590
So you could map
those from this--

00:10:03.590 --> 00:10:04.350
from this output.

00:10:04.350 --> 00:10:07.410
We can see we've got mountd,
NFS, and Lock Manager--

00:10:07.410 --> 00:10:09.390
common service ports
that we might need

00:10:09.390 --> 00:10:11.340
to mount an NFS file system.

00:10:11.340 --> 00:10:14.430
The way we would do that
is you show mount -e.

00:10:14.430 --> 00:10:19.470
If you were to run showmount -e,
192.168.56.3, what that will do

00:10:19.470 --> 00:10:21.570
is it will connect
to the NFS service

00:10:21.570 --> 00:10:23.580
and show us any of the
exported mount lists.

00:10:23.580 --> 00:10:27.990
And we can see here the
export list for 192.168.56.3

00:10:27.990 --> 00:10:30.502
includes slash data
and slash home.

00:10:30.502 --> 00:10:32.460
However, /home doesn't
have a star next to it--

00:10:32.460 --> 00:10:34.440
it has an explicitly
defined subnet.

00:10:34.440 --> 00:10:36.060
This is an access
control list that

00:10:36.060 --> 00:10:37.710
says that unless
I'm in this subnet,

00:10:37.710 --> 00:10:39.540
I'm not allowed to
mount this file system,

00:10:39.540 --> 00:10:42.900
so I would not be able to mount
the home directory due to an IP

00:10:42.900 --> 00:10:43.980
access control list.

00:10:43.980 --> 00:10:46.320
However, the star says,
anyone can access this

00:10:46.320 --> 00:10:48.920
from any IP address, so I
could attempt to mount that.

00:10:48.920 --> 00:10:54.840
So I will do mount 102.168.56.3,
colon, slash data, and then

00:10:54.840 --> 00:10:57.360
I'll do slash mount, slash data.

00:10:57.360 --> 00:10:59.110
You might have to make
slash [INAUDIBLE],,

00:10:59.110 --> 00:11:01.930
slash mount, slash data if
you don't have a file there,

00:11:01.930 --> 00:11:04.000
but I have it already
created on my system,

00:11:04.000 --> 00:11:06.050
so I'll ls-al slash data.

00:11:06.050 --> 00:11:07.900
And if you check the
output of mounts now,

00:11:07.900 --> 00:11:10.750
you can see that
there is a mounted NFS

00:11:10.750 --> 00:11:11.890
share on my system--

00:11:11.890 --> 00:11:16.408
192.168.56.3-- slash data
has been mounted with NFS.

00:11:16.408 --> 00:11:17.950
And you also have
the various options

00:11:17.950 --> 00:11:19.810
that were supported
at the time of mount,

00:11:19.810 --> 00:11:22.210
so I can see if there were
any security options set--

00:11:22.210 --> 00:11:26.160
in particular things like no
swede, or things like that.

00:11:26.160 --> 00:11:28.300
Route squash, another one
I would be looking for.

00:11:28.300 --> 00:11:30.258
I don't really see anything
like that on there.

00:11:30.258 --> 00:11:34.228
So what I would do is I would
go to cd /mnt/data ls-al.

00:11:34.228 --> 00:11:35.770
And what we can see
here is we've got

00:11:35.770 --> 00:11:37.120
numbers instead of usernames.

00:11:37.120 --> 00:11:39.760
So we're back to that Unix
permissions model, now.

00:11:39.760 --> 00:11:41.900
What we can see is,
we can see, OK, there

00:11:41.900 --> 00:11:43.060
were some files here--

00:11:43.060 --> 00:11:43.860
skeleton files.

00:11:43.860 --> 00:11:46.360
These are default files that
are in a user's home directory,

00:11:46.360 --> 00:11:48.610
typically-- so it appears
we've mounted a user's home

00:11:48.610 --> 00:11:49.550
directory--

00:11:49.550 --> 00:11:51.520
and we can see here
that the user who

00:11:51.520 --> 00:11:57.310
owns these files is the user ID
1006, and the group ID is 1006.

00:11:57.310 --> 00:11:59.290
And here we can see
that that user has read,

00:11:59.290 --> 00:12:02.275
write user permissions, but
it has read only permissions

00:12:02.275 --> 00:12:04.150
to the group, and everyone
else on the system

00:12:04.150 --> 00:12:05.255
has read permissions.

00:12:05.255 --> 00:12:06.880
Everyone else on the
system includes me

00:12:06.880 --> 00:12:10.300
from the network perspective,
so I can also read these files,

00:12:10.300 --> 00:12:11.890
because I have
mounted those files

00:12:11.890 --> 00:12:14.015
and that other flag
applies to me, as well.

00:12:14.015 --> 00:12:15.640
So if that wasn't
there, then I may not

00:12:15.640 --> 00:12:17.320
be able to open
these files unless I

00:12:17.320 --> 00:12:21.040
was a member of those groups
or part of that user ID.

00:12:21.040 --> 00:12:23.637
So we can see there, I can
access any of these files,

00:12:23.637 --> 00:12:25.720
because it's getting these
permission flags, here.

00:12:25.720 --> 00:12:29.020
So if I was to now look at
the remote backup server,

00:12:29.020 --> 00:12:32.840
cut the /etc/password
file and grep 1006,

00:12:32.840 --> 00:12:35.750
what you can see is 1006
is actually a backup user--

00:12:35.750 --> 00:12:38.420
and if I was to do
ls-al in this directory,

00:12:38.420 --> 00:12:40.850
we can see it's almost
the same file systems.

00:12:40.850 --> 00:12:42.850
And in fact, it is the
same folder and file

00:12:42.850 --> 00:12:45.640
system we've mounted over
NFS, but instead of 1,006,

00:12:45.640 --> 00:12:47.530
it's now given us a
human, readable mneomic

00:12:47.530 --> 00:12:48.550
of that user name.

00:12:48.550 --> 00:12:50.710
So that's actually the
user on this remote system.

00:12:50.710 --> 00:12:53.890
However, on my computer,
there is no user 1006,

00:12:53.890 --> 00:12:56.240
so these permissions
don't really matter.

00:12:56.240 --> 00:12:58.540
So, the-- it doesn't
tell you that it's

00:12:58.540 --> 00:13:01.130
the backupserv, because there's
no such user on my account.

00:13:01.130 --> 00:13:02.720
There's no such
issues on my computer.

00:13:02.720 --> 00:13:05.420
So what happens then,
if I create a file here?

00:13:05.420 --> 00:13:07.660
So if I make a
file called x, OK?

00:13:07.660 --> 00:13:09.910
We've now made an empty file
owned by the backup user.

00:13:09.910 --> 00:13:12.460
If I ls-al in this
directory, I can now

00:13:12.460 --> 00:13:14.260
see that there is
a file called x.

00:13:14.260 --> 00:13:17.590
OK, so I can add files in
there from that backup user--

00:13:17.590 --> 00:13:22.730
but what if I was to add a file
now from here, and type touchx.

00:13:22.730 --> 00:13:25.330
And then I was to go to
this system and type ls-al.

00:13:25.330 --> 00:13:26.890
Now, can you see the problem?

00:13:26.890 --> 00:13:30.010
We've got a root owned file
in that folder instead of one

00:13:30.010 --> 00:13:31.720
owned by the backup
server, and this

00:13:31.720 --> 00:13:33.790
is because the
network filing server

00:13:33.790 --> 00:13:36.730
has taken the permissions from
me, the connecting client,

00:13:36.730 --> 00:13:38.470
and is using and
trusting those--

00:13:38.470 --> 00:13:41.860
so I'm able to specify
whether or not--

00:13:41.860 --> 00:13:44.980
what user owns a file on
that share when I create it.

00:13:44.980 --> 00:13:47.830
And of course on this server, I
do not have root permissions--

00:13:47.830 --> 00:13:49.790
I, in fact, am only
a backup server.

00:13:49.790 --> 00:13:52.050
So I'm now going to give
myself root permissions.

00:13:52.050 --> 00:13:53.508
The way I'm going
to do that is I'm

00:13:53.508 --> 00:13:56.490
going to copy the file
bin/sh into this directory,

00:13:56.490 --> 00:13:57.960
and I'm going to
call it exploit--

00:13:57.960 --> 00:14:00.070
and I'm going to do that
from my Telnet shell,

00:14:00.070 --> 00:14:01.450
because that's the same binary--

00:14:01.450 --> 00:14:03.420
the same compiled shell--

00:14:03.420 --> 00:14:05.800
as is running on the
system currently.

00:14:05.800 --> 00:14:08.562
So with my exploit
there, sat on the server,

00:14:08.562 --> 00:14:10.270
I would now go for my
mounted NFS share--

00:14:10.270 --> 00:14:11.800
and if I look at
that file, I can

00:14:11.800 --> 00:14:14.140
see the exploit is owned
by the backup server.

00:14:14.140 --> 00:14:18.670
So I would do chown,
root, root on exploit,

00:14:18.670 --> 00:14:20.950
which will give me the exploit--

00:14:20.950 --> 00:14:22.540
will give me the exploit, there.

00:14:22.540 --> 00:14:24.340
I've got root, root--

00:14:24.340 --> 00:14:26.760
and I now own that by root--
and then I would do chmod.

00:14:26.760 --> 00:14:27.910
And what I'm going to
do is, I'm going to set

00:14:27.910 --> 00:14:29.500
that imaginary sticky bit.

00:14:29.500 --> 00:14:31.990
So I'm going to set that to
stick the user's permissions--

00:14:31.990 --> 00:14:34.210
and here you can see that
this file is executable--

00:14:34.210 --> 00:14:36.465
executable by group, and
executable by everyone else.

00:14:36.465 --> 00:14:38.590
Everyone can run this file,
everyone's allowed to--

00:14:38.590 --> 00:14:40.090
the root's user can
read and write to it,

00:14:40.090 --> 00:14:41.298
but I'm going to change that.

00:14:41.298 --> 00:14:44.557
I'm going to make it 6755.

00:14:44.557 --> 00:14:46.390
I'm going to make sure
I've got read, write,

00:14:46.390 --> 00:14:47.785
and execute for the root user.

00:14:47.785 --> 00:14:50.410
I'm going to make sure it's got
read and execute for the group,

00:14:50.410 --> 00:14:52.430
and read and execute
for everybody else--

00:14:52.430 --> 00:14:55.120
but I'm also going to enable
the sticky user and sticky group

00:14:55.120 --> 00:14:55.720
bits.

00:14:55.720 --> 00:14:59.230
So by doing that, if we
now ls-al the exploit,

00:14:59.230 --> 00:15:02.807
we can see that we've got read,
write, and s-- instead of an x,

00:15:02.807 --> 00:15:04.390
we now have an s--
and what that means

00:15:04.390 --> 00:15:06.940
is, it will stick
the user permissions

00:15:06.940 --> 00:15:08.330
when you run that file.

00:15:08.330 --> 00:15:10.780
So that file will be
run as the root user,

00:15:10.780 --> 00:15:13.390
and this group user, if
you run it as the group,

00:15:13.390 --> 00:15:14.410
will also stick.

00:15:14.410 --> 00:15:17.050
So you will be root
with a group of root

00:15:17.050 --> 00:15:18.620
if you were to run that file.

00:15:18.620 --> 00:15:21.010
So I will run that file,
but not on this server--

00:15:21.010 --> 00:15:23.900
on the remote server over here.

00:15:23.900 --> 00:15:26.920
So I'm now the backup server,
simply typing ./exploit

00:15:26.920 --> 00:15:27.472
and ID--

00:15:27.472 --> 00:15:29.680
you can now see that I've
obtained the effective user

00:15:29.680 --> 00:15:32.610
ID of ROOT, and the
effective group ID of root,

00:15:32.610 --> 00:15:34.570
and I now belong
to the group root.

00:15:34.570 --> 00:15:37.990
And in fact, if I was to just
grep etc/shadow, head-n1,

00:15:37.990 --> 00:15:41.050
you can see I can successfully
extract the passwords

00:15:41.050 --> 00:15:44.600
from this server, and begin
exploring it as the root user.

00:15:44.600 --> 00:15:48.790
So that's how we can use NFS to
leverage these vulnerabilities.

00:15:48.790 --> 00:15:51.347
You can do most of this
NFS attacking manually

00:15:51.347 --> 00:15:52.180
by the command line.

00:15:52.180 --> 00:15:53.680
There are some tools to
do it for you-- things

00:15:53.680 --> 00:15:55.652
like NFS Shell-- they're
very long in the tooth

00:15:55.652 --> 00:15:57.610
now, and very kind of
dated, and in fact, doing

00:15:57.610 --> 00:15:59.900
this process manually
is much easier.

00:15:59.900 --> 00:16:01.390
So you can just do it like that.

00:16:01.390 --> 00:16:04.180
You can, of course,
specify all the user IDs.

00:16:04.180 --> 00:16:06.250
You can, of course,
change things around

00:16:06.250 --> 00:16:07.470
however which you want--

00:16:07.470 --> 00:16:09.910
and if you were to
cache etc/bash exports

00:16:09.910 --> 00:16:13.690
on this system, you can see here
that there are some security

00:16:13.690 --> 00:16:16.860
options set on the other
option, which says root squash--

00:16:16.860 --> 00:16:18.580
and this one has no root squash.

00:16:18.580 --> 00:16:20.350
And in fact, the
system administrator

00:16:20.350 --> 00:16:22.540
can prevent these files
when they are uploaded--

00:16:22.540 --> 00:16:25.450
they could be changed to nobody,
so that anyone uploading a file

00:16:25.450 --> 00:16:26.680
would be set to nobody--

00:16:26.680 --> 00:16:29.290
and also prevent you
from accessing or running

00:16:29.290 --> 00:16:31.750
files and uploading
files with a sticky bit.

00:16:31.750 --> 00:16:34.648
So NFS can be configured to
prevent this attack, however,

00:16:34.648 --> 00:16:37.190
in this option here, we can see
that they haven't-- they have

00:16:37.190 --> 00:16:39.310
unsuccessfully set
the security options,

00:16:39.310 --> 00:16:42.880
leaving that /data NFS
mount exposed to a privilege

00:16:42.880 --> 00:16:44.225
escalation attack.

00:16:44.225 --> 00:16:45.850
So from there, we
were able to escalate

00:16:45.850 --> 00:16:48.610
privileges. we've gained
root access to the server--

00:16:48.610 --> 00:16:50.020
excellent-- through NFS.

00:16:50.020 --> 00:16:54.370
And looking through backup files
and connecting in from password

00:16:54.370 --> 00:16:55.870
guessing and similar attacks.

00:16:55.870 --> 00:16:58.337
So you wouldn't need to guess
a password to use that NFS,

00:16:58.337 --> 00:16:59.920
but you would need
some way of running

00:16:59.920 --> 00:17:01.450
that command on the system.

00:17:01.450 --> 00:17:03.910
You could just mount those
shares and upload files there.

00:17:03.910 --> 00:17:06.948
You could have added it
into the users bash profile,

00:17:06.948 --> 00:17:08.740
see if they-- the next
time they logged in,

00:17:08.740 --> 00:17:11.200
you could have just
added commands to there

00:17:11.200 --> 00:17:13.099
and they would have executed.

00:17:13.099 --> 00:17:16.329
So that's the NFS.

00:17:16.329 --> 00:17:17.920
If we were to now
go back to this,

00:17:17.920 --> 00:17:20.710
here-- we've explored some
of the NFS weaknesses.

00:17:20.710 --> 00:17:23.310
You can see there that's
most of the RPC services.

00:17:23.310 --> 00:17:26.470
There are, of course, now some
other NetBIOS name services

00:17:26.470 --> 00:17:28.005
and some [INAUDIBLE] services.

00:17:28.005 --> 00:17:30.130
But before I go on through
cups and various others,

00:17:30.130 --> 00:17:31.150
I want to have a
look at the server,

00:17:31.150 --> 00:17:33.250
because we're on an internal
network perspective.

00:17:33.250 --> 00:17:35.860
I want to perhaps have a
look for some UDP probes.

00:17:35.860 --> 00:17:38.715
So if I was to do a UDP scan
against this host, remember,

00:17:38.715 --> 00:17:40.090
it's probably much
quicker for me

00:17:40.090 --> 00:17:43.630
to just scan for common
UDP ports manually by hand.

00:17:43.630 --> 00:17:48.670
I'm looking for things like
TFTP, SNMP, and probably NTP--

00:17:48.670 --> 00:17:51.190
just for some information
leaks, if they're there--

00:17:51.190 --> 00:17:53.720
and then again, some
VPN related services.

00:17:53.720 --> 00:17:58.570
So I'm going to do for
port in cat udp.TXT.

00:17:58.570 --> 00:18:03.300
And then I'm going to
do echo $ testing port,

00:18:03.300 --> 00:18:06.130
and then I'm going
to do h ping 3 -2,

00:18:06.130 --> 00:18:08.527
and then I'm going
to do -p $ port.

00:18:08.527 --> 00:18:10.360
And then I'm going to
give it the IP address

00:18:10.360 --> 00:18:12.040
of the system I'm targeting.

00:18:12.040 --> 00:18:13.685
And I'm going to give it -c1.

00:18:13.685 --> 00:18:15.060
I want it to send
a single packet

00:18:15.060 --> 00:18:17.320
to each of those UDP ports
and see whether any of them

00:18:17.320 --> 00:18:18.030
are open.

00:18:18.030 --> 00:18:20.170
And I can see I get
ICMP port unreachable.

00:18:20.170 --> 00:18:21.310
Port unreachable.

00:18:21.310 --> 00:18:23.800
Port unreachable
for most services--

00:18:23.800 --> 00:18:26.800
with the exception
of 69 and 161.

00:18:26.800 --> 00:18:29.920
So these are port
1601 and port 69

00:18:29.920 --> 00:18:31.550
appear to be open on this host.

00:18:31.550 --> 00:18:34.900
So if port 69 appears open,
simply connecting to it

00:18:34.900 --> 00:18:39.010
with TFTP, and then
typing get test,

00:18:39.010 --> 00:18:40.930
would say OK, file not found.

00:18:40.930 --> 00:18:43.360
So on this service, now,
what we can actually do

00:18:43.360 --> 00:18:45.700
is we can try and test
for the presence of files,

00:18:45.700 --> 00:18:47.770
and see whether
or not they exist.

00:18:47.770 --> 00:18:51.880
So I can do get things like
backup, get config, get in it.

00:18:51.880 --> 00:18:53.055
And I would just keep going.

00:18:53.055 --> 00:18:55.180
And here we see actually
there was a password file.

00:18:55.180 --> 00:18:58.330
If I was to come out of that
[INAUDIBLE] password file,

00:18:58.330 --> 00:19:01.270
we can actually see that
TFTP service also leaks

00:19:01.270 --> 00:19:04.690
some information because
it has a password file

00:19:04.690 --> 00:19:06.150
accessible in its folder.

00:19:06.150 --> 00:19:08.770
So we can see here all the
different uses on the system,

00:19:08.770 --> 00:19:09.790
we can see--

00:19:09.790 --> 00:19:11.790
in fact, there are no
other users on the system.

00:19:11.790 --> 00:19:15.410
We can see FTP, TFTP, we can see
some information about accounts

00:19:15.410 --> 00:19:17.910
that are on there that we could
maybe try and get access to.

00:19:17.910 --> 00:19:19.952
We don't see that backup
server or anything else,

00:19:19.952 --> 00:19:22.570
so not 100% useful for us.

00:19:22.570 --> 00:19:25.780
But we saw that we can
use TFTP, and indeed,

00:19:25.780 --> 00:19:28.630
if you go to a website
like Packet Storm,

00:19:28.630 --> 00:19:31.270
you could find something
like TFTP Brute.

00:19:31.270 --> 00:19:33.900
I believe there's a number
of brute force scripts

00:19:33.900 --> 00:19:36.400
and tools out there-- and in
fact, there's one in Metasploit

00:19:36.400 --> 00:19:39.680
as well, that you can use
to guess those file names.

00:19:39.680 --> 00:19:41.710
So, OK, TFTP is enabled--

00:19:41.710 --> 00:19:47.920
But I also saw 161, which
is usually used for SNMP.

00:19:47.920 --> 00:19:52.650
So 161 can of course be
proved with a tool called 161.

00:19:52.650 --> 00:19:54.910
So 161 is a brute
force tool which

00:19:54.910 --> 00:19:58.400
will try to guess community
strings for open SNMP services.

00:19:58.400 --> 00:20:00.880
So we would do that by
opening the community file,

00:20:00.880 --> 00:20:02.410
giving it a list of passwords--

00:20:02.410 --> 00:20:04.880
I'll try things like
public, private, hacker--

00:20:04.880 --> 00:20:06.550
you know, seven characters.

00:20:06.550 --> 00:20:10.780
Hackers, support,
testing, engineer--

00:20:10.780 --> 00:20:14.620
you know, things like
this that might hopefully

00:20:14.620 --> 00:20:15.550
trigger something up.

00:20:15.550 --> 00:20:18.700
And then I would do 161,
give it the community string,

00:20:18.700 --> 00:20:21.190
give it the files
I want it to get--

00:20:21.190 --> 00:20:25.290
so the IP address I want to
target, which is this one--

00:20:25.290 --> 00:20:26.590
and simply type run.

00:20:26.590 --> 00:20:28.750
And as you can see here,
it will scan that host

00:20:28.750 --> 00:20:31.160
and see whether or not any
of those community strings

00:20:31.160 --> 00:20:31.660
are valid.

00:20:31.660 --> 00:20:33.680
And we can see public
and private are valid,

00:20:33.680 --> 00:20:37.670
So if I was to do SNMP walk
-c, then I would do public,

00:20:37.670 --> 00:20:41.813
then supply the IP
address 192.168.56.3--

00:20:41.813 --> 00:20:44.230
and you can see here, it says
"no security name specified"

00:20:44.230 --> 00:20:46.540
because it's trying to
connect with version three.

00:20:46.540 --> 00:20:49.040
It's trying to connect with a
newer version of the protocol.

00:20:49.040 --> 00:20:50.730
So I'm going to
specify -version 1.

00:20:50.730 --> 00:20:54.010
And here you can see, SNMP walk
for version one of the protocol

00:20:54.010 --> 00:20:55.990
with an insecure
community string

00:20:55.990 --> 00:20:57.640
allows us to get
maximum information,

00:20:57.640 --> 00:21:00.700
such as the operating
system kernel version,

00:21:00.700 --> 00:21:02.508
and some other
diagnostics information

00:21:02.508 --> 00:21:03.800
that could potentially be used.

00:21:03.800 --> 00:21:06.550
And we should be able to explore
this mid table and perhaps find

00:21:06.550 --> 00:21:09.700
things like Mac addresses
or other malicious stuff--

00:21:09.700 --> 00:21:11.170
boot arguments, perhaps--

00:21:11.170 --> 00:21:13.870
and could maybe try to
change some of these options

00:21:13.870 --> 00:21:17.830
with the private version,
which is a writable version.

00:21:17.830 --> 00:21:21.230
And if we were to
type private, you

00:21:21.230 --> 00:21:23.480
could then try
things like SNMP set,

00:21:23.480 --> 00:21:25.760
and actually try to change
some of these option

00:21:25.760 --> 00:21:28.970
and interfere with
the entries in there.

00:21:28.970 --> 00:21:31.490
So, SNMP, a way of reading
and writing entries,

00:21:31.490 --> 00:21:33.200
and they may be
beneficial to you

00:21:33.200 --> 00:21:36.840
to compromise some
system or service.

00:21:36.840 --> 00:21:39.850
If I go back now to our output--
if I go back to our port scan

00:21:39.850 --> 00:21:40.490
output--

00:21:40.490 --> 00:21:42.415
we can see, well,
we've looked at NFS.

00:21:42.415 --> 00:21:43.790
We've gained route
to the server.

00:21:43.790 --> 00:21:47.840
But there's also this SMB
related services, as well,

00:21:47.840 --> 00:21:51.040
and some others later
on in the CUPS area.

00:21:51.040 --> 00:21:53.990
So before I go into the kind of
other exploitation areas, what

00:21:53.990 --> 00:21:55.407
we're going to try
and do is we're

00:21:55.407 --> 00:21:57.350
going to try and look
at that Samba service

00:21:57.350 --> 00:22:00.200
using a tool called NBT scan.

00:22:00.200 --> 00:22:03.650
NBT scan will do a
NetBIOS table lookup,

00:22:03.650 --> 00:22:05.780
so it will be using
things like server message

00:22:05.780 --> 00:22:10.280
block and NetBIOS to
do a scan, to identify

00:22:10.280 --> 00:22:14.030
options and settings
and group-- group IDs

00:22:14.030 --> 00:22:16.170
and things that the
server might have set,

00:22:16.170 --> 00:22:17.378
and that can be useful to us.

00:22:17.378 --> 00:22:19.003
And we're going to
try-- we want to get

00:22:19.003 --> 00:22:20.780
into that common
internet filing system

00:22:20.780 --> 00:22:22.940
to see what kind of files
and things are on there.

00:22:22.940 --> 00:22:28.460
So I'm going to just run NBT
scan, -v, the IP address.

00:22:28.460 --> 00:22:29.720
And what we can see here is--

00:22:29.720 --> 00:22:31.610
I've done an NBT scan--
and it says here it's

00:22:31.610 --> 00:22:33.740
a file server group, MS browse.

00:22:33.740 --> 00:22:36.800
It's giving us a lot of
information about group

00:22:36.800 --> 00:22:40.280
for unique, you
know, what kind of--

00:22:40.280 --> 00:22:42.935
groups and work spaces and
work groups it belongs to,

00:22:42.935 --> 00:22:44.810
and whether or not it's
a member of a domain.

00:22:44.810 --> 00:22:48.020
And then these services actually
equate back to the services

00:22:48.020 --> 00:22:49.920
that it provides available.

00:22:49.920 --> 00:22:52.702
So if I was to download, now,
a couple of other tools--

00:22:52.702 --> 00:22:54.410
and we're going to
explore through these.

00:22:54.410 --> 00:22:56.500
So I'm going to download
from Hacker House stuff.

00:22:56.500 --> 00:22:58.140
I'm going to download
a tool called RI,

00:22:58.140 --> 00:22:59.390
and another tool called ewalk.

00:23:02.390 --> 00:23:04.090
chmod +x, ewalk.

00:23:04.090 --> 00:23:07.440
ewalk is a tool for enumerating
extra information out

00:23:07.440 --> 00:23:10.080
of hosts when you've got
a valid community string.

00:23:10.080 --> 00:23:13.060
So I'll do Ewalk -SMTP.

00:23:13.060 --> 00:23:15.340
And then it says,
dump the art case.

00:23:15.340 --> 00:23:19.690
Try and do complete sundries--

00:23:19.690 --> 00:23:21.963
[INAUDIBLE] for sun systems--

00:23:21.963 --> 00:23:24.130
we'll maybe look at that
slightly later on, as well.

00:23:24.130 --> 00:23:28.640
But trying it with public,
you can see here, no.

00:23:28.640 --> 00:23:29.140
Exit.

00:23:29.140 --> 00:23:31.960
So you can see here that this
ewalk tool will basically

00:23:31.960 --> 00:23:35.560
try to do some enumeration as
well, using that SNMP service

00:23:35.560 --> 00:23:36.370
that we saw--

00:23:36.370 --> 00:23:38.380
and it's also got
a touch for a--

00:23:38.380 --> 00:23:40.720
basic touch for
some exploitation

00:23:40.720 --> 00:23:43.540
purpose, but also
has the ability

00:23:43.540 --> 00:23:47.500
of looking at
different processes

00:23:47.500 --> 00:23:50.620
and looking through like doing
a walk on HP-UX and getting

00:23:50.620 --> 00:23:52.000
extra information.

00:23:52.000 --> 00:23:54.667
So ewalk's a useful tool
for probing RPC services,

00:23:54.667 --> 00:23:56.500
because you can get
some extra data with it.

00:23:56.500 --> 00:23:57.000
Another

00:23:57.000 --> 00:24:00.370
Useful tool from the NSA
leak is a tool called RI,

00:24:00.370 --> 00:24:02.335
which when we did that
our RPC info tool,

00:24:02.335 --> 00:24:06.190
and we did RI instead, and we
could do grab all available

00:24:06.190 --> 00:24:11.260
info with -c, and just simply
supply it to an RPC port mapper

00:24:11.260 --> 00:24:11.890
service--

00:24:11.890 --> 00:24:13.750
and you can see this one
is actually segfaulted.

00:24:13.750 --> 00:24:15.542
Just trying to connect
to that port service

00:24:15.542 --> 00:24:17.710
and try to use UDP.

00:24:17.710 --> 00:24:19.930
I'll try and see does it
make a difference with TCP?

00:24:19.930 --> 00:24:21.390
It doesn't seem to.

00:24:21.390 --> 00:24:24.090
And I'll just try and see
if I can do it with -c,

00:24:24.090 --> 00:24:25.960
see if that changes it at all.

00:24:25.960 --> 00:24:28.560
OK, and it seems to just be
crashing on this RPC service.

00:24:28.560 --> 00:24:30.040
But that when this
tool works, it

00:24:30.040 --> 00:24:32.502
can connect to some of those
RPC services that it finds

00:24:32.502 --> 00:24:34.210
and give you a bit of
extra information--

00:24:34.210 --> 00:24:35.770
not just the same
kind of information

00:24:35.770 --> 00:24:38.770
you get from 192.56.3.

00:24:38.770 --> 00:24:40.150
So some of those
NSA tools can be

00:24:40.150 --> 00:24:43.135
quite useful for proving
additional hosts and services

00:24:43.135 --> 00:24:46.510
and gathering a little
bit of extra information.

00:24:46.510 --> 00:24:49.940
So we're looking back
now at this NetBIOS team,

00:24:49.940 --> 00:24:51.220
that NetBIOS scan.

00:24:51.220 --> 00:24:54.630
If I was to do enum4linux
at 1 and 2 to 56.3,

00:24:54.630 --> 00:24:57.000
enum4linux will allow us
to connect to the server.

00:24:57.000 --> 00:25:01.150
Enum4linux makes use of these
common windows service ports

00:25:01.150 --> 00:25:02.590
and does various enumerations.

00:25:02.590 --> 00:25:04.132
It connects into
them and does things

00:25:04.132 --> 00:25:06.790
like uses RPC checking
tools to actually probe

00:25:06.790 --> 00:25:09.170
some of these server message
blocks and learn things.

00:25:09.170 --> 00:25:10.660
So you can see
here for instance,

00:25:10.660 --> 00:25:13.030
it's actually changed
those service numbers

00:25:13.030 --> 00:25:13.907
into actual services.

00:25:13.907 --> 00:25:15.490
And one of the things
that you can see

00:25:15.490 --> 00:25:18.100
is the number 20 is a
file server service.

00:25:18.100 --> 00:25:21.100
So we know that this Server
Message Block service

00:25:21.100 --> 00:25:23.410
offers the common
internet filing system,

00:25:23.410 --> 00:25:26.380
because it's got a service type
defined as number 20, which

00:25:26.380 --> 00:25:27.940
is the file server service.

00:25:27.940 --> 00:25:29.802
So we can actually
try to mount that.

00:25:29.802 --> 00:25:31.510
We've also got some
username enumeration.

00:25:31.510 --> 00:25:34.180
You can see if we can find
some users from that service.

00:25:34.180 --> 00:25:35.830
We could try some
brute force attacks.

00:25:35.830 --> 00:25:38.530
So if we would just try
enum4linux and let it enumerate

00:25:38.530 --> 00:25:41.680
information from there, we
might find extra information

00:25:41.680 --> 00:25:43.060
that could be valuable.

00:25:43.060 --> 00:25:45.340
And indeed it's
even outputted all

00:25:45.340 --> 00:25:47.840
of the shares that might
be accessible on that host.

00:25:47.840 --> 00:25:50.330
And I'll show you how to
get those in just a moment.

00:25:50.330 --> 00:25:52.045
This enumeration
tool can give us

00:25:52.045 --> 00:25:54.670
a lot of information when we see
these so-called Windows Server

00:25:54.670 --> 00:25:55.780
services.

00:25:55.780 --> 00:26:01.120
So if I was to do now smbclient,
for instance, smbclient -L,

00:26:01.120 --> 00:26:02.820
and then the IP
address of the server,

00:26:02.820 --> 00:26:04.510
it simply says enter
workgroup and password.

00:26:04.510 --> 00:26:06.177
So I could supply
username and password.

00:26:06.177 --> 00:26:08.350
I'm simply going to return
because this server seems

00:26:08.350 --> 00:26:10.810
to have been set up
for anonymous logging.

00:26:10.810 --> 00:26:13.150
So we can actually connect
to the service and list

00:26:13.150 --> 00:26:14.320
the shares that are exposed.

00:26:14.320 --> 00:26:15.695
So we can see
here, well, it says

00:26:15.695 --> 00:26:17.830
I can mount the data share.

00:26:17.830 --> 00:26:20.110
So I will do mount -T6.

00:26:20.110 --> 00:26:24.660
I'm going to un-mount the data
share I already have mounted.

00:26:24.660 --> 00:26:27.160
And I'm going to try mount it
through Common Internet Filing

00:26:27.160 --> 00:26:27.660
Systems.

00:26:27.660 --> 00:26:31.150
So I'm going to do mount -T,
Common Internet Filing System,

00:26:31.150 --> 00:26:33.670
and then I'm going to -O.
And in my options field,

00:26:33.670 --> 00:26:36.330
I'm going to supply version=1.0.

00:26:36.330 --> 00:26:39.190
Because server message about
1.0 is considered to be a legacy

00:26:39.190 --> 00:26:41.890
and more insecure, you might
have to explicitly set it

00:26:41.890 --> 00:26:43.030
as new SMB.

00:26:43.030 --> 00:26:45.550
And Server Message Block clients
will enforce newer versions

00:26:45.550 --> 00:26:48.910
of the protocol as opposed to
using legacy insecure versions

00:26:48.910 --> 00:26:51.790
which are susceptible to a
number of man-in-the-middle

00:26:51.790 --> 00:26:54.280
and replay related
vulnerabilities.

00:26:54.280 --> 00:27:00.130
So I'll do version=1.0, and
I'll also do user=guest.

00:27:00.130 --> 00:27:03.390
And then I'll supply the
IP address of the server.

00:27:03.390 --> 00:27:07.180
And I will also do a :/data, and
then I will give it my folder

00:27:07.180 --> 00:27:09.300
path, which is mount/data.

00:27:09.300 --> 00:27:10.900
And I need to
change this path now

00:27:10.900 --> 00:27:14.130
to be what's known as a
unified network or a UNC path.

00:27:14.130 --> 00:27:16.555
And I will do
slash-slash-slash-slash.

00:27:16.555 --> 00:27:20.230
And remember to doublescape
your slashes on Windows

00:27:20.230 --> 00:27:22.658
and then it's also
slash-slash like this.

00:27:22.658 --> 00:27:24.700
So if you've ever mounted
a share under a Windows

00:27:24.700 --> 00:27:27.130
environment, you may be
familiar with that path looking

00:27:27.130 --> 00:27:27.630
like this.

00:27:27.630 --> 00:27:30.005
But I would actually need to
ensure that there are double

00:27:30.005 --> 00:27:32.080
slashes to ensure that
those slashes make it

00:27:32.080 --> 00:27:33.070
into the command.

00:27:33.070 --> 00:27:35.650
So we can see now we've
got guest at this use.

00:27:35.650 --> 00:27:36.660
So I'll hit Return.

00:27:36.660 --> 00:27:37.960
And it says permission denied.

00:27:37.960 --> 00:27:41.260
I can't mount this data share
unless I have a valid username

00:27:41.260 --> 00:27:42.160
and password.

00:27:42.160 --> 00:27:44.200
So without a valid
username and password,

00:27:44.200 --> 00:27:47.920
I can't actually access
that data directory.

00:27:47.920 --> 00:27:50.260
But I could enumerate those
usernames and passwords

00:27:50.260 --> 00:27:51.160
from my list.

00:27:51.160 --> 00:27:53.530
So I could then try
a brute force attack.

00:27:53.530 --> 00:27:55.930
I could try all of those
users with weak passwords

00:27:55.930 --> 00:27:58.180
and a brute force attack
and see if I could get in.

00:27:58.180 --> 00:28:01.510
But I already know the backup
server uses password of backup

00:28:01.510 --> 00:28:02.470
from password guessing.

00:28:02.470 --> 00:28:05.900
So I'll try backup serve and
then the password of backup.

00:28:05.900 --> 00:28:08.500
And you can see that that allows
me to mount the directory,

00:28:08.500 --> 00:28:10.380
and I'm back in that
users home directory.

00:28:10.380 --> 00:28:13.870
And if I do Touch X, I can now
also write to that directory

00:28:13.870 --> 00:28:14.560
as well.

00:28:14.560 --> 00:28:21.010
So that gives me a
little bit of information

00:28:21.010 --> 00:28:22.360
about the SMB service.

00:28:22.360 --> 00:28:26.720
I can mount that file system
and I can write files there.

00:28:26.720 --> 00:28:28.720
So what else can I learn
about that file system?

00:28:28.720 --> 00:28:30.430
I've got Common
Internet Filing System.

00:28:30.430 --> 00:28:32.540
I've got an exposed
Server Message Block

00:28:32.540 --> 00:28:34.660
port that provides a
number of services which

00:28:34.660 --> 00:28:37.390
I can interact with, one of
them being the Common Internet

00:28:37.390 --> 00:28:38.570
Filing System.

00:28:38.570 --> 00:28:41.260
So if I was to go back to
my MDT scan, or in fact

00:28:41.260 --> 00:28:45.340
my EnMAP output, and have
a look at what information

00:28:45.340 --> 00:28:46.550
came out from there.

00:28:46.550 --> 00:28:48.640
And we can see from
the SMB information

00:28:48.640 --> 00:28:52.370
that port 445, it was possible
to fingerprint this service

00:28:52.370 --> 00:28:55.810
as being smbd 3.5.6.

00:28:55.810 --> 00:28:58.300
So if I was to do
SearchSploit Samba,

00:28:58.300 --> 00:29:01.438
we can see here that the
Samba server is 3.5.6.

00:29:01.438 --> 00:29:02.980
It is considerably
out of date and is

00:29:02.980 --> 00:29:06.160
vulnerable to an attack known
as is-known-pipename, which

00:29:06.160 --> 00:29:08.680
is commonly known as SambaCry.

00:29:08.680 --> 00:29:11.320
It's a way to upload a
file onto a link system

00:29:11.320 --> 00:29:14.620
and get code
execution this using

00:29:14.620 --> 00:29:16.660
this is-known-pipename exploit.

00:29:16.660 --> 00:29:19.210
So if I was to have a look at
this is-known-pipe exploit,

00:29:19.210 --> 00:29:21.910
I believe that there was
some limited worms that

00:29:21.910 --> 00:29:24.250
tried to leverage this
capability as well.

00:29:24.250 --> 00:29:29.260
It was labeled as a
vulnerability like WannaCry

00:29:29.260 --> 00:29:31.480
for the Linux-like
filing systems

00:29:31.480 --> 00:29:33.910
because there's so many little
things that would use this.

00:29:33.910 --> 00:29:36.370
And in fact, I've been finding
increasingly a large number

00:29:36.370 --> 00:29:39.280
of embedded devices which don't
keep their Samba services fully

00:29:39.280 --> 00:29:41.740
up to date and have been
exposed to vulnerable attacks

00:29:41.740 --> 00:29:42.857
and weaknesses like this.

00:29:42.857 --> 00:29:44.440
And in fact, several
of them currently

00:29:44.440 --> 00:29:46.180
are still awaiting
patches from vendors.

00:29:46.180 --> 00:29:47.770
So it is a continual problem.

00:29:47.770 --> 00:29:50.950
So if you were to search through
here and do a search for Samba,

00:29:50.950 --> 00:29:53.470
we could see various exploits
for Samba that might exist,

00:29:53.470 --> 00:29:56.020
one of them being the
is-known-pipe overflow.

00:29:56.020 --> 00:29:58.660
And we can see here it says
it's excellent in terms of rank.

00:29:58.660 --> 00:29:59.920
So I'm not really
going to be concerned

00:29:59.920 --> 00:30:02.440
that this might crash the
server or cause any corruption

00:30:02.440 --> 00:30:03.570
or anything else.

00:30:03.570 --> 00:30:07.412
When it starts to get to
average, normal, great, things

00:30:07.412 --> 00:30:09.370
like that, I might be
concerned that they could

00:30:09.370 --> 00:30:11.470
crash systems and services.

00:30:11.470 --> 00:30:14.350
So let me have a look and see
what we can do with this one.

00:30:14.350 --> 00:30:18.543
I'll do Use, Edit,
Paste, Show Information.

00:30:18.543 --> 00:30:20.960
Here we can get an information
as to the description, what

00:30:20.960 --> 00:30:21.850
the problem is.

00:30:21.850 --> 00:30:25.090
It says that if we can upload
a file and it's writable

00:30:25.090 --> 00:30:27.010
and we're using this
version of Samba,

00:30:27.010 --> 00:30:31.150
we can use this to exploit it.

00:30:31.150 --> 00:30:33.670
And it even says in some
cases, simple anonymous access

00:30:33.670 --> 00:30:34.540
is sufficient.

00:30:34.540 --> 00:30:36.332
So in our case we are
going to actually set

00:30:36.332 --> 00:30:40.270
[INAUDIBLE] various
targets, automatic targets

00:30:40.270 --> 00:30:41.390
on this system.

00:30:41.390 --> 00:30:43.300
So if I was to do
Show Options, we

00:30:43.300 --> 00:30:45.750
can see here that the
options are specified.

00:30:45.750 --> 00:30:49.120
I'll set our host to specify
the host I'm targeting,

00:30:49.120 --> 00:30:51.880
set the SMB folder, which
is the writable folder

00:30:51.880 --> 00:30:53.260
that I can access.

00:30:53.260 --> 00:30:55.360
And the name of the SMB share--

00:30:55.360 --> 00:30:59.540
oh, I'm going to change
that to SMB-sharename, data,

00:30:59.540 --> 00:31:01.590
and the SMB folder I don't need.

00:31:01.590 --> 00:31:05.060
And then I'm also going to
set SMB-user to be my backup

00:31:05.060 --> 00:31:07.970
serve user, which is missing
from the readme of this module.

00:31:07.970 --> 00:31:10.400
But simply setting SMB
pass will make sure

00:31:10.400 --> 00:31:13.010
that these are the SMB usernames
and passwords that are used

00:31:13.010 --> 00:31:14.270
to serve the message block.

00:31:14.270 --> 00:31:15.860
So if I then do
Show Options, you

00:31:15.860 --> 00:31:17.943
can see that those options
aren't specified there,

00:31:17.943 --> 00:31:20.120
but they are required
for this exploit to work.

00:31:20.120 --> 00:31:21.620
And if I was to
do Show Payloads,

00:31:21.620 --> 00:31:24.498
you'll see there's only a
single payload available.

00:31:24.498 --> 00:31:27.040
And that payload allows me to
have an interactive Unix shell.

00:31:27.040 --> 00:31:29.170
So if I run this
exploit, you can see now

00:31:29.170 --> 00:31:30.970
that it's connected
to the server.

00:31:30.970 --> 00:31:35.770
It's uploaded an exploit and
it's created a shared object

00:31:35.770 --> 00:31:37.505
using that .SharedObject file.

00:31:37.505 --> 00:31:39.380
We'll look at some more
shared objects later.

00:31:39.380 --> 00:31:40.940
And it's now opened
a command shell.

00:31:40.940 --> 00:31:42.732
And when I execute that
command you can see

00:31:42.732 --> 00:31:44.300
I have root permissions
on this host.

00:31:44.300 --> 00:31:46.060
And this exploit is
a little bit unstable

00:31:46.060 --> 00:31:48.477
as the process will eventually
get terminated by the Samba

00:31:48.477 --> 00:31:50.230
service, so you may
only have root access

00:31:50.230 --> 00:31:51.303
for a couple of seconds.

00:31:51.303 --> 00:31:51.970
So there you go.

00:31:51.970 --> 00:31:53.590
Command shell one
session is closed.

00:31:53.590 --> 00:31:55.600
That's how you could
leverage SambaCry

00:31:55.600 --> 00:31:57.370
to probe these services.

00:31:57.370 --> 00:32:01.000
So using SMB client, mounting
shares, probing shares, brute

00:32:01.000 --> 00:32:03.130
forcing attacks, as
I've said before,

00:32:03.130 --> 00:32:05.295
it's worth trying
these things out.

00:32:05.295 --> 00:32:06.670
So once you've
uploaded files, we

00:32:06.670 --> 00:32:09.130
can see we can leverage
that command injection

00:32:09.130 --> 00:32:12.130
vulnerability there, or code
injection vulnerability, I

00:32:12.130 --> 00:32:12.670
apologize.

00:32:12.670 --> 00:32:17.690
And now we have some things
like printing protocols.

00:32:17.690 --> 00:32:20.800
And we have a couple of
other things available to us.

00:32:20.800 --> 00:32:22.780
So we'll have a look at
that printing protocol.

00:32:22.780 --> 00:32:30.380
So by connecting to
192.56.2, powerage 631--

00:32:30.380 --> 00:32:31.310
oh, I apologize.

00:32:31.310 --> 00:32:32.240
It's 3.

00:32:32.240 --> 00:32:34.910
So 192.168.56.3.

00:32:34.910 --> 00:32:37.790
We now see we've got the
CUPS service accessible there

00:32:37.790 --> 00:32:40.310
with various printing
capabilities--

00:32:40.310 --> 00:32:43.160
introductions of CUPS, CUPS
API, filter backgrounds.

00:32:43.160 --> 00:32:45.560
If you were to click on
Printers, click on Jobs,

00:32:45.560 --> 00:32:48.032
click on Classes, you can
see that this printer service

00:32:48.032 --> 00:32:50.240
doesn't seem to have any
kind of password protection.

00:32:50.240 --> 00:32:51.890
And in fact, if I
click into Admin,

00:32:51.890 --> 00:32:53.900
I can seem to try
and add printers.

00:32:53.900 --> 00:32:56.900
And then it says I
need to upgrade to SSL.

00:32:56.900 --> 00:33:00.070
And once I've upgraded to
SSL, I could add exception.

00:33:00.070 --> 00:33:02.480
And it seems that this is
an insecure printer service.

00:33:02.480 --> 00:33:05.408
When you actually get to
these kinds of services,

00:33:05.408 --> 00:33:06.950
it's very typical
that people haven't

00:33:06.950 --> 00:33:08.033
configured them correctly.

00:33:08.033 --> 00:33:09.980
And it says, allow
remote administration,

00:33:09.980 --> 00:33:12.440
share printers, and allow
printing from the internet.

00:33:12.440 --> 00:33:14.400
So I can actually manage
the printers on here.

00:33:14.400 --> 00:33:16.220
But one thing that I can see,
and there's a little nice

00:33:16.220 --> 00:33:17.030
trick about CUPSes.

00:33:17.030 --> 00:33:18.940
It says, edit
configuration file.

00:33:18.940 --> 00:33:20.540
And inside this
configuration file,

00:33:20.540 --> 00:33:23.740
I could actually set the options
that are being used for CUPS.

00:33:23.740 --> 00:33:30.640
And if we have a look for CUPS
set and directive set::ends

00:33:30.640 --> 00:33:37.000
and passend, if we were to
look at set::end and passend we

00:33:37.000 --> 00:33:40.360
might be able to specify
environment variables inside

00:33:40.360 --> 00:33:41.500
of this configuration file.

00:33:41.500 --> 00:33:43.940
So maybe I would specify at
the very top of this file,

00:33:43.940 --> 00:33:45.580
say set::end.

00:33:45.580 --> 00:33:50.230
In my environment I'd like you
to set tic my evil commands

00:33:50.230 --> 00:33:53.500
and specify my benshare
SH, 192, whatever.

00:33:53.500 --> 00:33:57.070
So that when CUPS restarts,
it will try to run my commands

00:33:57.070 --> 00:33:59.920
using this set::end that we'll
try and use for that parameter

00:33:59.920 --> 00:34:00.500
in there.

00:34:00.500 --> 00:34:01.870
And then saving that file.

00:34:01.870 --> 00:34:03.670
Say OK.

00:34:03.670 --> 00:34:05.940
We would hope that CUPS
would then try and use

00:34:05.940 --> 00:34:07.690
some password guessing
to try and save it.

00:34:07.690 --> 00:34:10.929
So I might use brute force that
password and see what happens.

00:34:10.929 --> 00:34:14.469
Simply typing route, maybe a
blank password, route route,

00:34:14.469 --> 00:34:18.080
things like CUPS
CUPS, et cetera.

00:34:18.080 --> 00:34:19.840
CUPS, CUPS.

00:34:19.840 --> 00:34:22.679
But once you can set
that configuration file,

00:34:22.679 --> 00:34:24.350
the next time CUPS
restarts, it would

00:34:24.350 --> 00:34:26.420
try to read that
configuration file

00:34:26.420 --> 00:34:29.210
and subsequently
execute your commands.

00:34:29.210 --> 00:34:31.820
So that's a way of experimenting
and hacking the CUPS service,

00:34:31.820 --> 00:34:34.400
adding printers, trying to
make use of these services,

00:34:34.400 --> 00:34:37.070
trying to get them to load code
or execute commands, command

00:34:37.070 --> 00:34:40.212
line printing and options,
changing things like that.

00:34:40.212 --> 00:34:42.170
Trying to mess around
with the printing service

00:34:42.170 --> 00:34:43.350
to get code to run.

00:34:43.350 --> 00:34:45.260
And again, as I
mentioned earlier,

00:34:45.260 --> 00:34:46.909
there's a really
cool tool that I've

00:34:46.909 --> 00:34:49.895
been using for years
called Hijetter, which is

00:34:49.895 --> 00:34:53.000
a really nice PFT and hijetter.

00:34:53.000 --> 00:34:55.280
If you haven't ever done
any printer hacking,

00:34:55.280 --> 00:34:57.050
this is a really
cool little tool

00:34:57.050 --> 00:34:59.630
that's worth reading through
and having a little play with,

00:34:59.630 --> 00:35:03.020
as it allows you to do some
fun and interesting things.

00:35:03.020 --> 00:35:05.578
So CUPS printing services,
command injection

00:35:05.578 --> 00:35:07.370
sometimes vulnerable
to shellshock as well.

00:35:07.370 --> 00:35:09.410
Worth checking for
vulnerabilities

00:35:09.410 --> 00:35:12.140
too like shellshock on
that system and service.

00:35:12.140 --> 00:35:14.640
So I'm just going to look back
on my port scan outputs here.

00:35:14.640 --> 00:35:15.710
I want to ensure
that we've covered

00:35:15.710 --> 00:35:16.835
everything for this module.

00:35:16.835 --> 00:35:18.530
We've done SNMP services.

00:35:18.530 --> 00:35:20.630
We probed our TFTP service.

00:35:20.630 --> 00:35:23.400
We've looked at our various
different vulnerabilities.

00:35:23.400 --> 00:35:25.770
We've been able to exploit
the SambaCry service.

00:35:25.770 --> 00:35:27.770
And I'm going to show you
one more vulnerability

00:35:27.770 --> 00:35:30.320
and how it works in
Metasploit just because it's

00:35:30.320 --> 00:35:31.250
an interesting one.

00:35:31.250 --> 00:35:33.020
But you will never
see this in the wild.

00:35:33.020 --> 00:35:37.850
If I was to telnet to the
FTP service on port 21

00:35:37.850 --> 00:35:42.590
and try to log in as the user,
testing with a smiley face

00:35:42.590 --> 00:35:45.110
and the password of
testing with a smiley face,

00:35:45.110 --> 00:35:47.570
you'll see the
application is halted.

00:35:47.570 --> 00:35:49.460
And indeed, if I was
to now net cancel

00:35:49.460 --> 00:35:52.370
that server on
port 6,200, you'll

00:35:52.370 --> 00:35:54.930
find that I have a route
shell waiting for me.

00:35:54.930 --> 00:35:56.270
And I'll explain this now.

00:35:56.270 --> 00:35:58.520
This basically is a backdoor
that was implemented

00:35:58.520 --> 00:36:01.400
into the vsftpd 2.3.4.

00:36:01.400 --> 00:36:04.378
A hacker broke into the
software service site, modified

00:36:04.378 --> 00:36:06.170
the service code so
that when you logged in

00:36:06.170 --> 00:36:08.990
with a smiley face, it
would open a little backdoor

00:36:08.990 --> 00:36:12.070
and allow him to connect in
and get root permissions.

00:36:12.070 --> 00:36:15.230
And it was done to the
very secure ftpd service

00:36:15.230 --> 00:36:17.400
and was accessible
for about three weeks.

00:36:17.400 --> 00:36:19.330
So for around three
weeks this backdoor

00:36:19.330 --> 00:36:21.770
may have trickled down into
some software packages,

00:36:21.770 --> 00:36:24.290
although it's very rare to
actually see it in the wild.

00:36:24.290 --> 00:36:27.380
And if you do search vsftpd,
you can see here there's

00:36:27.380 --> 00:36:31.100
a module for vsftpd backdoor
that you can use in Metasploit

00:36:31.100 --> 00:36:32.730
to trigger this vulnerability.

00:36:32.730 --> 00:36:37.980
So using Edit, you use
Paste to show info.

00:36:37.980 --> 00:36:39.370
You can see the
description here.

00:36:39.370 --> 00:36:41.250
It adds a malicious
backdoor, a backdoor

00:36:41.250 --> 00:36:42.960
when it was introduced
and removed,

00:36:42.960 --> 00:36:44.320
and gives you some information.

00:36:44.320 --> 00:36:46.410
But all this
Metasploit module does

00:36:46.410 --> 00:36:49.140
is the exact same thing that we
just did there in the terminal.

00:36:49.140 --> 00:36:51.540
It simply tries to log
in with a smiley face

00:36:51.540 --> 00:36:53.890
and then opens a
connection to that port.

00:36:53.890 --> 00:36:56.448
So although it's not
actually a complex exploit,

00:36:56.448 --> 00:36:58.740
you can actually see what
this is doing under the hood.

00:36:58.740 --> 00:37:00.960
So you can get familiar with
how these modules are written.

00:37:00.960 --> 00:37:02.710
And I advise you to
have a read through it

00:37:02.710 --> 00:37:06.360
and see if you can see how to
manually recreate that process

00:37:06.360 --> 00:37:08.880
just from this module input.

00:37:08.880 --> 00:37:10.500
And if you were to
do Show Payloads,

00:37:10.500 --> 00:37:12.083
you would get the
same kind of output,

00:37:12.083 --> 00:37:14.850
because it only allows one
particular kind of payload,

00:37:14.850 --> 00:37:16.620
because it's actually
using a backdoor.

00:37:16.620 --> 00:37:18.530
So if you were to
then run this attack,

00:37:18.530 --> 00:37:21.630
you'd see the port is already
open because I've already

00:37:21.630 --> 00:37:22.510
connected to it.

00:37:22.510 --> 00:37:29.303
So if I was to come out of
here now, kill the service,

00:37:29.303 --> 00:37:31.220
and you can see now the
back door was spawned.

00:37:31.220 --> 00:37:33.100
It tried to log in
with a smiley face,

00:37:33.100 --> 00:37:34.760
and it's done the
exact same thing.

00:37:34.760 --> 00:37:36.218
But now we have
the nicety of being

00:37:36.218 --> 00:37:38.580
able to manage it with
the Metasploit framework,

00:37:38.580 --> 00:37:40.300
be able to background
our session

00:37:40.300 --> 00:37:42.270
and kill it if we
no longer need it.

00:37:42.270 --> 00:37:44.770
So we could actually make use
of more management from there.

00:37:44.770 --> 00:37:48.057
So there was one service,
just referring back to that.

00:37:48.057 --> 00:37:50.140
And as clients there, we
can see there is actually

00:37:50.140 --> 00:37:51.770
one service which
we didn't cover,

00:37:51.770 --> 00:37:53.390
which was this arcing service.

00:37:53.390 --> 00:37:55.450
And remember, we touched
on it in the theory.

00:37:55.450 --> 00:37:58.000
We were able to look at--

00:37:58.000 --> 00:37:59.450
there was an arcing
vulnerability,

00:37:59.450 --> 00:38:01.430
which was exploited
previously in the past.

00:38:01.430 --> 00:38:06.700
So to use arcing services, we
simply provide a URL or URI

00:38:06.700 --> 00:38:10.870
which has arcing:// and then the
IP address of the system that

00:38:10.870 --> 00:38:12.640
has the arcing service exposed.

00:38:12.640 --> 00:38:16.130
And here we can see it will list
out the data or home directory.

00:38:16.130 --> 00:38:19.690
So if I was to go /data, you
can actually see I could access

00:38:19.690 --> 00:38:21.193
that users home directory.

00:38:21.193 --> 00:38:23.110
And if I wanted to
download a file from there,

00:38:23.110 --> 00:38:27.220
I could do like that, .profile.

00:38:27.220 --> 00:38:30.670
Download here, and then I can
have a look at that .profile

00:38:30.670 --> 00:38:34.222
file and see what was actually
contained inside of it.

00:38:34.222 --> 00:38:36.430
You probably don't want to
overwrite your own profile

00:38:36.430 --> 00:38:39.910
by doing that, but this
one should be .profile,

00:38:39.910 --> 00:38:41.440
as it's in a hacker
house directory.

00:38:41.440 --> 00:38:44.410
So I can copy files off
that system using arcing,

00:38:44.410 --> 00:38:47.100
because of course there's
no authentication enabled.

00:38:47.100 --> 00:38:49.670
And just connecting to it
will list out information.

00:38:49.670 --> 00:38:52.480
So if I do arcing/home,
what we can see here

00:38:52.480 --> 00:38:55.320
is that the arcing service
exposes the home directories.

00:38:55.320 --> 00:38:57.070
And if you look at
those home directories,

00:38:57.070 --> 00:38:58.820
you can see each of
those home directories

00:38:58.820 --> 00:38:59.830
are in fact usernames.

00:38:59.830 --> 00:39:02.080
So we've got another
username enumeration leak

00:39:02.080 --> 00:39:04.090
that we could try and
use to information leak

00:39:04.090 --> 00:39:05.380
off the server.

00:39:05.380 --> 00:39:08.350
And we've also got here what
looks to be misconfigured

00:39:08.350 --> 00:39:09.640
Unix file permissions.

00:39:09.640 --> 00:39:12.880
You can see we've got Peter,
Peter K. And remember,

00:39:12.880 --> 00:39:15.580
we mentioned that the
other field applies also

00:39:15.580 --> 00:39:16.900
to people on the network.

00:39:16.900 --> 00:39:18.760
Peter K has set
his home directory

00:39:18.760 --> 00:39:21.220
as accessible to
anyone on the network.

00:39:21.220 --> 00:39:23.800
So through this arcing service,
if I tried to access Claire

00:39:23.800 --> 00:39:27.430
A's folder, you can see that I
don't have enough permissions

00:39:27.430 --> 00:39:30.010
to access Claire A's folder
because the other user cannot

00:39:30.010 --> 00:39:30.790
access them.

00:39:30.790 --> 00:39:34.360
However, I can access the file
in Peter K's home directory.

00:39:34.360 --> 00:39:36.340
And inside Peter
K's home directory,

00:39:36.340 --> 00:39:39.640
you can see there are so-called
Unix skeleton files that make

00:39:39.640 --> 00:39:42.003
that user's access--

00:39:42.003 --> 00:39:43.420
sets up that user
when he logs in.

00:39:43.420 --> 00:39:45.670
And one of those files
is the .plan file.

00:39:45.670 --> 00:39:48.170
And I'll save that to my
file called Peter's plan.

00:39:48.170 --> 00:39:49.977
And if you then open
up Peter's plan,

00:39:49.977 --> 00:39:52.060
inside there you can
actually see that his account

00:39:52.060 --> 00:39:53.740
has a password of Monday1.

00:39:53.740 --> 00:39:57.106
And if we were to simply
connect to that service,

00:39:57.106 --> 00:40:00.082
I type Peter K, Monday1.

00:40:00.082 --> 00:40:02.040
We can see that there's
another way in which we

00:40:02.040 --> 00:40:03.270
could have accessed things.

00:40:03.270 --> 00:40:06.570
So trawling through
arcing-related services

00:40:06.570 --> 00:40:08.460
to identify vulnerabilities.

00:40:08.460 --> 00:40:11.630
And again it's worth looking
at that case from 2003,

00:40:11.630 --> 00:40:15.150
as the individuals
responsible were never caught

00:40:15.150 --> 00:40:18.150
and it did involve a zero
day attack against a vendor's

00:40:18.150 --> 00:40:19.290
arcing service.

00:40:19.290 --> 00:40:20.880
So very interesting read.

00:40:20.880 --> 00:40:23.850
So basically, that pretty
much concludes the arcing

00:40:23.850 --> 00:40:24.630
enumeration.

00:40:24.630 --> 00:40:27.180
And remember again this is all
about Unix file permissions,

00:40:27.180 --> 00:40:30.900
that that other field also
relates to network users.

00:40:30.900 --> 00:40:34.560
So that concludes all of
the practical demonstrations

00:40:34.560 --> 00:40:35.610
for this module.

00:40:35.610 --> 00:40:38.400
I do believe that you could
also use dirty counter

00:40:38.400 --> 00:40:39.605
privest on this server.

00:40:39.605 --> 00:40:40.980
But the main
takeaway really is I

00:40:40.980 --> 00:40:43.950
want you to get comfortable
with that concept of Unix file

00:40:43.950 --> 00:40:44.520
permissions.

00:40:44.520 --> 00:40:46.560
I want you to get
experience with changing

00:40:46.560 --> 00:40:48.227
these different file
permissions around.

00:40:48.227 --> 00:40:50.130
So copying files
over, understanding

00:40:50.130 --> 00:40:52.050
that permissions
model, because it

00:40:52.050 --> 00:40:54.720
is important to be able
to find files on a system.

00:40:54.720 --> 00:40:56.460
If you have a look at
that file test now,

00:40:56.460 --> 00:40:58.800
you can see we've got read,
write, and execute for user,

00:40:58.800 --> 00:41:00.108
read and execute for group.

00:41:00.108 --> 00:41:02.400
And I want to try some of
those theory numbers I tried.

00:41:02.400 --> 00:41:04.962
So 754, the test,
and you should see

00:41:04.962 --> 00:41:07.170
that you get the same
permissions as was demonstrated

00:41:07.170 --> 00:41:07.762
in our charts.

00:41:07.762 --> 00:41:09.720
And I want you to get
comfortable with changing

00:41:09.720 --> 00:41:11.790
those permissions and
understanding the concepts

00:41:11.790 --> 00:41:13.560
and process of the sticky bits.

00:41:13.560 --> 00:41:15.600
Because when you're
trying to audit systems,

00:41:15.600 --> 00:41:19.410
one of the commands you maybe
use is find/-perm and search

00:41:19.410 --> 00:41:22.150
for files that have certain
kinds of permissions.

00:41:22.150 --> 00:41:26.580
So -4000 is find all the files
that have the sticky bit, not

00:41:26.580 --> 00:41:28.705
minus type L. Don't
show me linked files

00:41:28.705 --> 00:41:30.330
because they have
some erroneous errors

00:41:30.330 --> 00:41:31.470
that we don't care about.

00:41:31.470 --> 00:41:33.283
Send all the garbage
to the dev/null.

00:41:33.283 --> 00:41:34.950
I only want to know
about the files that

00:41:34.950 --> 00:41:38.250
exist on the system that
have this sticky bit set.

00:41:38.250 --> 00:41:39.900
And when you do that,
you can see here

00:41:39.900 --> 00:41:42.150
it will list all of
the files on the system

00:41:42.150 --> 00:41:45.320
that could potentially be
used to gain root permissions.

00:41:45.320 --> 00:41:47.820
And you can see our exploits
sitting right there at the top.

00:41:47.820 --> 00:41:50.670
So that concludes our
practical demonstrations

00:41:50.670 --> 00:41:52.080
for the NAS appliance.

00:41:52.080 --> 00:41:54.750
As I said, this module does
mimic commonly seen network

00:41:54.750 --> 00:41:57.120
attached storage in the wild.

00:41:57.120 --> 00:41:59.250
And you'll find that some
of these vulnerabilities

00:41:59.250 --> 00:42:01.770
will be present on many
of these appliances.

00:42:01.770 --> 00:42:04.540
So I want you to repeat
some of these exercises.

00:42:04.540 --> 00:42:05.700
Try and breach that server.

00:42:05.700 --> 00:42:07.500
Leverage the NFS vulnerability.

00:42:07.500 --> 00:42:09.000
Try and do some
kind of brute force,

00:42:09.000 --> 00:42:10.500
probe some of those services.

00:42:10.500 --> 00:42:12.470
Enumerate as much
information as you can.

00:42:12.470 --> 00:42:15.630
And try to think about how would
you report this to your client?

00:42:15.630 --> 00:42:17.830
How would you explain
what these problems are?

00:42:17.830 --> 00:42:20.190
It's really important that
being able to use these tasks

00:42:20.190 --> 00:42:22.860
and being able to conduct
these assessments is fantastic,

00:42:22.860 --> 00:42:26.150
however, you would also need to
explain some of these findings.

00:42:26.150 --> 00:42:27.900
When you're able to
gain root permissions,

00:42:27.900 --> 00:42:29.940
you need to be able to
explain how you did that,

00:42:29.940 --> 00:42:31.200
or why it's such a problem.

00:42:31.200 --> 00:42:32.908
So it's important to
be able to do things

00:42:32.908 --> 00:42:35.220
like check the
exports file and see

00:42:35.220 --> 00:42:38.820
why that vulnerability exists
and make recommendations

00:42:38.820 --> 00:42:41.550
that say, hey, what
is that vulnerability

00:42:41.550 --> 00:42:42.790
and how to fix it.

00:42:42.790 --> 00:42:45.900
And so that concludes
the NAS appliance.

00:42:45.900 --> 00:42:47.280
Thank you very
much for your time

00:42:47.280 --> 00:42:50.270
and I look forward to seeing
you in the next module.
