-
Notifications
You must be signed in to change notification settings - Fork 0
/
aruba_wifi_user
90 lines (77 loc) · 2.66 KB
/
aruba_wifi_user
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env python3
import json
import argparse
import urllib3
import concurrent.futures
from constants import *
from utils import *
from aruba_query import *
requests.packages.urllib3.disable_warnings()
def main():
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# CLI parser for the command
parser = argparse.ArgumentParser(description="Aruba Wifi User Search.")
# Get input from CLI
parser.add_argument(
"-u",
"--user",
default="NONE",
help="Enter the username to search for",
)
parser.add_argument(
"-m",
"--mac",
default="NONE",
help="Enter the mac address to search for",
)
parser.add_argument(
"-r",
"--remove",
action="store_true",
default=False,
help="Remove the user from the controllers, must use mac address",
)
parser.add_argument(
"--dl_add",
action="store_true",
default=False,
help="Add user to the denylist, must use mac address",
)
parser.add_argument(
"--dl_query",
action="store_true",
default=False,
help="Query user to see if they are on the denylist, must use mac address",
)
parser.add_argument(
"--dl_remove",
action="store_true",
default=False,
help="Remove user from the denylist, must use mac address",
)
args = parser.parse_args()
query = ArubaQuery()
inventory = ArubaInventory()
arubapost = ArubaPost()
# determine dc/mc to use based on args
with concurrent.futures.ThreadPoolExecutor() as executor:
for wc in MOBILITY_CONDUCTORS:
executor.submit(query.get_aruba_api_token, wc, PASSWORD, inventory)
with concurrent.futures.ThreadPoolExecutor() as executor:
for wc in MOBILITY_CONTROLLERS:
executor.submit(query.get_aruba_api_token, wc, PASSWORD, inventory)
if args.dl_query:
with concurrent.futures.ThreadPoolExecutor() as executor:
for wc in MOBILITY_CONTROLLERS:
executor.submit(query.aruba_denylist_query, wc, args, inventory, query)
elif args.dl_add or args.dl_remove:
with concurrent.futures.ThreadPoolExecutor() as executor:
for wc in MOBILITY_CONTROLLERS:
executor.submit(arubapost.denylist_add_remove, wc, args, inventory, query)
else:
print("mac,user,ip,ssid,bssid,ap,band,role,controller")
with concurrent.futures.ThreadPoolExecutor() as executor:
for wc in MOBILITY_CONDUCTORS:
executor.submit(query.aruba_wifi_client, wc, args, inventory, query)
if __name__ == "__main__":
main()