A simple application to generate HTTP and WebSocket traffic. The code is designed and licensed solely for legitimate use, as a protective measure against MITM attacks. For instance, if you suspect network equipment compromise, this application can help obfuscate your traffic and mitigate eavesdropping risks.
This application is designed to generate HTTP and WebSocket traffic to a set of configurable URLs, using a variety of user agents. It can be used for various purposes, such as testing, load generation, or simulating user activity.
The application uses the Cobra library for the command-line interface, Viper for configuration management, and Gorilla WebSocket for WebSocket communication. The main traffic generation logic is handled in the sendRequests()
function, which alternates between sending HTTP requests and generating WebSocket traffic, with a configurable rate limit.
-
Configuration Management: The application uses Viper to load and parse the configuration file, which specifies the URLs, user agents, and rate limit.
-
Command-Line Interface: Cobra is used to implement the command-line interface, allowing users to easily run the application with custom configuration options.
-
Traffic Generation: The
sendRequests()
function is the core of the application, managing the main traffic generation loop. It alternates between sending HTTP requests using thesendHTTPRequests()
function and generating WebSocket traffic with thegenerateWebSocketTraffic()
function, with a delay for rate limiting. ThedownloadFileTorrent()
function downloads a file from a magnet URI using a torrent client, retrying the download up to a specified number of attempts, saving the file, and cleaning up the client, to hide parallel proxy connections.
Config
struct: Defines the structure of the configuration.rootCmd
: The main Cobra command that runs the application.initConfig()
andloadConfig()
: Functions responsible for loading and parsing the configuration file.sendRequests()
: The main traffic generation loop.sendHTTPRequests()
: Sends HTTP GET requests to the configured URLs using the configured user agents.generateWebSocketTraffic()
: Establishes WebSocket connections to the configured URLs, sends a random message, and immediately closes the connection.
main()
: The entry point of the application, which executes therootCmd
.downloadFileTorrent()
softly hides tunnel, vpn and proxy connections, via torrent ip connection
The application relies on the following external libraries:
- Cobra: For the command-line interface.
- Viper: For configuration management.
- Gorilla WebSocket: For WebSocket communication.
- Anacrolix Torrent: For torrents IP
These dependencies are managed using Go modules.
The application uses a YAML configuration file, which can be specified using the --config
flag. The default configuration file is config.yaml
.
The configuration file should have the following structure:
urls:
- "https://example.com"
- "https://another-example.com"
user_agents:
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8"
rate_limit: 1 # Requests per second
In Go, you typically don't need to manually install each dependency using go get
. Instead, just run the go build
command, which will automatically fetch and install any missing dependencies listed in your go.mod
file.
go build
You might need to use go get
for specific dependencies only if the automatic installation during go build
fails. This can be useful when you're modifying the source code or setting up the project for the first time and want to ensure all dependencies are in place.
To install the required libraries for the anon-traffic-gen
, you can use the following commands. Make sure you have Go installed on your system.
-
Gorilla WebSocket:
go get github.com/gorilla/websocket
-
Cobra:
go get github.com/spf13/cobra
-
Viper:
go get github.com/spf13/viper
-
YAML:
go get gopkg.in/yaml.v2
-
Anacrolix Torrent:
go get github.com/anacrolix/torrent
After installing the libraries, you might run into some challenges that could affect how the application performs. There could be configuration issues that lead to instability, so it's a good idea to double-check your settings.
In some cases, certain functionalities might be better implemented manually instead of relying entirely on the libraries, which could improve performance and give you more control.
While the code works, there may be opportunities to enhance its readability and documentation, making it easier for others to understand and contribute.
Additionally, the application might not always manage rate limiting perfectly, which could lead to unexpected behavior during traffic generation. The torrent functionality may also need some adjustments for optimal performance.
These aspects present a chance for improvement, and exploring the code could lead to valuable insights and enhancements!
To run the application, use the following command:
main --config=config.yaml
This will start the traffic generation and continue until you press to stop.
If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request on the anon-traffic-gen.
This project is licensed under the MIT License. Free use for peaceful purposes only.