All language subtitles for 16. Building a Port Scanner

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,120 --> 00:00:00,480 All right. 2 00:00:00,480 --> 00:00:03,550 Welcome to the last video in our python module. 3 00:00:03,570 --> 00:00:06,690 So now we're going to be making a port scanner. 4 00:00:06,690 --> 00:00:12,090 And you heard me say in last video that it's going to be a terrible port scanner and it is but it's 5 00:00:12,090 --> 00:00:14,270 going to be a functional port scanner as well. 6 00:00:14,580 --> 00:00:18,950 And we'll talk about what we can do to improve it and how we can think this through. 7 00:00:18,990 --> 00:00:26,070 So what we're going to do is we're going to go ahead and open up a g edit here some Nisei g at it and 8 00:00:26,070 --> 00:00:36,820 we'll just go ahead and call the scanner dot pi and we'll do the ampersand at the end and let's go ahead 9 00:00:36,820 --> 00:00:40,390 and declare that this is going to be Python 3. 10 00:00:42,580 --> 00:00:44,410 And now let's talk through some things. 11 00:00:44,460 --> 00:00:47,500 So there's going to be a lot of familiarity. 12 00:00:47,500 --> 00:00:51,760 Everything I've done up until this point has been for a reason and you're going to start to see it all 13 00:00:51,760 --> 00:00:53,200 tied together. 14 00:00:53,410 --> 00:01:01,030 So the end goal of this project is going to be that we run something along the lines of Python 3 scanner 15 00:01:01,030 --> 00:01:05,420 dot pi and we provide an IP address here. 16 00:01:05,440 --> 00:01:11,740 Now with that IP address it's going to go ahead and scan through a selected port range for us and try 17 00:01:11,740 --> 00:01:16,000 to return back results whether or not the port is open. 18 00:01:16,030 --> 00:01:20,500 So we're just checking if a port is open on a machine. 19 00:01:20,500 --> 00:01:25,210 So to do that we're going to need a few things. 20 00:01:25,210 --> 00:01:35,080 So first of all we're going to need to import cysts we're going to import socket as we are going to 21 00:01:35,080 --> 00:01:45,250 make a node to node connection and we're going to import date time from date time as we're going to 22 00:01:45,250 --> 00:01:51,240 make a pretty little banner as well so why was this important. 23 00:01:51,240 --> 00:01:53,510 I told you assisted come back into play. 24 00:01:53,730 --> 00:01:57,330 So we have here an argument. 25 00:01:57,330 --> 00:02:05,340 So there are actually two arguments in theory argument zero is that we're running scattered up pie argument 26 00:02:05,340 --> 00:02:09,810 one is that we are running against an IP address. 27 00:02:09,810 --> 00:02:15,970 Now since we're building this script out we want it to take two arguments and only two arguments. 28 00:02:16,140 --> 00:02:20,160 So we're going to build that into our script from the get go. 29 00:02:20,310 --> 00:02:23,420 So let's go ahead and just define our target. 30 00:02:24,210 --> 00:02:29,130 And it's always good when you're building out a script to have good notes in there as well. 31 00:02:29,130 --> 00:02:33,750 So not only that you can go back and read it but if you send this somebody else they could also read 32 00:02:33,750 --> 00:02:38,200 through it as well so put good comments in here good notes saying what you're doing. 33 00:02:38,220 --> 00:02:43,200 So in this instance we're going to put an if statement again conditional argument here and we're going 34 00:02:43,200 --> 00:02:51,600 to say if the length of CIS dot ARG we remember this is the same thing is like a dollar sign one in 35 00:02:51,600 --> 00:02:57,090 bash we're going to take that we're going to say if it's equal to two we're going to go ahead and do 36 00:02:57,090 --> 00:02:58,430 something. 37 00:02:58,660 --> 00:03:06,610 What we're going to do is we're gonna declare a variable of target and we're going to say socket get 38 00:03:06,750 --> 00:03:13,910 a host by name and then we're going to get CIs we won. 39 00:03:13,930 --> 00:03:15,550 So we're taking the first argument. 40 00:03:15,640 --> 00:03:19,530 Again this is same thing as dollar sign one like this in bash. 41 00:03:19,570 --> 00:03:21,100 Why are we doing this. 42 00:03:21,100 --> 00:03:27,570 Well we're just translating a hostname here to IP for now. 43 00:03:27,610 --> 00:03:30,840 This is not inherently necessary. 44 00:03:30,940 --> 00:03:34,000 We could just declare the target by input. 45 00:03:34,000 --> 00:03:34,780 It could just be. 46 00:03:34,810 --> 00:03:37,170 Target equals sister RB 1. 47 00:03:37,360 --> 00:03:44,020 But we're just taking an extra step here in case instead of somebody putting in an IP address they could 48 00:03:44,020 --> 00:03:50,770 just put in like a hostname say we have a host here and it's you know like a one of mine is called The 49 00:03:50,770 --> 00:03:51,570 Punisher. 50 00:03:51,640 --> 00:03:56,620 You know what if it were they put in Punisher wall that Punisher name does DNS and a resolves to an 51 00:03:56,620 --> 00:03:57,690 IP address. 52 00:03:58,030 --> 00:04:01,460 It's going to go ahead and do that with this argument here. 53 00:04:01,480 --> 00:04:05,910 So we're just putting an extra step thinking ahead. 54 00:04:05,950 --> 00:04:07,660 We also need else to this. 55 00:04:07,720 --> 00:04:14,650 So if it doesn't equal two if it's three if it's one it's nine then we're gonna go ahead and just print 56 00:04:14,650 --> 00:04:25,370 out and say invalid amount of arguments and then we can actually take this here. 57 00:04:26,440 --> 00:04:33,620 And we can put this into a print statement as well as print to say something like syntax. 58 00:04:33,670 --> 00:04:37,160 Python 3 scanner IP address. 59 00:04:37,360 --> 00:04:40,370 Something along those lines OK. 60 00:04:40,410 --> 00:04:42,530 So I always like to say that. 61 00:04:42,540 --> 00:04:45,180 And then just run it make sure everything works fine. 62 00:04:45,180 --> 00:04:47,740 So let's go ahead and give it Python 3. 63 00:04:47,910 --> 00:04:56,850 We'll say scanner add up pi and we'll give it no argument and it's gonna say OK invalid arguments syntax 64 00:04:56,850 --> 00:05:03,700 is Python 3 standard pi IP so we'll just give it an argument here OK. 65 00:05:03,740 --> 00:05:13,040 So it writes didn't get the we met the conditions and we set the target variable to well to this right. 66 00:05:13,040 --> 00:05:16,220 So that's OK for now. 67 00:05:16,220 --> 00:05:20,480 So let's go ahead and I like to always put it in a pretty little banner or something. 68 00:05:20,500 --> 00:05:26,150 Now let's add a pretty banner and I'm just gonna do something like this. 69 00:05:26,150 --> 00:05:29,940 I'm going to say print and we're gonna do dashes. 70 00:05:30,030 --> 00:05:33,700 We'll do 50 dashes and then we'll go ahead. 71 00:05:33,700 --> 00:05:34,600 I'm going to copy this. 72 00:05:34,600 --> 00:05:43,000 Just easier and let's go ahead and print a couple of things we'll say print we'll say scanning the target 73 00:05:43,810 --> 00:05:53,860 and then we'll add a space all of us do plus target and then we'll say print time started and then we 74 00:05:53,860 --> 00:06:00,390 can just do a space there plus the string of date time now. 75 00:06:00,670 --> 00:06:03,040 Now that came back into play as well. 76 00:06:03,190 --> 00:06:05,380 So make sure you have three closing parentheses. 77 00:06:05,410 --> 00:06:11,590 So we've now utilized this socket and date time all of which we have seen in the past. 78 00:06:11,770 --> 00:06:18,130 And then that last copy paste here for the banner says go ahead and save this and give it another go 79 00:06:20,270 --> 00:06:26,510 and you can see it says OK scanning target and it's resolving to this twenty three this is this is not 80 00:06:26,510 --> 00:06:32,150 accurate but you know just let it do its thing and then it's got the time started of the scan here so 81 00:06:32,360 --> 00:06:38,420 you can see here I'm putting in a hostname and it's trying to resolve to DNS to this maybe this is how 82 00:06:38,420 --> 00:06:42,350 what it resolves to I don't know but we'll move on. 83 00:06:42,350 --> 00:06:47,900 So the next thing we're going to do is what is called a tri statement. 84 00:06:47,930 --> 00:06:49,520 So we're going to try to do something. 85 00:06:50,210 --> 00:06:53,110 And if we can't do it we have exceptions. 86 00:06:53,120 --> 00:06:56,930 So you'll see what this looks like when it's all built out. 87 00:06:56,930 --> 00:07:02,300 So go ahead and type try and you're going to see try later as well we get into the exploit development 88 00:07:02,630 --> 00:07:06,370 so we're going to do a for statement. 89 00:07:06,400 --> 00:07:14,870 So for port in range now when you specify the range if we were going to do a full on port scanner we 90 00:07:14,870 --> 00:07:22,120 would do for port one through sixty five five thirty five OK that will take forever. 91 00:07:22,130 --> 00:07:24,830 We'll talk about why I told you this was a bad port scanner. 92 00:07:24,830 --> 00:07:27,190 We'll talk about why we're not going to do this in a little bit. 93 00:07:28,310 --> 00:07:34,430 So let's go ahead and delete these and we're just going to put something like 50 to eighty five and 94 00:07:34,430 --> 00:07:37,450 I'll clarify why we're doing that in just a second. 95 00:07:37,520 --> 00:07:44,900 So on top of this let's add in some familiar language we're going to say X equals socket dot socket 96 00:07:45,860 --> 00:07:57,620 and then socket dot a f underscore iiNet comma socket dot SOC stream remember a fine it is IP for SOC 97 00:07:57,620 --> 00:07:59,940 stream is our port. 98 00:08:00,350 --> 00:08:11,630 So we're going to say socket dot set default time out to one why are we doing this. 99 00:08:11,640 --> 00:08:14,650 This is going to attempt to connect to a port. 100 00:08:14,940 --> 00:08:19,710 If that port is not connected all it's going to wait one second and then it's going to move on. 101 00:08:19,710 --> 00:08:22,610 That way we're not sitting there forever trying to make a connection to a port. 102 00:08:22,620 --> 00:08:28,770 We set the timer ourselves so we're also going to store a result. 103 00:08:28,770 --> 00:08:40,350 So the result is going to be s dot connect underscore E X and it's going to be target comma port so 104 00:08:40,350 --> 00:08:42,180 why are we doing this. 105 00:08:42,180 --> 00:08:49,530 Well when we do this connect underscore at e x ray returns an error indicator someone returns an air 106 00:08:49,530 --> 00:08:51,270 indicator. 107 00:08:51,630 --> 00:08:57,120 If a port is open the result back is going to be zero. 108 00:08:57,540 --> 00:09:02,970 If a port is not open it's going to throw an error which is going to trigger a one. 109 00:09:02,970 --> 00:09:12,000 So let's think that through if results is equal to zero then we're going to go ahead and just print 110 00:09:12,000 --> 00:09:15,300 out that this port is open. 111 00:09:17,520 --> 00:09:23,490 We'll throw this in here this time for a place holder instead let's say it is open and we'll do a format 112 00:09:23,850 --> 00:09:29,640 port and then one more thing I'll close it out and we'll walk through this one more time so that it 113 00:09:29,700 --> 00:09:30,720 all makes sense. 114 00:09:31,850 --> 00:09:32,240 OK. 115 00:09:32,460 --> 00:09:35,470 So then we're closing the connection. 116 00:09:35,540 --> 00:09:35,780 OK. 117 00:09:35,780 --> 00:09:37,310 So you've got this tri statement. 118 00:09:37,430 --> 00:09:39,120 Let's walk through it one more time. 119 00:09:39,140 --> 00:09:40,460 We've got a for loop here. 120 00:09:40,460 --> 00:09:45,890 Remember four is just an outer it we're going through and iterate we're going through four fifty in 121 00:09:46,130 --> 00:09:48,220 so we're defining a port right in this range. 122 00:09:48,240 --> 00:09:50,210 Fifty fifty one fifty two. 123 00:09:50,210 --> 00:09:51,810 All of it to eighty five. 124 00:09:51,890 --> 00:09:53,790 We're going to repeat this whole process. 125 00:09:53,960 --> 00:09:58,250 We're going to establish our variable s which we did in the socket video the previous video. 126 00:09:58,250 --> 00:09:58,900 Right. 127 00:09:58,910 --> 00:10:05,180 We're just declaring Hey I know I'm going to want to connect to IP before and a port when I do make 128 00:10:05,180 --> 00:10:06,410 that connection. 129 00:10:06,500 --> 00:10:10,080 I want that default time out to be one second OK. 130 00:10:10,110 --> 00:10:13,290 So then I'm going to store inside of a variable of result. 131 00:10:13,290 --> 00:10:18,850 I'm going to say let's connect to the target which we've already established. 132 00:10:18,880 --> 00:10:19,490 As. 133 00:10:19,590 --> 00:10:29,400 The V1 and the port which is our it it here in our loop and if that port is open it's gonna return 0. 134 00:10:29,400 --> 00:10:31,860 If it's not open it's going to return 1. 135 00:10:31,890 --> 00:10:38,250 So if that result is zero go ahead and print out that that port is open close the connection and then 136 00:10:38,250 --> 00:10:42,450 we're gonna go back and try to establish another connection with port or with the port number fifty 137 00:10:42,450 --> 00:10:47,060 one fifty two fifty three will loop through all this until we make it all the way through. 138 00:10:47,070 --> 00:10:49,010 Eighty five OK. 139 00:10:49,040 --> 00:10:51,910 So it's just one big loop that we're doing now. 140 00:10:52,010 --> 00:10:55,520 We need to throw in a few exceptions to make this code really work. 141 00:10:55,580 --> 00:10:59,230 So here's an exception exception. 142 00:10:59,900 --> 00:11:01,960 Keyboard interact. 143 00:11:02,000 --> 00:11:07,690 So if you've been using Linux for a little bit now you should know something like control C is a keyboard. 144 00:11:07,700 --> 00:11:08,080 Interrupt. 145 00:11:08,080 --> 00:11:13,610 So if we want to interrupt the scan we need to define that there is an interruption here. 146 00:11:13,730 --> 00:11:18,390 So I'm just going to put in something like exiting program. 147 00:11:19,070 --> 00:11:24,770 And we're gonna say when that happens when there is a keyboard interrupt we're gonna say sis exec. 148 00:11:24,920 --> 00:11:27,630 That allows for that clean exit. 149 00:11:27,950 --> 00:11:30,320 Hey there's another exception that could be occurred here. 150 00:11:30,320 --> 00:11:30,590 Right. 151 00:11:30,620 --> 00:11:40,820 So we're gonna see a socket that gee I air and we're gonna say print hostname could not be resolved. 152 00:11:41,240 --> 00:11:46,280 So if we can't resolve the hostname DNS is failing us we're just gonna go ahead and exit out. 153 00:11:47,510 --> 00:11:48,740 And then one more. 154 00:11:49,130 --> 00:11:51,860 What if we can't make the connection to the address in general. 155 00:11:52,370 --> 00:11:54,320 Well that's what's called a socket error. 156 00:11:54,500 --> 00:12:05,110 So we're gonna say socket dot error and we're going to print out couldn't get a type that couldn't connect 157 00:12:05,620 --> 00:12:09,750 to server and then we're also going to exit this. 158 00:12:10,000 --> 00:12:11,290 So it's a cyst that exit. 159 00:12:13,060 --> 00:12:16,840 So I'll give you a little bit of time to catch up on this script if you're behind. 160 00:12:16,840 --> 00:12:19,050 I was typing fast and talking as well. 161 00:12:20,040 --> 00:12:21,650 So one more walkthrough. 162 00:12:21,720 --> 00:12:26,340 We're going to do our for loop through these specific ports and then we're gonna go ahead and have some 163 00:12:26,340 --> 00:12:26,930 exception. 164 00:12:26,940 --> 00:12:33,070 So we're gonna try these with exceptions here if we had control C we want to exit the program if there 165 00:12:33,070 --> 00:12:38,580 is no hostname resolution we want to exit the program if we can't connect to the IP address that we 166 00:12:38,580 --> 00:12:40,730 specify we want to exit the program. 167 00:12:40,920 --> 00:12:46,710 So we need to build in these exits and these are this that this is that thinking logically that I talked 168 00:12:46,710 --> 00:12:53,220 about earlier in earlier videos right that we it wouldn't hurt to build this out and then just think 169 00:12:53,220 --> 00:12:58,890 logically and I will be the first person to tell you that when I build a script out and I write it it's 170 00:12:59,040 --> 00:13:01,410 always terrible first time's always terrible. 171 00:13:01,440 --> 00:13:04,050 Tenth time still probably pretty terrible. 172 00:13:04,050 --> 00:13:09,870 You have to start thinking of things logically like you might not define an if statement the beginning 173 00:13:09,870 --> 00:13:10,200 right. 174 00:13:10,200 --> 00:13:15,330 You might have to think through that because you might need one argument or two arguments or three arguments 175 00:13:15,360 --> 00:13:15,960 and you don't know. 176 00:13:15,960 --> 00:13:19,930 So maybe this doesn't look like this and it doesn't look like the pretty banner in here either. 177 00:13:20,250 --> 00:13:25,950 And you just start with this for loop and then you realize well maybe I should make that a try statement 178 00:13:25,980 --> 00:13:31,950 because what if the user wants to exit or there's no connection for a hostname or there's no connection 179 00:13:31,950 --> 00:13:32,480 to the server. 180 00:13:32,490 --> 00:13:36,500 How do we get out of that or elsewhere is going to be stuck in this for loop until it's done. 181 00:13:36,510 --> 00:13:40,330 But if we get into one of these air situations it's going to get weird. 182 00:13:40,680 --> 00:13:40,950 Right. 183 00:13:40,980 --> 00:13:43,940 So and then you start thinking through OK well I know my argument. 184 00:13:43,950 --> 00:13:48,750 So let me go add in a statement at the top so the user knows how to use it and then maybe I'll put a 185 00:13:48,750 --> 00:13:54,660 pretty banner in there when it's all said and done and it starts to really design itself. 186 00:13:54,660 --> 00:14:00,600 Now before we run this let's talk about why this isn't great this is going to sit here and run through 187 00:14:00,600 --> 00:14:08,190 one port at a time for a second of a timeout and then reiterate this is going to take a little bit to 188 00:14:08,190 --> 00:14:09,710 run through these little ports. 189 00:14:09,720 --> 00:14:14,820 Now when we get into scanning you're going to see that there are tools out there designed that do it 190 00:14:14,880 --> 00:14:20,860 much better much more efficiently and much faster this is not the best way. 191 00:14:20,860 --> 00:14:25,270 There is something that we could do called threading now threading would take the process and run multiple 192 00:14:25,270 --> 00:14:29,870 processes at once for us and allow us to scan a lot of ports at once. 193 00:14:29,950 --> 00:14:35,320 That would be a potential idea here and there's just improvements that we can do. 194 00:14:35,390 --> 00:14:41,140 You know some of the things that we thought about already like the socket get host by hostname you might 195 00:14:41,140 --> 00:14:45,030 not have thought about that in your first iteration you might just say hey I want to just put its IP 196 00:14:45,030 --> 00:14:54,580 for and what happens if you know we supply an argument and the argument is something like a mixed bunch 197 00:14:54,580 --> 00:15:01,900 of numbers now notably be like 1 5 2 and then you got letters and somebody mistyped or or what if you 198 00:15:01,900 --> 00:15:06,040 give you know an IP address that doesn't exist. 199 00:15:06,040 --> 00:15:13,930 Something like this or you know maybe like 256 dot or 257 or something you know that that isn't possible 200 00:15:13,940 --> 00:15:14,980 how is that built in. 201 00:15:14,980 --> 00:15:18,650 How are we going to prevent that in our script right now. 202 00:15:18,700 --> 00:15:20,080 Not that big of a deal. 203 00:15:20,110 --> 00:15:25,660 We're writing this for ourselves so you know it's not doesn't be perfect but if we write this for somebody 204 00:15:25,660 --> 00:15:27,370 else we go put this on github. 205 00:15:27,370 --> 00:15:32,530 We kind of want all those errors to be handled and that's where these exceptions come into play and 206 00:15:32,530 --> 00:15:36,880 these if statements at the beginning come into play as well so we can handle those errors and those 207 00:15:36,880 --> 00:15:41,590 exceptions and we can really start thinking logically on how an end user might fat finger something 208 00:15:41,590 --> 00:15:46,200 or break a program or do something even maliciously possibly. 209 00:15:46,210 --> 00:15:52,660 So there are ways around this and we'll talk about it as well when we get into a bash script that I 210 00:15:52,660 --> 00:15:57,280 wrote later on in the course and we can kind of look at how that was written and how it strips out some 211 00:15:57,280 --> 00:16:01,260 arguments and prevent some human error but we'll get to that later. 212 00:16:01,270 --> 00:16:07,000 So let's go ahead and actually save this now we've got our scanners scanner script and we're gonna go 213 00:16:07,000 --> 00:16:14,090 ahead and run it so I'm going to run this and I'm going to run this against my router. 214 00:16:14,090 --> 00:16:21,890 So my suggestion to you is to do the same or do it to a machine that you know is in your network and 215 00:16:21,890 --> 00:16:23,400 has a port open. 216 00:16:23,420 --> 00:16:26,540 Why am I choosing my router and this specific range. 217 00:16:26,540 --> 00:16:32,540 Now my router should have port 53 open because of DNS and it should have port 80 open because I need 218 00:16:32,540 --> 00:16:34,670 to access the web interface on it. 219 00:16:34,670 --> 00:16:41,240 So I'm going to go ahead and run this and I have a typo. 220 00:16:41,810 --> 00:16:44,090 So I have something called soccer here. 221 00:16:44,090 --> 00:16:45,390 I sure do. 222 00:16:45,530 --> 00:16:48,230 If you caught that originally good job. 223 00:16:48,230 --> 00:16:49,590 You knew I was going to mess up. 224 00:16:49,610 --> 00:16:52,810 Let's try one more time. 225 00:16:52,930 --> 00:16:54,250 And there you go. 226 00:16:54,280 --> 00:17:01,090 So it just ran through it really fast said Port fifty three is open port 80 is open and immediately 227 00:17:01,260 --> 00:17:03,350 you know it knew it knew. 228 00:17:03,370 --> 00:17:10,040 So it did its job it went out there and it found port 53 in Port 80 which is what I was expecting. 229 00:17:10,150 --> 00:17:12,520 Hopefully yours did the same. 230 00:17:12,580 --> 00:17:18,390 Now I could back this off to one through you know sixty five thousand five thirty five. 231 00:17:18,670 --> 00:17:23,710 And another thing we can do if you want to see the speed let's say sixty five five thirty five. 232 00:17:23,710 --> 00:17:32,470 I am going to keyboard interrupt this but we can print out something along the lines of checking for 233 00:17:32,560 --> 00:17:34,840 and then we'll do something like this. 234 00:17:35,410 --> 00:17:35,930 OK. 235 00:17:35,950 --> 00:17:38,740 And then we say dot format and then port. 236 00:17:39,800 --> 00:17:43,270 So when we say this and we run it take a look. 237 00:17:43,270 --> 00:17:43,660 Now 238 00:17:47,840 --> 00:17:50,060 so it's checking through all these ports. 239 00:17:50,060 --> 00:17:51,230 It's going kind of fast. 240 00:17:51,240 --> 00:17:54,830 But look it's it's finding ports but this isn't pretty. 241 00:17:54,910 --> 00:17:55,220 All right. 242 00:17:55,230 --> 00:17:57,990 We wouldn't want this we only wanted to say when the ports open. 243 00:17:58,610 --> 00:18:01,270 But it's taking some time. 244 00:18:01,340 --> 00:18:02,560 We're on port. 245 00:18:02,600 --> 00:18:09,160 Twenty thousand of sixty five thousand or so on top of you know just being being a little bit annoying. 246 00:18:09,150 --> 00:18:14,720 It's it's really you know throwing our screen into twenty thousand lines now. 247 00:18:14,720 --> 00:18:20,360 So the only reason I would put a statement in here like this is if I was doing a couple numbers and 248 00:18:20,360 --> 00:18:25,270 I wanted to see like if we go back to 50 and to 80 we'll do 80 1. 249 00:18:25,400 --> 00:18:26,240 We do this. 250 00:18:26,240 --> 00:18:29,870 It's good way to see how fast your scanners running if it's running. 251 00:18:29,870 --> 00:18:34,220 It's a good way to have print statements in there if you might see any errors and you could see it ran 252 00:18:34,220 --> 00:18:37,170 through 80 pretty fast and found fifty three and 80 open. 253 00:18:37,190 --> 00:18:43,460 So I would delete this if you want to do a full port scan again you could do one through sixty five 254 00:18:43,460 --> 00:18:45,650 five thirty five. 255 00:18:45,650 --> 00:18:50,240 Go ahead and say that sorry if you heard my dog barking It's really windy tonight. 256 00:18:51,200 --> 00:18:53,390 So we're gonna go ahead and do it one more time. 257 00:18:53,390 --> 00:18:56,330 And now it should be a little prettier. 258 00:18:56,480 --> 00:19:00,030 And then as the ports are open it'll print out. 259 00:19:00,240 --> 00:19:03,940 And if you want to get fancier you can have a little thing at the bottom that says hey this took this 260 00:19:03,940 --> 00:19:04,900 long to scan. 261 00:19:04,910 --> 00:19:07,420 Here's how many ports are open et cetera. 262 00:19:07,420 --> 00:19:12,280 So this is finding all the ports some to go ahead and control sea and you can see now exiting program 263 00:19:12,310 --> 00:19:14,100 our keyboard interrupt worked. 264 00:19:14,320 --> 00:19:16,670 So everything is working really really well. 265 00:19:16,840 --> 00:19:18,160 And that is it. 266 00:19:18,190 --> 00:19:20,530 So that's it for the python series. 267 00:19:20,530 --> 00:19:23,950 And hopefully this all made sense is all built upon it. 268 00:19:23,980 --> 00:19:29,320 You know we could take this in the goal here again is not to be an expert in Python the goal here is 269 00:19:29,320 --> 00:19:33,720 to get you interested in Python to get you seeing that it's really not that bad. 270 00:19:33,730 --> 00:19:40,560 And in about an hour and a half to two hours time we started with nothing and built out a nice script 271 00:19:40,560 --> 00:19:44,050 at all you know just built less upon less until we got here. 272 00:19:44,050 --> 00:19:49,630 So we're going to move on and actually get into the hacking you have successfully completed all of your 273 00:19:49,630 --> 00:19:50,800 foundational courses. 274 00:19:50,800 --> 00:19:55,840 We've got the Linux down we've got the networking down we've got the python down and now we're ready 275 00:19:55,840 --> 00:19:57,100 to get into the good stuff. 276 00:19:57,490 --> 00:19:59,980 So I'm very excited to do the hacking. 277 00:19:59,980 --> 00:20:04,350 This is our strong suit this is our bread and butter and we're really going to knock out of the park 278 00:20:04,390 --> 00:20:08,980 so I will catch you over in the next video when we start learning about hacking. 28449

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.