Hello everybody and welcome back.
Right now let's see how we can write our keystrokes to file every 20 seconds for example or not really
write.
We actually want to upend the keystrokes to that file.
So let us see how we can actually do that.
Let us make our final project which will be here longer apply.
So let us first copy everything from the key logger to the PI select everything
we actually can select everything so or I'm not really sure if this will work.
Control it doesn't work basically will have to copy from two times or you know what we can actually
just simply rename key logger to the PI into a key logger Pi which is a much simpler solution.
So let's first delete the key logger that you see and delete the key logger wondered by now.
Let us now know our key logger want a PI and right here what we want to do is basically just add it
to the report function since that is the function that actually sends us back the actual keystrokes
to our terminals.
So let's first of all see what we need to do.
So basically let us think about it.
We want to write this to a file so we do not want to print the keys.
We want to type here with open but not right here since that would be something that we actually don't
want to do.
We don't want to open our file every 20 seconds.
What we want to do to our file is actually write to it every 20 seconds.
So let us see how we can do that we need to open the file.
Let's see where actually we can open it so we can open it in the process keys.
I believe so with open.
Well let's not open a thread here.
Let the sexually open it out of the entire program right here.
So before we actually run any of this we want to open the file so with open and we want to call it the
for example test or key logger that the extent being before we want to open it as the append.
And the operators for example.
And then what we want to do after that is actually run run.
This function right here
both of these functions.
So let me see let me think about this this should actually work if we run the report function it will
run it every five seconds and in our report function we will actually try to for example
keys equal nothing
or we actually want to do it before so faint.
Right.
I want to do is write the keys.
Then we set keys to be nothing that we call the function every five seconds which we will change to
10 seconds
and we also listen for the for the listener of our keyboard.
So let us see if this will actually work.
So control.
Oh let me just check this out.
KG The pi hello world.
What is happening enter we wait for example for 10 seconds we can see nothing get printed out right
here.
But if we close this program we have key logger that the 16th that doesn't have anything which isn't
really good.
So let's see what we need to fix right here.
Process keys.
We set the report to be good.
Timer right here.
Keyboard listener.
So maybe we actually have to wait a little bit longer.
I'm not really sure let us actually run this once again.
Hello.
Now let's wait for 10 seconds to pass.
Maybe we didn't wait long enough.
This basically doesn't work we'll take another approach with.
So we 10 seconds pass for sure so let us close this gap.
The key logger 2016.
Nothing there so something is wrong.
Let's see how we can fix it.
So now know Kyogle by
right here.
What we want to actually do is for example instead of opening the file right here let us open it in
our process keys function.
So we got this one back one back
and instead of actually doing this let's actually write something like this.
So right here
we do not want this.
We do not want to print.
So let us remove that and right here.
Before the global keys we want to use the with open and then let's open for example key logger dock.
He exclaimed open it for the append as always.
As Finn let's call it like that then what we want to do is basically write the string of that key.
So what we actually want to do right here is tab this all of this to our file to see if this will work
if we tap every line by one so it belongs to our top statement right here.
Let's see if this will work.
So keys and this as well.
And then down here we specify Phil right keys.
Let's see if this will actually work.
Set this to be five seconds so we don't have to wait 10 say this.
Now this I have no idea this will work.
We will have to try it out.
Attribute error in right keys.
Let us see what is wrong.
OK.
We probably can't really do this right here.
But what we can do is actually perform the print statement or the right statement right here.
So let us see if only one of these will work.
So print or not print find that right keys.
Now I'm pretty sure what the error was but let's type here.
Hello world once again presenter wait for five seconds.
We will close this program in order to see if anything has been written to our key logger that the extreme.
So Cat kill over 60.
And here we have hello world.
But something right here doesn't really work since we got hello world printed out here five times or
something like that.
That means that we actually get the key logger to be specified wrongly so it opens this file every time
and then it writes Our keys every time
but what if we do it like this.
So let us get everything back as before.
Now sometimes it's good to experiment with things like this and this is all you actually learn to code.
This part right here we can delete
this is how you will actually learn to make your own programs by experimenting with some of this stuff.
So sometimes some function will not work.
Sometimes something will not be specified correctly so you have to experiment in order to get it right
next time.
So right here we want to actually open the file right here after the keys.
Let the sexually open it normally so free equals open key logger
not the 60 we open it for the appending man then we actually write here where we actually can usually
the global keys as a first line so we don't get confused.
So copy it right here and then fill open for the appending and then in that right case we write the
keys and then at the end we want to actually close
the program or the file.
Pardon me.
So find that closes what we use to close the file and let us see if this will actually work right now
we run this Hello World Center we wait for five seconds in order to see what we get printed out in our
file.
So I believe five seconds has passed.
So we control access.
So right here then we check out the DST and we can see we finally got this to work we only got printed
this yellow world in our file.
We had two arrows.
First time we didn't get printed anything.
Then we copied to another function.
Then we got printed out Hallowell like five times.
And right now it's not Rochelle.
Everything works well.
So what we did this function should stay the same so as before.
All we have to do is actually at the opening in the report function which will open every five seconds
this file then it provide the keys.
It will set the variable keys to be nothing and then it will close the file then it will call this function
once again in the next five seconds.
So let us see if now we run this for a few more seconds.
So first we write Hello world in first five seconds and in the next five seconds we will write something
else so we can see if it adds twice or not.
So after five seconds
what are you doing right now.
Question mark that a presenter for example type your not much.
What about you presenter and then we can close this can see what we got printed out in our key logger
that the axes so hello world.
What are you doing right now.
Not much.
Now what I am confused about is this part right here.
So it did print out hello world.
What are you doing twice or basically just a hello world.
So let me see.
Why did it do that
so let's run this once again.
Hello.
Which will be the first five seconds and then in the next five seconds will type world and it next five
seconds we will type.
For example what.
So world
then we wait for a few seconds and we will type here.
What so we can see how many times it printed out each word.
And let's wait another five seconds before we actually close this.
So hello.
What now.
That's right.
Now close this and get our key logger done.
Hello world.
What are you doing right now.
OK.
Oh yes.
So we actually opened this file every time so we actually appends to it what we want to do now as we
could see it printed out everything correctly so hello world what.
Now what I.
This part right here of which I was confused about is because we actually need to delete the file every
time we close our key logger so right now
it opens this key logger to 60 every time and it appends every time we use this key logger.
We will also get in our key logger.
This part right here.
So this is good once you actually want to for example write everything to a file and then get back everything
that the user has typed which we actually want to do but we may need to make sure that right after the
we close the reverse shell we actually delete the key logger dot the file.
So what we need to do is basically nothing at the moment but once we code this in the next we do and
in our reverse shell we need to delete this file every time we actually close our reverse shell.
So what we will do that basically at the end of the program we will just import the OS and that always
start remove key logger dusty axes so that'll be about it.
In this video we will have to specify a few other options in the next video and then we will be good
to go.
So I hope you enjoyed it and I hope I see you in the next video by.