HDTBReturnItem SoftwareSubModuleModify::processRequest(std::vector<std::string> args) { history.push(args); // Make sure commands are given, and if they are if there are enough if(args.size() == 1) { // Call to super class displayAvailableCommands(); return errorHandler.generateGenericError("No commands given"); } // Make sure command exists if(commands.find(args[1]) == commands.end()) { // Call to super class displayAvailableCommands(); return errorHandler.generateGenericError("Command not found"); } //Handle command switch(commands[args[1]]) { case HDTB_SOFTWARE_CMD_MODIFY_JAVA: return modifyJava(); break; case HDTB_SOFTWARE_CMD_MODIFY_IE: #ifdef _WIN32 if (args.size() != 3) { return errorHandler.generateGenericError("No version given <10/11>"); } else { return modifyIE(args[2]); } #else return errorHandler.generateGenericError("OS not supported"); #endif default: break; } return errorHandler.generateGenericError("Uncaught return"); }
HDTBReturnItem SoftwareSubModuleInstall::processRequest(std::vector<std::string> args) { history.push(args); // Make sure commands are given, and if they are if there are enough if(args.size() == 1) { // Call to super class displayAvailableCommands(); return errorHandler.generateGenericError("No commands given"); } // Make sure command exists if(commands.find(args[1]) == commands.end()) { // Call to super class displayAvailableCommands(); return errorHandler.generateGenericError("Command not found"); } //Handle command switch(commands[args[1]]) { case HDTB_SOFTWARE_CMD_INSTALL_JAVA: return installJava(); break; case HDTB_SOFTWARE_CMD_INSTALL_KACE: return installKACE(); break; case HDTB_SOFTWARE_CMD_INSTALL_AVIRA: return installAvira(); default: break; } return errorHandler.generateGenericError("Uncaught return"); }
HDTBReturnItem NetworkModule::processRequest(std::vector<std::string> args) { history.push(args); // Make sure commands are given if(args.size() == 1) { // Call to super class displayAvailableCommands(); return errorHandler.generateGenericError("No commands given"); } // Make sure command exists if(commands.find(args[1]) == commands.end()) { // Call to super class displayAvailableCommands(); return errorHandler.generateGenericError("Command not found"); } //Handle command switch(commands[args[1]]) { case HDTB_NETWORK_CMD_PING: if (args.size() != 4) return errorHandler.generateGenericError("Usage : ping <address> <count>"); // Make sure count is int if( !(atoi(args[3].c_str())) ) return errorHandler.generateGenericError("Usage : ping <address> <count> [Count must be an int]"); // Send data to ping return ping(args[2], args[3]); break; case HDTB_NETWORK_CMD_RESET: return reset(); break; case HDTB_NETOWRK_CMD_REACH: if (args.size() != 5) return errorHandler.generateGenericError("send <destination> <port> <message>"); if( !(atoi(args[3].c_str())) ) return errorHandler.generateGenericError("Invalid port, must be an integer"); return reach(args[2], args[3], args[4]); break; case HDTB_NETWORK_CMD_KNOCK_SEQUENCE: return knock(); break; case HDTB_NETWORK_CMD_COMMLINK: return comm(); break; default: break; } return errorHandler.generateGenericError("Uncaught return"); }
HDTBReturnItem NetworkClient::processRequest(std::vector<std::string> args) { /* std::cout << "ARGUMENTS IN" << std::endl; for(std::vector<std::string>::iterator it = args.begin(); it != args.end(); ++it) { std::cout << "ARG :" << *it << std::endl; } */ history.push(args); // Make sure command exists if(commands.find(args[0]) == commands.end()) { // Call to super class displayAvailableCommands(); for(std::vector<std::string>::iterator it = args.begin(); it != args.end(); ++it) { std::cout << "ARG :" << *it << std::endl; } return errorHandler.generateGenericError("Unknown command"); } //Handle command int c = 0; switch(commands[args[0]]) { case HDTB_CLIENT_LOAD: if (args.size() != 3) { std::cout << " CLIENT_LOAD " << std::endl; return HDTBReturnItem(HDTB_RETURN_BAD, "not enough args -setinfo <<"); } // Make sure port is int if( !( c = atoi(args[2].c_str())) ) return HDTBReturnItem(HDTB_RETURN_BAD, "invalid port"); return setConnectionInfo(args[1], c); break; case HDTB_CLIENT_SEND: { if (args.size() != 2) return HDTBReturnItem(HDTB_RETURN_BAD, "not enough args -fsend"); HDTBReturnItem t = send(args[2]); if(t.retCode == HDTB_RETURN_GOOD) { if(recieve_data()) { std::cout << "\t Recieved data back from " << connectionInfo.address << std::endl; t.message = statusInfo.data_received; t.comm = 'R'; } else { std::cout << "\t Didn't recieve any data back from " << connectionInfo.address << std::endl; t.comm = 'N'; } return t; } else return t; return send(args[2]); break; } case HDTB_CLIENT_COMM: return initiateComms(); break; case HDTB_CLIENT_BLIND_COMM: return initiateBlindComms(); break; case HDTB_NETWORK_CMD_KILL: return kill(); break; default: return errorHandler.generateGenericError("Default accessed in command switch"); break; } return errorHandler.generateGenericError("Uncaught return"); }