Okay, now we have done almost one of the one section or one part of creating our vulnerability scanner
and 3 or 4 section or four part of it still not completed.
Okay.
So now that we have created this program that is extracting links, and the next thing is something
that we create and we need to create a program or this part is going to be about extracting forms,
okay.
From the web page that we want.
And then uh, executing or putting some data to the form so we can see the result.
Okay.
So here we have some thing or some part that was doing the extraction form for me, for us.
Okay I'm going to use this code.
Just copy and paste it and then modify it to Uh, user here, so let me.
Just a moment.
I have this method.
Okay.
And let's create another method.
This method is going to be extract arms okay.
In here we are going to give this the URL.
So it will get the URL and then extract the form for me.
So how can I do that.
Very easy I can copy that uh, from here.
Or I can create it myself.
Uh, let me see this part.
Okay.
We use the request method.
Then we have the beautiful soap here.
Okay.
That needs to be imported first.
And then we have first HTML point all.
Okay, let's copy three line from here and then modify it here.
Okay.
The first thing is we need to import beautifulsoup.
Okay.
Uh, we can use from BS4 import.
Beautiful.
Soup from base form all the time.
I'm writing this form.
I don't know why.
Okay, so from BS4 input Beautifulsoup.
When we import that then we can use it here.
So we have the response and the response is equal to right now you see we use the request here that
when it's not exist here okay I need to remove this.
Instead of that I'm going to use session.
So self love that station.
Okay.
Uh, dot get.
And instead of target URL in here, I'm just going to provide the URL that we are giving that as argument
to extract form method.
So that is that was it okay.
And the next thing is beautifulsoup.
We have post HTML.
Uh it is equal to Beautifulsoup dot response dot content okay.
Response dot content.
And the next thing we are storing this data, uh, the form into something here, uh, from the list.
Now instead of storing this into something, I'm going to return it.
Okay.
So return past HTML first HTML that find all and then the form.
So this will extract the form for me and then it will return it.
And then I can use it somewhere.
The next thing is going to going to be another method.
This method is going to be submit a form maybe.
So the first thing that I am going to give to this is going to be the form okay.
Because this is going to extract the form.
So I have the form from here from this method.
And then I will give the form to this.
And the next one we need to give a value okay.
So I will let her explain it.
And then the URL that is going to be necessary URL to the specific form okay.
Now also we have done this into this part okay.
We have action is equal to something blah blah blah that is here.
So let's use it here and then select this part.
Hit tab once and we are done okay.
Action is equal to formula.
Get.
Okay.
Action.
So we are searching for action.
If the action is, um.
Do something okay.
And then we are joining these two URL okay.
One of them is target URL with the action.
So we are parsing that.
So in here now instead of giving this target URL I am just going to give the URL that is coming from
here.
So and then print our post URL.
Um uh okay.
And next thing we need actually I don't need this.
I can remove it.
Not necessary.
The next thing is going to be a method.
The method is going to be equal to form that is here.
Okay.
It will come that get dot get method.
It will get the method.
Maybe it is uh post or get or something.
Okay.
Now I am going to remove this print from here as well.
Okay.
And then we have the input list.
We will get all the input.
Okay.
We have found all the input.
That is okay.
And also we have post data.
It is a dictionary.
And then I want to iterate through the all inputs.
So for input in inputs uh input list.
So in here I'm going to uh you see we are capturing three things here.
Name type and also value.
And I'm checking if input type is text.
Then enter or change the input value that is here and to name it.
So you see that we are changing this to name it.
And now this time I'm going to change it to something else that is going to be value.
What is the value.
Value comes here.
Okay.
And then we have post data input.
Input value.
That is okay.
And also you see that maybe or sometime or all the time here right now here we are checking that request
dot post.
That means we are just using the post method not get method.
So we need to check that here.
If the method is post then do this.
If it is not post then we need to handle this in another way okay.
So before that let me.
Write in here and I am going to check if the method is going to be equal to if the method.
Okay.
Uh, if the method.
Let me see where the method is.
Okay.
That is here.
If the method is equal to.
Post.
Then let's return this thing okay.
And also let me hit this that in here right now.
You see we are using request.
But instead of request I am going to use self dot session okay self dot session dot post.
And then I have the post URL.
And then data is equal to post data.
So this is the if part.
If it is not then it is good.
Okay.
So when it is gate come on.
When it is gate we need to return something else.
And that is going to be return um self dot session dot get.
And we have the post URL.
And the next one is going to be params.
And this one is going to be post data.
Okay.
So.
Uh perfect.
I will show you now something about the links, the forms that some forms may use git.
Some forms may use post as method okay.
So and here also we need to handle this thing.
So right now you see we are using this travel method.
Let me comment that and use another method that we just created.
The first thing is to extract something.
Okay, so let's call that method uh I have the forms.
For example, it is going to be forms that I that I'm extracting.
So I use the object dot extract form.
And you see in here we need to give a URL okay.
Okay.
It is only asking for one URL and no more thing okay.
So here we need to provide a URL for this.
And let's see for some URL here.
Uh let's go to Access Reflected I'm going to give this okay.
Let me use copy.
P and then I'm going to paste that here.
Use Ctrl V to paste it.
And let's print this form once to see what do we have here.
And then let's see.
And right now you see it is giving me a form okay.
It's action nothing.
It's method.
You see right now it is get okay and name.
And also we have what is your what's your name.
And then we have input type is text.
And also we have something like that.
So.
Also if you want to see that detail into the browser you will be able to see that too like here on the
mouse.
And then select that.
So you see we have a form name is this action.
And then we have the method which is get here okay.
Perfect.
So what is the next part?
The next part is to use or call the other method that was to execute something.
Okay.
Submitform.
So I want to submit something.
The first one I want to give the form that we just get it, okay, that we extracted using this one.
And then I want to give a value and then I need to give it a URL.
So.
We are going to call it here I'm going to restore it into something called response.
So this response is going to be equal to the same thing.
Here goes here okay.
And we have what was the name of that.
This one was extract form.
The other one was submit forms.
And here it gives you the first thing which is going to be.
Uh form value and then URL.
So the first one is going to be farms.
So we have our farms here.
Okay.
The next one is going to be a value.
So as you see this form is a list.
So I want this to be the first uh element.
And then you need to give it a value.
For example I'm going to give it test test for just hello world.
Let's see.
Hello.
Hello world.
As or as a value.
And then you need to give the link or the URL.
So the URL is going to be the same thing as goes here.
So I paste it.
And then I'm going to print this response and then use Ctrl s.
Is.
Now it will come first.
It will extract the form and then it will.
After it's extracted, it will come and use Hello World to execute that or on the form and then give
me the result.
So let's see.
What is going on.
Okay.
So right now you see that we have code 200.
That means it is happened successfully.
So let's print the content of this.
When I save it coming back here heading enter.
You see the first thing we use we get is a form.
And then we have this thing.
And then it will give you hello world here somewhere in here.
Okay.
You may be able to find that, but I'm not able to find it again.
You see, we have home and then.
Okay.
I'm not able to find it.
You may be able to find it if you search it.
Okay.
So by the way, that means we have some kind of result.
Uh, here, if I search for hello world, not search, enter the hello World here and then hit the submit,
you will see that we get a Hello world here.
That means it is vulnerable for XSS.
Okay, attack.
We get the hello world here.
So you need to.
You must be able to find this hello world in your result.
If you're.
If you don't believe me that you're you have that kind of result.
So I will just copy this and then paste it here.
And then control F it.
And then we have.
Hello.
You see that here?
You see?
Hello.
Hello, world.
Hello.
Hello, world.
Okay, I think that is it.
And hello.
Hello, world.
Okay, that is the same thing.
When you see when you give the hello world, you will get one extra.
Hello.
Here.
Okay.
If you, uh, test something else.
Let's see.
For example, I search for test.
Let's admit it will give you hello test.
Okay.
And this hello comes from the website.
So.
And that is it.
Okay.
Now you're able to do two more things.
One of them is to extract the form to execute something on the form.
And still we have a lot of things to do with this.
Okay.
So thanks for watching and I will see you in the next lecture.