We are going to study about the keel over and how to make it with the python in dyslexia.
So for that we have to make use of a python package that is bind.
So by inputting uses the python packages are the module that will allows us to control and monitor the
keyboard and mouse Axon.
So for that we have to first install that package on your machine so first of all let me just open my
command prompt and use this python pack is manager which is beep here and I'll just say beep install
by input.
So this is the pack is that is going to this it is input and this is going to this being stolen are
much into control and monitor the keyboard as well as the mouse Dixon.
So let me just install it real quick and I have already started.
So I don't need to install twice so in your case you sort install this by input which is the module.
So next thing what do you need to do is open your browser and let me just type by input documentation
in this Google and let me show you the documentation part of William.
They did give to Lord and this is this small documentation for these back is and it would seem this
is the library that is going us to allow to control Lua and monitor basically input devices that can
be the keyboard as well as the mouse.
So you can see there is a two section over here saying the handling the mouse and handling the keyboard.
So let's see for controlling the keyboard first let's go over there and it is going to give us the the
defense scored over here saying that you have to first import your by input and that is key in a controller.
So this is very important here we have the key and a controller.
If we go to the monitoring section you could see will have the listener.
So this is very important this is going to this collect event until release.
So that means that this is going to be used to make the key logger in the case of our section or for
this selection.
So first of all we have to make use of this listener as a controller of this by input to the stick for
this on Press and on release attribute and we'll just join that the listener part or basically any keyboard
to our formatting key or basically to our Python cell or console.
So first of all what you need to do is simply use this by input and make some fun sense of the module.
And basically based on that once and so the method will just have the listener which will just act like
this way.
That is it to this collective end until it is released.
So let's see how we can just make this.
So first of all as always I'll just create the new script I'll save this discrete and let me say this
is a bad program.
DA B why endless lists.
Let me just say key lower key logger dot B way.
Let me just say this in the deck stop.
Now we have our script radio over here.
So let's make some basic program for our killer.
So first of all as always we have to import the module and we have already installed the by input so
we can now make these spy input and we want to import keyboard.
So first of all we'll just see for the keyboard.
So we are just importing the keyboard from this by input.
That means we can thus control and monitor the extent of the keyboard now.
So first of all let me just define one method over here which will be on press.
So here I'll just pass key so what are you going to do here is we'll just see the And over here which
will be printed so I'll leave scheme and list format this key and I'll just say pressed.
So this will be the output to the user and the format this first.
So okay let's format this with the key that is passed to the function so let's close this on this method
now.
Now next is on release method.
So let's make this on release.
And here we are going to pass again the key.
So in this we're going to print something that is obviously the key that is to be released while there's
a key and it is now released because this is unreleased matter.
So as this format does again with the key that has been released so let's format this.
Now here we have to take if we are creating a n0 there should be some key to quit.
So all this is key.
And if that key is it called to key dot EMC which is basically to quit that script.
So if it is the key.
What you gonna do is we're just going to print that is exiting from the key lower and less close this
first and after that we are going to return now false.
So what is this do dude here was we just made this only so this would be here and now we have this printed
over here with the formatting that this key has been released.
And if this is the case that we just placed the key that is easy then it is going to exit and it is
going to return a pulse.
But for some convention we have to first typecast to this through this string.
So first of all we'll just convert this to this string and we'll take that key with this key if that
key is EMC ordered.
So this is the keyboard key which is to exit.
So let's put our list not now.
So if we just remember in the documentation we have this list not right over here.
So we have to make use of this listener.
But if we see here it has imported the listener right over here.
But what we're gonna do is we have this imported keyboard.
So we have to call this listener from the keyboard.
So this a keyboard dot listener.
So this is our listener.
So in this listener I'm going to this add some of these attribute which is on press is going to call
us the on press method when keyboard is pressed and when the keyboard is release then we are going to
call again on release method which is done by this controller and we are going to this alive it is listener
and let's join this listener now which is basically the way.
OK.
So what we just did over here let's go to the documentation again and you can see it strictly right
here.
Okay.
So you can see straight here.
This is the way to this colleague the event when this is released.
Basically when this listener event is called so when there is any event that is pressed on the keyboard
or released from the keyboard this listener is going to be active.
And this is going to call on press and on release matter what we just did in this script.
And this is going to join us a key and this is going to return if there is any exit condition.
So what we just did here was we just submitted this by input to have the listener injected on this keyboard
so we can do similar in the case of the mouse.
So you can see for the most documentation right here.
And if I just say go in the mouse you can grow over here and you can now put some of this chord in the
listener on move on click on his call.
So now I'm just going to go with the keyboard for.
So let's take this verse.
So let me just say this.
And if you see we are going to run this from the command prompt so it is in here.
So let me this here on this come on.
Sometimes this is going to go first in the deck stop because it is in the deck step and now I have to
run these key logger.
So this is key logger dot way.
And it is saying there is no key logger.
So what is this do here.
Okay.
We just said key logger P Way that way.
Let me just go again.
So the name was b way Darby y if I had.
Now it is saying key dot into release.
So our killer Gary is active now.
So if I just say go to any Web site let me say Bing dot com and if I just go to the Bing you search
see that it is active right away.
If I press any key let me just starts here with a Google then you'll see that this key logger will have
the Google right here.
So have pressed the G and we have released the G.
We have a press deal.
And again the l.
So that means it is going to give us over here.
That is the Google.
So he has been pressed and released and again pressed and released so there is a two Exxon which is
going to be handled by this script on priests and on release when we just press this is going to be
called when we release the button of the keyboard.
This is going to be called and if he does see that if I just press EOC this is going to be called that
is Kedar DSC and we just exit out of this script.
So this is the way to work with this killer.
So next thing what you can do about here is some modifications.
So next thing what you can do over here is some modification.
So let me show you one thing that can be annoying over here is when you just run this script again.
So let me just run this again.
And we have to go again to the next step and it is obviously the way to
just execute it.
So if you see anything right you could see that key is pressed.
But we want something that is this e or this letter should be outside of this particular court.
What if we one that changes or modification in the key lower they say how can we can this do that.
And let me show you what I am talking about over here.
So first of all if I want to the screen the key code so you can do right away here.
When use this space that key you can also print that key.
So let's see that if I want key type to be printed the less formatted first.
And it is done with this format once then.
And now I want the class name.
So that means the type.
So if you want the type we have some inbuilt method the special method which is going to be class dot
if C dot and name.
So if you do this this is a special method.
So this is going to give us the type of the key.
So when it is say this again and you have to this exited first and now again if I just run the same
key lower.
Now if you came it is saying that it is not defined obviously.
So it was because this would be dark over here.
Now the comma let's say this again and let's go back to our command prompt
in here again Let's navigate to that deck stop let's run our bite and kill other
and now if I just enter any key you could see what is the key core type here.
So everything here is key code.
So if I say that if I enter the city at all then it is not going to active.
If I say yes then you could see that when this city I placed it is going to source the key type is key.
But if you press any chord from the keyboard that is showing us that it is equal.
So that is one man who in a modification you can do on a key logger to check if that key is either a
key that priest is either a key or key code if it is the key code that means it is alphabetical or if
it is a key that means it is some of these control statements that is placed in the keyboard.
So there can be the one modifications or next thing what we can do here in our key logger is to get
the key name.
So let's define the another method to get that key name.
So I'll just go with this and get he name matter.
And over here let me just pass the key and now first of all I want to take is instance this important
matter.
And so it is going to get us the object and about the key code.
So first of all we'll just get the object we have now keyboard which is obviously the module of this
spy input and we're going to get the key code and let's take this first if the article then we're going
to return the key dot character.
Only the character else we are going to return.
Okay as we are going to return our key.
Let's see what we're doing over here.
So we're just taking first.
If that key code.
So if we just remember from that meant place in that we just ceded this key code was the code that is
going to be something like a b c d.
So if we did the instance then we are just returning with that character elsewhere getting only the
keyboard.
So let me just show you what is happening over here.
So if a s go again and let me navigate again
let's run out key logger.
So now OK.
Maybe something happened over here.
We haven't saved this and next thing was we didn't even call over here.
Let's format this before on release.
We have to call this a Sigurd Keenum method.
So first of all we'll just see a name because we have added this get kidney metal but we haven't called
this.
So we have to have first came we disclosed this first.
Now here I have to this had to kill him first.
So in this game I'll just call our gate key name and I'll despise the key that is placed are basically.
That is a win on we release.
So next is also to get the him.
So all this together.
Kill him again in the on press method and that is also going to get the key and after we get the Keenum
we're going to format this with taking him
and let's remove this or you can simply comment this out.
So again here you have to this formatted with key name that we just get from here and it is also going
to be if the string key name so it's easy then we're exiting from here and we are done over here.
So this the way to get the key name let's say this again and let's see if this works or not.
So we're going to this execute it again
so it is saying that we have entered something over here.
So now if I enter any key you could see.
Now we have formatted our result.
So instead of this quotation in these character we have now the simple logic so you could see if the
key has been released or key has been timed and everything.
So you can simply go to the Hotmail
and
let me see Twitter if I just go to the Twitter log in and
get some valuable here and password
and if I just see a logging native the thing you could see you'll get everything over here.
So it is repeated twice.
And if you one to only the one key to be seen you can simply remove that on release code and you could
get all of you.
So you could see the user name over here and the password was typed right here.
So this is the simple key logger that we just built from the PI input.
We just made a use of this a list now.
That is the controller that is going to be handled by the spy input module.
And this is going to call this on press on release method.
And based on that we have just formatted we had to get the keys.
And based on that keys we have formatted the key name and we just saw how this output looks like.
So this is the way to make a simple key logger with the advance key logo in the upcoming lecture.
See you in the next one.