diff --git a/dict.txt b/dict.txt deleted file mode 100644 index 5f74a0d..0000000 --- a/dict.txt +++ /dev/null @@ -1,30 +0,0 @@ -change Password: - #512 Length: 6 Value: admin - #513 Length: 6 Value: admin - #514 Length: 10 Value: - #515 Length: 10 Value: - - - -login: - #2305 Length: 0 Value: (null) - - #512 Length: 6 Value: admin - #514 Length: 10 Value: - - #10 Length: 0 Value: (null) - - #2 Length: 0 Value: (null) - - - -change Hostname: - #2305 Length: 0 Value: (null) - - #2 Length: 11 Value: - #4 Length: 4 Dec: 192.168.0.5 - #5 Length: 4 Dec: 255.255.255.0 - #6 Length: 4 Dec: 0.0.0.0 - #9 Length: 1 Hex: 00 - #512 Length: 6 Value: admin - #514 Length: 17 Value: \ No newline at end of file diff --git a/src/Packet.cpp b/src/Packet.cpp index 99eff5a..8f5a21d 100644 --- a/src/Packet.cpp +++ b/src/Packet.cpp @@ -20,7 +20,7 @@ Packet::Packet(OpCode c) { } void Packet::printHeader() { - std::cout << "Header:\n\tOpCode:\t\t" << opCodeToString() << "\n"; + std::cout << "Header:\n"; std::cout << "\tID:\t\t" << sequenceId << "\n"; std::cout << "\tVersion:\t" << version << "\n"; std::cout << "\tError:\t\t" << errorCode << "\n"; @@ -145,8 +145,10 @@ std::string Packet::opCodeToString() { return "GET"; case SET: return "SET"; - case READ: - return "READ"; + case RECEIVE: + return "RECEIVE"; + case READ5: + return "READ5"; default: return "NONE"; } diff --git a/src/Packet.h b/src/Packet.h index be55666..89d1047 100644 --- a/src/Packet.h +++ b/src/Packet.h @@ -18,7 +18,7 @@ class Packet { public: enum OpCode { - DISCOVERY, GET, SET, READ + DISCOVERY, GET, SET, READ4,RECEIVE, READ5 }; Packet(OpCode); void encode(bytes&); diff --git a/src/Program.cpp b/src/Program.cpp index e8c5075..6bb0563 100644 --- a/src/Program.cpp +++ b/src/Program.cpp @@ -66,29 +66,40 @@ int Program::sniff() { Socket s(io_service); s.setHostIp(h.getIp()); s.init(DST_PORT, SRC_PORT); - s.callback = [](Packet p) { - if (options.flags & FLAG_HEADER) { - if (options.flags & FLAG_HEX) { - std::cout <<"Received Header:\n\t"<< p.getHead() <<"\n"; - } else { - p.printHeader(); - printf("\n"); - } - } - if (options.flags & FLAG_HEX) { - std::cout <<"Received Payload:\n\t"<0) { + std::cout< +#include #include "Types.h" #include "Types/bytes.h" #include "Types/datasets.h" @@ -16,19 +17,37 @@ #define DEFAULT_USER "admin" #define DEFAULT_PASS "admin" -/* - * - static bitable lookup = { - {1, "type"}, - {2, "hostname"}, - {3, "mac"}, - {4, "ip_addr"}, - {5, "ip_mask"}, - {6, "gateway"}, - {7, "firmware_version"}, - {8, "hardware_version"}, - {9, "dhcp"}}; - */ +static std::map rcv_lookup= { + { 1, "type"},//string + { 2, "hostname"},//string + { 3, "mac"},//byte[6] + { 4, "ip_addr"},//byte[4] + { 5, "ip_mask"},//byte[4] + { 6, "gateway"},//byte[4] + { 7, "firmware_version"},//string + { 8, "hardware_version"},//string + { 9, "dhcp"}};//bool byte + +static std::map snd_lookup= { + {10,"???"},//after login + {2,"???"},//after login + {512,"login_user"},//string + {513,"new_user"},//string + {514,"login_password"},//string + {515,"new_passwoord"},//string + {2200,"vlan"}, + {2305,"???"},//sent before login and before change hostname + {4608,"port_trunk"},//byte[5] last byte bitmask?? + {8192,"mtu_vlan"},//byte[2] first byte bool, second byte port id + {8449,"port_vlan"},//??? + {8705,"802.1q vlan"},//??? + {8706,"802.1q vlan pvid"},//???? + {12288,"QoS Basic"},//bool = QoS Mod + {16640,"port_mirror"},//byte[10] second byte port id?? + {17152,"loop_prevention"},//bool byte + //{0000," "}, +}; + struct vlan { int vlan_id; diff --git a/src/smrtlink.cpp b/src/smrtlink.cpp index 2db75ea..a5ee5c6 100644 --- a/src/smrtlink.cpp +++ b/src/smrtlink.cpp @@ -117,7 +117,6 @@ int main(int argc, char *argv[]) { std::string cmd = std::string(argv[optind++]); switch (caseArg(cmd.c_str())) { - case caseArg("get"): case caseArg("set"): case caseArg("reboot"): case caseArg("reset"): @@ -128,6 +127,11 @@ int main(int argc, char *argv[]) { exit(EXIT_FAILURE); break; + case caseArg("get"): + if (p.getProperty()) + exit(EXIT_SUCCESS); + break; + case caseArg("list"): if (p.list()) exit(EXIT_SUCCESS);