Right now, it's time to write our own first Web directory discovery, so again, I already write the
code and upload it.
So to avoid any stupid mistakes syntax in order to avoid wasting your time.
OK, but don't worry.
Again, we would go through this line by line and explain everything indicates.
OK, all right.
Now, actually, again, I already upload the code so you can download it and open it so we can test
it together.
Right now, the first thing we import this library, which is called requests, and actually this is
the main library that used for their directory discovery tool.
OK, now here we define a target.
You are a variable and we input please enter a target you are in and then we have that fine name variable
and inside it this enter the name of the file containing directory is OK by the way.
You can but that addresses that are the one that are V2 and so on.
But it's up to you how to customize your script.
But for now just we will do these things.
OK, ok.
Now we define a function and this function as you can see, we call that request and we put a barometer
called You are OK.
Now this function we will call here, actually, by the way, here you can see.
But don't worry, we'll go to there.
So for now, def request you are now try this except this and on this exception.
Besse OK, now try this.
What is this.
So we will return because this is a function, we will return the requests, which is the name of the
library we use here or you don't get and we will use this function digit function and this will get
when I get to request OK for it.
For what.
Or wear to this HDB slash plus which is a concatenation with the U R N and the R is that variable or
the parameter we bust here from here as you can see.
But don't worry, we will go to there and we will kind of that and repeat that, repeat the logic again.
But don't worry, it's fine for me for now.
No, try this.
So if there is no hero, it's OK, we will return request to that response to somewhere, OK, but if
we have excessive except request the exception, that connection and by the way, that I accept here,
this is something from that library itself, which is the request library.
So accept this thing and this thing actually, which is request the exceptions, that connection, then
do what best or you can.
But this is not found or something.
But actually it is makes sense to only send there what we found, not what is not exist.
Right.
Because it is a it is a directory discovery after.
All right.
So far so good.
Now this is the function.
This would be used to send the request or return the request.
Now, how this logic actually work, we would talk about this right away, which is fine.
We define this fine variable equally open.
And the open is we already talked about this.
So we open the find in the directory or the file that containing all the directories.
So slash admin, slash something or whatever.
OK, and we will open it.
AZRI so the file we provided here, we will open it as readable and we will go.
As for loop here, which is for line in file.
So we would go through line by line for this specific file that we provided here by timing its name.
So this is for the first line and the first line, we defined a variable called directory.
And we can see that we used a line, which is the first line from this fight dot strip.
Now this to strip it from any white spaces, OK?
And after we strip it from any spaces for this specific line in this file, we store it inside the directory
variable.
OK, now we have the full you are, which is the target you are in, which is that something, as you
can see, that we provide here?
Enter the target.
You are in either IP address or at the domain name.
It's OK.
It will do the job, then we will add or concatenate that slash here, the forward slash and then we
would call that in the directory, which is the one we strip from here, which is line the strip and
we will put it inside the actually and we will use it here.
OK, so the four year old will be the IP address or the domain name would clash with the directory or
the line we have in this specific file, which is the one that we open it from here.
You, as you can see.
All right.
So far, so good.
Now we will create a variable called response, as you can see.
So we will use the request function, as you can see that we define here.
And we would bet the full you are that we have it here.
OK, so the phone you are in will be best to this request function and then it will try or accept.
Depends on it.
So try if it is good, nothing or nothing.
The problem we will return the value and the value will be request to get the HDTV.
With that you are ok, which is what we provided here.
OK, where it is yet.
Which is the point we are OK, including the target you the slash and this directive by the way, if
we provide the photo array or that target, you are right, if we provided HDB, this will be redundant
actually or it will be extra.
So actually to be slash dash and another activist, that's OK too.
There are a lot of ways to get rid of that.
But anyway, we will not enter it here.
It's OK.
It's not nobody deal actually.
You can just put the filter if is or or you can do a lot of things actually.
But anyway we will just assume that you are on is the domain name or the IP address OK without using
that protocol.
Which is that to be all right now after we got the request from here and return everything.
So either this or Besse, if there is requested exception, that connection, which means there is no
connection.
So we would best Abbott if there is a connection, which means that you are on is existed or the directory
is existed, it will be returned and will be stored inside the.
OK.
Now if the response is empty, so it will not this if statement will not work, but if the response
has value or has a retained value.
So yes.
If response.
Yes.
Which means yeah it has value.
So which means that we will bring this thing which is discovery or discovery.
Discovery at this Beth.
And we would bring the footbath that we basit to the request.
All right.
OK, so far so good.
Now let's have it here.
As you can see, I already have the code here, which is directories that by by the way, I already
uploaded it.
So you can just download it and destroy it out together.
OK, all right.
Now, Python three and then directives.
OK, by the way, I have this list, the text file, actually if I open open it using any text, ignore
them, for example, you can see that I have some data inside it.
OK, so text login and login here.
As you can see, BHB, my admin web log in this for the WordPress, WordPress admin tweaky or actually
a lot of things actually.
But this is just for testing for for example.
Yeah.
Actually before I run this command on this program, I already have this Brotherman machine that I already
talked about in the previous section.
So you can see that I have it here and this is the IP address for it.
So I will use it here actually.
And by the way, if I go to its IP address, which is this one, you can see that we have it here and
you can see that we have the wiki readme the text.
Actually, I put some of these actually here so you can see that bhb my admins or copy that and basically
they're.
Well, actually.
Yeah, and let's put it here.
Yeah.
So actually, this is for this thing.
So instead of testing on real machines and actually this is a better way to do that.
By the way, if you are using Linux, you already have a long list of words, which is the text?
I think it is.
It is very big.
And you can just use it there if you are interested to check more.
OK.
All right.
Now it's an under command.
You can see it will start asking for Target.
You are in that spot or provide the IP address, which is one one, as you can see, one one down.
Yeah.
So enter the name of the fight, which is what we have on the current directory.
But remember, this is this must be in the current working directory of the program or of that outreach
by.
So yeah, you can see that.
Yeah.
Discovered directory at this because I already know there is something that I've discovered we actually
might have missed.
All right.
So actually if we have a long list of words and we want to test them out, we can put it and use this
long list of words, OK?
And it will start looking and searching for directories inside this.
OK.
All right.
And by the way, you can customize it whatever you want so you can instead of putting please input or
present into the target or present that containing directories.
No, actually, you can just provide this as a sister, RTV, as what we learned in that Botkin section
and use this actually, again, that RTV two or three or whatever.
And you can just use this instead of writing it like this.
No, you can go to the IP address here and provide the name of the directory or the list of the directories
that's supposed to be here.
OK, or the.
Suggested that.
OK.
By the way, you need to provide your Python program here with a very huge list so it can search everything
possible for this.
You are.
And again, I'm using.
I recommend you to install it to download as a virtual machine and run your program on this method.
Don't use that on real machines or servers because you will get in trouble.
All right.
I want you actually you need to be cautious in these situations.
All right.
Thanks for watching.