In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly shows you "how to install and use graftcp in linux", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn how to install and use graftcp in linux "this article.
Brief introduction
Graftcp can redirect TCP connections from any specified program (applications, scripts, shell, etc.) to SOCKS5 or HTTP agents.
Comparing tsocks, proxychains or proxychains-ng,graftcp does not use the LD_PRELOAD technique to hijack the shared library's connect (), getaddrinfo () and other functions to achieve the purpose of redirection, this method is only effective for programs compiled with dynamic links.
For programs compiled with static links, such as Go programs compiled with the default option, proxychains-ng is invalid. Graftcp uses ptrace (2) system calls to track or modify connect information for any given program, which is valid for any program. How it works will be explained later.
Project address: https://github.com/hmgle/graftcp
Installation
Graftcp runs within the Linux system. Graftcp-local is written in Go, and the Go environment is required.
$git clone https://github.com/hmgle/graftcp.git $cd graftcp $make
After the make is executed, you can run graftcp-local/graftcp-local and. / graftcp. You can also install them all into the system:
$sudo make install
Graftcp-local then runs automatically as the system starts.
Usage parameters
Graftcp-local:
$graftcp-local/graftcp-local-h Usage of graftcp-local/graftcp-local:-config string Path to the configuration file-http_proxy string http proxy address E.g.127.0.0.1 logfile string Write logs to file 8080-listen string Listen address (default ": 2233")-logfile string Write logs to file-loglevel value Log level (0-6) (default 1)-pipepath string Pipe path for graftcp to send address info (default "/ tmp/graftcplocal.fifo")-select_proxy_mode string Set the mode for select a proxy [auto | random | only _ http_proxy | only_socks5] (default "auto")-service string Control the system service: ["start", "stop", "restart", "install"uninstall"]-socks5 string SOCKS5 address (default "127.0.0.1 default 1080")-syslog Send logs to the local system logger (Eventlog on Windows Syslog on Unix)
Graftcp:
Graftcp- h Usage: graftcp [options] prog [prog-args] Options:-a-- local-addr= graftcp-local's IP address. Default: localhost-p-local-port= Which port is graftcp-local listening? Default: 2233-f-- local-fifo= Path of fifo to communicate with graftcp-local. Default: / tmp/graftcplocal.fifo-b-- blackip-file= The IP in black-ip-file will connect direct-w-- whiteip-file= Only redirect the connect that destination ip in the white-ip-file to SOCKS5-n-- not-ignore-local Connecting to local is not changed by default This option will redirect it to SOCKS5-h-help Display this help and exit
Use the example
Suppose you are running the SOCKS5 agent at the default address "localhost:1080". Start graftcp-local first:
$graftcp-local/graftcp-local
Install the Go package from golang.org through graftcp:
$. / graftcp go get-v golang.org/x/net/proxy
Open the Chromium / Chrome / Firefox browser through graftcp, and all requests for the web page will be redirected to the SOCKS5 proxy:
$. / graftcp chromium-browser
Start Bash / Zsh / Fish through graftcp, and any TCP connections generated by any new commands executed in this new shell will be redirected to the SOCKS5 agent:
%. / graftcp bash $wget https://www.google.com
working principle
To achieve the goal of redirecting an app-initiated TCP to another destination address and the app itself is unaware of it, you probably need these conditions:
Fork (2) A new process that starts the app through execve (2) and tracks using ptrace (2), captures and intercepts the connect (2) system call before each TCP connection is performed by the app, obtains the parameters of the target address, and passes it to graftcp-local through the pipeline.
Modify the target address parameter of this connect (2) system call to the address of graftcp-local, and then resume the execution of the interrupted system call. After returning successfully, the program thought it was connected to the original address, but in fact it was connected to the address of graftcp-local. This is called "moving flowers and trees".
According to the connection information and destination address information, graftcp-local establishes a connection with SOCKS5 proxy and redirects the requested data of app to SOCKS5 proxy.
There may be a question here: since you can modify the parameters of any system call, wouldn't it be easier to append the original destination address information to graftcp-local directly to buffer by changing the parameters of app's write (2) / send (2)? The answer is that it cannot be done. If you add information directly to the buffer of the tracked program running in the child process, it may cause a buffer overflow, cause the program to crash or overwrite other data.
In addition, execve (2) will separate all the shared memory, so the write buffer of the tracked app cannot carry more data by the way of shared memory, so here the original destination address information is transmitted to graftcp-local by pipeline.
The simple process is as follows:
+-+ | graftcp | dest host | (tracer) +-- PIPE- > | | | ^ | info | ptrace | | v | | + | -+ | | connect | | +-> | graftcp +-> | SOCKS5 +-> | dest | |-local | | or | | host | app | | req | | req | HTTP | req | (tracee) +-> | +-> | proxy +-> | | resp | | resp | | resp |
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.