Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for additional protocol commands (for GS30x series) #35

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
8c152d1
Fix some syntax to make it work with Python3
rhulme Sep 29, 2020
24826d4
Listen on both broadcast and unicast addresses for replies from switch
rhulme Sep 30, 2020
d1c9e57
Command 0x7400 retrieves supported TLVs (bitfield not yet decoded)
rhulme Oct 30, 2020
1e54863
Make leading whitespace in nsdp.lua consistent (4 spaces per soft tab)
rhulme Oct 30, 2020
d37793b
Show command name (or number if not recognized) instead of FIXME
rhulme Oct 30, 2020
836d727
Fix typo
rhulme Oct 30, 2020
33b886b
Create nsdp header after assembling commands.
rhulme Oct 31, 2020
ebe29a4
Cache IP address directly in ip_from_mac.
rhulme Oct 31, 2020
cac4624
Add decoding of errors.
rhulme Oct 31, 2020
8b3fbc9
Add decoding of 'number of ports'
rhulme Oct 31, 2020
66cdd63
Add support for broadcast filtering (0x5400)
rhulme Oct 31, 2020
0226a69
Speed status (0x0c00) is now port status
rhulme Oct 31, 2020
294f875
Show values of 0x0002 and 0x000c in Wireshark
rhulme Oct 31, 2020
4dbc736
Add decoding of ingress, egress and broadcast rate limits
rhulme Oct 31, 2020
cce1d1b
Decode QoS mode
rhulme Oct 31, 2020
14aa1e1
Add decoding of QoS port-based priorities
rhulme Oct 31, 2020
3a9ddcd
Add 'port_admin' command (0x9400)
rhulme Nov 1, 2020
6f25ff8
Add 'loop detection' (0x9000)
rhulme Nov 1, 2020
d8e7f91
Decode port mirroring
rhulme Nov 1, 2020
c736388
Add decoding of vlan802_id (0x2800) and vlan_pvid (0x3000)
rhulme Nov 1, 2020
bb11e55
Add 'delete vlan' (0x2c00)
rhulme Nov 1, 2020
a389a06
Allow creation of a new VLAN without assigning any ports
rhulme Nov 1, 2020
79191bb
Rename parameters of vlan802_id (0x2800)
rhulme Nov 7, 2020
32f77db
Add support of new password mechanism
rhulme Dec 5, 2020
50a88af
Make python3 the default interpreter
rhulme Mar 14, 2021
5841d05
Remove trailing whitespace
rhulme Mar 14, 2021
dcc76ed
Decode cable testing
rhulme Mar 25, 2021
380baf2
Encapsulate errors in a separate class
rhulme Mar 25, 2021
4ff1d22
Allow ports to be passed as a list as well as a comma-separated string
rhulme Mar 25, 2021
14ca35c
Improve Wireshark decoding of vlan_pvid, delete_vlan and vlan802_id q…
rhulme Mar 25, 2021
63fdf4f
Add support for querying a switch's serial number
rhulme Mar 25, 2021
bdd8f55
Allow commands to be set multiple times in one transaction.
rhulme Mar 25, 2021
6ec672a
Support discover multiple devices
hamarituc Dec 5, 2021
53737b7
Fix setting a single multi-value option
rhulme Jun 28, 2022
d6f235a
Add missing Wireshark decoding of VLAN_ID
rhulme Jul 1, 2022
b59c169
Fix variable name for tagged ports (802.1q)
rhulme Jul 2, 2022
a61c342
Make sure that the password (hash) is transmitted before anything else.
rhulme Jul 3, 2022
b4fcd57
Report number of ports in decimal rather than hex
rhulme Jul 3, 2022
c43bb8c
Fix support for switches with more than 8 ports
rhulme Jul 3, 2022
5c0bb0e
Don't crash if a single value is received when a list was expected
rhulme Jul 3, 2022
3cbce0f
Fix uninitialised variable in 'discover'
rhulme Sep 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions psl-cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"Main Program executed by the user"

Expand All @@ -13,12 +13,15 @@
def discover(args, switch):
"Search for Switches"
print("Searching for ProSafe Plus Switches ...\n")
data = switch.discover()
if data != False:
found = False

for data in switch.discover():
found = True
for entry in data.keys():
print entry.get_name() + ': ' + data[entry]
print ""
else:
print(entry.get_name() + ': ' + data[entry])
print("")

if not found:
print("No result received...")
print("did you try to adjust your timeout?")

Expand All @@ -27,9 +30,15 @@ def discover(args, switch):
def exploit(args, switch):
"exploit in current (2012) fw, can set a new password"
switch.passwd_exploit(args.mac[0], args.new_password[0])

def set_switch(args, switch):
"Set values on switch"
results = switch.query(switch.CMD_NUMBER_OF_PORTS, args.mac[0])
if switch.CMD_NUMBER_OF_PORTS in results:
switch.CMD_PORT_MIRROR.set_total_ports(results[switch.CMD_NUMBER_OF_PORTS])
switch.CMD_VLAN_ID.set_total_ports(results[switch.CMD_NUMBER_OF_PORTS])
switch.CMD_VLAN802_ID.set_total_ports(results[switch.CMD_NUMBER_OF_PORTS])

cmds = {ProSafeLinux.CMD_PASSWORD: args.passwd[0]}
for scmd in switch.get_setable_cmds():
if vars(args)[scmd.get_name()] is not None:
Expand All @@ -40,20 +49,20 @@ def set_switch(args, switch):
if isinstance(scmd, psl_typ.PslTypBoolean):
cmds[scmd] = (vars(args)[scmd.get_name()][0] == "on")
else:
if len(vars(args)[scmd.get_name()])==1:
if len(vars(args)[scmd.get_name()])==1 and scmd.get_num_args()==1:
cmds[scmd] = vars(args)[scmd.get_name()][0]
else:
cmds[scmd] = vars(args)[scmd.get_name()]

valid, errors = switch.verify_data(cmds)
if not valid:
for error in errors:
print error
print(error)
else:
print("Changing Values..\n")
result = switch.transmit(cmds, args.mac[0])
if 'error' in result:
print "FAILED: Error with " + str(result['error'])
print("FAILED: Error with " + str(result['error']))


def query(args, switch, querycommand = None):
Expand Down Expand Up @@ -148,7 +157,7 @@ def main():
subparsers = parser.add_subparsers(help='operation', dest="operation")

subparsers.add_parser('discover', help='Find all switches in all subnets')

exploit_parser = subparsers.add_parser("exploit",
help="set a password without knowing the old one")
exploit_parser.add_argument("--mac", nargs=1,
Expand All @@ -165,7 +174,7 @@ def main():
for cmd in switch.get_query_cmds():
choices.append(cmd.get_name())
choices.append("all")

query_parser.add_argument("query", nargs="+", help="What to query for",
choices=choices)

Expand All @@ -187,12 +196,16 @@ def main():
dest=cmd.get_name(), action='store_true')

else:
set_parser.add_argument("--" + cmd.get_name(),
action = 'store'
if cmd.allow_multiple():
action = 'append'
set_parser.add_argument("--" + cmd.get_name(),
nargs=cmd.get_num_args(),
type=cmd.get_set_type(),
help=cmd.get_set_help(),
metavar=cmd.get_metavar(),
choices=cmd.get_choices())
choices=cmd.get_choices(),
action=action)

args = parser.parse_args()
interface = args.interface[0]
Expand Down
2 changes: 1 addition & 1 deletion psl-cmd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#

Expand Down
Loading