Skip to content

Basic Web traffic generator that probes links on a provided URL.

License

Notifications You must be signed in to change notification settings

CiscoSE/web-traffic-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

web-traffic-generator

A basic Python script generates traffic (GET) against a given web site.


A basic Python script that takes command line entry to run against a web site. Taking all available links on the target site and randomly doing gets against each. This is to generate traffic against the target only. Results of connecting are logged as STDOUT only and not to file. Setting log levels is supported to limit output if required, default is INFO.

Usage

This example script is to be used a test site to generate web traffic against a specific web site to provide data in other tools for example creating flow traffic in Nexus Dashboard Insights.

Two methods are available to use the script:

  1. Locally from a laptop with python 3.10 installed and using virtual environments.
  2. Using the provided Dockerfile to create a local image and run as a container.

Installation

To begin clone the repository to you local working directory.

git clone https://github.com/CiscoSE/web-traffic-generator.git

Once cloned change to the new project directory cd web-traffic-generator choose one of the following to run.

Run Locally with Python Virtual Envirnonment

If running locally start by creating and activating a python virtual environment.

python3 -m venv venv
source venv/bin/activate

Next use pip to install the required python libraries.

pip install -f requirements.txt

Finally, run the python scipt using cli arguments to set the target URL and optional flags.

python3 main.py <URL>

Available Command Line Option Flags

Option Flag Default Description
--sleep 5 Set the time between request against found links
--log, -l INFO Sets the logging level for output

Example

The following are examples of executing the different options against a target URL.

python3 main.py https://cisco.com
python3 main.py -l DEBUG https://cisco.com
  • Running script against https://cisco.com with 10 seconds between requests (sleep timer)
python3 main.py --sleep 10 https://cisco.com
  • Running script against https://cisco.com with 10 seconds between requests (sleep timer) with logging set to DEBUG
python3 main.py --sleep 10 -l DEBUG https://cisco.com

Run using Docker

A Dockerfile is included to quickly build a docker contaitner and start generating GET request against a target URLs contained links. It is assumed that Docker is already installed please refer to offical Docker installation documentation for help on setting up Docker locally.

  1. To start clone the repository locally.
  2. Build a docker image using the Dockerfile
docker build -t <image name> .
  1. Create and run Docker container updating environment variables as required to set target URL. By default target URL is set to https://google.ca.
docker run -it --rm -e URL="https://cisco.com" web-traffic-generator

Available Environment Variable

Environment Variable Default
URL https://google.ca
SLEEP 5
LOG INFO

Example Docker Run Commands

docker run -it --rm -e URL="https://cisco.com" -e LOG="DEBUG" web-traffic-generator
  • Running script against https://cisco.com with 10 seconds between requests (sleep timer)
docker run -it --rm -e URL="https://cisco.com" -e SLEEP="10" web-traffic-generator
  • Running script against https://cisco.com with 10 seconds between requests (sleep timer) with logging set to DEBUG
docker run -it --rm -e URL="https://cisco.com" -e SLEEP="10" -e LOG="DEBUG" web-traffic-generator

About

Basic Web traffic generator that probes links on a provided URL.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published