Skip to content

The Linux Toolbox for Pentesters

Updated: at 04:04 AM (6 min read)

Here’s a collection of useful Linux tips and tricks that have improved my workflow throughout my career. I will continue to update this post as I come across more awesome techniques.

Table of Contents

Open Table of Contents

Fish

Why use fish?

To change the current shell to fish, run the following:

echo /usr/local/bin/fish | sudo tee -a /etc/shells && chsh -s /usr/local/bin/fish

Installing omf

Next, install omf.

curl https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install | fish

Setting up a theme

Personally, I like to use the coffeandcode.

omf install coffeeandcode
omf theme coffeeandcode

Adding the time to the fish prompt

Sometimes it’s nice to have timestamps for your commands. Find fish_prompt.fish for your current theme:

find / -name "fish_prompt.fish" 2>/dev/null

Prepend the echo line associated with your fish prompt with (date +%H:%M) ' ':

echo -s (date +%H:%M) ' ' (whatever-your-fish-prompt-is)

The echo command may be different depending on which theme you are using.

Configuring aliases

To configure aliases, run the following in the fish shell:

# This will run rm -i your-argument, mind the space between "-i" and "your-argument"
alias rmi "rm -i" --save
# For a bit more complex stuff (no space after command)
function new-folder
  mkdir /opt/project-$argv
end
funcsave new-folder

Some aliases I’ve used:

# Basically a proxychains shortcut
alias pxc 'proxychains -q' --save
# Search history for keywords
alias hg 'history | grep' --save
# I stole this from reddit
alias myip 'ip addr show eth0 | grep -oP "(?<=inet\s)\d+(\.\d+){3}"' --save
# Opens up chromium with a google search appended
# Usage: gsearch "what is love"
function gsearch
  chromium https://www.google.com/search\?q=$argv
end
funcsave gsearch

Tmux

Install tmux:

sudo apt install tmux

Start new tmux session with name:

tmux new -s mysession

Attach to a named tmux session:

tmux a -t mysession

List sessions:

tmux ls

Kill a session:

tmux kill-session -t mysession

Tmux shortcuts to know

Tmux plugins

Install tmux plugin manager:

git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm

Add this to the bottom of ~/.tmux.conf:

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'

# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'github_username/plugin_name#branch'
# set -g @plugin '[email protected]:user/plugin'
# set -g @plugin '[email protected]:user/plugin'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

To install plugins:

Add plugin into ~/.tmux.conf:

set -g @plugin myplugin

Then run Ctrl + B -> I to install.

To uninstall, run Ctrl + B > Alt + u.

Tmux config file

My personal config file:

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'catppuccin/tmux'
set -g @nova-nerdfonts false
set -g base-index 1
set -g history-limit 50000

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

Here’s a cool example of another from a buddy of mine.

Python virtual environments

Python virtual environments save lives. Run the following before installing packages from a requirements.txt file:

python3 -m venv my-venv-name
source my-venv-name/bin/activate.fish

Neovim

Neovim is another cool tool I’ve began to use a bit more. There are precompiled binaries out there, but since I’m on an ARM64-based Kali VM, I had to install from source.

Install dependencies:

sudo apt-get install ninja-build gettext cmake unzip curl build-essential

Select the Release build:

make CMAKE_BUILD_TYPE=Release

Install with CMake:

sudo make install

NvChad

Install NvChad:

git clone https://github.com/NvChad/starter ~/.config/nvim && nvim

You may want to install ripgrep as well.

Some extra configuration stuff:

"" Make it so that Insert Mode displays relative line numbers only
autocmd InsertEnter * :set relativenumber
autocmd InsertLeave * :set norelativenumber
"" Make it so that hitting "Esc" sets mode to Normal Terminal in a Nvim Terminal
tnoremap <Esc> <C-\><C-n>

Some keyboard shortcuts / commands to remember:

General vim stuff:

To modify the beginning/end of multiple lines (useful for commenting out multiple lines)

NvimTree:

Tabs:

Searching:

Other stuff:

7za

To add files to archive:

7za a myfiles.zip *

To extract an archive to a specific directory:

7za x myfiles.zip -o/path/to/directory

Install common tooling

I made a tool called kali-on-command that uses Ansible to install some common tools for red team operations. It’s primarily meant for Red vs. Blue Team competitions but can be used for general red teaming purposes.

# Install dependencies
apt -y update
apt -y install ansible-core sshpass
ansible-galaxy collection install community.general

# Clone git repo
git clone https://github.com/fyrworx4/kali-on-command.git
cd kali-on-command

# Run playbook
ansible-playbook -c local -i localhost, playbook.yml

References