1 00:00:00,060 --> 00:00:06,390 OK, Senator, we did bash let's go over Python basics, so Python is one of the most utilized scripting 2 00:00:06,390 --> 00:00:09,240 languages in that community, if not the most utilized. 3 00:00:09,960 --> 00:00:15,120 This is due to its simplicity and power because it's pretty much like almost like English kind of it's 4 00:00:15,120 --> 00:00:17,330 a little bit easier than the Bashkim thing is. 5 00:00:17,340 --> 00:00:18,510 And it's very, very powerful. 6 00:00:18,520 --> 00:00:21,530 You can literally do anything that you could imagine with Python. 7 00:00:22,140 --> 00:00:27,750 So it's very easy to pick up and it's going to drastically help you with your acting career, any career 8 00:00:27,750 --> 00:00:32,580 that you have in cybersecurity generally, because Python is used typically, you know, to automate 9 00:00:32,580 --> 00:00:35,580 processes, you know, in gigantic enterprises. 10 00:00:35,730 --> 00:00:38,800 And it's very, very valuable to know Python. 11 00:00:38,820 --> 00:00:40,020 So we're going to go over the basics. 12 00:00:40,470 --> 00:00:45,750 And since, you know, a majority of the experts that you're going to see are written in Python, being 13 00:00:45,750 --> 00:00:50,330 able to read it and, you know, know what's going on and how to modify it, it's going to be key. 14 00:00:51,220 --> 00:00:53,040 There are some basic Python syntax. 15 00:00:53,040 --> 00:00:59,910 So Python scripts in Lennix start similarly to the bad ones, except this time is going to say user 16 00:01:00,480 --> 00:01:01,590 in Python. 17 00:01:01,590 --> 00:01:04,880 That's going to tell the system to interpret this as a python script when it runs. 18 00:01:05,220 --> 00:01:11,220 So if you want to declare a variable here, which is variable name equals value, when X is variable, 19 00:01:11,220 --> 00:01:12,870 you just type the variable name. 20 00:01:13,620 --> 00:01:15,450 If you want to print something out on the screen. 21 00:01:15,660 --> 00:01:16,560 So he's an echo. 22 00:01:16,570 --> 00:01:23,310 In this case, we would use print and then we would put the parentheses signs and whatever text that 23 00:01:23,310 --> 00:01:24,300 we want to put inside of it. 24 00:01:24,360 --> 00:01:26,960 OK, so let's talk about creating functions in Python. 25 00:01:27,210 --> 00:01:33,420 So if you want to create a function, you start with def and then the function name with the provinces 26 00:01:33,420 --> 00:01:38,700 and then colon, and you would then start defining your function. 27 00:01:38,910 --> 00:01:43,590 And if you want to call the function in Python, you need a function name followed by two parentheses 28 00:01:43,590 --> 00:01:44,590 and of all the function. 29 00:01:44,940 --> 00:01:50,220 So if you want to create a function that actually takes in an argument, you would just do the naming 30 00:01:50,220 --> 00:01:56,100 of function and you will put the argument right there inside of the parentheses you would use that you 31 00:01:56,100 --> 00:02:02,580 would access that variable, you know, with the ARG one variable in this case because it was passed 32 00:02:02,580 --> 00:02:03,480 in in parentheses. 33 00:02:03,570 --> 00:02:08,260 And then as you pass on those parentheses, you would be able to use inside of that function. 34 00:02:09,120 --> 00:02:11,010 So, yeah, this just prints out. 35 00:02:11,040 --> 00:02:16,000 So this one principle, you know, you passed in and whatever the argument is right there. 36 00:02:17,280 --> 00:02:23,160 So all this function from the command line would probably look like function, the function name, and 37 00:02:23,160 --> 00:02:27,750 then you have the in parentheses and inside the quality will put my name. 38 00:02:28,200 --> 00:02:30,360 And that would be the argument that you passed in. 39 00:02:31,080 --> 00:02:32,470 So let's actually go and try this out. 40 00:02:32,860 --> 00:02:35,340 OK, so I'm going to do a new file. 41 00:02:35,340 --> 00:02:39,820 So the python peepy function. 42 00:02:40,110 --> 00:02:40,630 There we go. 43 00:02:41,670 --> 00:02:43,870 So let's start with our command. 44 00:02:43,890 --> 00:02:52,440 So is countersign at some point as viewers are so experienced, Python so now knows that this is a Python 45 00:02:52,440 --> 00:02:52,860 script. 46 00:02:53,100 --> 00:03:02,130 So A.F. and then our function name, let's say it is to you, just name, keep it simple and then our 47 00:03:02,130 --> 00:03:06,290 colon and then we're going to start to make our function. 48 00:03:06,660 --> 00:03:09,780 So it would just, you know, if we wanted to print something out, so. 49 00:03:12,670 --> 00:03:16,060 My name is Anthony. 50 00:03:18,860 --> 00:03:19,400 There you go. 51 00:03:19,430 --> 00:03:20,760 So that's the function right there. 52 00:03:21,020 --> 00:03:27,120 So then I would be able to call the function like this, you know, right away. 53 00:03:28,420 --> 00:03:39,280 So now we can do C.H. Mod plus X PI function and now we do dogpile function and say, my name is Anthony 54 00:03:39,320 --> 00:03:39,590 there. 55 00:03:39,590 --> 00:03:41,060 We created a simple function. 56 00:03:41,240 --> 00:03:45,320 OK, so let's say that we wanted to pass something into dysfunction. 57 00:03:45,330 --> 00:03:52,820 So we'll go up here and in parentheses, input, maybe name and we would take our name right here where 58 00:03:52,820 --> 00:03:58,760 we have it right now and we do plus name and then less. 59 00:03:59,000 --> 00:04:02,230 When we call the function we would actually, you know, probably want. 60 00:04:02,250 --> 00:04:03,440 So this Anthony. 61 00:04:04,070 --> 00:04:06,920 So now, right now, let's try to run it. 62 00:04:07,720 --> 00:04:10,260 That's slash PI function. 63 00:04:10,340 --> 00:04:11,270 My name is Anthony. 64 00:04:11,300 --> 00:04:11,730 There we go. 65 00:04:11,750 --> 00:04:15,260 So now we passed a function and we passed in something into Python. 66 00:04:15,710 --> 00:04:20,750 OK, so if you want to capture user input in Python, you would just set it up like a variable. 67 00:04:20,750 --> 00:04:23,780 So the variable name right here is user input. 68 00:04:23,990 --> 00:04:29,900 And then that method from Python is input, parentheses and then input is what is going to print out 69 00:04:29,900 --> 00:04:32,720 on the screen and wait for you to actually type in your input. 70 00:04:33,890 --> 00:04:37,250 And you can print this by printing the variable with the print command. 71 00:04:37,970 --> 00:04:39,890 That would be a lowercase period there as well. 72 00:04:41,390 --> 00:04:48,400 So now let's actually go over and try to do this, started new files of the PI input. 73 00:04:49,490 --> 00:04:55,690 So we're going to insert our common user in Python. 74 00:04:57,890 --> 00:05:05,370 So now that's a user's keyboard like it was in their user input equals input. 75 00:05:06,560 --> 00:05:16,720 I say insert your age and make sure we have parentheses around that and let's make sure that we spell 76 00:05:16,730 --> 00:05:17,180 input. 77 00:05:17,180 --> 00:05:17,600 Right. 78 00:05:18,980 --> 00:05:22,340 And then we're going to print. 79 00:05:25,090 --> 00:05:27,310 User input. 80 00:05:27,970 --> 00:05:28,670 There we go. 81 00:05:29,050 --> 00:05:32,740 So I was very quick siege mod. 82 00:05:35,550 --> 00:05:44,490 Plus x pi and put Bam that slash PI input and see your age. 83 00:05:44,700 --> 00:05:45,930 Ask me how old I am. 84 00:05:46,150 --> 00:05:48,120 Let's say I'm 28 because I am. 85 00:05:48,660 --> 00:05:50,440 Yeah now I'm 28. 86 00:05:50,440 --> 00:05:52,620 So now we know how to cash and put it in, print it out. 87 00:05:52,680 --> 00:05:57,990 OK, so just like Bashour and give you an example of a conditional statement in Python as well, similar 88 00:05:57,990 --> 00:05:58,650 to the other one. 89 00:05:58,690 --> 00:06:01,650 So in Python, this is how you would type this. 90 00:06:01,720 --> 00:06:07,830 You would say, you know, if for example, five is greater than 10, you print out, five is greater 91 00:06:07,830 --> 00:06:12,440 than 10 in text or else print five is less than 10. 92 00:06:13,170 --> 00:06:16,560 So in that case, is it five is not greater than 10. 93 00:06:16,710 --> 00:06:21,280 You're going to print out five is less than ten, which makes sense because five is less than ten. 94 00:06:21,720 --> 00:06:27,390 So this is otherwise a little bit simpler when it comes to, you know, making the conditional statement. 95 00:06:27,400 --> 00:06:32,160 So you kind of seeing that python is very simplistic in a way. 96 00:06:32,820 --> 00:06:36,200 So now let's talk about for loops. 97 00:06:36,420 --> 00:06:42,330 So this is another iterate through maybe lists of different things. 98 00:06:42,340 --> 00:06:48,390 So like for this example, right here, we have a list right here called Fruits. 99 00:06:48,390 --> 00:06:51,550 We have apple and a banana and then cherry. 100 00:06:51,840 --> 00:07:00,750 So if we want to access all those values inside of that list, we would say for X in fruits colon and 101 00:07:00,750 --> 00:07:02,400 then we're printing X. 102 00:07:02,850 --> 00:07:07,680 So X in this case is, you know, each individual, one of those. 103 00:07:08,610 --> 00:07:16,230 So for each individual thing inside this list, inside the fruits list, we're going to print it out 104 00:07:16,230 --> 00:07:16,920 on the screen. 105 00:07:17,760 --> 00:07:22,050 There's another way that you can use for loops as you print out every letter in a string. 106 00:07:22,080 --> 00:07:29,010 So right here in this next one, we have four X in and then parentheses my string. 107 00:07:29,010 --> 00:07:33,420 So it'll take each one of those characters, including the space, and print it out on the screen. 108 00:07:34,350 --> 00:07:38,490 OK, so one thing that you're going to notice, Python is used for a lot. 109 00:07:39,510 --> 00:07:44,340 You're going to be noticing that you're like some of the experts that you're looking at, they're going 110 00:07:44,340 --> 00:07:47,030 to be connecting to, you know, something called sockets. 111 00:07:47,250 --> 00:07:51,150 And this is just simply creating, you know, connections over specific ports. 112 00:07:51,330 --> 00:07:55,440 Think back to our networking section, to another computer using Python. 113 00:07:55,980 --> 00:07:58,860 It's very important, understand, because, you know, it's going to allow you to quickly connect to 114 00:07:58,860 --> 00:08:03,830 ports on the go or be able to understand and explain changes. 115 00:08:03,830 --> 00:08:08,070 You know, if you need to like you need change porridge, change something, maybe some syntax is wrong. 116 00:08:08,170 --> 00:08:08,770 We'll do it. 117 00:08:08,850 --> 00:08:12,660 So here's an example, Python script for, you know, connect to a port. 118 00:08:13,120 --> 00:08:14,560 So you see our recommended top. 119 00:08:15,180 --> 00:08:21,910 So then we have import socket and then we have IP as a variable and then it says more input. 120 00:08:21,930 --> 00:08:25,740 So let's say that actually to put the IP address. 121 00:08:25,740 --> 00:08:31,830 So it takes it as more input and then you have the port which you taken as input into port in. 122 00:08:32,190 --> 00:08:35,040 And this is also a user captured input. 123 00:08:35,850 --> 00:08:42,090 And then we have another variable that's going to be this is the line at the nexus to the port. 124 00:08:42,090 --> 00:08:44,240 So socket socket. 125 00:08:44,430 --> 00:08:50,440 And then these commands right in here is going to allow you to connect to a socket. 126 00:08:50,610 --> 00:08:56,790 So the way that we would actually make this connection is using the stamey. 127 00:08:56,790 --> 00:09:05,040 So if s that connect underscore X and then you put those two variables in there, the IP in the port, 128 00:09:05,340 --> 00:09:11,190 then we will present, you know, port and then say that that port is actually close. 129 00:09:11,430 --> 00:09:14,610 So this is a way to check to see if you can actually get to this port. 130 00:09:14,610 --> 00:09:18,180 If you can get to it, then I would say that it was open. 131 00:09:18,180 --> 00:09:22,130 But in this case, you know, if you can't get to it, it would say that it's closed. 132 00:09:22,500 --> 00:09:28,440 So that's like a basic overview of, you know, how you would actually connect to, like different ports 133 00:09:28,440 --> 00:09:32,520 if you wanted to, like, you know, maybe do like a manual port scan, which you will probably never 134 00:09:32,520 --> 00:09:32,970 want to do. 135 00:09:32,970 --> 00:09:37,080 But if you wanted to do something like that, you know, you will be able to check to see if a port 136 00:09:37,080 --> 00:09:37,560 is open. 137 00:09:37,560 --> 00:09:40,910 If you want to check on a fly, you can have this script handy and you could check that. 138 00:09:40,980 --> 00:09:45,390 OK, so you kind of already see me do this and I've kind of already gone over it. 139 00:09:45,660 --> 00:09:50,940 But, you know, if you want to just go over really quickly individually, if you want to execute any 140 00:09:50,940 --> 00:09:57,180 script the same as a file, you're going to want to go to, you know, the directors and it's time to 141 00:09:57,360 --> 00:09:59,610 send in the script name and then just hit enter. 142 00:09:59,610 --> 00:10:01,140 And you're going to be good to go. 143 00:10:01,470 --> 00:10:03,180 See, you've already seen me do that many times. 144 00:10:03,180 --> 00:10:05,660 And if you're going along with me, you've probably known as well. 145 00:10:05,880 --> 00:10:08,420 So you know how to write and execute scripts now. 146 00:10:09,270 --> 00:10:13,600 So we've got all of the bases and Linux bash in Python. 147 00:10:13,620 --> 00:10:14,890 So what's next? 148 00:10:15,210 --> 00:10:20,330 So now that we, you know, have some of those important, you know, scripting basics down and the 149 00:10:20,520 --> 00:10:25,650 bases down, we're going to quickly go over how you can maintain your privacy in a nice and safe so 150 00:10:25,650 --> 00:10:27,120 no one can really be watching. 151 00:10:27,120 --> 00:10:32,130 You know, we're going to go over, you know, some applications and techniques that you can use to 152 00:10:32,130 --> 00:10:33,830 remain anonymous and safe on the web. 153 00:10:33,840 --> 00:10:34,140 So. 154 00:10:34,420 --> 00:10:38,340 I appreciate you for watching his lecture and I will see you guys in the next segment.