Sobre
Terminal based intercepting proxy written in rust with tmux and vim as user interface.
Sistemas e infraestruturaO que você pode fazer
- tmux and vim as user interface.
- Disk based storage.
- Custom http/1.1 parser to send malformed requests.
- http/1.1, http/2 and websocket support.
Crescimento medido de estrelas
- em 24 h
- 0
- em 7 dias
- 0
- em 15 dias
- 0
- em 1 mês
- Coletando histórico
Variações líquidas em períodos sobrepostos, não totais diários. Medições ausentes ficam em branco. Estrelas indicam interesse, não qualidade.
README.md
OriginalTerminal based intercepting proxy written in rust with tmux and vim as user
interface.
Table of Contents
Screenshots
Interceptor
Interceptor Showq
History with 100k+ entries
History edit host scope
History edit status code scope
History edit uri scope
History show host scope
History show status code scope
History show uri scope
History show filters
History apply filters
Repeater
Repeater websocket
Addons - ffuf
Addons - sqlmap
Edit buffer variables
Edit Local Config in popup
Log
About The Project
The tool requires vim plugin which enables vim to function
as a user interface. Each window and filetype has its own set of keybindings
and commands.
The following windows are present in zxc:
When zxc is called a list of bash is used to spawn vim
with specific window name which loads corresponding vim config. All windows are
vim instances which communicate with zxc binary via unixsocket channel.
| Alias | Window |
|---|---|
| interceptor | Interceptor |
| vhistory | History |
| repeater | Repeater |
| addons | Addons |
The windows (except history which halts recording) can be closed and reopened using their respective aliases.
┌─────────────┐
┌───────────────►│ zxc binary │◄────┬───────────────┐
│ └┬────────────┘ │ │
│ │ │ │
│ │ unix socket │ │
│ │ │ │
┌──────▼──────┐ ┌──────▼──────┐ ┌───────▼─────┐ ┌─────▼──────┐
│ Interceptor │ │ History │ │ Repeater │ │ Addons │
└─────────────┘ └─────────────┘ └─────────────┘ └────────────┘
Features
- tmux and vim as user interface.
- Disk based storage.
- Custom http/1.1 parser to send malformed requests.
- http/1.1, http/2 and websocket support.
Prerequisites
- getfattr (Linux) or xattr (built-in on macOS), required for request metadata in Vim
- tmux
- vim (>= 8.2.4684) with the following features
- channel
- popupwin
- terminal
- timers
- ffuf (optional, used by the Addons window)
- sqlmap (optional, used by the Addons window)
- column with
-osupport (optional for indenting history files; macOS needs Homebrewutil-linux)
If getfattr/xattr is missing, make warns and continues; request metadata
will not be displayed in Vim.
Packages
Linux (Debian/Ubuntu):
attr tmux vim ffuf sqlmap bsdextrautils
macOS (Homebrew):
brew install tmux vim ffuf sqlmap
Installation
Requirements
- cargo msrv 1.100
- make
- openssl
CA certificate
make ca
Make
make
make install
make install builds the release binary. Copy target/release/zxc into a
directory in $PATH, for example $HOME/.local/bin. If CARGO_TARGET_DIR is
set, copy $CARGO_TARGET_DIR/release/zxc instead. Install vim
plugin.
Manual Installation
- Copy config files
mkdir -p "$HOME/.config/zxc"
cp ./config/alias ./config/config.toml ./config/tmux.conf "$HOME/.config/zxc/"
- Generate private key
(umask 077 && openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 \
-out "$HOME/.config/zxc/private.key")
chmod 600 "$HOME/.config/zxc/private.key"
- Generate CA certificate using ./mkscripts/CA.cnf as CA config.
openssl req -x509 -new -nodes -key "$HOME/.config/zxc/private.key" \
-sha256 -days 1024 -out "$HOME/.config/zxc/zxca.crt" \
-extensions v3_req -config ./mkscripts/CA.cnf
chmod 644 "$HOME/.config/zxc/zxca.crt"
- Copy vim config
mkdir -p "$HOME/.vim/plugin"
cp ./config/example/zxc.vim "$HOME/.vim/plugin/zxc.vim"
- Copy filetype plugins (optional)
mkdir -p "$HOME/.vim/ftplugin"
cp -R ./config/example/ftplugin/. "$HOME/.vim/ftplugin/"
- Build zxc or download from release.
cargo build --release
Then copy ./target/release/zxc into a directory in $PATH.
vim plugin
Install zxc.vim plugin.
mkdir -p $HOME/.vim/pack/git-plugins/start/
git clone --depth 1 https://github.com/hail-hydrant/zxc.vim $HOME/.vim/pack/git-plugins/start/zxc.vim
Add CA
Add CA certificate from $HOME/.config/zxc/zxca.crt to your trusted CA
or browser.
Usage
zxc
Options
-n, --new-name <NEW_NAME> Session name to create
-a, --attach <ATTACH_NAME> Session name to attach to
-l, --listen <LISTEN> Interface to bind the proxy listener to [default: 127.0.0.1]
-p, --port <PORT> Proxy port to use [default: 8080]
-i, --include <INCLUDED_DOMAINS> List of domains to intercept
-e, --exclude <EXCLUDED_DOMAINS> List of domains to not intercept
--no-ws Do not intercept WebSocket connections
-d, --debug Debug mode
-h, --help Print help
-i and -e are mutually exclusive. The values should be in format
domain:port.
For example, to intercept all domains except https://example.com,
zxc -e example.com:443
The flags also support wildcard. For example, to intercept all sub domains of http://*.example.com
zxc -i *.example.com:80
The domains can be comma separated list of values.
zxc -i example.com:80,example.com:443
Windows
Interceptor
Displays intercepted requests and responses. Each request or response is added as buffer.
| Command | Description |
|---|---|
| InterToggle | Toggle Interception |
| InterForward | Forward current request/response |
| InterForwardAll | Forward all requests and responses in queue |
| InterForwardWithRes | Forward Request + Intercept Response |
| Showq | Show interception queue with their respective scheme and host |
| DropMsg | Drop current request/response |
History
Displays the following history files,
Performs history recording. Closing it halts recording. In case of closing the
window accidentally reopen it by calling vhistory to resume recording. If zxc
exits without the history window, a state file .history.state is created to
resume logging the next time zxc is attached to this session.
Note
Window is non modifiable and read only.
Repeater
Repeater window is used to repeat requests. The original request is copied to a
folder named r-<n> for http and websocket/r-ws-<n>/scratch.wreq for
websocket within the specific history folder, where <n> is the next repeater index.
| Command | Description | Availability |
|---|---|---|
| RepeaterSend | Send Request | .req and scratch.wreq |
| WsEstablish | Establish Websocket Connection | .req in ws repeater |
| WsBinary | Toggle binary websocket frame | .wreq and scratch.wreq |
To repeat a websocket request,
- In a websocket request (
wreq) file, callWsSendToRepeater. - In repeater window, http request corresponding to the websocket handshake is displayed in top-left.
- Call
WsEstablishin the request(req) window to establish a websocket connection. - Write the data in
scratch.wreqin bottom left and callRepeaterSendto send. CallWsBinaryto toggle between text and binary frames.
Addons
Addons window is used to run additional tools. The original request is copied
to addons/$addon_prefix-$id.req within the specific history folder, with the
prefix specific to the addon being called. . The request is displayed in the
top window and a terminal with addon cmd and arguments is displayed in bottom
split. Currently, ffuf and sqlmap are available.
Add New Addons
Refer to for example addon integration.
1. Defining addon
Define a new table in $HOME/.config/zxc/config.toml file.
prefix and request_flag are required; the other keys are optional.
| Key | Description |
|---|---|
| prefix | Prefix for resulting file used by the addon |
| request_flag | Flag used by the addon to identify the request file For example, -r for sqlmap and -request for ffuf |
| http_flag | Flag used by the addon to identify http scheme For example, -request-proto http for ffuf |
| https_flag | Flag used by the addon to identify https scheme For example, --force-ssl for sqlmap |
| http2_flag | Flag used by the addon to enable HTTP/2 For example, --http2 for sqlmap and -http2 for ffuf |
| add_flag | Additional flags that will be added to the end of the command |
Note
If the binary by default uses https, skip http_flag and vice versa.
http2_flag is appended only when the forwarded request is HTTP/2. If the
field is missing, the tool runs without an HTTP/2 flag. The copied request
keeps its original request line; edit the copy manually if the tool requires
HTTP/1.1. For HTTP/2 copies, a canonical Host header is inserted when it
is missing.
2. Calling Addon
The addon can be called from request .req file by calling RequestToAddon
function
call RequestToAddon("addon_name")
Calling from history .his file, by calling HistoryToAddon function
call HistoryToAddon("addon_name")
3. Define Addon Command
Add command or keymap via the ftplugin for req and his.
Example Command
for .req
command RequestToAddon_Name :call RequestToAddon("addon_name")
For .his
command HistoryToAddon_Name :call HistoryToAddon("addon_name")
Example Keymap
for .req
nnoremap <silent> <Leader>q :call RequestToAddon("addon_name")
For .his
nnoremap <silent> <Leader>q :call HistoryToAddon("addon_name")
File Types
The following file types are available in zxc.
his [http history]
| Command | Description |
|---|---|
| HistoryView | View highlighted history Default keybinding is <CR> |
| HistoryIndent | Indent history |
| HistoryToRepeater | Send to Repeater |
| HistoryToFuzz | Send to Ffuf addon |
| HistoryToSql | Send to Sqlmap addon |
| ApplyFilters | Apply filters |
| ShowFilters | Show filters in popup Use q to close popup |
| ClearFilters | Clear all filters |
| AddToHostScope | Add host in current line to view scope |
| ClearHostScope | Clear host view scope list |
| EditHostScope | Edit host scope in popup Supports Vim Regex To match as regex add prefix /r |
| ShowHostScope | Show host scope in popup Use q to close popup |
| AddScode | Add Command argument to status code scope Use 'x' in place of wildcard Example, 1xx : shows status code in range 100 - 199 21x : shows status code in range 210 - 219 |
| ClearScode | Clear status code scope |
| EditScode | Edit status code scope in popup |
| ShowScode | Show status code scope in popup Use q to close popup |
| AddToUriScope | Add uri in current line to view scope |
| ClearUriScope | Clear uri view scope list |
| EditUriScope | Edit uri scope in a popup Supports Vim Regex To match as regex add prefix /r |
| ShowUriScope | Show uri scope list in a popup |
| EditConfig | Edit local config in popup If the config is modified then reloaded automatically |
| ReloadConfig | Manually Reload config |
| ConcealUri | Conceal URI column |
Note
Vim fold is used to apply filters. Use
zRto open all folds.The
HistoryIndentcommand uses thecolumnshell command and can be resource intensive on large files. Use sparingly.HostScope and UriScope support vim regex. Prefix the entry with
/rto match as regex. For example to match all subdomains of google.com,/r .*.google.com
Conceal
For his filetype, the URI can be concealed. Set g:conceal variable in
.his ftplugin to the number of characters to be concealed. Set the
conceallevel in your vimrc to enable this feature.
req [http request]
| Command | Description |
|---|---|
| EditBufVar | Edit buffer variables in a popup available in interceptor and repeater windows only |
| RequestToFuzz | Send to Ffuf addon |
| RequestToRepeater | Send to Repeater |
| RequestToSql | Send to Sqlmap addon |
Variables
req filetype has specific set of variables which can be modified to customize
request handling. EditBufVar command can be used to edit buffer variables in
a popup. Save and quit popup to reflect changes. The following variables are
available in interceptor and repeater windows.
| Variable | Type | Description |
|---|---|---|
| b:host | string | Host to send request to, including optional port |
| b:scheme | string | http/https |
| b:sni | string | SNI to use in TLS handshake (only when b:scheme is https) |
| b:update | bool | Whether request should be updated according to RFC. |
| b:authority | string | HTTP/2 :authority pseudo-header (HTTP/2 only) |
| b:h2_scheme | string | HTTP/2 :scheme pseudo-header (HTTP/2 only) |
| b:is_h2 | number | 1 for HTTP/2 requests, 0 otherwise (set by the backend) |
For HTTP/2, EditBufVar shows b:authority, b:h2_scheme; b:host,
b:scheme, and b:sni are not shown (sending request to new host not
supported yet).
Extended Attributes
The following extended attributes are set to the .req filetype for users to
identify the destination for a request outside of zxc.
| Value | Description |
|---|---|
| user.host | Host to which request was sent, including optional port |
| user.http | Set to "1" when scheme is http. for https, ignored. |
| user.sni | Set when scheme is https and host != sni |
| user.is_h2 | Set to "1" for HTTP/2 requests |
| user.authority | HTTP/2 :authority pseudo-header |
| user.h2_scheme | HTTP/2 :scheme pseudo-header |
res [http response]
| Command | Description |
|---|---|
| OpenReq | Open the corresponding request in a vertical split |
Only variable b:update available.
whis [All websocket history]
| Command | Description |
|---|---|
| ViewWsHistory | View highlighted ws flow. Default binding is <CR>. |
wsess [Single websocket session history]
| Command | Description |
|---|---|
| ViewWsSessionHistory | View highlighted ws req/res in split. Default binding is <CR>. |
wreq [websocket request]
Binary Frames are indicated by 'b' in right corner of status line. The b:is_bin
buffer variable marks the frame as binary (true for binary, false for text).
It is set when opening binary frames and toggled with WsBinary.
| Command | Description |
|---|---|
| WsSendToRepeater | Send ws request to Repeater |
| WsBinary | Toggle binary frame |
| Variables | Description |
|---|---|
| b:is_bin | Marks frame as binary (true for binary, false for text).Set when opening binary frames; toggled with WsBinary. |
popup [popup window]
The popup window can be customised by setting g:popup_options with vim's
popup_create-arguments option in users zxc.vim file.
Additional Filetypes
| FileType | Description |
|---|---|
| wres | websocket response |
| popup | popup window |
Search
The following commands search and fill their respective lists.
| Quickfix-list | Location-list | Filetypes searched |
|---|---|---|
| Greq | LGreq | .req |
| Gres | LGres | .res |
| Greb | LGreb | both .req and .res |
Encoding and Decoding
The following commands are available in VISUAL mode for encoding and decoding
in interceptor and repeater windows.
| Command | Description |
|---|---|
| EBase64 | Base64 encode |
| DBase64 | Base64 decode |
| EUrl | URL encode |
| DUrl | URL decode |
| EUrlAll | URL encode all characters |
| DUrlAll | URL decode all characters |
Note
register x is used to store the selected text.
Configuration
tmux config
is used to set up session aliases. In addition it
sources user's tmux.conf file from
- $HOME/.tmux.conf
- $XDG_CONFIG_HOME/tmux/tmux.conf
- $HOME/.config/tmux/tmux.conf
If the tmux.conf is in custom location add the location to zxc's tmux.conf file
in $HOME/.config/zxc/tmux.conf
source-file /path/to/tmux.conf
zxc config
There are two types of config files, Global and per session local config. Local config is given preference over global config.
Global
Global Config file is located in $HOME/.config/zxc/config.toml. Default
| Keys | Description | Possible Values |
|---|---|---|
| excluded_domains | List of domains to be relayed | string list |
| excluded_content_types | List of content types to be relayed | list of: app, audio, font, img, msg, model, multipart, txt, video |
| excluded_extensions | List of extensions to be relayed | string list |
| with_ws | Whether to proxy websocket requests | bool (default true in shipped config) |
| addons | Addon definitions | table |
Local
Per session config is created in $session/config.toml based on user flags.
Only if any flag is used, local config is created. Example .
| Keys | Description | Possible Values |
|---|---|---|
| listen | Interface to bind proxy listener to | ip address (default 127.0.0.1) |
| port | Proxy port to use | number (default 8080) |
| included_domains | List of domains to proxy | string list |
| excluded_domains | List of domains to relay | string list |
| no_ws | Whether to relay websocket requests | bool (default false) |
Note
Include and exclude lists are mutually exclusive. If both lists are present Include list is given preference. Supports wildcard.
Edit Local Config
EditConfig command in history window will open local config file in a popup
window. On quitting the window if the file is modified the configuration will be
reloaded automatically. If the file is edited outside of history window, call
ReloadConfig in history window.
Vim Config
Each window and filetype has its own set of commands. Filetypes can be
configured in their respective ftplugin. The commands are further explained in
:h zxc.txt.
The following global variables are available
| Variables | Description |
|---|---|
| g:popup_options | Options passed to vim's popup_create-arguments. |
| g:timeout | The time to wait for a response from zxc when blocking. Default 5000 ms |
Example ftplugin links
| Link | For |
|---|---|
| zxc | interceptor, repeater, Addons, Encoding, Decoding |
| his | his filetype. |
| req | req filetype. |
Highlight Groups
Each filetype has its own set of highlight groups. Use :h zxc-highlight-groups to list available highlight groups. A gist of available
highlight groups can be found here.
| FileType | Highlight Group Help |
|---|---|
| his | zxc-hl-his |
| req | zxc-hl-req |
| res | zxc-hl-res |
Logging
The log is written to $session/log.txt. The log can be viewed in tmux popup
using tmux command zxcl or bind-key e shortcut.
Note
By default, tmux command-alias of index 1000 is used to store the command. In
case of conflict change the index to some unassigned value in
$HOME/.config/zxc/tmux.conf.
Debugging
Run zxc with -d flag to enable debugging. The proxy debug info from binary is
written to $session/log/proxy.log. The channel log for each window is written
to $session/log/$window_chan.log. The windows have the following debug
commands.
| Command | Description |
|---|---|
| PrintDebug | Prints debug info |
| WriteDebug | Writes debug info to a file named $window_debug.log in $session/log directory |
Roadmap
- Configuration based host redirection.
- Follow redirects in repeater.
- Nvim support.
- Socks support.
- http/3 support.
Contributing
Feel free to report issues and PR's. Feature requests are most welcome.
Explore projetos relacionados
Carregando…