1
00:00:00,270 --> 00:00:05,400
Hello everybody and welcome to this project where we are going to start off with the e-mail attacks

2
00:00:06,100 --> 00:00:06,340
now.

3
00:00:06,330 --> 00:00:11,520
E-mail attacks are one of the most important things and parts of social engineering you can use e-mails

4
00:00:11,550 --> 00:00:13,320
in order to further extend your attack.

5
00:00:13,320 --> 00:00:18,390
For example the backdoor that be coded we could gather all of the emails from a specific company and

6
00:00:18,390 --> 00:00:21,000
send our backdoor to each and every email.

7
00:00:21,090 --> 00:00:26,290
And hopefully one of those people will open it and therefore we have the access to that company.

8
00:00:26,640 --> 00:00:29,080
And that is exactly what we are going to try right now.

9
00:00:29,100 --> 00:00:34,350
We are going to create the program that is going to be able to scrape all of the e-mails from a specific

10
00:00:34,350 --> 00:00:35,730
domain name.

11
00:00:35,730 --> 00:00:39,780
For example we want to be able to specify the link to a specific Web site.

12
00:00:39,990 --> 00:00:44,200
And our program will gather all of the e-mails regarding that specific domain.

13
00:00:44,670 --> 00:00:46,400
So let's see how we can do that.

14
00:00:46,410 --> 00:00:51,180
I already created a project called e-mail attacks because in the future we actually might add a few

15
00:00:51,180 --> 00:00:52,490
more programs to this project.

16
00:00:52,500 --> 00:00:54,590
But for now on this is the main one.

17
00:00:54,720 --> 00:00:57,300
And trust me this is going to be a good program.

18
00:00:57,300 --> 00:00:59,260
You will use it a lot.

19
00:00:59,310 --> 00:01:01,830
So it is similar to the harvester program.

20
00:01:01,830 --> 00:01:05,360
Many of you might know it in case you're an experienced ethical hacker.

21
00:01:05,430 --> 00:01:09,990
And this program will actually be able to extract even more e-mails than the harvester.

22
00:01:09,990 --> 00:01:17,590
So let's create the program first we'll call it e-mail dash scraper dot B why we will import the needed

23
00:01:17,600 --> 00:01:18,100
libraries.

24
00:01:18,110 --> 00:01:24,210
So we're going to need a library that we haven't used before which is the beautiful soup library but

25
00:01:24,210 --> 00:01:35,350
we don't want to import like this we want imported from beautiful soup for import beautiful soup just

26
00:01:35,350 --> 00:01:38,140
like this and you will notice it is red underlined.

27
00:01:38,140 --> 00:01:41,470
We're going to install it as soon as we import all the needed libraries.

28
00:01:41,470 --> 00:01:49,080
So let's import the next one which is going to be the requests library and we also need to import requests

29
00:01:49,320 --> 00:01:51,270
not exceptions.

30
00:01:51,270 --> 00:01:59,760
We will need to import you our l let that pass we will import from collections import.

31
00:01:59,880 --> 00:02:04,860
You know I know most of these libraries or something that we haven't used but it doesn't really matter

32
00:02:04,890 --> 00:02:07,050
as we will use them inside of this program.

33
00:02:07,680 --> 00:02:12,580
And the last one which we did use before is the regex library which is r e.

34
00:02:13,200 --> 00:02:17,670
So now that we import it all the need the libraries let us Prompt the user for the information that

35
00:02:17,670 --> 00:02:24,240
we need in order for our program to run such as for example the URL several specify a variable called

36
00:02:24,300 --> 00:02:37,700
user you URL to be equal to input now let's prompt the user enter target you are out scan and we want

37
00:02:37,700 --> 00:02:44,060
to convert all of this into a string just in case it doesn't present this problem and we will perform

38
00:02:44,060 --> 00:02:45,620
a d q onto this url.

39
00:02:45,680 --> 00:02:46,730
So how can we do that.

40
00:02:46,850 --> 00:02:54,310
Well we will specify a variable called you or else to be equal to Dick you open up the brackets open

41
00:02:54,310 --> 00:02:58,490
up square brackets and specify user your URL.

42
00:02:58,540 --> 00:03:05,140
Now before we continue let us install these needed libraries open up your terminal let's go with the

43
00:03:05,140 --> 00:03:11,190
requests first so Page 3 install requests it will install the library and let's go with the beautiful

44
00:03:11,190 --> 00:03:16,610
soups of Pip 3 install the S4 let's first of all try it like this.

45
00:03:16,660 --> 00:03:16,950
Okay.

46
00:03:17,010 --> 00:03:19,310
So be it for is the correct name to use.

47
00:03:19,560 --> 00:03:21,200
And I believe that's it.

48
00:03:21,210 --> 00:03:26,900
If we close this in just a few seconds we should lose these red lines.

49
00:03:27,280 --> 00:03:29,100
Okay we no longer have any errors.

50
00:03:29,100 --> 00:03:35,610
Let's continue with our program and let's create a set which is going to be scraped you or else because

51
00:03:35,670 --> 00:03:41,970
our program is going to be based on actually scraping all of the URLs from the main page and trying

52
00:03:41,970 --> 00:03:47,660
to find the pattern of an email using regex for every pattern of an email that we manage to find.

53
00:03:47,670 --> 00:03:49,820
We're going to save it and then print it.

54
00:03:49,860 --> 00:03:54,810
At the end of the execution of our program we also want to create another set which is going to be equal

55
00:03:54,810 --> 00:03:55,640
to emails.

56
00:03:55,680 --> 00:04:00,770
So we have a set that is going to be scraped your URLs and set that is going to be emails.

57
00:04:00,780 --> 00:04:08,900
Now we can try to scrape and find the emails so we can use the try statement and inside of that Trai

58
00:04:08,900 --> 00:04:09,370
statement.

59
00:04:09,370 --> 00:04:18,480
We're going to use a wild length loop of the URLs which remember our added Q from the user your url.

60
00:04:18,520 --> 00:04:23,680
We want to also create account variable that is going to be equal to zero and which we will increase

61
00:04:23,860 --> 00:04:24,880
right at the beginning.

62
00:04:24,940 --> 00:04:32,230
So count plus equals 1 if we reach the count number to be equal to 100 then we will break out of this

63
00:04:32,230 --> 00:04:38,650
program and what this simply means is we're telling the program that we only want to scrape first 100

64
00:04:38,790 --> 00:04:45,350
or else if you leave the program to scrape thousand two or else it will scrape positive or else but

65
00:04:45,340 --> 00:04:46,240
that'll take too long.

66
00:04:46,240 --> 00:04:52,070
That's why we only leave 100 year olds to scrape from the main page there is really no need to scrape

67
00:04:52,070 --> 00:04:59,180
more hundred is more than enough and after it reaches 100 or else that it already searched then it will

68
00:04:59,180 --> 00:05:05,140
break out of this while loop and we will print all the emails that we found since our URLs are in a

69
00:05:05,290 --> 00:05:06,080
queue.

70
00:05:06,200 --> 00:05:11,950
We want to create a variable called the URL and we want to use the top left function onto our you or

71
00:05:11,950 --> 00:05:18,000
else for you or else dot pop left and we can use that your URL and add it to our sets of scraped you

72
00:05:18,010 --> 00:05:24,590
or else dot add add is the function that we use to add a certain element to our set and then we can

73
00:05:24,590 --> 00:05:27,160
specify your URL inside with brackets.

74
00:05:27,370 --> 00:05:27,710
OK.

75
00:05:28,070 --> 00:05:32,720
So for now on this is the base part of our program in the next video we're going to take a look at how

76
00:05:32,720 --> 00:05:38,580
we can convert our new URL and split it into a base part and the path part and then see how we can create

77
00:05:38,580 --> 00:05:43,540
the pattern that is going to try to find emails inside of each and every of those two or else.

78
00:05:43,800 --> 00:05:44,120
OK.

79
00:05:44,300 --> 00:05:47,690
So thank you for watching and I will see you in the next lecture by.
