This is open source for our project, RegexNet. This branch includes codes for experiments of end-to-end performance of RegexNet (Fig. 6, Fig. 9 and Fig. 12) as well as accuracy of the classifier (Fig. 13 and Fig. 14).
- source: Codes for the core functions of RegexNet
- scripts: Scripts to help to run RegexNet
- experiments: Scripts to run some experiments.
- Select servers to run the system
- For exmaple, you can use one CPU server and one GPU server.
- CPU server:
MongoDB
,redis
(optional),sandbox
,node.js
application,backend
,load_balancer
,data_collector
. - GPU server:
data_manager
,detector
.
- Modify IP addresses and absolute paths.
node.js
application: Change the address of theMongoDB
atsource/application/config/setting.json::databaseConnectionString
. Change the address of theredis
atsource/application/app.js
for stored attacks (optional).backend
: All codes are insource/http_proxy/http_proxy.cpp
. Change the address of thedata_collector
. Change the address of thesandbox
. Change the path to thenode.js
application, including thenode.js
path andapp.js
path.haproxy
: Change the address to thedetector
atsource/haproxy-with/include/customize.h
. Change the address of thebackend
atsource/haproxy-with/config/my_proxy.cfg
. A trick is that the name of the server is the same as the IP address of the server.data_collector
: All codes are insource/data_collector/data_collector.cpp
. Change the address to thedata_manager
.data_manager
: All codes are insource/data_manager/data_manager.py
. Change the path to the model file, the flag file and the folder for samples.detector
: All codes are insource/detector/detector.py
. Change the path to the model file and the flag file.attacker
: All codes are insource/attacker
. For the inteded attacker, change the value of 'X-Server' field in HTTP header to the IP address of the backend.
- Modify vulnerable modules in
node.js
application.- Uncommet codes for required vulnerable modules in
source/application/app.js
. If you want to run experiments for stored attacks, you will also need to uncomment codes for connectingredis
and setting the address to theredis
correctly.
- Uncommet codes for required vulnerable modules in
- Compile codes.
bash scripts/build.sh
- Run components
- Start
mongodb
- Start
redis
for stored attacks. Insert the malicious content to some vulnerable module into the redis server with keymalicious_id
. - Start sandbox:
bash scripts/run.sh application
- Start backend:
bash scripts/run.sh backend
- Start load balancer:
bash scripts/run.sh haproxy
- Start data collector:
bash scripts/run.sh collector
- Before start the data manager and the detector, clean the stale files:
rm -rf build/model.bin build/flag.txt
- Start data manager:
bash scripts/run.sh data_manager
- Start detector:
bash scripts/run.sh detector
- Start background throughput: For reflected dattacks, use
ab -c 32 -n 10000000 http://127.0.0.1:8080/
. Here the URL is the address to the load balancer. For stored attacks, useab -c 32 -n 10000000 -H"stored_id:benign_id" http://127.0.0.1:8080/
.
- Start
- Start attacking the system
- To warm up the system, you need to wait for about 30s after starting the background throughput. Then you can launch attacks. For example, for
fresh
module, you can usebash scripts/run.sh attacker fresh http://127.0.0.1:8080/ 60 30000
. Here60
is the frequency of the attack in the unit of requests/minute, and30000
is the length of the malicious content. The parameters might be a bit different for different attacks. You can refer to codes insource/attacker
.
- To warm up the system, you need to wait for about 30s after starting the background throughput. Then you can launch attacks. For example, for
- Observe the result.
- The printed information of
load_balancer
is the throughput in the unit of request/second. Note that there will be no output if there is no packets.
- The printed information of
- Select a GPU server to run experiments for the classifier.
- Compile codes.
bash scripts/build.sh all
You can comment unnecessary items for faster compilation. - Run the requried scripts. For example,
bash experiments/classifier/3-single-complex.sh
. You can modify psettings inexperiments/classifier/3-single-complex.sh
orexperiments/classifier/util.sh
.
Note that, to run 5-single-rescue
, you need to generate malicious content with ReScue
(source code) in advance. You can copy codes in source/dataset/rescue_helper
to ReScue/release
to do so.
Refer to docs/rampart
to set up Rampart (Code). To simulate distribtued ReDoS attacks, run Rampart in a docker container and send attacks from different docker containers.