diff --git a/fuzztestsplainwebsocket/plainwebsocketpacket1.dat b/fuzztestsplainwebsocket/plainwebsocketpacket1.dat new file mode 100644 index 0000000..1b57b58 --- /dev/null +++ b/fuzztestsplainwebsocket/plainwebsocketpacket1.dat @@ -0,0 +1,9 @@ +GET /mqtt HTTP/1.1 +Host: localhost:8080 +Upgrade: websocket +Connection: Upgrade +Origin: https://localhost:8080 +Sec-WebSocket-Key: t0gTTkLcTIeCWbst7pmP3A== +Sec-Websocket-Version: 13 +Sec-Websocket-Protocol: mqtt + diff --git a/fuzztestsplainwebsocket/plainwebsocketpacket2.dat b/fuzztestsplainwebsocket/plainwebsocketpacket2.dat new file mode 100644 index 0000000..25dc0ee --- /dev/null +++ b/fuzztestsplainwebsocket/plainwebsocketpacket2.dat @@ -0,0 +1 @@ +JZq{Zu%ZMG)#5%?q,;?)JV!?9)8> \ No newline at end of file diff --git a/fuzztestsplainwebsocket/plainwebsocketpacket3.dat b/fuzztestsplainwebsocket/plainwebsocketpacket3.dat new file mode 100644 index 0000000..7345215 --- /dev/null +++ b/fuzztestsplainwebsocket/plainwebsocketpacket3.dat @@ -0,0 +1 @@ +jl_il µµ[^_ZS\YX]T[^_ZS\YX]T[^_ZS\YX]T[^_ZS\YX]T[^_ZS\YX]T[^_ZS\YX]T[^_ZS\YX]T[^_ZS\YX]T[^_ZS\YX]T[^_ZS\YX]T[^_ZS\YX]T[^_ZS\YX]T[^_ZS\YX]T[^_ZS\YX]T[^_ZS\YX]T[^_ZS\YX]T[^_ZS\YX]T[^_ZS\YX]T[^_ZS\YX]T[^_ZS\YX]T \ No newline at end of file diff --git a/fuzztestsplainwebsocket/plainwebsocketpacket4.dat b/fuzztestsplainwebsocket/plainwebsocketpacket4.dat new file mode 100644 index 0000000..663aa43 --- /dev/null +++ b/fuzztestsplainwebsocket/plainwebsocketpacket4.dat diff --git a/fuzztestsplainwebsocket/plainwebsocketpacket5.dat b/fuzztestsplainwebsocket/plainwebsocketpacket5.dat new file mode 100644 index 0000000..f3d0cdc --- /dev/null +++ b/fuzztestsplainwebsocket/plainwebsocketpacket5.dat @@ -0,0 +1 @@ +RTP\VRTP\VRTP\VRTP\VRTP\VRTP\VRTP\VRTP\VR \ No newline at end of file diff --git a/fuzztestsplainwebsocket/websocket5packets.dat b/fuzztestsplainwebsocket/websocket5packets.dat new file mode 100644 index 0000000..6296fab --- /dev/null +++ b/fuzztestsplainwebsocket/websocket5packets.dat diff --git a/mainapp.cpp b/mainapp.cpp index 969b292..eb5d214 100644 --- a/mainapp.cpp +++ b/mainapp.cpp @@ -187,6 +187,9 @@ void MainApp::doHelp(const char *arg) puts(" -t, --test-config Test configuration file."); #ifndef NDEBUG puts(" -z, --fuzz-file For fuzzing, provides the bytes that would be sent by a client."); + puts(" -W, --fuzz-websockets Mark the client as websockets for fuzzing. The handshaking process makes"); + puts(" it a less useful though, because the fuzzer is not able to handle"); + puts(" replies from the server, which would change the internal state."); #endif puts(" -V, --version Show version"); puts(" -l, --license Show license"); @@ -264,6 +267,11 @@ void MainApp::setFuzzFile(const std::string &fuzzFilePath) this->fuzzFilePath = fuzzFilePath; } +void MainApp::setFuzzWebsockets(bool val) +{ + this->fuzzWebsockets = val; +} + void MainApp::initMainApp(int argc, char *argv[]) { if (instance != nullptr) @@ -275,6 +283,7 @@ void MainApp::initMainApp(int argc, char *argv[]) {"config-file", required_argument, nullptr, 'c'}, {"test-config", no_argument, nullptr, 't'}, {"fuzz-file", required_argument, nullptr, 'z'}, + {"fuzz-websockets", no_argument, nullptr, 'W'}, {"version", no_argument, nullptr, 'V'}, {"license", no_argument, nullptr, 'l'}, {nullptr, 0, nullptr, 0} @@ -282,11 +291,12 @@ void MainApp::initMainApp(int argc, char *argv[]) std::string configFile; std::string fuzzFile; + bool fuzzWebsockets = false; int option_index = 0; int opt; bool testConfig = false; - while((opt = getopt_long(argc, argv, "hc:Vltz:", long_options, &option_index)) != -1) + while((opt = getopt_long(argc, argv, "hc:Vltz:W", long_options, &option_index)) != -1) { switch(opt) { @@ -302,6 +312,9 @@ void MainApp::initMainApp(int argc, char *argv[]) case 'z': fuzzFile = optarg; break; + case 'W': + fuzzWebsockets = true; + break; case 'h': MainApp::doHelp(argv[0]); exit(16); @@ -339,6 +352,7 @@ void MainApp::initMainApp(int argc, char *argv[]) instance = new MainApp(configFile); instance->setFuzzFile(fuzzFile); + instance->setFuzzWebsockets(fuzzWebsockets); } @@ -392,7 +406,7 @@ void MainApp::start() { std::vector packetQueueIn; - Client_p client(new Client(fd, threads[0], nullptr, false, settings, true)); + Client_p client(new Client(fd, threads[0], nullptr, fuzzWebsockets, settings, true)); client->readFdIntoBuffer(); client->bufferToMqttPackets(packetQueueIn, client); diff --git a/mainapp.h b/mainapp.h index 6008567..24586fb 100644 --- a/mainapp.h +++ b/mainapp.h @@ -40,6 +40,7 @@ class MainApp std::list> listeners; std::mutex quitMutex; std::string fuzzFilePath; + bool fuzzWebsockets = false; Logger *logger = Logger::getInstance(); @@ -51,6 +52,7 @@ class MainApp void wakeUpThread(); void queueKeepAliveCheckAtAllThreads(); void setFuzzFile(const std::string &fuzzFilePath); + void setFuzzWebsockets(bool val); MainApp(const std::string &configFilePath); public: