1 00:00:00,300 --> 00:00:02,070 Okay, so let's run our script. 2 00:00:02,070 --> 00:00:09,240 OSPF p y hopefully what we'll see are ospf passwords and there you go. 3 00:00:09,270 --> 00:00:13,110 OSPF password is cisco now on the Cisco router? 4 00:00:13,110 --> 00:00:16,590 Once again, I could change that password. 5 00:00:16,590 --> 00:00:22,320 So interface gigabit is zero zero ip ospf authentication key. 6 00:00:22,320 --> 00:00:24,330 Let's set it to ospf poss. 7 00:00:24,540 --> 00:00:30,290 What should happen is our python script should show us the new OSPF password. 8 00:00:30,300 --> 00:00:34,110 This has been captured off the wire in real time. 9 00:00:34,110 --> 00:00:35,130 And there you go. 10 00:00:35,130 --> 00:00:36,300 OSPF pass. 11 00:00:36,900 --> 00:00:39,990 So my simple Python script. 12 00:00:41,960 --> 00:00:43,850 And I'll Katyusha. 13 00:00:43,880 --> 00:00:45,880 OSPF dot p y. 14 00:00:46,040 --> 00:00:53,990 This simple Python script is capturing packets off the wire and then displaying the password. 15 00:00:54,050 --> 00:00:57,410 Now, you may want to save that to a file rather than. 16 00:00:59,010 --> 00:01:00,630 Have it just print to the screen. 17 00:01:01,410 --> 00:01:11,640 So as an example, Nano or SPF, JPY, let's rather than just print it to the screen, save it to a 18 00:01:11,640 --> 00:01:12,300 file. 19 00:01:12,390 --> 00:01:14,850 So I'll create a variable called my file. 20 00:01:15,570 --> 00:01:23,940 I'll open up a file called and let's make this OSPF passwords text. 21 00:01:24,720 --> 00:01:26,790 This is going to be a ratable file. 22 00:01:26,790 --> 00:01:29,780 So basically I'm opening up a file with this name. 23 00:01:30,520 --> 00:01:31,540 I don't have to use text. 24 00:01:31,540 --> 00:01:34,590 I'll just use that to be consistent with, say, what Windows does. 25 00:01:34,600 --> 00:01:42,880 It's a read write file and then I'm going to write the output to this file. 26 00:01:42,880 --> 00:01:44,320 Now that's actually writing the packet. 27 00:01:44,320 --> 00:01:45,610 So let's not do that. 28 00:01:46,000 --> 00:01:47,770 Let's say write. 29 00:01:49,760 --> 00:01:52,550 OSPF pass equals this. 30 00:01:54,900 --> 00:01:59,970 So equals the OSPF password string plus the actual password. 31 00:02:00,510 --> 00:02:04,560 And then I'm going to write the OSPF pass here. 32 00:02:05,010 --> 00:02:10,039 And if you concerned that it's actually the same word, I'll just change it here to something else. 33 00:02:10,050 --> 00:02:17,580 So this is just a variable called OSPF password that equals OSPF password, plus the actual password 34 00:02:17,580 --> 00:02:18,540 that's captured. 35 00:02:18,570 --> 00:02:22,590 We're opening up a file and then we're going to save that to the file. 36 00:02:22,590 --> 00:02:27,720 And actually, what I will do here is I don't want to open the file up every time because it'll override 37 00:02:27,720 --> 00:02:28,080 it. 38 00:02:28,080 --> 00:02:33,570 I'll open up the file there and then write to the file per that output. 39 00:02:34,230 --> 00:02:37,620 So it'll write the password consistently to the file. 40 00:02:37,660 --> 00:02:41,370 Now I'm coding this on the fly, so hopefully my code isn't that bad. 41 00:02:41,370 --> 00:02:42,780 So let's give it a go. 42 00:02:42,990 --> 00:02:44,090 I'll run the script. 43 00:02:44,100 --> 00:02:48,750 We won't see anything because we're not writing to the screen. 44 00:02:48,750 --> 00:02:53,670 In this example, I'm just saving the information to a file. 45 00:02:54,380 --> 00:02:56,630 But hopefully we'll stop that script now. 46 00:02:58,550 --> 00:03:06,250 Hopefully we've got a file called OSPF Password, which we do. 47 00:03:06,260 --> 00:03:14,840 And if I get that which is basically reading it, notice we can see ospf password is ospf poss ospf 48 00:03:14,840 --> 00:03:18,410 password and then we get a prompt. 49 00:03:18,440 --> 00:03:21,320 Now that's not such a great way to do it. 50 00:03:21,320 --> 00:03:28,100 So like all things when it comes to coding, you iterate, you iterate what you, what you do. 51 00:03:30,020 --> 00:03:37,010 So what I'll do is write that, but put a carriage return after it and let's see what that does. 52 00:03:39,330 --> 00:03:40,470 So run it again. 53 00:03:40,470 --> 00:03:42,110 Python three ospf. 54 00:03:42,400 --> 00:03:43,110 P. 55 00:03:44,040 --> 00:03:45,330 Very simple script. 56 00:03:45,570 --> 00:03:46,500 Didn't like that. 57 00:03:46,500 --> 00:03:48,960 Let's see what I did wrong here. 58 00:03:54,070 --> 00:03:56,830 Let's add that like that. 59 00:03:59,630 --> 00:03:59,750 Okay. 60 00:04:00,130 --> 00:04:01,090 That looks better. 61 00:04:01,630 --> 00:04:03,190 This is the thing with coding. 62 00:04:03,280 --> 00:04:05,100 You know, start with a small script. 63 00:04:05,110 --> 00:04:06,100 Try something. 64 00:04:06,130 --> 00:04:07,480 See if it works. 65 00:04:07,660 --> 00:04:09,190 Then try something else. 66 00:04:10,060 --> 00:04:11,200 See if that works. 67 00:04:11,440 --> 00:04:14,170 Keep iterating and keep improving your scripts. 68 00:04:14,740 --> 00:04:16,690 So that should be long enough. 69 00:04:18,250 --> 00:04:19,329 Clear the screen. 70 00:04:22,160 --> 00:04:23,720 Ellis shows us our files. 71 00:04:23,720 --> 00:04:26,630 Cat ospf password txt. 72 00:04:26,660 --> 00:04:30,290 Notice there's our password with the carriage returns after it. 73 00:04:30,740 --> 00:04:31,010 Okay. 74 00:04:31,010 --> 00:04:37,310 So just to make the point, I'll run that again and then what I'll do here is clear the process. 75 00:04:37,310 --> 00:04:39,800 But then I'll go onto the. 76 00:04:40,720 --> 00:04:44,950 Interface and change the password to something else. 77 00:04:45,700 --> 00:04:47,170 So let's set it to. 78 00:04:47,440 --> 00:04:48,370 Hello? 79 00:04:49,240 --> 00:04:50,260 One, two, three. 80 00:04:51,490 --> 00:04:55,300 So that should display in our text file. 81 00:04:55,780 --> 00:04:59,200 Now again, you could use cron to schedule this. 82 00:05:00,560 --> 00:05:04,580 I'll end that now rather than running it interactively. 83 00:05:05,030 --> 00:05:09,800 Just schedule this to run in the background and notice there's our password. 84 00:05:09,830 --> 00:05:10,250 Hello? 85 00:05:10,250 --> 00:05:11,030 One, two, three. 86 00:05:12,350 --> 00:05:14,690 So I could, as an example, do this. 87 00:05:17,880 --> 00:05:21,280 Notice I've started this script. 88 00:05:21,300 --> 00:05:24,470 It's running in the background and I've got my terminal prompt. 89 00:05:24,480 --> 00:05:26,880 Now, if I type top. 90 00:05:27,240 --> 00:05:31,320 So notice top shows us that T Chalk is running in the background. 91 00:05:31,830 --> 00:05:33,300 So is Python three. 92 00:05:33,330 --> 00:05:36,480 So that script is busy running in the background. 93 00:05:36,990 --> 00:05:39,690 What I could do is kill the process. 94 00:05:39,700 --> 00:05:42,720 So let's kill t shock kill process. 95 00:05:42,720 --> 00:05:43,740 One, two, four, eight. 96 00:05:44,070 --> 00:05:47,280 And notice we see some output that the script is done. 97 00:05:48,030 --> 00:05:49,330 So clear the screen. 98 00:05:49,350 --> 00:05:51,510 Liz shows us our files. 99 00:05:51,600 --> 00:05:54,450 Let's read that OSPF password file. 100 00:05:54,480 --> 00:05:58,230 Notice there's the password written to the file. 101 00:05:58,680 --> 00:06:00,750 Now, you could get fancy with your scripts. 102 00:06:00,750 --> 00:06:05,580 You could get cron to kick start that script and then run it for a period of time. 103 00:06:05,880 --> 00:06:07,610 So let's run it for half an hour. 104 00:06:07,620 --> 00:06:11,010 We'll run it for a day or for a period of time. 105 00:06:11,010 --> 00:06:13,140 You could get your script to email you. 106 00:06:13,140 --> 00:06:15,300 The passwords do all kinds of things. 107 00:06:15,510 --> 00:06:24,330 The moral of the story here is you can leverage Python and T shark to capture packets off the wire and 108 00:06:24,330 --> 00:06:25,510 then do things. 109 00:06:25,560 --> 00:06:27,240 So let me show you another example. 110 00:06:27,240 --> 00:06:33,150 In the next video, I'll show you how to use this to capture, for instance, FTP passwords.