In this lecture, we will create a command center page if the government requests made it is post and
it has hostname IP address and operating system version as data.
We will return the command from a database according to the given information.
To do so, we will be using store result being resolved and fetch functions.
If you are new to these concepts, please learn more about them before keeping continue.
So let's start coding.
Create a new file called.
Get comment that BHP and inside the get comment that BHP we need to create.
And if statement if the given request method.
It's post and.
If the post method has hostname IP address.
And
operating system parameters.
We will be returning the comment from a database, so we need to create a prepared statement in order
to execute our database curie's.
To do so, we need to include that profile because we need to use that mailshot variable in order to
execute that database queries, so let's create a prepared statement.
For receiving comment from the database.
I will call it Command Curie and our jury will be
select command from the victims were hostname is, of course the question mark and IP address is, of
course the question mark and operating system is, of course, the question mark.
We will be replacing those question marks with different parameters.
So let's replace them by using Binda method.
The data type of the given parameters will be string, so I'm using three s four three parameters and
replace the first question mark with hostname.
And second question might be replaced with IP address and the third question mark will be replaced with
operating system.
And then we need to execute augury.
In order to store results, we will be using store result method.
And in order to assign the result of security to a variable, we will be using being resolved methods.
It takes an argument, I will call it command variable.
So the result of security will be assigned to command variable.
And lastly, we need to use pfeg function to fetch results from the database.
And then we can return the comment by using echo function after returning the comment, we need to remove
the command from the database in order to prevent duplicate comment executions.
So to do so, we need to create one more prepared statement and let's call it remove command.
I will call remove command and create jobs.
Creates a new prepared statement and our comment will be.
The from victims.
Actually, let's use the update function, update victims set command is empty where hostname is the
given host name and IP address is given IP address and let's replace the question marks with the given
parameters.
They will be strange, both of them will be strange and replaced the.
First question mark with the hostname parameter and the second question mark with the IP address parameter
and execute the Courey.
So we are ready in order to test all caught.
We need to put a sample comments into our database.
Normally, the comment will be said from the control panel interface, but we will create that page
in the further lectures.
So just open your database and create simple commands.
Let's see the data in the victim's table and let's set a sample comment to the first sample victim.
To do so, use update function of my skill updates, victims said command text commands where ID is
equal to one.
And in order to store called, we need to send the post request to get comment that page to do so,
we will be using Kerl.
We have already installed the kernel in the previous lecture's.
So here's OLDCO comment or comment is.
It has.
Hostname IPN operating system parameters, and it sends a post request to the get comment that page.
So.
No comment has been drawn from the database, there must be an error to fix this.
Let's check the Apache logs.
I won't be closing the video because you may face the same kind of errors.
So let me show you how to fix those.
Let's check the Apache blog page, as you can see, or page returned to hundreds as a statistic also,
which means that there wasn't an error, internal error.
So which means that all has worked.
Let's try the command again.
Let's check our database
and verify that our database has a sample command in victim stable.
Yes, actually, tests and the whole sample comment is test command, so what is wrong?
Let's check the parameters given parameters.
I may yep, here is the error.
So it should be operating system.
So there is a typo.
And let's try to execute our comment again to see if it is a return.
The.
Past comment or not?
Still not returning the comment from the database.
So what could be the problem here?
Let me check again the IP address.
That's the KOORIE, the IP address segment from the victim's.
Not the that should be the key word here, so oculi was wrong, so that should take solid case and let's
try it again.
Yeah, as you can see, this comment is returned and if I try again, it won't return.
Any comment?
Because he removed that comment after returning the comment here, returned the comment and was deleted
from the database.
So we have completed our task.
That's it for this picture.
See you in the next one.