Skip to content

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

Added discovery command stubs

Andrei Vladescu6e96fcf019f2
diff --git a/src/Abstracts/ANetworkController.cpp b/src/Abstracts/ANetworkController.cpp
index 98952f6a..2155bade 100644
--- a/src/Abstracts/ANetworkController.cpp
+++ b/src/Abstracts/ANetworkController.cpp
@@ -60,6 +60,47 @@ void ANetworkController::handlePing(const TerminalCommand &cmd)
terminalView.print(icmpService.getReport());
}
+void ANetworkController::handleDiscovery(const TerminalCommand &cmd)
+{
+ bool wifiConnected = wifiService.isConnected();
+ bool ethConnected = ethernetService.isConnected();
+ phy_interface_t phy_interface = phy_interface_t::None;
+
+ if (!wifiConnected && !ethConnected) {
+ terminalView.println("Discovery: You must be connected to Wi-Fi or Ethernet. Use 'connect' first.");
+ return;
+ }
+
+ // Which interface to scan
+ auto args = argTransformer.splitArgs(cmd.getArgs());
+ if (cmd.getSubcommand().empty() || args.size() < 1) {
+ if (wifiConnected){
+ terminalView.println("Discovery: Using WiFi as default interface.");
+ phy_interface = phy_interface_t::WiFi;
+ }
+ else{
+ terminalView.println("Discovery: Using Ethernet as default interface.");
+ phy_interface = phy_interface_t::Eth;
+ }
+ }
+ else {
+ if (cmd.getSubcommand() == "eth"){
+ terminalView.println("Discovery: Using Ethernet as default interface.");
+ phy_interface = phy_interface_t::Eth;
+ }else if (cmd.getSubcommand() == "wifi"){
+ terminalView.println("Discovery: Using WiFi as default interface.");
+ phy_interface = phy_interface_t::WiFi;
+ }
+ else {
+ terminalView.println("Discovery: Invalid interface. Use 'wifi' or 'eth'.");
+ }
+ }
+
+ const std::string deviceIP = phy_interface == phy_interface_t::WiFi ? wifiService.getLocalIP() : ethernetService.getLocalIP();
+ icmpService.startDiscoveryTask(deviceIP);
+
+}
+
/*
Netcat
*/
diff --git a/src/Abstracts/ANetworkController.h b/src/Abstracts/ANetworkController.h
index 1725380c..59e8560a 100644
--- a/src/Abstracts/ANetworkController.h
+++ b/src/Abstracts/ANetworkController.h
@@ -41,6 +41,7 @@ protected:
void handleNmap(const TerminalCommand& cmd);
void handleSsh(const TerminalCommand& cmd);
void handlePing(const TerminalCommand& cmd);
+ void handleDiscovery(const TerminalCommand &cmd);
protected:
ITerminalView& terminalView;
diff --git a/src/Controllers/EthernetController.cpp b/src/Controllers/EthernetController.cpp
index c28aead5..9c85f3d5 100644
--- a/src/Controllers/EthernetController.cpp
+++ b/src/Controllers/EthernetController.cpp
@@ -10,6 +10,7 @@ void EthernetController::handleCommand(const TerminalCommand& cmd) {
else if (root == "connect") handleConnect();
else if (root == "nc") handleNetcat(cmd);
else if (root == "nmap") handleNmap(cmd);
+ else if (root == "discovery") handleDiscovery(cmd);
else if (root == "ping") handlePing(cmd);
else if (root == "ssh") handleSsh(cmd);
else if (root == "status") handleStatus();
diff --git a/src/Controllers/WifiController.cpp b/src/Controllers/WifiController.cpp
index 65d98e46..e6feddb3 100644
--- a/src/Controllers/WifiController.cpp
+++ b/src/Controllers/WifiController.cpp
@@ -20,6 +20,7 @@ void WifiController::handleCommand(const TerminalCommand &cmd)
else if (root == "ssh") handleSsh(cmd);
else if (root == "nc") handleNetcat(cmd);
else if (root == "nmap") handleNmap(cmd);
+ else if (root == "discovery") handleDiscovery(cmd);
else if (root == "reset") handleReset();
else if (root == "deauth") handleDeauth(cmd);
else handleHelp();
diff --git a/src/Services/ICMPService.cpp b/src/Services/ICMPService.cpp
index 14ff936f..be2773ac 100644
--- a/src/Services/ICMPService.cpp
+++ b/src/Services/ICMPService.cpp
@@ -72,6 +72,11 @@ static int median_ms(std::vector<uint32_t> &v)
return (int)((v[n / 2 - 1] + v[n / 2] + 1) / 2);
}
+void ICMPService::startDiscoveryTask(const std::string deviceIP){
+ // Assume network mask is 255.255.255.0 for now
+
+}
+
void ICMPService::startPingTask(const std::string &host, int count, int timeout_ms, int interval_ms)
{
// Cleanup first
diff --git a/src/Services/ICMPService.h b/src/Services/ICMPService.h
index 2a3c1c49..4e3ab569 100644
--- a/src/Services/ICMPService.h
+++ b/src/Services/ICMPService.h
@@ -1,12 +1,21 @@
#pragma once
#include <string>
+enum phy_interface_t {
+ None,
+ WiFi,
+ Eth
+};
+
class ICMPService {
public:
ICMPService();
~ICMPService();
+ // Normal ping
void startPingTask(const std::string& host, int count = 5, int timeout_ms = 1000, int interval_ms = 200);
+ // Discovery of devices
+ void startDiscoveryTask(const std::string deviceIP);
// Results
bool isReady() const { return ready; }