-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.network_fuzzing.sh
executable file
·53 lines (43 loc) · 2.35 KB
/
.network_fuzzing.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# Licensed to Systerel under one or more contributor license
# agreements. See the NOTICE file distributed with this work
# for additional information regarding copyright ownership.
# Systerel licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this
# file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
set -o errexit
set -o nounset
set -o pipefail
# Set Path to server binary
DIRECTORY_PATH=$1
[ -z ${DIRECTORY_PATH} ] && echo "First argument must be the path to the directory where the server should run in" && exit 1
[ ! -f ${DIRECTORY_PATH}"/toolkit_demo_server" ] && echo " ${DIRECTORY_PATH}/toolkit_demo_server file doesn't exist. Please give a path to a valid opc ua server binary" && exit 2
FUZZER_WD=/work/opcua_network_fuzzer-main
# Fuzz all possible requests
export TEST_SERVER_XML_CONFIG=../../tests/ClientServer/data/config/S2OPC_Server_Demo_Config_Fuzzer.xml TEST_SERVER_XML_ADDRESS_SPACE=./S2OPC_Demo_NodeSet.xml TEST_USERS_XML_CONFIG=./S2OPC_Users_Demo_Config.xml
request_list=(read_request browse_request create_subscription_request browse_next_request add_nodes_request)
for request in "${request_list[@]}"
do
echo FUZZING "$request"
# Launch the fuzzing process in opcua_fuzzer.py file. Timeout is set to 4 hours for every request
if python3 tests/ClientServer/scripts/with-opc-server.py --server-wd ${DIRECTORY_PATH} --server-cmd ./toolkit_demo_server --wait-timeout 14400 "python3" ${FUZZER_WD}/opcua_fuzzer.py --target_host_ip localhost --target_host_port 4841 --target_app_name s2opc --r "$request" ; then
exit_status=$?
echo fuzzing of "$request" ended with SUCCESS!
echo Exit status : $exit_status
else
crash_status=$?
echo "$request" ended with an ERROR!
echo Exit status : $crash_status
exit $crash_status
fi
done