Can I get any help figuring out what's wrong with the code? it gives me this error when I run it:
Traceback (most recent call last):
File "ap_settings.py", line 19, in <module>
AP_NUMBER = SETTINGS[TEST_SETTINGS_INDEX][0]
IndexError: list index out of range
This is the file ap_settings.py:
# Define variables
# SETTINGS is [ (AP_NUMBER, SAVE_RESULTS, SKIP) ]
TEST_SETTINGS_INDEX = 3
SETTINGS = [
(0, 0, 0),
]
# Defining the fuzzing MAC address device
STA_MAC = "00:20:A6:61:2D:09"
# Defining the injection interface
IFACE = "ath0"
##### BELOW VARIABLES SHOULD NOT BE TWEAKED BY THE USER
AP_NUMBER = SETTINGS[TEST_SETTINGS_INDEX][0]
SAVE_RESULTS = SETTINGS[TEST_SETTINGS_INDEX][1]
SKIP = SETTINGS[TEST_SETTINGS_INDEX][2]
# Defining fuzzing specific variables
AP = [
('kikoo', '00:11:22:33:44:55', 11, 'WPA-PSK'),
][AP_NUMBER]
SSID = AP[0]
AP_MAC = AP[1]
CHANNEL = chr(AP[2])
AP_CONFIG = AP[3]
# Defining the number of retries when authenticating/associating to the AP
CRASH_RETRIES = 10
DELAY = 1
STATE_WAIT_TIME = 2
DELAY_REBOOT = 10
LOG_LEVEL = 3
CRASH_THRESHOLD = 3
TRUNCATE = True
# Defining the log file
FNAME = [None, 'audits/ap-%s-%s.session' % (AP_MAC, AP_CONFIG)][SAVE_RESULTS]
At the top of your file you have this:
TEST_SETTINGS_INDEX = 3
SETTINGS = [
(0, 0, 0),
]
Then a little further down you have this:
AP_NUMBER = SETTINGS[TEST_SETTINGS_INDEX][0]
SAVE_RESULTS = SETTINGS[TEST_SETTINGS_INDEX][1]
SKIP = SETTINGS[TEST_SETTINGS_INDEX][2]
You are trying to access index position 3
of SETTINGS
because that is what TEST_SETTINGS_INDEX
is set to, but SETTINGS
only has one item in it, so you should be looking at index 0
:
AP_NUMBER = SETTINGS[0][0]
SAVE_RESULTS = SETTINGS[0][1]
SKIP = SETTINGS[0][2]
SETTINGS list contains a tuple of (0,0,0) so basically your list contains only one element. ie len(SETTINGS)=1
so your code says
AP_NUMBER=SETTINGS[TEST_SETTINGS_INDEX][0]
where TEST_SETTINGS_INDEX=3, i:e
AP_NUMBER=SETTINGS[3][0]
which means you are accessing 3rd element of the list which doesn't exists, that's why you are getting the error 'index out of range'.
Also list contains n elements then to access nth element you need to use n-1. for example
x = [1,2,3,4] then x[0]=1, x[1]=2, x[2]=3, x[3]=4
So in your case code should be
AP_NUMBER = SETTINGS[0][TEST_SETTINGS_INDEX]
Also since len of tuple in the SETTINGS list is 3 i:e
len((0,0,0)) = 3
Therefore your value of TEST_SETTINGS_INDEX should range from 0 to 2.
AP_NUMBER = SETTINGS[0][0]
AP_NUMBER = SETTINGS[0][1]
AP_NUMBER = SETTINGS[0][2]
For more info refer list and tuples
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.