Gus Khawaja - Kali Linux Penetration Testing Bible

Здесь есть возможность читать онлайн «Gus Khawaja - Kali Linux Penetration Testing Bible» — ознакомительный отрывок электронной книги совершенно бесплатно, а после прочтения отрывка купить полную версию. В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Жанр: unrecognised, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

Kali Linux Penetration Testing Bible: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Kali Linux Penetration Testing Bible»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

A comprehensive how-to pentest book, using the popular Kali Linux tools  Kali is a popular Linux distribution used by security professionals and is becoming an important tool for daily use and for certifications. Penetration testers need to master Kali’s hundreds of tools for pentesting, digital forensics, and reverse engineering. 
 is a hands-on guide for getting the most from Kali Linux for pentesting. This book is for working cybersecurity professionals in offensive, hands-on roles, including red teamers, white hat hackers, and ethical hackers. Defensive specialists will also find this book valuable, as they need to be familiar with the tools used by attackers. 
This is the most comprehensive pentesting book on the market, covering every aspect of the art and science of penetration testing. It covers topics like building a modern Dockerized environment, the basics of bash language in Linux, finding vulnerabilities in different ways, identifying false positives, and practical penetration testing workflows. You’ll also learn to automate penetration testing with Python and dive into advanced subjects like buffer overflow, privilege escalation, and beyond. 
Gain a thorough understanding of the hundreds of penetration testing tools available in Kali Linux Master the entire range of techniques for ethical hacking, so you can be more effective in your job and gain coveted certifications Learn how penetration testing works in practice and fill the gaps in your knowledge to become a pentesting expert Discover the tools and techniques that hackers use, so you can boost your network’s defenses For established penetration testers, this book fills all the practical gaps, so you have one complete resource that will help you as your career progresses. For newcomers to the field, 
 is your best guide to how ethical hacking really works.

Kali Linux Penetration Testing Bible — читать онлайн ознакомительный отрывок

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Kali Linux Penetration Testing Bible», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

This chapter will not only teach you the Bash scripting language, it will go beyond that to show you the ideology of programming as well. If you're new to programming, this is a good starting point for you to understand how programming languages work (they share a lot of similarities).

Here's what you're going to learn in this chapter:

Printing to the screen using Bash

Using variables

Using script parameters

Handling user input

Creating functions

Using conditional if statements

Using while and for loops

Basic Bash Scripting

Figure 2.1summarizes all the commands, so you can use it as a reference to grasp all the contents of this chapter. In summary, basic Bash scripting is divided into the following categories:

Variables

Functions

User input

Script output

Parameters

Printing to the Screen in Bash

There are two common ways to write into the terminal command‐line output using Bash scripting. The first simple method is to use the echocommand that we saw in the previous chapter (we include the text value inside single quotes or double quotes):

$echo 'message to print.'

The second method is the printfcommand; this command is more flexible than the echocommand because it allows you to format the string that you want to print:

$printf 'message to print'

The previous formula is too simplified; in fact, printfallows you to format strings as well (not just for printing; it's more than that). Let's look at an example: if we want to display the number of live hosts in a network, we can use the following pattern:

root@kali:~# printf "%s %d\n" "Number of live hosts:" 15 Number of live hosts: 15 Figure 21Bash Scripting Lets divide the command so you can understand whats - фото 23

Figure 2.1Bash Scripting

Let's divide the command so you can understand what's going on:

%s : Means we're inserting a string (text) in this position

%d : Means we're adding a decimal (number) in this position

\n : Means that we want to go to a new line when the print is finished

Also, take note that we are using double quotes instead of single quotes. Double quotes will allow us to be more flexible with string manipulation than the single quotes. So, most of the time, we can use the double quotes for printf(we rarely need to use the single quotes).

To format a string using the printfcommand, you can use the following patterns:

%s : String (texts)

%d : Decimal (numbers)

%f : Floating‐point (including signed numbers)

%x : Hexadecimal

\n : New line

\r : Carriage return

\t : Horizontal tab

Variables

What is a variable, and why does every programming language use it anyway?

Consider a variable as a storage area where you can save things like strings and numbers. The goal is to reuse them over and over again in your program, and this concept applies to any programming language (not just Bash scripting).

To declare a variable, you give it a name and a value (the value is a string by default). The name of the variable can only contain an alphabetic character or underscore (other programming languages use a different naming convention). For example, if you want to store the IP address of the router in a variable, first you will create a file var.sh(Bash script files will end with .sh), and inside the file, you'll enter the following:

#!/bin/bash #Simple program with a variable ROUTERIP="10.0.0.1" printf "The router IP address: $ROUTERIP\n"

Let's explain your first Bash script file:

#!/bin/bash is called the Bash shebang; we need to include it at the top to tell Kali Linux which interpreter to use to parse the script file (we will use the same concept in Chapter 18, “Pentest Automation with Python,” with the Python programming language). The # is used in the second line to indicate that it's a comment (a comment is a directive that the creator will leave inside the source code/script for later reference).

The variable name is called ROUTERIP , and its value is 10.0.0.1.

Finally, we're printing the value to the output screen using the printf function.

To execute it, make sure to give it the right permissions first (look at the following output to see what happens if you don't). Since we're inside the same directory ( /root), we will use ./var.shto execute it:

root@kali:~# ./var.sh bash: ./var.sh: Permission denied root@kali:~# chmod +x var.sh root@kali:~# ./var.sh The router IP address: 10.0.0.1

Congratulations, you just built your first Bash script! Let's say we want this script to run automatically without specifying its path anywhere in the system. To do that, we must add it to the $PATHvariable. In our case, we will add /optto the $PATHvariable so we can save our custom scripts in this directory.

First, open the .bashrcfile using any text editor. Once the file is loaded, scroll to the bottom and add the line highlighted in Figure 2.2.

Figure 22Export Config The changes will append optto the PATHvariable At - фото 24

Figure 2.2Export Config

The changes will append /optto the $PATHvariable. At this stage, save the file and close all the terminal sessions. Reopen the terminal window and copy the script file to the /optfolder. From now on, we don't need to include its path; we just execute it by typing the script name var.sh(you don't need to re‐execute the chmodagain; the execution permission has been already set):

root@kali:~# cp var.sh /opt/ root@kali:~# cd /opt root@kali:/opt# ls -la | grep "var.sh" -rwxr-xr-x 1 root root 110 Sep 28 11:24 var.sh root@kali:/opt# var.sh The router IP address: 10.0.0.1

Commands Variable

Sometimes, you might want to execute commands and save their output to a variable. Most of the time, the goal behind this is to manipulate the contents of the command output. Here's a simple command that executes the lscommand and filters out the filenames that contain the word simple using the grepcommand. (Don't worry, you will see more complex scenarios in the upcoming sections of this chapter. For the time being, practice and focus on the fundamentals.)

#!/bin/bash LS_CMD=$(ls | grep 'simple') printf "$LS_CMD\n"

Here are the script execution results:

root@kali:/opt# simplels.sh simpleadd.sh simplels.sh

Script Parameters

Sometimes, you will need to supply parameters to your Bash script. You will have to separate each parameter with a space, and then you can manipulate those params inside the Bash script. Let's create a simple calculator ( simpleadd.sh) that adds two numbers:

#!/bin/bash #Simple calculator that adds 2 numbers #Store the first parameter in num1 variable NUM1=$1 #Store the second parameter in num2 variable NUM2=$2 #Store the addition results in the total variable TOTAL=$(($NUM1 + $NUM2)) echo '########################' printf "%s %d\n" "The total is =" $TOTAL echo '########################'

You can see in the previous script that we accessed the first parameter using the $1syntax and the second parameter using $2(you can add as many parameters as you want).

Let's add two numbers together using our new script file (take note that I'm storing my scripts in the optfolder from now on):

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «Kali Linux Penetration Testing Bible»

Представляем Вашему вниманию похожие книги на «Kali Linux Penetration Testing Bible» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «Kali Linux Penetration Testing Bible»

Обсуждение, отзывы о книге «Kali Linux Penetration Testing Bible» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x