天天看點

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

磨刀不誤砍柴工。 工欲善其事必先利其器

2. Getting Comfortable with Kali Linux

2.1 Booting Up Kali Linux

修改密碼:

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux
[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

2.2 The Kali Menu

2.3 Kali Documentation

The Kali Linux Official Documentation The Kali Linux Support Forum The Kali Linux Tools Site The Kali Linux Bug Tracker The Kali Linux Training

多利用Kali 官方文檔

https://www.kali.org/docs/
[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux
https://forums.kali.org/
[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

這些在排錯的時候都可能用得到

2.4 Finding Your Way Around Kali

2.4.1 The Linux Filesystem

早期的 Linux 使用 Ext2 檔案系統格式,CentOS 5.x 預設使用 Ext3,本教程中所用的 CentOS 6.x 預設使用 Ext4,而目前最新的 CentOS 7.x 預設使用 xfs 格式。

通常情況下,檔案系統會将檔案的實際内容和屬性分開存放:

檔案的屬性儲存在 inode 中(i 節點)中,每個 inode 都有自己的編号。每個檔案各占用一個 inode。不僅如此,inode 中還記錄着檔案資料所在 block 塊的編号;

檔案的實際内容儲存在 block 中(資料塊),類似衣櫃的隔斷,用來真正儲存衣物。每個 block 都有屬于自己的編号。當檔案太大時,可能會占用多個 block 塊。

另外,還有一個 super block(超級塊)用于記錄整個檔案系統的整體資訊,包括 inode 和 block 的總量、已經使用量和剩餘量,以及檔案系統的格式和相關資訊等。

Linux支援的常見檔案系統

Linux 系統能夠支援的檔案系統非常多,除 Linux 預設檔案系統 Ext2、Ext3 和 Ext4 之外,還能支援 fat16、fat32、NTFS(需要重新編譯核心)等 Windows 檔案系統。也就是說,Linux 可以通過挂載的方式使用 Windows 檔案系統中的資料。

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

The directories:

• /bin - basic programs (ls, cd, cat, etc.)

• /sbin - system programs (fdisk, mkfs, sysctl, etc)

• /etc - configuration files

• /tmp - temporary files (typically deleted on boot)

• /usr/bin - applications (apt, ncat, nmap, etc.)

• /usr/share - application support and data files

2.4.2 Basic Linux Commands

2.4.2.1 Man Pages

man手冊分為多個section,每個section用一個字元表示

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux
[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

use the -k option with man, we can perform a keyword search as shown below :

man -k:根據關鍵字搜尋聯機幫助,是一種模糊搜尋。例如要查找"passwd"相關的資訊,使用man -k passwd會找到很多和passwd相關的幫助頁。

man -f:關鍵字精确搜尋,與-k不同,它隻搜尋與關鍵字完全比對的幫助頁。

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux
[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

a regular expression:

也可以使用正規表達式

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

2.4.2.2 apropos

apropos指令 在一些特定的包含系統指令的簡短描述的資料庫檔案裡查找關鍵字,然後把結果送到标準輸出。

如果你不知道完成某個特定任務所需要指令的名稱,可以使用一個關鍵字通過Linux apropos實用程式來搜尋它。該實用程式可以搜尋關鍵字并且顯示所有包含比對項的man頁面的簡短描述。另外,使用man實用程式和-k(關鍵字)選項,可以得到和用Linux apropos實用程式相同的結果(實際上是相同的指令)。

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

2.4.2.3 Listing Files

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

思考題:

如何檢視/var/log目錄下的檔案數?

ls /var/log/ -1R | grep "-" | wc -l

2.4.2.4 Moving Around

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

2.4.2.5 Creating Directories

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

遞歸建立檔案夾:

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

2.4.3 Finding Files in Kali Linux

Three of the most common Linux commands used to locate files in Kali Linux include find, locate,and which.

2.4.3.1 which

Linux which指令用于查找檔案。

which指令會在環境變量$PATH設定的目錄裡查找符合條件的檔案。

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

2.4.3.2 locate

locate 檔案名

在背景資料庫中按檔案名搜尋,搜尋速度更快

/var/lib/mlocate

#locate指令所搜尋的背景資料庫

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

updatedb

更新資料庫

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

2.4.3.3 find

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

根據指定條件對文本搜尋

find  / -name xxx  指定内容

find . -user xxx    根據擁有者

find . -size 10M  根據檔案大小

find . -type   d     根據檔案類型

-a  将多個指定條件組合起來  

例 find . -name xxx -a -type f

-o 滿足多個條件中一個即可

例 find . -size +10M -o size 10M

-fprint 将搜尋結果列印到檔案

Tips:

locate:可以搜尋檔案和目錄的名稱,但是不能搜尋檔案的内容。

grep:在檔案中搜尋資料

find:根據指定條件對文本進行搜尋

2.5 Managing Kali Linux Services

2.5.1 SSH Service

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux
[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux
[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

開啟自啟:

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

Kali開啟ssh服務:

1.vim /etc/ssh/sshd_config編輯sshd配置檔案

2.找到#PermitRootLogin prohibit-password,把前面的#去掉,并且将“prohibit-password”修改為YES

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

3.找到PasswordAuthentication這一行,将前面的#号注釋去掉,如果後面寫的是no,需要修改成yes

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

4.Esc 退出編輯 ,輸入:wq 回車,完成編輯

5./etc/init.d/ssh restart

2.5.2 HTTP Service

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

To see a table of all available services, run systemctl with the list-unitfiles option

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

2.6 Searching, Installing, and Removing Tools

2.6.1 apt update

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux
[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

2.6.2 apt upgrade

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux
[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

2.6.3 apt-cache search and apt show

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux
[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

2.6.4 apt install

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

2.6.5 apt remove --purge

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux

2.6.6 dpkg

dpkg 即 package manager for Debian ,是 Debian 和基于 Debian 的系統中一個主要的包管理工具,可以用來安裝、建構、解除安裝、管理 deb 格式的軟體包。

[OSCP]-2.Getting Comfortable with Kali Linux2. Getting Comfortable with Kali Linux