WEBVTT

00:00:00.666 --> 00:00:04.700
Remote File Inclusion (RFI)

00:00:06.366 --> 00:00:10.500
RFI vulnerabilities are
less common than LFIs

00:00:10.500 --> 00:00:14.600
since the target system must
be configured in a specific way.

00:00:15.033 --> 00:00:18.300
In PHP web applications, for example,

00:00:18.300 --> 00:00:24.333
the allow_url_include option needs
to be enabled to leverage RFI,

00:00:24.333 --> 00:00:28.133
just as with the data:// wrapper
from the previous section.

00:00:28.466 --> 00:00:33.233
While LFI vulnerabilities can be
used to include local files,

00:00:33.233 --> 00:00:38.066
RFI vulnerabilities allow us to
include files from a remote system

00:00:38.066 --> 00:00:41.066
over HTTP or SMB.

00:00:41.233 --> 00:00:47.066
The included file is also executed in
the context of the web application.

00:00:47.533 --> 00:00:51.033
Common scenarios where
we’ll find this option enabled

00:00:51.033 --> 00:00:55.800
is when the web application loads files
or contents from remote systems,

00:00:55.800 --> 00:00:58.566
like libraries or application data.

00:00:58.866 --> 00:01:02.966
We can discover RFI vulnerabilities
using the same techniques

00:01:02.966 --> 00:01:07.200
covered in the Directory
Traversal and LFI sections.

00:01:07.433 --> 00:01:13.333
Kali Linux includes several PHP
webshells that can be used for RFI.

00:01:15.466 --> 00:01:21.000
A webshell is a small script that provides
a web-based command line interface,

00:01:21.000 --> 00:01:24.933
making it easier and more
convenient to execute commands.

00:01:25.433 --> 00:01:26.900
In this example,

00:01:26.900 --> 00:01:30.933
we’ll use the simple-backdoor.php webshell

00:01:30.933 --> 00:01:36.333
 to exploit an RFI vulnerability in the
“Mountain Desserts” web application.

00:01:36.700 --> 00:01:41.066
First, let’s briefly review
the contents of the webshell.

00:01:46.933 --> 00:01:52.866
We’ll use it to test the LFI vulnerability
from the previous sections for RFI.

00:01:53.200 --> 00:01:58.933
The code is very similar to the PHP
snippet we used in previous sections.

00:01:59.233 --> 00:02:05.966
It accepts commands in the cmd parameter
and executes them via the system function.

00:02:07.033 --> 00:02:09.633
To leverage an RFI vulnerability,

00:02:09.633 --> 00:02:13.933
we need to make the remote
file accessible by the target system.

00:02:14.533 --> 00:02:21.533
We can use the Python http.server module
to start a web server on our Kali machine

00:02:21.533 --> 00:02:25.900
and serve the file we want to include
remotely on the target system.

00:02:31.166 --> 00:02:33.400
After the web server is running,

00:02:33.400 --> 00:02:37.700
we have completed all necessary
steps on our attacking machine.

00:02:46.900 --> 00:02:52.600
Next, we’ll use curl to include
the hosted file via HTTP

00:02:52.600 --> 00:02:55.700
and specify ls as our command.

00:02:58.600 --> 00:03:02.266
We successfully exploited
an RFI vulnerability

00:03:02.266 --> 00:03:05.266
by including a remotely hosted webshell.
