desc
stringlengths 3
26.7k
| decl
stringlengths 11
7.89k
| bodies
stringlengths 8
553k
|
---|---|---|
'Get the Field containing the FCS of the frame (instead of it being appended to the frame as it would appear on the air.)'
| def get_FCS_in_header(self):
| values = self.__get_field_values(self.RTF_FCS_IN_HEADER)
if (not values):
return None
return values[0]
|
'Set the number of RTS retries a transmitted frame used.'
| def set_RTS_retries(self, retries):
| self.__set_field_values(self.RTF_RTS_RETRIES, [retries])
|
'Get the number of RTS retries a transmitted frame used.'
| def get_RTS_retries(self):
| values = self.__get_field_values(self.RTF_RTS_RETRIES)
if (not values):
return None
return values[0]
|
'Set the properties of transmitted frames.'
| def set_tx_flags(self, flags):
| self.__set_field_values(self.RTF_TX_FLAGS, [flags])
|
'Get the properties of transmitted frames.'
| def get_tx_flags(self):
| values = self.__get_field_values(self.RTF_TX_FLAGS)
if (not values):
return None
return values[0]
|
'Set extended channel information: flags, freq, channel and maxpower'
| def set_xchannel(self, flags, freq, channel, maxpower):
| self.__set_field_values(self.RTF_XCHANNEL, [flags, freq, channel, maxpower])
|
'Get extended channel information: flags, freq, channel and maxpower'
| def get_xchannel(self):
| values = self.__get_field_values(field=self.RTF_XCHANNEL)
return values
|
'Set the number of data retries a transmitted frame used.'
| def set_data_retries(self, retries):
| self.__set_field_values(self.RTF_DATA_RETRIES, [retries])
|
'Get the number of data retries a transmitted frame used.'
| def get_data_retries(self):
| values = self.__get_field_values(self.RTF_DATA_RETRIES)
if (not values):
return None
return values[0]
|
'Set the hardware queue to send the frame on.'
| def set_hardware_queue(self, queue):
| self.__set_field_values(self.RTF_HARDWARE_QUEUE, [queue])
|
'Update the RadioTap header length field with the real size'
| def __update_header_length(self):
| self.header.set_word(2, self.get_header_size(), '<')
|
'Return 802.11 Management frame \'Duration\' field'
| def get_duration(self):
| b = self.header.get_word(0, '<')
return b
|
'Set the 802.11 Management frame \'Duration\' field'
| def set_duration(self, value):
| nb = (value & 65535)
self.header.set_word(0, nb, '<')
|
'Return 802.11 Management frame \'Destination Address\' field as a 6 bytes array'
| def get_destination_address(self):
| return self.header.get_bytes()[2:8]
|
'Set 802.11 Management frame \'Destination Address\' field as a 6 bytes array'
| def set_destination_address(self, value):
| for i in range(0, 6):
self.header.set_byte((2 + i), value[i])
|
'Return 802.11 Management frame \'Source Address\' field as a 6 bytes array'
| def get_source_address(self):
| return self.header.get_bytes()[8:14]
|
'Set 802.11 Management frame \'Source Address\' field as a 6 bytes array'
| def set_source_address(self, value):
| for i in range(0, 6):
self.header.set_byte((8 + i), value[i])
|
'Return 802.11 Management frame \'BSSID\' field as a 6 bytes array'
| def get_bssid(self):
| return self.header.get_bytes()[14:20]
|
'Set 802.11 Management frame \'BSSID\' field as a 6 bytes array'
| def set_bssid(self, value):
| for i in range(0, 6):
self.header.set_byte((14 + i), value[i])
|
'Return 802.11 Management frame \'Sequence Control\' field'
| def get_sequence_control(self):
| b = self.header.get_word(20, '<')
return b
|
'Set the 802.11 Management frame \'Sequence Control\' field'
| def set_sequence_control(self, value):
| nb = (value & 65535)
self.header.set_word(20, nb, '<')
|
'Return 802.11 Management frame \'Fragment Number\' subfield'
| def get_fragment_number(self):
| b = self.get_sequence_control()
return (b & 15)
|
'Set the 802.11 Management frame \'Fragment Number\' subfield'
| def set_fragment_number(self, value):
| mask = ((~ 15) & 65535)
masked = (self.header.get_word(20, '<') & mask)
nb = (masked | (value & 15))
self.header.set_word(20, nb, '<')
|
'Return 802.11 Management frame \'Sequence Number\' subfield'
| def get_sequence_number(self):
| b = self.get_sequence_control()
return ((b >> 4) & 4095)
|
'Set the 802.11 Management frame \'Sequence Number\' subfield'
| def set_sequence_number(self, value):
| mask = ((~ 65520) & 65535)
masked = (self.header.get_word(20, '<') & mask)
nb = (masked | ((value & 4095) << 4))
self.header.set_word(20, nb, '<')
|
'Return 802.11 Management frame \'Frame Body\' field'
| def get_frame_body(self):
| return self.get_body_as_string()
|
'Set 802.11 Management frame \'Frame Body\' field'
| def set_frame_body(self, data):
| self.load_body(data)
|
'Return the 802.11 Management Beacon frame \'Timestamp\' field'
| def get_timestamp(self):
| b = self.header.get_long_long(0, '<')
return b
|
'Set the 802.11 Management Beacon frame \'Timestamp\' field'
| def set_timestamp(self, value):
| nb = (value & 18446744073709551615L)
self.header.set_long_long(0, nb, '<')
|
'Return the 802.11 Management Beacon frame \'Beacon Inteval\' fieldTo convert it to seconds => secs = Beacon_Interval*1024/1000000'
| def get_beacon_interval(self):
| b = self.header.get_word(8, '<')
return b
|
'Set the 802.11 Management Beacon frame \'Beacon Inteval\' field'
| def set_beacon_interval(self, value):
| nb = (value & 65535)
self.header.set_word(8, nb, '<')
|
'Return the 802.11 Management Beacon frame \'Capability information\' field.'
| def get_capabilities(self):
| b = self.header.get_word(10, '<')
return b
|
'Set the 802.11 Management Beacon frame \'Capability Information\' field'
| def set_capabilities(self, value):
| nb = (value & 65535)
self.header.set_word(10, nb, '<')
|
'Get the 802.11 Management SSID element. The SSID element indicates the identity of an ESS or IBSS.'
| def get_ssid(self):
| return self._get_element(DOT11_MANAGEMENT_ELEMENTS.SSID)
|
'Get the 802.11 Management Supported Rates element. Specifies up to eight rates, then an Extended Supported Rate element shall be generated to specify the remaining supported rates.If human_readable is True, the rates are returned in Mbit/sec'
| def get_supported_rates(self, human_readable=False):
| s = self._get_element(DOT11_MANAGEMENT_ELEMENTS.SUPPORTED_RATES)
if (s is None):
return None
rates = struct.unpack(('%dB' % len(s)), s)
if (not human_readable):
return rates
rates_Mbs = tuple(map((lambda x: ((x & 127) * 0.5)), rates))
return rates_Mbs
|
'Set the 802.11 Management Supported Rates element. Specifies a tuple or list with up to eight rates, then an Extended Supported Rate element shall be generated to specify the remaining supported rates.'
| def set_supported_rates(self, rates):
| qty_rates = len(rates)
if (qty_rates > 8):
raise Exception('requires up to eight rates')
rates_string = struct.pack(('B' * qty_rates), *rates)
self._set_element(DOT11_MANAGEMENT_ELEMENTS.SUPPORTED_RATES, rates_string)
|
'Get the 802.11 Management DS Parameter set element. Contains information to allow channel number identification for STAs using a DSSS PHY.'
| def get_ds_parameter_set(self):
| s = self._get_element(DOT11_MANAGEMENT_ELEMENTS.DS_PARAMETER_SET)
if (s is None):
return None
(ch,) = struct.unpack('B', s)
return ch
|
'Set the 802.11 Management DS Parameter set element. Contains information to allow channel number identification for STAs using a DSSS PHY.'
| def set_ds_parameter_set(self, channel):
| channel_string = struct.pack('B', channel)
self._set_element(DOT11_MANAGEMENT_ELEMENTS.DS_PARAMETER_SET, channel_string)
|
'Get the 802.11 Management Robust Security Network element.'
| def get_rsn(self):
| s = self._get_element(DOT11_MANAGEMENT_ELEMENTS.RSN)
if (s is None):
return None
return s
|
'Set the 802.11 Management Robust Security Network element.'
| def set_rsn(self, data):
| self._set_element(DOT11_MANAGEMENT_ELEMENTS.RSN, data)
|
'Get the 802.11 Management ERP (extended rate PHY) Information element.'
| def get_erp(self):
| s = self._get_element(DOT11_MANAGEMENT_ELEMENTS.ERP_INFO)
if (s is None):
return None
(erp,) = struct.unpack('B', s)
return erp
|
'Set the 802.11 Management ERP (extended rate PHY) Inforamation element.'
| def set_erp(self, erp):
| erp_string = struct.pack('B', erp)
self._set_element(DOT11_MANAGEMENT_ELEMENTS.ERP_INFO, erp_string)
|
'Get the 802.11 Management Country element.Returnes a tuple containing Country code, frist channel number, number of channels and maximum transmit power level'
| def get_country(self):
| s = self._get_element(DOT11_MANAGEMENT_ELEMENTS.COUNTRY)
if (s is None):
return None
(code, first, num, max) = struct.unpack('3sBBB', s)
code = code.strip(' ')
return (code, first, num, max)
|
'Set the 802.11 Management Country element.'
| def set_country(self, code, first_channel, number_of_channels, max_power):
| if (len(code) > 3):
raise Exception('Country code must be up to 3 bytes long')
code += (' ' * (3 - len(code)))
country_string = struct.pack('3sBBB', code, first_channel, number_of_channels, max_power)
self._set_element(DOT11_MANAGEMENT_ELEMENTS.COUNTRY, country_string)
|
'Get the 802.11 Management Vendor Specific elements as a list of tuples.'
| def get_vendor_specific(self):
| 'The Vendor Specific information element is used to carry information not defined in the standard within a single defined format'
vs = []
gen_get_element = self._get_elements_generator(DOT11_MANAGEMENT_ELEMENTS.VENDOR_SPECIFIC)
try:
while 1:
s = gen_get_element.next()
if (s is None):
raise Exception('gen_get_element salio con None!!!')
oui = s[:3]
data = s[3:]
vs.append((oui, data))
except StopIteration:
pass
return vs
|
'Set the 802.11 Management Vendor Specific element. The Vendor Specific information element is used to carry information not defined in the standard within a single defined format'
| def add_vendor_specific(self, oui, data):
| max_data_len = (255 - 3)
data_len = len(data)
if (data_len > max_data_len):
raise Exception(('data allow up to %d bytes long' % max_data))
if (len(oui) > 3):
raise Exception('oui is three bytes long')
self._set_element(DOT11_MANAGEMENT_ELEMENTS.VENDOR_SPECIFIC, (oui + data), replace=False)
|
'Get the 802.11 Management SSID element. The SSID element indicates the identity of an ESS or IBSS.'
| def get_ssid(self):
| return self._get_element(DOT11_MANAGEMENT_ELEMENTS.SSID)
|
'Get the 802.11 Management Supported Rates element. Specifies up to eight rates, then an Extended Supported Rate element shall be generated to specify the remaining supported rates.If human_readable is True, the rates are returned in Mbit/sec'
| def get_supported_rates(self, human_readable=False):
| s = self._get_element(DOT11_MANAGEMENT_ELEMENTS.SUPPORTED_RATES)
if (s is None):
return None
rates = struct.unpack(('%dB' % len(s)), s)
if (not human_readable):
return rates
rates_Mbs = tuple(map((lambda x: ((x & 127) * 0.5)), rates))
return rates_Mbs
|
'Set the 802.11 Management Supported Rates element. Specifies a tuple or list with up to eight rates, then an Extended Supported Rate element shall be generated to specify the remaining supported rates.'
| def set_supported_rates(self, rates):
| qty_rates = len(rates)
if (qty_rates > 8):
raise Exception('requires up to eight rates')
rates_string = struct.pack(('B' * qty_rates), *rates)
self._set_element(DOT11_MANAGEMENT_ELEMENTS.SUPPORTED_RATES, rates_string)
|
'Get the 802.11 Management Deauthentication or Disassociation Code.'
| def get_reason_code(self):
| return self.header.get_word(0, '<')
|
'Get the 802.11 Management Authentication Algorithm.'
| def get_authentication_algorithm(self):
| return self.header.get_word(0, '<')
|
'Set the 802.11 Management Authentication Algorithm.'
| def set_authentication_algorithm(self, algorithm):
| self.header.set_word(0, algorithm, '<')
|
'Get the 802.11 Management Authentication Sequence.'
| def get_authentication_sequence(self):
| return self.header.get_word(2, '<')
|
'Set the 802.11 Management Authentication Sequence.'
| def set_authentication_sequence(self, seq):
| self.header.set_word(2, seq, '<')
|
'Get the 802.11 Management Authentication Status.'
| def get_authentication_status(self):
| return self.header.get_word(4, '<')
|
'Set the 802.11 Management Authentication Status.'
| def set_authentication_status(self, status):
| self.header.set_word(4, status, '<')
|
'Get the 802.11 Management Vendor Specific elements as a list of tuples.'
| def get_vendor_specific(self):
| 'The Vendor Specific information element is used to carry information not defined in the standard within a single defined format'
vs = []
gen_get_element = self._get_elements_generator(DOT11_MANAGEMENT_ELEMENTS.VENDOR_SPECIFIC)
try:
while 1:
s = gen_get_element.next()
if (s is None):
raise Exception('gen_get_element salio con None!!!')
oui = s[:3]
data = s[3:]
vs.append((oui, data))
except StopIteration:
pass
return vs
|
'Set the 802.11 Management Vendor Specific element. The Vendor Specific information element is used to carry information not defined in the standard within a single defined format'
| def add_vendor_specific(self, oui, data):
| max_data_len = (255 - 3)
data_len = len(data)
if (data_len > max_data_len):
raise Exception(('data allow up to %d bytes long' % max_data))
if (len(oui) > 3):
raise Exception('oui is three bytes long')
self._set_element(DOT11_MANAGEMENT_ELEMENTS.VENDOR_SPECIFIC, (oui + data), replace=False)
|
'Return the 802.11 Management Association Request Frame \'Capability information\' field.'
| def get_capabilities(self):
| b = self.header.get_word(0, '<')
return b
|
'Set the 802.11 Management Association Request Frame \'Capability Information\' field'
| def set_capabilities(self, value):
| nb = (value & 65535)
self.header.set_word(0, nb, '<')
|
'Return the 802.11 Management Association Request Frame \'Listen Interval\' field.'
| def get_listen_interval(self):
| b = self.header.get_word(2, '<')
return b
|
'Set the 802.11 Management Association Request Frame \'Listen Interval\' field'
| def set_listen_interval(self, value):
| self.header.set_word(2, value, '<')
|
'Get the 802.11 Management SSID element. The SSID element indicates the identity of an ESS or IBSS.'
| def get_ssid(self):
| return self._get_element(DOT11_MANAGEMENT_ELEMENTS.SSID)
|
'Get the 802.11 Management Supported Rates element. Specifies up to eight rates, then an Extended Supported Rate element shall be generated to specify the remaining supported rates.If human_readable is True, the rates are returned in Mbit/sec'
| def get_supported_rates(self, human_readable=False):
| s = self._get_element(DOT11_MANAGEMENT_ELEMENTS.SUPPORTED_RATES)
if (s is None):
return None
rates = struct.unpack(('%dB' % len(s)), s)
if (not human_readable):
return rates
rates_Mbs = tuple(map((lambda x: ((x & 127) * 0.5)), rates))
return rates_Mbs
|
'Set the 802.11 Management Supported Rates element. Specifies a tuple or list with up to eight rates, then an Extended Supported Rate element shall be generated to specify the remaining supported rates.'
| def set_supported_rates(self, rates):
| qty_rates = len(rates)
if (qty_rates > 8):
raise Exception('requires up to eight rates')
rates_string = struct.pack(('B' * qty_rates), *rates)
self._set_element(DOT11_MANAGEMENT_ELEMENTS.SUPPORTED_RATES, rates_string)
|
'Get the 802.11 Management Robust Security Network element.'
| def get_rsn(self):
| s = self._get_element(DOT11_MANAGEMENT_ELEMENTS.RSN)
if (s is None):
return None
return s
|
'Set the 802.11 Management Robust Security Network element.'
| def set_rsn(self, data):
| self._set_element(DOT11_MANAGEMENT_ELEMENTS.RSN, data)
|
'Get the 802.11 Management Vendor Specific elements as a list of tuples.'
| def get_vendor_specific(self):
| 'The Vendor Specific information element is used to carry information not defined in the standard within a single defined format'
vs = []
gen_get_element = self._get_elements_generator(DOT11_MANAGEMENT_ELEMENTS.VENDOR_SPECIFIC)
try:
while 1:
s = gen_get_element.next()
if (s is None):
raise Exception('gen_get_element salio con None!!!')
oui = s[:3]
data = s[3:]
vs.append((oui, data))
except StopIteration:
pass
return vs
|
'Set the 802.11 Management Vendor Specific element. The Vendor Specific information element is used to carry information not defined in the standard within a single defined format'
| def add_vendor_specific(self, oui, data):
| max_data_len = (255 - 3)
data_len = len(data)
if (data_len > max_data_len):
raise Exception(('data allow up to %d bytes long' % max_data))
if (len(oui) > 3):
raise Exception('oui is three bytes long')
self._set_element(DOT11_MANAGEMENT_ELEMENTS.VENDOR_SPECIFIC, (oui + data), replace=False)
|
'Return the 802.11 Management Association Response Frame \'Capability information\' field.'
| def get_capabilities(self):
| b = self.header.get_word(0, '<')
return b
|
'Set the 802.11 Management Association Response Frame \'Capability Information\' field'
| def set_capabilities(self, value):
| nb = (value & 65535)
self.header.set_word(0, nb, '<')
|
'Return the 802.11 Management Association Response Frame \'Status Code\' field.'
| def get_status_code(self):
| b = self.header.get_word(2, '<')
return b
|
'Set the 802.11 Management Association Response Frame \'Status Code\' field'
| def set_status_code(self, value):
| self.header.set_word(2, value, '<')
|
'Return the 802.11 Management Association Response Frame \'Association Id\' field.'
| def get_association_id(self):
| b = self.header.get_word(4, '<')
return b
|
'Set the 802.11 Management Association Response Frame \'Association Id\' field'
| def set_association_id(self, value):
| self.header.set_word(4, value, '<')
|
'Get the 802.11 Management Supported Rates element. Specifies up to eight rates, then an Extended Supported Rate element shall be generated to specify the remaining supported rates.If human_readable is True, the rates are returned in Mbit/sec'
| def get_supported_rates(self, human_readable=False):
| s = self._get_element(DOT11_MANAGEMENT_ELEMENTS.SUPPORTED_RATES)
if (s is None):
return None
rates = struct.unpack(('%dB' % len(s)), s)
if (not human_readable):
return rates
rates_Mbs = tuple(map((lambda x: ((x & 127) * 0.5)), rates))
return rates_Mbs
|
'Set the 802.11 Management Supported Rates element. Specifies a tuple or list with up to eight rates, then an Extended Supported Rate element shall be generated to specify the remaining supported rates.'
| def set_supported_rates(self, rates):
| qty_rates = len(rates)
if (qty_rates > 8):
raise Exception('requires up to eight rates')
rates_string = struct.pack(('B' * qty_rates), *rates)
self._set_element(DOT11_MANAGEMENT_ELEMENTS.SUPPORTED_RATES, rates_string)
|
'Get the 802.11 Management Vendor Specific elements as a list of tuples.'
| def get_vendor_specific(self):
| 'The Vendor Specific information element is used to carry information not defined in the standard within a single defined format'
vs = []
gen_get_element = self._get_elements_generator(DOT11_MANAGEMENT_ELEMENTS.VENDOR_SPECIFIC)
try:
while 1:
s = gen_get_element.next()
if (s is None):
raise Exception('gen_get_element salio con None!!!')
oui = s[:3]
data = s[3:]
vs.append((oui, data))
except StopIteration:
pass
return vs
|
'Set the 802.11 Management Vendor Specific element. The Vendor Specific information element is used to carry information not defined in the standard within a single defined format'
| def add_vendor_specific(self, oui, data):
| max_data_len = (255 - 3)
data_len = len(data)
if (data_len > max_data_len):
raise Exception(('data allow up to %d bytes long' % max_data))
if (len(oui) > 3):
raise Exception('oui is three bytes long')
self._set_element(DOT11_MANAGEMENT_ELEMENTS.VENDOR_SPECIFIC, (oui + data), replace=False)
|
'Return the 802.11 Management Reassociation Request Frame \'Capability information\' field.'
| def get_capabilities(self):
| b = self.header.get_word(0, '<')
return b
|
'Set the 802.11 Management Reassociation Request Frame \'Capability Information\' field'
| def set_capabilities(self, value):
| nb = (value & 65535)
self.header.set_word(0, nb, '<')
|
'Return the 802.11 Management Reassociation Request Frame \'Listen Interval\' field.'
| def get_listen_interval(self):
| b = self.header.get_word(2, '<')
return b
|
'Set the 802.11 Management Reassociation Request Frame \'Listen Interval\' field'
| def set_listen_interval(self, value):
| self.header.set_word(2, value, '<')
|
'Return the 802.11 Management Reassociation Request Frame \'Current AP\' field.'
| def get_current_ap(self):
| return self.header.get_bytes()[4:10]
|
'Set the 802.11 Management Reassociation Request Frame \'Current AP\' field'
| def set_current_ap(self, value):
| for i in range(0, 6):
self.header.set_byte((4 + i), value[i])
|
'Get the 802.11 Management SSID element. The SSID element indicates the identity of an ESS or IBSS.'
| def get_ssid(self):
| return self._get_element(DOT11_MANAGEMENT_ELEMENTS.SSID)
|
'Get the 802.11 Management Supported Rates element. Specifies up to eight rates, then an Extended Supported Rate element shall be generated to specify the remaining supported rates.If human_readable is True, the rates are returned in Mbit/sec'
| def get_supported_rates(self, human_readable=False):
| s = self._get_element(DOT11_MANAGEMENT_ELEMENTS.SUPPORTED_RATES)
if (s is None):
return None
rates = struct.unpack(('%dB' % len(s)), s)
if (not human_readable):
return rates
rates_Mbs = tuple(map((lambda x: ((x & 127) * 0.5)), rates))
return rates_Mbs
|
'Set the 802.11 Management Supported Rates element. Specifies a tuple or list with up to eight rates, then an Extended Supported Rate element shall be generated to specify the remaining supported rates.'
| def set_supported_rates(self, rates):
| qty_rates = len(rates)
if (qty_rates > 8):
raise Exception('requires up to eight rates')
rates_string = struct.pack(('B' * qty_rates), *rates)
self._set_element(DOT11_MANAGEMENT_ELEMENTS.SUPPORTED_RATES, rates_string)
|
'Get the 802.11 Management Robust Security Network element.'
| def get_rsn(self):
| s = self._get_element(DOT11_MANAGEMENT_ELEMENTS.RSN)
if (s is None):
return None
return s
|
'Set the 802.11 Management Robust Security Network element.'
| def set_rsn(self, data):
| self._set_element(DOT11_MANAGEMENT_ELEMENTS.RSN, data)
|
'Get the 802.11 Management Vendor Specific elements as a list of tuples.'
| def get_vendor_specific(self):
| 'The Vendor Specific information element is used to carry information not defined in the standard within a single defined format'
vs = []
gen_get_element = self._get_elements_generator(DOT11_MANAGEMENT_ELEMENTS.VENDOR_SPECIFIC)
try:
while 1:
s = gen_get_element.next()
if (s is None):
raise Exception('gen_get_element salio con None!!!')
oui = s[:3]
data = s[3:]
vs.append((oui, data))
except StopIteration:
pass
return vs
|
'Set the 802.11 Management Vendor Specific element. The Vendor Specific information element is used to carry information not defined in the standard within a single defined format'
| def add_vendor_specific(self, oui, data):
| max_data_len = (255 - 3)
data_len = len(data)
if (data_len > max_data_len):
raise Exception(('data allow up to %d bytes long' % max_data))
if (len(oui) > 3):
raise Exception('oui is three bytes long')
self._set_element(DOT11_MANAGEMENT_ELEMENTS.VENDOR_SPECIFIC, (oui + data), replace=False)
|
'[MS-CIFS]: 2.2.4.62.1 SMB_COM_NT_TRANSACT request.
:param tid:
:param function: The transaction subcommand code
:param max_param_count: This field MUST be set as specified in the subsections of Transaction subcommands.
:param setup: Transaction context to the server, depends on transaction subcommand.
:param param: Subcommand parameter bytes if any, depends on transaction subcommand.
:param data: Subcommand data bytes if any, depends on transaction subcommand.
:return: Buffer relative to requested subcommand.'
| def send_nt_trans(self, tid, function, max_param_count, setup='', param='', data=''):
| smb_packet = NewSMBPacket()
smb_packet['Tid'] = tid
setup_bytes = (pack('<H', setup) if (setup != '') else '')
transCommand = SMBCommand(SMB.SMB_COM_NT_TRANSACT)
transCommand['Parameters'] = SMBNTTransaction_Parameters()
transCommand['Parameters']['MaxDataCount'] = self._dialects_parameters['MaxBufferSize']
transCommand['Parameters']['Setup'] = setup_bytes
transCommand['Parameters']['Function'] = function
transCommand['Parameters']['TotalParameterCount'] = len(param)
transCommand['Parameters']['TotalDataCount'] = len(data)
transCommand['Parameters']['MaxParameterCount'] = max_param_count
transCommand['Parameters']['MaxSetupCount'] = 0
transCommand['Data'] = SMBNTTransaction_Data()
offset = (((32 + 3) + 38) + len(setup_bytes))
transCommand['Data']['Pad1'] = ''
if ((offset % 4) != 0):
transCommand['Data']['Pad1'] = ('\x00' * (4 - (offset % 4)))
offset += (4 - (offset % 4))
if (len(param) > 0):
transCommand['Parameters']['ParameterOffset'] = offset
else:
transCommand['Parameters']['ParameterOffset'] = 0
offset += len(param)
transCommand['Data']['Pad2'] = ''
if ((offset % 4) != 0):
transCommand['Data']['Pad2'] = ('\x00' * (4 - (offset % 4)))
offset += (4 - (offset % 4))
if (len(data) > 0):
transCommand['Parameters']['DataOffset'] = offset
else:
transCommand['Parameters']['DataOffset'] = 0
transCommand['Parameters']['DataCount'] = len(data)
transCommand['Parameters']['ParameterCount'] = len(param)
transCommand['Data']['NT_Trans_Parameters'] = param
transCommand['Data']['NT_Trans_Data'] = data
smb_packet.addCommand(transCommand)
self.sendSMB(smb_packet)
|
'[MS-CIFS]: 2.2.7.6.1
NT_TRANSACT_QUERY_SECURITY_DESC 0x0006
:param tid: valid tree id.
:param fid: valid file handle.
:param additional_information: SecurityInfoFields. default = owner + group + dacl ie. 7
:return: security descriptor buffer'
| def query_sec_info(self, tid, fid, additional_information=7):
| self.send_nt_trans(tid, function=6, max_param_count=4, param=pack('<HHL', fid, 0, additional_information))
resp = self.recvSMB()
if resp.isValidAnswer(SMB.SMB_COM_NT_TRANSACT):
nt_trans_response = SMBCommand(resp['Data'][0])
nt_trans_parameters = SMBNTTransactionResponse_Parameters(nt_trans_response['Parameters'])
return nt_trans_response['Data'][(- nt_trans_parameters['TotalDataCount']):]
|
':param clientId: Whatever cliend Id that represents you
:param username: if None, anonymous connection will be attempted
:param password: if None, anonymous connection will be attempted
:param protocolName: specification states default should be \'MQTT\' but some brokers might expect \'MQIsdp\'
:param version: Allowed versions are 3 or 4 (some brokers might like 4)
:param flags:
:param keepAlive: default 60
:return: True or MQTTSessionError if something went wrong'
| def connect(self, clientId=' ', username=None, password=None, protocolName='MQIsdp', version=3, flags=CONNECT_CLEAN_SESSION, keepAlive=60):
| connectPacket = MQTT_Connect()
connectPacket['Version'] = version
connectPacket['Flags'] = flags
connectPacket['KeepAlive'] = keepAlive
connectPacket['ProtocolName'] = MQTT_String()
connectPacket['ProtocolName']['Name'] = protocolName
connectPacket['ClientID'] = MQTT_String()
connectPacket['ClientID']['Name'] = clientId
if (username is not None):
connectPacket['Flags'] |= (CONNECT_USERNAME | CONNECT_PASSWORD)
if (username is None):
user = ''
else:
user = username
if (password is None):
pwd = ''
else:
pwd = password
username = MQTT_String()
username['Name'] = user
password = MQTT_String()
password['Name'] = pwd
connectPacket['Payload'] = (str(username) + str(password))
data = self.sendReceive(connectPacket)[0]
response = MQTT_ConnectAck(str(data))
if (response['ReturnCode'] != 0):
raise MQTTSessionError(error=response['ReturnCode'], errorString=CONNECT_ACK_ERROR_MSGS[response['ReturnCode']])
return True
|
':param topic: Topic name you want to subscribe to
:param messageID: optional messageId
:param flags: Message flags
:param QoS: define the QoS requested
:return: True or MQTTSessionError if something went wrong'
| def subscribe(self, topic, messageID=1, flags=0, QoS=1):
| subscribePacket = MQTT_Subscribe()
subscribePacket['MessageID'] = messageID
subscribePacket['Topic'] = MQTT_String()
subscribePacket['Topic']['Name'] = topic
subscribePacket['Flags'] = flags
subscribePacket.setQoS(QoS)
try:
data = self.sendReceive(subscribePacket)[0]
except Exception as e:
raise MQTTSessionError(errorString=str(e))
subAck = MQTT_SubscribeACK(str(data))
if (subAck['ReturnCode'] > 2):
raise MQTTSessionError(errorString='Failure to subscribe')
return True
|
'Unsubscribes from a topic
:param topic:
:param messageID:
:param QoS: define the QoS requested
:return:'
| def unSubscribe(self, topic, messageID=1, QoS=0):
| packet = MQTT_UnSubscribe()
packet['MessageID'] = messageID
packet['Topics'] = MQTT_String()
packet['Topics']['Name'] = topic
packet.setQoS(QoS)
return self.sendReceive(packet)
|
'Get 16 bit message ID.'
| def get_transaction_id(self):
| return self.header.get_word(0)
|
'Set 16 bit message ID.'
| def set_transaction_id(self, value):
| self.header.set_word(0, value)
|
'Get 16 bit message ID.'
| def get_transaction_id_tcp(self):
| return self.header.get_word(2)
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.