1 00:00:00,060 --> 00:00:00,810 Hello, everyone. 2 00:00:01,320 --> 00:00:06,270 Today, we will talk about an essential command line skills for penetration testers. 3 00:00:07,320 --> 00:00:09,120 First command is the history command. 4 00:00:09,960 --> 00:00:14,670 As a penetration tester, it's very important to keep in mind that all the commands that we have been 5 00:00:14,670 --> 00:00:17,520 using in our Besch are stored in a history file. 6 00:00:18,790 --> 00:00:24,040 In order for us to view the previous commands, we can type history in our command line. 7 00:00:25,110 --> 00:00:25,830 Let's try 8 00:00:30,600 --> 00:00:32,310 in the penetration testing phase. 9 00:00:32,490 --> 00:00:37,860 This command is very important since we might find valuable commands that has been entered by the user 10 00:00:37,860 --> 00:00:38,490 or the admin. 11 00:00:40,380 --> 00:00:47,370 Now, if we found of long command in our history, we can simply retype this command using its NO from 12 00:00:47,370 --> 00:00:48,200 the history list. 13 00:00:49,440 --> 00:00:57,690 Let's try our code DST IP Command, which is number seven or five in the list in order to repeat a command 14 00:00:57,690 --> 00:00:58,690 using its number. 15 00:00:58,740 --> 00:01:01,830 We need to add exclamation mark before the number. 16 00:01:13,820 --> 00:01:21,590 Also, if we want to repeat the last command we typed, we can do that by typing double exclamation 17 00:01:21,590 --> 00:01:22,010 marks. 18 00:01:27,930 --> 00:01:28,410 Nice. 19 00:01:29,160 --> 00:01:33,630 Now let's switch to common one, standard output and Kimelman standard error. 20 00:01:34,920 --> 00:01:40,920 Remember that if you want to display the content of our directory or any other directory, we use the 21 00:01:40,920 --> 00:01:41,730 Ellas command. 22 00:01:42,570 --> 00:01:46,800 But what if we want to display the content and redirect its output to a file? 23 00:01:48,030 --> 00:01:54,010 In order to do that, we have to use the greater than sine and then the name of the file you want the 24 00:01:54,030 --> 00:01:55,710 output redirected to. 25 00:01:56,880 --> 00:01:58,070 Let's take an example. 26 00:01:59,610 --> 00:02:06,390 Let's use Ellis' in our current directory and redirect the output to a text file called output dot text. 27 00:02:13,110 --> 00:02:18,700 Now, let's open the output that text file and see if we have the same output from our previous Ellas 28 00:02:18,750 --> 00:02:19,170 command. 29 00:02:24,410 --> 00:02:28,400 Let's verify the content with the ellos command without redirection. 30 00:02:31,940 --> 00:02:32,430 Nice. 31 00:02:33,260 --> 00:02:39,650 Now, if we want to use the same text file for other outputs as a log file, we have to use a double 32 00:02:39,650 --> 00:02:46,790 greater than sign because one greater than sine will delete everything in the file and create the actual 33 00:02:46,790 --> 00:02:47,310 file. 34 00:02:47,330 --> 00:02:48,350 If it doesn't exist. 35 00:02:49,370 --> 00:02:54,950 But since we want to keep the file and its content, then we have to use double greater than sine. 36 00:02:56,030 --> 00:02:56,780 Let's try. 37 00:03:08,420 --> 00:03:14,030 As you see it from the output we appended, the output of the second Ellas command to our current text 38 00:03:14,030 --> 00:03:14,360 file. 39 00:03:15,830 --> 00:03:20,800 We can also use Echo or CAD commands to redirect output to files. 40 00:03:22,700 --> 00:03:26,030 Let's echo Hello World and append it to our file. 41 00:03:40,900 --> 00:03:41,390 Nice. 42 00:03:42,160 --> 00:03:47,770 Now let's use KAB Command, but this time we will redirect our output to a new text file. 43 00:04:00,520 --> 00:04:00,810 Nice. 44 00:04:01,480 --> 00:04:03,280 Now, let's switch to a standard here. 45 00:04:06,610 --> 00:04:12,940 Sometimes when we create a best script, we don't want to see expected errors, or we might want to 46 00:04:12,940 --> 00:04:20,050 save all errors in a log file for feature checking in order to redirect only errors to a text file. 47 00:04:20,380 --> 00:04:24,160 We use the number two and greater than sign together. 48 00:04:25,630 --> 00:04:32,530 Let's take an example and try to get a file which it doesn't exist and normally we should get an error. 49 00:04:38,940 --> 00:04:42,000 Now let's use a standard air redirection. 50 00:04:51,280 --> 00:04:56,720 As you see, there was no error because it was redirected to the er the log file. 51 00:04:57,790 --> 00:04:59,440 Let's examine the file and check. 52 00:05:03,980 --> 00:05:06,740 Nice, let's switch to something else now, 53 00:05:09,530 --> 00:05:16,040 Peiping is extremely important when it comes to best reporting, which we will get into in later videos, 54 00:05:16,970 --> 00:05:22,850 piping in turmoil means we take an output of one command and used as input for another command. 55 00:05:24,080 --> 00:05:29,750 Let's take a practical example and try to filter the output of the eye of conflict command to display 56 00:05:29,750 --> 00:05:31,760 our network interface information. 57 00:05:36,130 --> 00:05:42,100 Now, let's pass the output of the eye of Conficker in to the grip command, using the vertical bar 58 00:05:42,130 --> 00:05:44,800 or the pipe character and search for a keyword. 59 00:05:55,920 --> 00:06:03,520 As you can see, we filtered the previous output and showed only anyone with the strength at zero nine. 60 00:06:04,440 --> 00:06:08,010 Let's switch to some string manipulation using this said utility. 61 00:06:09,540 --> 00:06:15,540 The set utility is very powerful when it comes with many functions, but we will only look at one of 62 00:06:15,540 --> 00:06:16,070 them today. 63 00:06:17,460 --> 00:06:24,060 Let's echo something to the screen and use that as input to our said utility, then replace one word. 64 00:06:47,410 --> 00:06:52,780 Here we use the letter S to substitute the word Lennix for the word Unix. 65 00:06:53,920 --> 00:06:55,660 Let's use the same set comen. 66 00:06:55,660 --> 00:06:58,630 But this time we will take our input from a file. 67 00:06:59,870 --> 00:07:03,820 But before we do that, let's open the file and display its content. 68 00:07:07,360 --> 00:07:12,910 Let's replace the word Linux and all lines by adding the characters in our self-command 69 00:07:17,590 --> 00:07:18,300 notice. 70 00:07:18,310 --> 00:07:21,190 We replace the word Linux, but we did save it. 71 00:07:21,460 --> 00:07:25,780 And if we had the same file again, we will notice that nothing had happened. 72 00:07:30,940 --> 00:07:35,620 If we want to save, but we changed, we can redirect the output to a new file. 73 00:07:47,180 --> 00:07:54,410 If we want to modify and save changes to our file, we can use the dashi argument, but we have to be 74 00:07:54,410 --> 00:07:57,830 extremely careful since this argument will modify your file. 75 00:07:58,010 --> 00:07:59,750 So it's better if you have a backup. 76 00:08:09,320 --> 00:08:10,520 Now, let's check it out. 77 00:08:10,550 --> 00:08:11,540 Changes were saved. 78 00:08:18,930 --> 00:08:23,640 Nice, we had reached the end of this lesson, thank you and see you in the next room.