Try   HackMD

成為駭客的前一哩路

Chapter 1 - Getting Start With The Basics

Introductory Terms and Concepts

  • Binaries: 二進位執行檔 (就像在 Linux 中的 Windows 上的執行檔) ,通常是 Linux 的指令及工具。
  • Case sensitivity: 在 Linux 系統中,檔案名稱和路徑的大小寫要區分好 (不然會找不到)
  • Directory: 資料夾
  • Home: /home 資料夾,通常檔案創建儲存的地方
  • Kali: 一個 for hacker 的 Linux 系統
  • Root: 管理員帳號
  • Script: 在終端上執行的指令、腳本
  • Shell: 在 Linux 上執行指令的環境 (bash)
  • Terminal: 命令行介面 (Command Line Interface CLI)

A Tour of Kali

  • /root: 管理員的主資料夾
  • /etc: 包含 Linux 設定檔 (控制程序啟動)
  • /home: 使用者的主資料夾
  • /mnt: 其他額外的檔案系統
  • /media: CD 或 USB 連接或安裝到的資料夾
  • /bin: 裝 binaries 的地方
  • /lib: 裝 libraries 的地方 (類似 Windows 的 DLL 檔案)

Basic Commands in Linux

  1. 查詢當前路徑: pwd (print working directory)

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  2. 查看當前登陸的使用者: whoami

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  3. 改變當前所在位置: cd (change directory)

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    如果想要回到上一層資料夾可以用 cd ..

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    想要回到上上層可以使用 cd ../.. 以此類推

  4. 查看當前資料夾內資料: ls (list)

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    也可以用 ls PATH 來去查看特定資料夾內的資料

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    也可以加上參數 -l 來查看更詳細有關權限 (l 代表 long)

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    另外也可以加上 -a 來查看隱藏的資料夾或檔案

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    -l-a 都可以單獨使用或混合使用,順序也不影響

  5. 查看幫助: help

    • -- 代表要使用單字的選擇 (--help)
    • - 代表要使用單字元的選擇 (-h)

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  6. 查看幫助手冊(更詳細): man (manual)

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    進入 man 的頁面後可以使用上下方向滾動菜單

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    如果要退出就按下 q,按下 h 可以進入指令幫助


Finding Stuff

  1. 查看儲存庫中含有關鍵字的資料: locate

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  2. 找到工具的 binariesman 位置: whereis

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  3. 找到工具的 binaries 路徑(比 whereis 更精確去找執行檔): which

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  4. 更強力的查找工具: find

    語法: find directory option expression

    • 範例:
    • 顯示資料夾裡面的內容

      Image Not Showing Possible Reasons
      • The image was uploaded to a note which you don't have access to
      • The note which the image was originally uploaded to has been deleted
      Learn More →

    • 退回 /home 開始找 crud.py

      Image Not Showing Possible Reasons
      • The image was uploaded to a note which you don't have access to
      • The note which the image was originally uploaded to has been deleted
      Learn More →

    • 獲得找尋路徑

      Image Not Showing Possible Reasons
      • The image was uploaded to a note which you don't have access to
      • The note which the image was originally uploaded to has been deleted
      Learn More →

  5. 顯示運行中的進程: ps aux

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  6. 篩選出特殊關鍵字: grep

    我們可以搭配 ps aux 去使用查找特定的進程

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →


Modifying Files and Directories

  1. 查看檔案內容或創建檔案: cat

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  2. 新增檔案內容或創建檔案: cat >>

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  3. 複寫檔案內容或創建檔案: cat >

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  4. 創建檔案: touch

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  5. 創建資料夾: mkdir

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  6. 複製檔案: cp

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  7. 重新命名檔案: mv

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  8. 刪除檔案: rm

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

  9. 刪除資料夾: rmdir

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    如果資料夾內有資料是不能直接刪除的,要先進入資料夾刪除檔案後才能刪除資料夾

    screenshot_20231102_215206.png
    使用 rm -r 即可刪除資料夾及其內容


Exercise

  1. 在 root (/) 資料夾內使用 ls 探索 Linux 的檔案結構,利用 cd 改變位置和 pwd 查看是否真的進入該資料夾
  2. 使用 whoami 查看登陸的使用者
  3. 使用 locate 查找 wordlists (用來 Password Cracking)
  4. 使用 cat 創建新檔案再新增內容到檔案
  5. 創建新資料夾 hackeddirectory,在裡面創建新檔案 hackedfile,將其複製到 /root 資料夾並重命名為 secretfile

下一篇: Chapter 2