Skip to main content

Here is how I setup tmux in Kali. This is the file I start with or just use as it is: tmux.conf

Put the .tmux.conf file in the home directory, wherever your home may be: /home/USERNAME/.tmux.conf or /root/.tmux.conf

I usually use Kali as root. The easiest way to get started with root in Kali is with with the incredibly handy pimpmykali.

Create a tmux plugins directory inside the home directory:

cd /root/
mkdir /root/.tmux/plugins

Use git to clone tpm:

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

Install xsel, the command line X11 selection and clipboard tool:

apt install xsel

Run tpm, the tmux plugin:

~/.tmux/plugins/tpm/bin/install_plugins

Create directories for the logs. I use two different methods for creating logs so I create a directory for each:

mkdir /root/tmux_logs
mkdir /root/tmux_buffers

Start a new tmux session:

tmux new -s SESSION_NAME

The session name should be the subject or project name,

Now you can start using tmux…

Start tmux-logging on current tab you are on: Ctrl-a-Shift-p
You will see a notice telling you the logging was started. Do that for each tab you want to start the tmux-logging.
Give current tab a proper name: Ctrl-a-,
Open new tab: Ctrl-a-c
Go to tab 1: Ctrl-a-1
Go to tab 2: Ctrl-a-2

I might name the tabs something like this:
Tab 1: recon
Tab 2: netcat
Tab 3: msfconsole
Tab 4: transfers
Tab 5: exploit1
Tab 6: exploit2

After you have some activity in the terminal, you can copy something specific you want to save in your notes. Click hold and drag to select text in the terminal. The selection should be orange. Let go when you selected what you want and press Ctrl-c to copy. Press Enter to release the selection. Paste what you copied into a text editor. You can also start scrolling up after you make a selection to copy a larger area or you can just use key commands to make selections (see shortcuts below). You can play around with it.

The logs that get automatically saved in the tmux_logs directory with the tmux-logging plugin can sometimes get filled with “garbage” and I haven’t found a solution for that yet so until that is fixed, I usually save them manually with tmux.

Steps to manually save the buffer:

  1. Capture contents of the current pane to the temp-capture-buffer for each tab.
  2. Store contents of the temp-capture-buffer buffer to the ~/tmux.log file.
  3. Delete temp-capture-buffer buffer.
tmux capture-pane -b temp-capture-buffer -S -
tmux save-buffer -b temp-capture-buffer /root/tmux_buffers/htbActive_061621_1-recon.log
tmux delete-buffer -b temp-capture-buffer

When you’re all done with the session, and have saved the logs, etc, you can kill it:

tmux kill-session -t SESSION_NAME

Here are some other shortcuts I might use. You can search for more if you need something else.

Capture text on current screen: Ctrl+a+Alt+p
New vertical pane/window: Ctrl-a-Shift-%
New horizontal pane/window: Ctrl-a-Shift-”
Navigate around to each pane: Ctrl-a-right, Ctrl-a-left, Ctrl-a-up, Ctrl-a-down
Resize pane: HOLD-Ctrl-a-left, HOLD-Ctrl-a-right, HOLD-Ctrl-a-up, HOLD-Ctrl-a-down
It will resize the pane just one Hold/arrow click at at time.
Close current pane (y/n): Ctrl-a-x
Scroll window up: Ctrl-a-PgUp
Scroll window down: Ctrl-a-PgDn
Make a selection with keyboard: Ctrl-a-[
(Press up/down/right/left arrows to starting point -> Press Spacebar to begin selection -> Press up/down/right/left arrows or PageUp/PageDown to make a selection -> Press Ctrl-c to copy -> Press Enter to release selection and return to current cursor  -> Or press Esc to release selection and keep cursor at the same position in terminal)
If you see the orange line numbers at the top right, you are in selection mode. Just press Enter to go back to the terminal.
Commit the config changes: Ctrl-a-i