Hello, everyone.
So in this lesson, we are going to understand about nuclei
file based templates.
We have seen so far that with the help of nuclei. We
are able to create templates and send it for
HTTP request and responses.
But with the help of nuclei we can not only send
HTTP request, but we can search for
files as well.
This is really amazing. When you have
a bunch of code a bunch of files and you
want to search and match or extract specific
words.
So all nuclei templates using the file block starts from
file colon.
Nuclei file template extensions are also
there which means you can match specific
extensions with the particular file as well.
If you want to match for all you can specify hyphen all
which will match all extensions or else
you can specify extension schooling by go
txt Etc.
Matches are the keywords that match a particular
content inside any file.
So there are two types of matches in file-based templates.
The first one is the word and the second
one is a Rejects.
both matcha types match in the entire request and
response
word matches the exact same word in
the whole file in the whole word. Whereas rejax
matches for a reach X word into that
file.
There are some other options that you can use while you're
running a file based template, which is Max size,
which allows to provide a limit of
the size file that nuclei can read if I
don't want to read a file which is greater than 5 MB
you can specify that as well.
No, recursive disables recursively enumeration of
files and folders inside multiple directories.
So it is the Practical time and let's see how you can use this.
So currently I am onto my terminal and
I have created some files inside the
files folder
It's cool with there and let's see some files. You can
see file 1 File 2 file 3 4 and
5.
alright
So now we are going to write our first
file based template.
Let's give it a name as file underscore txt.yml.
The ID block b simple filematcher. This
is the information block.
and now
this would not contain request block
instead would contain a file block. So
file colon. We only want
to match extensions of file that have txt. You
can replace this
with all as well. If you want to match all the
files currently. Let's stick to txt only.
I'm also specifying the max size as 1024 only.
In the matches. I'm also specifying the
word type that I want to match which is Apple.
So this would find the word Apple in
the files as a whole word.
So let's run this.
So I'm going to specify nuclei and the
template that we have written. So the template
name is
File underscore txt dot yml, let's specify
the target as well, which is our
files folder and let's hit enter.
Once we do that you can see we are successfully able
to find
Apple matches into file 1 and file
3 let us also
run this in verbose more. So let's
run it in verbose mode first and you
can see it's successfully mashed in file one and file 3.
Let's run this in debug mode only.
And you can see this is the response that we have got.
Here we can identify that it matched Apple in
file 3 at line number 5.
excellent
Here we can see file 1 at line. Number one apple
was matched successfully.
This can be super useful if you want to identify hard-coded
usernames passwords API Keys
tokens Etc in multiple files
as well.
So I hope you guys understood how you can use file based
template.
In our upcoming lesson. We are going to see how we
can not only match for a specific word, but
extract it as well. Thank
you.