tmux is a terminal multiplexer. It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal. It has the ability to send keystrokes into the shells automatically. Through this feature, let's create internal environment variables through which we can convert a non-interactive reverse shell into an interactive one.
Now every time you get a non-interactive shell, you can simply hit Ctrl-aqq, in order to trigger the first binding (Ctrl-aq) and then sending the second part (Ctrl-q).
Prerequisites:
- tmux >= "v2.4"
To install tmux-config:
$ git clone https://github.com/hax3xploit/EZ-Tmux
$ ./EZ-Tmux/install.sh
tmux key | Description | iTerm2 key |
C-a |
Default prefix, used instead of "C-b". Same prefix is used in screen program, and it's easy to type. The only drawback of "C-a" is that underlying shell does not receive the keystroke to move to the beginning of the line. | - |
<prefix> Ctrl-q |
Spawn python's shell. | - |
Ctrl-q |
Basic reverse shell to a fully interactive TTY | - |
<prefix> Z |
Rename current session | - |
<prefix> z |
Rename current window | - |
<prefix> r |
Reloads the configuration/td> | - |
<prefix> _ |
Split new pane horizontally | ⌘⇧D |
<prefix> | |
Split new pane vertically | ⌘D |
<Ctrl> ← |
Select pane on the left | ⌘⌥← |
<Ctrl> → |
Select pane on the right | ⌘⌥→ |
<Ctrl> ↑ |
Select pane on the top | ⌘⌥↑ |
<Ctrl> ↓ |
Select pane on the bottom | ⌘⌥↓ |
<prefix>C-← |
Resize pane to the left | ^⌘← |
<prefix>C-→ |
Resize pane to the right | ^⌘→ |
<prefix>C-↑ |
Resize pane to the top | ^⌘↑ |
<prefix>C-↓ |
Resize pane to the bottom | ^⌘↓ |
<Shift> → |
Move to next window | ⌘⇧] |
<Shift> ← |
Move to previous window | ⌘⇧[ |
<prefix> x |
Kill current pane | ⌘W |
<prefix> X |
Kill current window | ⌘⌥W |
<prefix>C-x |
Kill other windows but current one (with confirmation) | - |
<prefix> Q |
Kill current session (with confirmation) | - |
<prefix> d |
Detach from session | - |
<prefix> D |
Detach other clients except current one from session | - |