Hello everybody.
And welcome back.
And right now what we want to do is let us implement a function that will take the screenshot of the
target's b c this is something that we saw in the metal plate framework a maternity show.
So let's try to actually implement that as well in our rivers show.
So of course we will not be coding our own screenshot function since that would take a lot of time.
What we want to do is basically use a library that already allows us to do that.
So let us see which library that is if you just find find or search on the Internet you will be probably
you'll probably find our library called the basically the MSF.
Now the MSF is a library that allows us to actually take a screenshot with through two or three lines
of code.
Then the screenshot is saved under a certain name and then we have this screenshot of our target's browser.
So we will implement that.
So let us just open our remote shall first so open it.
And what we want to do is first of all go down to the elif statement so let us scroll down right here.
Now let's add another elif statement that will allow us to take a function with a part of me that will
allow us to take a screenshot.
So tell us if the command and the first 10 letters is that is how many letters screenshot has equals
equals screenshot.
We want to actually try and accept as always so our program doesn't crash.
We want to run a screenshot function.
So we do not have this function yet but we will code it for now and let us just put it here and let's
see what we actually have to do after we have the screenshots of this cell shell.
So we need to read from that screenshot and we need to send the files of the content of that screenshot
to the server.
So we will use the similar as before in the file download an Apple Google basically open the screenshot
itself and it would and we will send the encoded content of that picture basically to our server.
Now if you open right here now let me just show you if we can find it.
The MSA library saves every screenshot it takes as a monitor minus one dot BMG.
So emphasis library I missed this but it doesn't matter.
We will be able to find it.
Let this just load.
Let's see and assess and ultrafast cross platform multiple screens and module in python using C types.
So let me show you.
We will also have to import the C types.
So we will do that as well.
But right now let me show you that it saves every every screenshot as monitor dot or monitor minus one
dot BMG.
Let me just scroll down if it says anywhere.
We will have to also perform these commands since we need to download it in our main folder.
It doesn't say it anywhere but trust me it will save the file or every screenshot it makes as a monitor
minus one that BMG.
So first of all we need to think about two things.
Then if we want to for example take multiple screenshots if it all saves them as our same name then
it basically means that they will overwrite each other.
So we need to make sure to actually save two different screenshots after two different names.
So let's see how we can do that but that is something that we need to do to take care of in our server
side of code so for now on.
Let us just try to implement the sending of the contents of the screenshots so we will open monitor
minus one that BMG.
So make sure to specify the same name since this is the name that the says library saves the screenshot
us and we want to specify the read by its function.
So we read from the phone from the image and let's save it at C S for example for a screenshot then
two dots at the end pops where two dots there they are.
And we want to reliable send this function or this screenshot reliable sent base64 since this is our
picture we want to encode it so it doesn't crash base64 encode see as Dot read and we specify the open
and closed three brackets.
So this is basically what we want to try to do can after this.
We also want to remove the screenshots so it doesn't stay on the target system since with when we use
the screenshot function it will save the screenshot on the target b c then it will read from it and
send it back to us.
So we do not want to leave that screenshot there we want to actually delete it right after it sends
it.
So the target doesn't see it.
So always dot remove is the function that we will use from our always library and then we remove monitor
minus one.
That being G I'll make sure to specify the cream.
Otherwise this will fail.
And then in the except we want to send our normal reliable send
exclamation mark for the error first of all let me just find these quotes there.
They are failed to take screenshot and then we close this.
So we send an error message that will say failed to take a screenshot and right now what we want to
do is basically just find or basically code the screen shall function with the emphasis library.
So first of all let us go up and import the emphasis library as well as seed types so import si types.
Maybe we will need it.
It said that it is based on seed types and also type here from A.S. import MSF.
This is how we will use it.
So once you specify it let's add the function itself.
So let's set it right here.
Def screenshot since that is what this part is what since that is what we specified in the coding of.
If statement so and all we have to do right here is if you know the syntax it would be very simple.
So right now with M ss as a function as screenshot
we just want to step here.
Screenshot that shot.
This will perform this screenshot function it will save these screenshot as monitor minus one that being
Jeep and then we will read from it in our LCD statement.
We will open the file for reading and we will send the file.
We do reliable send and base64 encode.
Then we will remove the screenshots so it doesn't stay on target b c in case that doesn't work.
We will send to our server failed to take screenshot so let us save this and close this since we were
done with the reverse Shell site.
Now we want to do is open our server and actually code the part of the server code for the screenshot.
So what we need to do.
We do not need any function for this or we want to.
All we have to do is handle the message back properly.
So let's add an LS If statement else.
If command is first telnet there's a screenshot you close to screenshot
we want to try to receive the screenshots so with open and right now we need to specify the thing that
I told you before.
So if we open the file we need to make something that will open every screenshot with different name.
So what we will do is we will add a variable called count for example so let us do it right here.
Global count we make a variable that will count our screenshot so we go down here.
So I did just below the shell function and then go on here with open and then we need to stack the file
name to be different so we will use the percent deep for a number or close this.
Let me just open the apostrophe at the end as well so screenshot percent deep and then we want to instead
of percent use count every time.
So count and then comma right bytes.
So we want to write the screenshot we want to call it for example as screen we call that is the file
name and what we want to do right now is add variable for example called image.
So image equals reliable dot or underscore received.
This is us receiving the image itself.
And right now what we need to do is decode the image.
We did these base 64 so letters to image decoded equals base64 dot v 64 decode and then we paste the
image to be decoded.
Now we need to specify since we are receiving either our image.
If it works well enough or either a string that says failed to take image so this image variable right
here will either be a content of a screenshot or it will be a simple string that says failed to take
screenshot.
So once we decoded we need to check if it contains if image underscore decoded and first four characters
equal to this.
So this is something that is specified in the reversal function.
When it fails to take screenshots so these are the first four characters and effort that goes failed
to take screenshot but will only specify first for if the first four characters are equal to this we
want to print the image that underscore decoded.
So we actually know that it failed to to take the screenshot.
Else we want to write the screenshot to the file so screen that screen that right image decoded.
So simple.
Simply explain.
This means that once we receive either an image or stream we check if it is we first decoded.
Then we check if it is a string with this form.
If it is of an error message if it is not equal right the contents of the image to the file screen Now
also what we need to do is after this for x we need to increase count by 1.
So for example if count equals I don't know 3 or 4 and we also need to specify.
We need to specify.
Count to be a number.
So we said global count.
Global count
unless specified.
Then up here since we put to be global.
Not really sure if it has to it probably doesn't have to be global but since we said that it is global
we will set count to be 1 for the first time and we will use it right here.
So global count is 1.
So the first screenshot will be saved with the name screenshot 1.
The second screenshot since this will be increased by 1 will be named under the screenshot screenshot
2 and so on and so on for as many screenshots as we take.
So let us see how this works.
Control or to save control X to exit and we need to compile the program so we use the same command.
I just find it once again.
Here it is.
But before we use this command what we have to do is actually installed the the MSF library and steps
library.
But I believe Italy already has he types into our wine folder so we use wine slash root not wine drive
C by 10 27 and Python not exceed 10 minus M for deep pit.
We use Pip to install and assess.
I believe we can use it with this thread here so let's see if this works it should work.
So we are installing the MSF library for our wine python.
Collecting MSF and hopefully it will download it successfully so we will see and we can see it all finished
successfully so installs collective packages MSF successfully installed MSF.
So let the see for the C types as well.
It probably does have them but just in case so we don't actually run into an error.
Let us collect that as well if it has them.
I believe it will say something like requirement already satisfied or something like that.
If it doesn't have them it will download it and we will be able to use C types as well.
So no matching distribution so we already have that.
OK so let us compile this right now with the same command.
So one file no console press enter right here.
Meanwhile we delete this file which is previous Shell.
Are you sure.
Yes I'm sure.
Then we go and plug in our USP drive.
So simple as before.
And as soon as this finish finishes compiling we can paste it to the kids we drive.
So this more reverse shell to the media route calorie Caroline.
We move it.
We go on directly back and we run our server unexpected you on indent so that see.
We have a code error in our server at all so let us see where it is
not through this show.
If else.
Right here
so what is the error.
I'm not really sure if it has anything to do with this so let us see if image with open try
I accept.
Oh yes.
So we didn't even code the except through.
So what happens when it doesn't work.
So except
we want to create an hour for actually we do not need a try and accept the challenge.
Right here we have it in our reverse shell so we can just delete this.
We can just leave it without the try and accept.
So us see once again server listening for incoming connection so basically at the screenshot part just
delete the try that we added since we do not need it.
But we want to do right now we want to go to the Today unplug my ISP try.
So first of all unplug the U.S. me drive
and right now what they want to do is basically run the reverse show that the AKC again from the US
beat right.
It doesn't even matter you can paste it on your desktop and it'll work the same.
So let us see how this will work right now.
Let us lower our screen so that screenshot actually takes the part of the screen of Windows 10 as well
so it doesn't take on the screen of the Linux machine.
And if I just type your screenshot it will take a few seconds in order to take the screenshot and also
send it back to us.
I believe and soon enough we should receive screenshot successfully taken or something like that.
So let's see it's taking a rather long time.
We didn't receive anything so it means I believe that screenshot worked well enough as we can see on
the desktop.
We do not have any monitor minus one that BMG so we can also take the screenshot with Calvin next machine
in the lower right corner corner so we can see that it saved properly with screenshot 1 and screenshot
2 that it doesn't overwrite the screenshot.
So let us see as we can see it does take a few seconds to perform this but it should work.
Once we check the folder of our killer Linux machine which is the same folder as our server so let us
open this up we do not need this anymore.
We can quit the shell and if I just type your files we have screenshot 1 and screenshot 2.
Now let's see if they are actually the pictures that we got that we took from our monitor of Windows
10.
So let's open the folder.
We go to the root we go to the Python program so let us find Python programs reverse and as we can see
screenshot 1 and screenshot 2 are good screenshots of our target desktop.
So right now as we can see we can successfully take screenshots of the target's machine.
So this is another useful thing.
We coded and we will continue in the next video.
Hope you enjoyed this one and I hope I see you in the next one.
By.