WEBVTT

00:01.080 --> 00:01.400
Okay.

00:01.440 --> 00:07.600
In the previous lecture, we created this simple keylogger that is capturing only the keys that we were

00:07.600 --> 00:08.120
pressing.

00:08.880 --> 00:18.040
And here, as you see that while we are pressing each key, it is showing me that key in one new line.

00:18.040 --> 00:25.960
We want to send this into an email or into a server, or even writing into a file.

00:26.240 --> 00:28.120
We need to here, as you see.

00:28.160 --> 00:35.760
For example, if you're pressing 100 keys so it will send 100 emails to a person or the email you're

00:35.760 --> 00:36.400
providing.

00:37.000 --> 00:37.240
So.

00:39.360 --> 00:44.160
The best solution for this is to have a global variable here okay.

00:44.600 --> 00:51.400
So while we are having a global variable we can add or we can concatenate each keys that is adding or

00:51.400 --> 00:55.080
that that the user or the victim is entering.

00:55.680 --> 01:00.920
So for that we need to use let's create a variable.

01:00.960 --> 01:02.280
Name it log.

01:02.320 --> 01:05.730
It is equal to an empty string right now.

01:05.770 --> 01:09.370
Okay, so we have this empty.

01:09.410 --> 01:10.970
This empty string is here.

01:11.570 --> 01:14.370
Now we have the key here.

01:14.410 --> 01:14.850
Okay.

01:15.170 --> 01:19.850
Each time that person is entering the key, we need to add this into the lock.

01:20.210 --> 01:21.450
So very easy.

01:21.490 --> 01:26.130
Log is equal to log plus key.

01:26.170 --> 01:30.450
And you may know or may not know that this key is not a string.

01:30.450 --> 01:31.810
It is an object okay.

01:31.850 --> 01:33.050
Object type of key.

01:33.450 --> 01:35.410
So we need to change this to a string.

01:35.450 --> 01:36.610
So very good.

01:38.050 --> 01:38.650
STR.

01:40.930 --> 01:42.410
STR finished.

01:43.170 --> 01:45.370
And now let's print the log.

01:45.490 --> 01:48.970
And let's see how does it looks like.

01:50.210 --> 01:50.650
Okay.

01:55.890 --> 01:56.450
Oops.

01:56.890 --> 01:58.530
Use Ctrl c.

01:58.570 --> 02:00.050
Let's clear this.

02:06.250 --> 02:06.690
Okay.

02:06.730 --> 02:09.010
Can't open file.

02:10.370 --> 02:12.210
No such file or directory.

02:12.250 --> 02:15.490
What do you mean you don't?

02:15.490 --> 02:19.410
We have in here Python key logger.

02:22.890 --> 02:23.290
Oops.

02:24.410 --> 02:25.090
This again.

02:26.770 --> 02:28.090
Let me use RLS.

02:29.930 --> 02:32.610
We have this okay.

02:32.650 --> 02:36.050
Python key logger.py hit enter.

02:37.370 --> 02:39.250
So right now it is waiting to write something.

02:39.250 --> 02:42.170
Let's here write r.

02:42.490 --> 02:45.530
And you see again it is giving me an error.

02:45.930 --> 02:47.570
And that is log is equal to.

02:47.610 --> 02:53.690
This cannot access local variable log where it is not associated with a value.

02:53.690 --> 02:54.250
Okay.

02:55.410 --> 02:56.170
Beautiful.

02:57.290 --> 03:01.690
You see we are having log here which is out of this function.

03:01.690 --> 03:03.730
And we are using it inside the function.

03:04.170 --> 03:08.850
We need to use something called global variable okay.

03:08.890 --> 03:16.060
We need to use global and then global keyword and then name of this uh, variable.

03:16.100 --> 03:16.460
Okay.

03:17.060 --> 03:17.260
So.

03:20.380 --> 03:31.180
Here let me use once again execute this and let's, uh, hit backspace and then write R again.

03:31.220 --> 03:32.420
R again.

03:32.460 --> 03:34.820
R backspace.

03:34.820 --> 03:36.980
Let's write hello world.

03:37.740 --> 03:38.420
Hit enter.

03:39.260 --> 03:43.780
And here right now you see that we have backspace okay.

03:44.300 --> 03:45.380
We have three R.

03:45.420 --> 03:49.620
We have backspace backspace backspace backspace.

03:49.620 --> 03:55.140
We have hello space world key enter.

03:55.180 --> 03:59.060
So now if we want to send this to an email.

03:59.300 --> 04:03.460
So we will be sending all these into an email.

04:03.460 --> 04:05.900
And right now it is more readable okay.

04:05.940 --> 04:10.780
Or if you want to write this into a text file we will be opening a txt file.

04:10.780 --> 04:14.220
And we can write this into a file okay.

04:14.900 --> 04:17.620
We will be improving this in the next lecture.

04:17.820 --> 04:20.220
So let's go and see that.
