Skip to content

A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol

Working netcat

Andrei Vladescu0d8e3137d174
diff --git a/src/Controllers/WifiController.cpp b/src/Controllers/WifiController.cpp
index 0846feb0..f21c89e8 100644
--- a/src/Controllers/WifiController.cpp
+++ b/src/Controllers/WifiController.cpp
@@ -489,7 +489,7 @@ void WifiController::handleNetcat(const TerminalCommand &cmd)
// Connect, start the netcat task
terminalView.println("Netcat: Connecting to " + host + " with port " + port_str + "...");
- netcatService.startTask(host, false, port);
+ netcatService.startTask(host, 0, port, true);
// Wait 5sec for connection success
unsigned long start = millis();
@@ -512,17 +512,24 @@ void WifiController::handleNetcat(const TerminalCommand &cmd)
while (true)
{
char terminalKey = terminalInput.readChar();
- if (terminalKey != KEY_NONE)
- netcatService.writeChar(terminalKey);
+ if (terminalKey == KEY_NONE){
+ continue;
+ }
- char deviceKey = deviceInput.readChar();
- if (deviceKey != KEY_NONE)
- break;
+ netcatService.writeChar(terminalKey);
+ terminalView.print(std::string(1, terminalKey)); // local echo
+ if (terminalKey == 0x1B || terminalKey == 0x03) break; // ESC or CTRL+C to exit
+ if (terminalKey == '\r' || terminalKey == '\n')
+ terminalView.println("");
std::string output = netcatService.readOutputNonBlocking();
if (!output.empty())
terminalView.print(output);
+ char deviceKey = deviceInput.readChar();
+ if (deviceKey != KEY_NONE)
+ break;
+
delay(10);
}
diff --git a/src/Services/NetcatService.cpp b/src/Services/NetcatService.cpp
index 8bee0b25..15dc01ab 100644
--- a/src/Services/NetcatService.cpp
+++ b/src/Services/NetcatService.cpp
@@ -80,7 +80,7 @@ void NetcatService::writeChar(char c)
if (buffered)
{
txBuf.push_back(c);
- if (c == '\n')
+ if (c == '\n' || c == '\r')
{
::send(sock, txBuf.data(), txBuf.size(), 0);
txBuf.clear();