desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'queries basic information about an opened file/directory :param HANDLE treeId: a valid handle for the share where the file is to be opened :param HANDLE fileId: a valid handle for the file/directory to be closed :return: a smb.SMBQueryFileBasicInfo structure. raises a SessionError exception if error.'
def queryInfo(self, treeId, fileId):
try: if (self.getDialect() == smb.SMB_DIALECT): res = self._SMBConnection.query_file_info(treeId, fileId) else: res = self._SMBConnection.queryInfo(treeId, fileId) return smb.SMBQueryFileStandardInfo(res) except (smb.SessionError, smb3.SessionError) as e: raise SessionError(e.get_error_code())
'creates a directory :param string shareName: a valid name for the share where the directory is to be created :param string pathName: the path name or the directory to create :return: None, raises a SessionError exception if error.'
def createDirectory(self, shareName, pathName):
try: return self._SMBConnection.mkdir(shareName, pathName) except (smb.SessionError, smb3.SessionError) as e: raise SessionError(e.get_error_code())
'deletes a directory :param string shareName: a valid name for the share where directory is to be deleted :param string pathName: the path name or the directory to delete :return: None, raises a SessionError exception if error.'
def deleteDirectory(self, shareName, pathName):
try: return self._SMBConnection.rmdir(shareName, pathName) except (smb.SessionError, smb3.SessionError) as e: raise SessionError(e.get_error_code())
'waits for a named pipe :param HANDLE treeId: a valid handle for the share where the pipe is :param string pipeName: the pipe name to check :param integer timeout: time to wait for an answer :return: None, raises a SessionError exception if error.'
def waitNamedPipe(self, treeId, pipeName, timeout=5):
try: return self._SMBConnection.waitNamedPipe(treeId, pipeName, timeout=timeout) except (smb.SessionError, smb3.SessionError) as e: raise SessionError(e.get_error_code())
'writes to a named pipe using a transaction command :param HANDLE treeId: a valid handle for the share where the pipe is :param HANDLE fileId: a valid handle for the pipe :param string data: buffer with the data to write :param boolean waitAnswer: whether or not to wait for an answer :return: None, raises a SessionError exception if error.'
def transactNamedPipe(self, treeId, fileId, data, waitAnswer=True):
try: return self._SMBConnection.TransactNamedPipe(treeId, fileId, data, waitAnswer=waitAnswer) except (smb.SessionError, smb3.SessionError) as e: raise SessionError(e.get_error_code())
'reads from a named pipe using a transaction command :return: data read, raises a SessionError exception if error.'
def transactNamedPipeRecv(self):
try: return self._SMBConnection.TransactNamedPipeRecv() except (smb.SessionError, smb3.SessionError) as e: raise SessionError(e.get_error_code())
'writes to a named pipe :param HANDLE treeId: a valid handle for the share where the pipe is :param HANDLE fileId: a valid handle for the pipe :param string data: buffer with the data to write :param boolean waitAnswer: whether or not to wait for an answer :return: None, raises a SessionError exception if error.'
def writeNamedPipe(self, treeId, fileId, data, waitAnswer=True):
try: if (self.getDialect() == smb.SMB_DIALECT): return self._SMBConnection.write_andx(treeId, fileId, data, wait_answer=waitAnswer, write_pipe_mode=True) else: return self.writeFile(treeId, fileId, data, 0) except (smb.SessionError, smb3.SessionError) as e: raise SessionError(e.get_error_code())
'read from a named pipe :param HANDLE treeId: a valid handle for the share where the pipe resides :param HANDLE fileId: a valid handle for the pipe :param integer bytesToRead: amount of data to read :return: None, raises a SessionError exception if error.'
def readNamedPipe(self, treeId, fileId, bytesToRead=None):
try: return self.readFile(treeId, fileId, bytesToRead=bytesToRead, singleCall=True) except (smb.SessionError, smb3.SessionError) as e: raise SessionError(e.get_error_code())
'downloads a file :param string shareName: name for the share where the file is to be retrieved :param string pathName: the path name to retrieve :param callback callback: :return: None, raises a SessionError exception if error.'
def getFile(self, shareName, pathName, callback, shareAccessMode=None):
try: if (shareAccessMode is None): return self._SMBConnection.retr_file(shareName, pathName, callback) else: return self._SMBConnection.retr_file(shareName, pathName, callback, shareAccessMode=shareAccessMode) except (smb.SessionError, smb3.SessionError) as e: raise SessionError(e.get_error_code())
'uploads a file :param string shareName: name for the share where the file is to be uploaded :param string pathName: the path name to upload :param callback callback: :return: None, raises a SessionError exception if error.'
def putFile(self, shareName, pathName, callback, shareAccessMode=None):
try: if (shareAccessMode is None): return self._SMBConnection.stor_file(shareName, pathName, callback) else: return self._SMBConnection.stor_file(shareName, pathName, callback, shareAccessMode) except (smb.SessionError, smb3.SessionError) as e: raise SessionError(e.get_error_code())
'renames a file/directory :param string shareName: name for the share where the files/directories are :param string oldPath: the old path name or the directory/file to rename :param string newPath: the new path name or the directory/file to rename :return: True, raises a SessionError exception if error.'
def rename(self, shareName, oldPath, newPath):
try: return self._SMBConnection.rename(shareName, oldPath, newPath) except (smb.SessionError, smb3.SessionError) as e: raise SessionError(e.get_error_code())
'reconnects the SMB object based on the original options and credentials used. Only exception is that manualNegotiate will not be honored. Not only the connection will be created but also a login attempt using the original credentials and method (Kerberos, PtH, etc) :return: True, raises a SessionError exception if error'
def reconnect(self):
(userName, password, domain, lmhash, nthash, aesKey, TGT, TGS) = self.getCredentials() self.negotiateSession(self._preferredDialect) if (self._doKerberos is True): self.kerberosLogin(userName, password, domain, lmhash, nthash, aesKey, self._kdcHost, TGT, TGS, self._useCache) else: self.login(userName, password, domain, lmhash, nthash, self._ntlmFallback) return True
'logs off and closes the underlying _NetBIOSSession() :return: None'
def close(self):
try: self.logoff() except: pass self._SMBConnection.close_session()
'Return \'WEP Data\' decrypted'
def decrypt_data(self, key_string):
if (len(self.body_string) < 8): return self.body_string key = (self.get_iv() + key_string) rc4 = RC4(key) out = rc4.decrypt(data) dwd = Dot11WEPData(out) if False: return dwd else: return self.body_string
'LDAPConnection class :param string url: :param string baseDN: :param string dstIp: :return: a LDAP instance, if not raises a LDAPSessionError exception'
def __init__(self, url, baseDN='', dstIp=None):
self._SSL = False self._dstPort = 0 self._dstHost = 0 self._socket = None self._baseDN = baseDN self._messageId = 1 self._dstIp = dstIp if url.startswith('ldap://'): self._dstPort = 389 self._SSL = False self._dstHost = url[7:] elif url.startswith('ldaps://'): self._dstPort = 636 self._SSL = True self._dstHost = url[8:] else: raise LDAPSessionError(errorString=("Unknown URL prefix: '%s'" % url)) if (self._dstIp is not None): targetHost = self._dstIp else: targetHost = self._dstHost LOG.debug(('Connecting to %s, port %d, SSL %s' % (targetHost, self._dstPort, self._SSL))) try: (af, socktype, proto, _, sa) = socket.getaddrinfo(targetHost, self._dstPort, 0, socket.SOCK_STREAM)[0] self._socket = socket.socket(af, socktype, proto) except socket.error as e: raise socket.error(('Connection error (%s:%d)' % (targetHost, 88)), e) if (self._SSL is False): self._socket.connect(sa) else: ctx = SSL.Context(SSL.TLSv1_METHOD) self._socket = SSL.Connection(ctx, self._socket) self._socket.connect(sa) self._socket.do_handshake()
'logins into the target system explicitly using Kerberos. Hashes are used if RC4_HMAC is supported. :param string user: username :param string password: password for the user :param string domain: domain where the account is valid for (required) :param string lmhash: LMHASH used to authenticate using hashes (password is not used) :param string nthash: NTHASH used to authenticate using hashes (password is not used) :param string aesKey: aes256-cts-hmac-sha1-96 or aes128-cts-hmac-sha1-96 used for Kerberos authentication :param string kdcHost: hostname or IP Address for the KDC. If None, the domain will be used (it needs to resolve tho) :param struct TGT: If there\'s a TGT available, send the structure here and it will be used :param struct TGS: same for TGS. See smb3.py for the format :param bool useCache: whether or not we should use the ccache for credentials lookup. If TGT or TGS are specified this is False :return: True, raises a LDAPSessionError if error.'
def kerberosLogin(self, user, password, domain='', lmhash='', nthash='', aesKey='', kdcHost=None, TGT=None, TGS=None, useCache=True):
if ((lmhash != '') or (nthash != '')): if (len(lmhash) % 2): lmhash = ('0' + lmhash) if (len(nthash) % 2): nthash = ('0' + nthash) try: lmhash = unhexlify(lmhash) nthash = unhexlify(nthash) except TypeError: pass from impacket.krb5.ccache import CCache from impacket.krb5.asn1 import AP_REQ, Authenticator, TGS_REP, seq_set from impacket.krb5.kerberosv5 import getKerberosTGT, getKerberosTGS from impacket.krb5 import constants from impacket.krb5.types import Principal, KerberosTime, Ticket import datetime if ((TGT is not None) or (TGS is not None)): useCache = False if useCache: try: ccache = CCache.loadFile(os.getenv('KRB5CCNAME')) except: pass else: if (domain == ''): domain = ccache.principal.realm['data'] LOG.debug(('Domain retrieved from CCache: %s' % domain)) LOG.debug(('Using Kerberos Cache: %s' % os.getenv('KRB5CCNAME'))) principal = ('ldap/%s@%s' % (self._dstHost.upper(), domain.upper())) creds = ccache.getCredential(principal) if (creds is None): principal = ('krbtgt/%s@%s' % (domain.upper(), domain.upper())) creds = ccache.getCredential(principal) if (creds is not None): TGT = creds.toTGT() LOG.debug('Using TGT from cache') else: LOG.debug('No valid credentials found in cache') else: TGS = creds.toTGS(principal) LOG.debug('Using TGS from cache') if ((user == '') and (creds is not None)): user = creds['client'].prettyPrint().split('@')[0] LOG.debug(('Username retrieved from CCache: %s' % user)) elif ((user == '') and (len(ccache.principal.components) > 0)): user = ccache.principal.components[0]['data'] LOG.debug(('Username retrieved from CCache: %s' % user)) userName = Principal(user, type=constants.PrincipalNameType.NT_PRINCIPAL.value) if (TGT is None): if (TGS is None): (tgt, cipher, oldSessionKey, sessionKey) = getKerberosTGT(userName, password, domain, lmhash, nthash, aesKey, kdcHost) else: tgt = TGT['KDC_REP'] cipher = TGT['cipher'] sessionKey = TGT['sessionKey'] if (TGS is None): serverName = Principal(('ldap/%s' % self._dstHost), type=constants.PrincipalNameType.NT_SRV_INST.value) (tgs, cipher, oldSessionKey, sessionKey) = getKerberosTGS(serverName, domain, kdcHost, tgt, cipher, sessionKey) else: tgs = TGS['KDC_REP'] cipher = TGS['cipher'] sessionKey = TGS['sessionKey'] blob = SPNEGO_NegTokenInit() blob['MechTypes'] = [TypesMech['MS KRB5 - Microsoft Kerberos 5']] tgs = decoder.decode(tgs, asn1Spec=TGS_REP())[0] ticket = Ticket() ticket.from_asn1(tgs['ticket']) apReq = AP_REQ() apReq['pvno'] = 5 apReq['msg-type'] = int(constants.ApplicationTagNumbers.AP_REQ.value) opts = [] apReq['ap-options'] = constants.encodeFlags(opts) seq_set(apReq, 'ticket', ticket.to_asn1) authenticator = Authenticator() authenticator['authenticator-vno'] = 5 authenticator['crealm'] = domain seq_set(authenticator, 'cname', userName.components_to_asn1) now = datetime.datetime.utcnow() authenticator['cusec'] = now.microsecond authenticator['ctime'] = KerberosTime.to_asn1(now) encodedAuthenticator = encoder.encode(authenticator) encryptedEncodedAuthenticator = cipher.encrypt(sessionKey, 11, encodedAuthenticator, None) apReq['authenticator'] = None apReq['authenticator']['etype'] = cipher.enctype apReq['authenticator']['cipher'] = encryptedEncodedAuthenticator blob['MechToken'] = encoder.encode(apReq) bindRequest = BindRequest() bindRequest['version'] = 3 bindRequest['name'] = user bindRequest['authentication']['sasl']['mechanism'] = 'GSS-SPNEGO' bindRequest['authentication']['sasl']['credentials'] = blob.getData() response = self.sendReceive(bindRequest)[0]['protocolOp'] if (response['bindResponse']['resultCode'] != ResultCode('success')): raise LDAPSessionError(errorString=('Error in bindRequest -> %s: %s' % (response['bindResponse']['resultCode'].prettyPrint(), response['bindResponse']['diagnosticMessage']))) return True
'logins into the target system :param string user: username :param string password: password for the user :param string domain: domain where the account is valid for :param string lmhash: LMHASH used to authenticate using hashes (password is not used) :param string nthash: NTHASH used to authenticate using hashes (password is not used) :param string authenticationChoice: type of authentication protocol to use (default NTLM) :return: True, raises a LDAPSessionError if error.'
def login(self, user='', password='', domain='', lmhash='', nthash='', authenticationChoice='sicilyNegotiate'):
bindRequest = BindRequest() bindRequest['version'] = 3 if (authenticationChoice == 'simple'): if ('.' in domain): bindRequest['name'] = ((user + '@') + domain) elif domain: bindRequest['name'] = ((domain + '\\') + user) else: bindRequest['name'] = user bindRequest['authentication']['simple'] = password response = self.sendReceive(bindRequest)[0]['protocolOp'] elif (authenticationChoice == 'sicilyPackageDiscovery'): bindRequest['name'] = user bindRequest['authentication']['sicilyPackageDiscovery'] = '' response = self.sendReceive(bindRequest)[0]['protocolOp'] elif (authenticationChoice == 'sicilyNegotiate'): if ((lmhash != '') or (nthash != '')): if (len(lmhash) % 2): lmhash = ('0' + lmhash) if (len(nthash) % 2): nthash = ('0' + nthash) try: lmhash = unhexlify(lmhash) nthash = unhexlify(nthash) except TypeError: pass bindRequest['name'] = user negotiate = getNTLMSSPType1('', domain) bindRequest['authentication']['sicilyNegotiate'] = negotiate response = self.sendReceive(bindRequest)[0]['protocolOp'] type2 = response['bindResponse']['matchedDN'] (type3, exportedSessionKey) = getNTLMSSPType3(negotiate, str(type2), user, password, domain, lmhash, nthash) bindRequest['authentication']['sicilyResponse'] = type3 response = self.sendReceive(bindRequest)[0]['protocolOp'] else: raise LDAPSessionError(errorString=("Unknown authenticationChoice: '%s'" % authenticationChoice)) if (response['bindResponse']['resultCode'] != ResultCode('success')): raise LDAPSessionError(errorString=('Error in bindRequest -> %s: %s' % (response['bindResponse']['resultCode'].prettyPrint(), response['bindResponse']['diagnosticMessage']))) return True
'Return 802.11 frame \'Order\' field'
def get_order(self):
b = self.header.get_byte(1) return ((b >> 7) & 1)
'Set 802.11 frame \'Order\' field'
def set_order(self, value):
mask = ((~ 128) & 255) masked = (self.header.get_byte(1) & mask) nb = (masked | ((value & 1) << 7)) self.header.set_byte(1, nb)
'Return 802.11 frame \'Protected\' field'
def get_protectedFrame(self):
b = self.header.get_byte(1) return ((b >> 6) & 1)
'Set 802.11 frame \'Protected Frame\' field'
def set_protectedFrame(self, value):
mask = ((~ 64) & 255) masked = (self.header.get_byte(1) & mask) nb = (masked | ((value & 1) << 6)) self.header.set_byte(1, nb)
'Return 802.11 frame \'More Data\' field'
def get_moreData(self):
b = self.header.get_byte(1) return ((b >> 5) & 1)
'Set 802.11 frame \'More Data\' field'
def set_moreData(self, value):
mask = ((~ 32) & 255) masked = (self.header.get_byte(1) & mask) nb = (masked | ((value & 1) << 5)) self.header.set_byte(1, nb)
'Return 802.11 frame \'Power Management\' field'
def get_powerManagement(self):
b = self.header.get_byte(1) return ((b >> 4) & 1)
'Set 802.11 frame \'Power Management\' field'
def set_powerManagement(self, value):
mask = ((~ 16) & 255) masked = (self.header.get_byte(1) & mask) nb = (masked | ((value & 1) << 4)) self.header.set_byte(1, nb)
'Return 802.11 frame \'Retry\' field'
def get_retry(self):
b = self.header.get_byte(1) return ((b >> 3) & 1)
'Set 802.11 frame \'Retry\' field'
def set_retry(self, value):
mask = ((~ 8) & 255) masked = (self.header.get_byte(1) & mask) nb = (masked | ((value & 1) << 3)) self.header.set_byte(1, nb)
'Return 802.11 frame \'More Fragments\' field'
def get_moreFrag(self):
b = self.header.get_byte(1) return ((b >> 2) & 1)
'Set 802.11 frame \'More Fragments\' field'
def set_moreFrag(self, value):
mask = ((~ 4) & 255) masked = (self.header.get_byte(1) & mask) nb = (masked | ((value & 1) << 2)) self.header.set_byte(1, nb)
'Return 802.11 frame \'from DS\' field'
def get_fromDS(self):
b = self.header.get_byte(1) return ((b >> 1) & 1)
'Set 802.11 frame \'from DS\' field'
def set_fromDS(self, value):
mask = ((~ 2) & 255) masked = (self.header.get_byte(1) & mask) nb = (masked | ((value & 1) << 1)) self.header.set_byte(1, nb)
'Return 802.11 frame \'to DS\' field'
def get_toDS(self):
b = self.header.get_byte(1) return (b & 1)
'Set 802.11 frame \'to DS\' field'
def set_toDS(self, value):
mask = ((~ 1) & 255) masked = (self.header.get_byte(1) & mask) nb = (masked | (value & 1)) self.header.set_byte(1, nb)
'Return 802.11 frame \'subtype\' field'
def get_subtype(self):
b = self.header.get_byte(0) return ((b >> 4) & 15)
'Set 802.11 frame \'subtype\' field'
def set_subtype(self, value):
mask = ((~ 240) & 255) masked = (self.header.get_byte(0) & mask) nb = (masked | ((value << 4) & 240)) self.header.set_byte(0, nb)
'Return 802.11 frame \'type\' field'
def get_type(self):
b = self.header.get_byte(0) return ((b >> 2) & 3)
'Set 802.11 frame \'type\' field'
def set_type(self, value):
mask = ((~ 12) & 255) masked = (self.header.get_byte(0) & mask) nb = (masked | ((value << 2) & 12)) self.header.set_byte(0, nb)
'Return 802.11 frame \'Type and Subtype\' field'
def get_type_n_subtype(self):
b = self.header.get_byte(0) return ((b >> 2) & 63)
'Set 802.11 frame \'Type and Subtype\' field'
def set_type_n_subtype(self, value):
mask = ((~ 252) & 255) masked = (self.header.get_byte(0) & mask) nb = (masked | ((value << 2) & 252)) self.header.set_byte(0, nb)
'Return 802.11 frame control \'Protocol version\' field'
def get_version(self):
b = self.header.get_byte(0) return (b & 3)
'Set the 802.11 frame control \'Protocol version\' field'
def set_version(self, value):
mask = ((~ 3) & 255) masked = (self.header.get_byte(0) & mask) nb = (masked | (value & 3)) self.header.set_byte(0, nb)
'Return \'True\' if is an QoS data frame type'
def is_QoS_frame(self):
b = self.header.get_byte(0) return ((b & 128) and True)
'Return \'True\' if it frame contain no Frame Body'
def is_no_framebody_frame(self):
b = self.header.get_byte(0) return ((b & 64) and True)
'Return \'True\' if it frame is a CF_POLL frame'
def is_cf_poll_frame(self):
b = self.header.get_byte(0) return ((b & 32) and True)
'Return \'True\' if it frame is a CF_ACK frame'
def is_cf_ack_frame(self):
b = self.header.get_byte(0) return ((b & 16) and True)
'Return 802.11 \'FCS\' field'
def get_fcs(self):
if (not self.__FCS_at_end): return None b = self.tail.get_long((-4), '>') return b
'Set the 802.11 CTS control frame \'FCS\' field. If value is None, is auto_checksum'
def set_fcs(self, value=None):
if (not self.__FCS_at_end): return if (value is None): payload = self.get_body_as_string() crc32 = self.compute_checksum(payload) value = crc32 nb = (value & 4294967295) self.tail.set_long((-4), nb)
'Return 802.11 CTS control frame \'Duration\' field'
def get_duration(self):
b = self.header.get_word(0, '<') return b
'Set the 802.11 CTS control frame \'Duration\' field'
def set_duration(self, value):
nb = (value & 65535) self.header.set_word(0, nb, '<')
'Return 802.11 CTS control frame 48 bit \'Receiver Address\' field as a 6 bytes array'
def get_ra(self):
return self.header.get_bytes()[2:8]
'Set 802.11 CTS control frame 48 bit \'Receiver Address\' field as a 6 bytes array'
def set_ra(self, value):
for i in range(0, 6): self.header.set_byte((2 + i), value[i])
'Return 802.11 ACK control frame \'Duration\' field'
def get_duration(self):
b = self.header.get_word(0, '<') return b
'Set the 802.11 ACK control frame \'Duration\' field'
def set_duration(self, value):
nb = (value & 65535) self.header.set_word(0, nb, '<')
'Return 802.11 ACK control frame 48 bit \'Receiver Address\' field as a 6 bytes array'
def get_ra(self):
return self.header.get_bytes()[2:8]
'Set 802.11 ACK control frame 48 bit \'Receiver Address\' field as a 6 bytes array'
def set_ra(self, value):
for i in range(0, 6): self.header.set_byte((2 + i), value[i])
'Return 802.11 RTS control frame \'Duration\' field'
def get_duration(self):
b = self.header.get_word(0, '<') return b
'Set the 802.11 RTS control frame \'Duration\' field'
def set_duration(self, value):
nb = (value & 65535) self.header.set_word(0, nb, '<')
'Return 802.11 RTS control frame 48 bit \'Receiver Address\' field as a 6 bytes array'
def get_ra(self):
return self.header.get_bytes()[2:8]
'Set 802.11 RTS control frame 48 bit \'Receiver Address\' field as a 6 bytes array'
def set_ra(self, value):
for i in range(0, 6): self.header.set_byte((2 + i), value[i])
'Return 802.11 RTS control frame 48 bit \'Transmitter Address\' field as a 6 bytes array'
def get_ta(self):
return self.header.get_bytes()[8:14]
'Set 802.11 RTS control frame 48 bit \'Transmitter Address\' field as a 6 bytes array'
def set_ta(self, value):
for i in range(0, 6): self.header.set_byte((8 + i), value[i])
'Return 802.11 PSPoll control frame \'AID\' field'
def get_aid(self):
b = self.header.get_word(0, '<') return b
'Set the 802.11 PSPoll control frame \'AID\' field'
def set_aid(self, value):
nb = (value & 65535) self.header.set_word(0, nb, '<')
'Return 802.11 PSPoll control frame 48 bit \'BSS ID\' field as a 6 bytes array'
def get_bssid(self):
return self.header.get_bytes()[2:8]
'Set 802.11 PSPoll control frame 48 bit \'BSS ID\' field as a 6 bytes array'
def set_bssid(self, value):
for i in range(0, 6): self.header.set_byte((2 + i), value[i])
'Return 802.11 PSPoll control frame 48 bit \'Transmitter Address\' field as a 6 bytes array'
def get_ta(self):
return self.header.get_bytes()[8:14]
'Set 802.11 PSPoll control frame 48 bit \'Transmitter Address\' field as a 6 bytes array'
def set_ta(self, value):
for i in range(0, 6): self.header.set_byte((8 + i), value[i])
'Return 802.11 CF-End control frame \'Duration\' field'
def get_duration(self):
b = self.header.get_word(0, '<') return b
'Set the 802.11 CF-End control frame \'Duration\' field'
def set_duration(self, value):
nb = (value & 65535) self.header.set_word(0, nb, '<')
'Return 802.11 CF-End control frame 48 bit \'Receiver Address\' field as a 6 bytes array'
def get_ra(self):
return self.header.get_bytes()[2:8]
'Set 802.11 CF-End control frame 48 bit \'Receiver Address\' field as a 6 bytes array'
def set_ra(self, value):
for i in range(0, 6): self.header.set_byte((2 + i), value[i])
'Return 802.11 CF-End control frame 48 bit \'BSS ID\' field as a 6 bytes array'
def get_bssid(self):
return self.header.get_bytes()[8:14]
'Set 802.11 CF-End control frame 48 bit \'BSS ID\' field as a 6 bytes array'
def set_bssid(self, value):
for i in range(0, 6): self.header.set_byte((8 + i), value[i])
'Return 802.11 \'CF-End+CF-ACK\' control frame \'Duration\' field'
def get_duration(self):
b = self.header.get_word(0, '<') return b
'Set the 802.11 \'CF-End+CF-ACK\' control frame \'Duration\' field'
def set_duration(self, value):
nb = (value & 65535) self.header.set_word(0, nb, '<')
'Return 802.11 \'CF-End+CF-ACK\' control frame 48 bit \'Receiver Address\' field as a 6 bytes array'
def get_ra(self):
return self.header.get_bytes()[2:8]
'Set 802.11 \'CF-End+CF-ACK\' control frame 48 bit \'Receiver Address\' field as a 6 bytes array'
def set_ra(self, value):
for i in range(0, 6): self.header.set_byte((2 + i), value[i])
'Return 802.11 \'CF-End+CF-ACK\' control frame 48 bit \'BSS ID\' field as a 6 bytes array'
def get_bssid(self):
return self.header.get_bytes()[8:16]
'Set 802.11 \'CF-End+CF-ACK\' control frame 48 bit \'BSS ID\' field as a 6 bytes array'
def set_bssid(self, value):
for i in range(0, 6): self.header.set_byte((8 + i), value[i])
'Return 802.11 \'Data\' data frame \'Duration\' field'
def get_duration(self):
b = self.header.get_word(0, '<') return b
'Set the 802.11 \'Data\' data frame \'Duration\' field'
def set_duration(self, value):
nb = (value & 65535) self.header.set_word(0, nb, '<')
'Return 802.11 \'Data\' data frame 48 bit \'Address1\' field as a 6 bytes array'
def get_address1(self):
return self.header.get_bytes()[2:8]
'Set 802.11 \'Data\' data frame 48 bit \'Address1\' field as a 6 bytes array'
def set_address1(self, value):
for i in range(0, 6): self.header.set_byte((2 + i), value[i])
'Return 802.11 \'Data\' data frame 48 bit \'Address2\' field as a 6 bytes array'
def get_address2(self):
return self.header.get_bytes()[8:14]
'Set 802.11 \'Data\' data frame 48 bit \'Address2\' field as a 6 bytes array'
def set_address2(self, value):
for i in range(0, 6): self.header.set_byte((8 + i), value[i])
'Return 802.11 \'Data\' data frame 48 bit \'Address3\' field as a 6 bytes array'
def get_address3(self):
return self.header.get_bytes()[14:20]
'Set 802.11 \'Data\' data frame 48 bit \'Address3\' field as a 6 bytes array'
def set_address3(self, value):
for i in range(0, 6): self.header.set_byte((14 + i), value[i])
'Return 802.11 \'Data\' data frame \'Sequence Control\' field'
def get_sequence_control(self):
b = self.header.get_word(20, '<') return b
'Set the 802.11 \'Data\' data frame \'Sequence Control\' field'
def set_sequence_control(self, value):
nb = (value & 65535) self.header.set_word(20, nb, '<')
'Return 802.11 \'Data\' data frame \'Fragment Number\' subfield'
def get_fragment_number(self):
b = self.header.get_word(20, '<') return (b & 15)
'Set the 802.11 \'Data\' data 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 \'Data\' data frame \'Sequence Number\' subfield'
def get_sequence_number(self):
b = self.header.get_word(20, '<') return ((b >> 4) & 4095)
'Set the 802.11 \'Data\' data 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 \'Data\' data frame \'Frame Body\' field'
def get_frame_body(self):
return self.get_body_as_string()
'Set 802.11 \'Data\' data frame \'Frame Body\' field'
def set_frame_body(self, data):
self.load_body(data)
'Return 802.11 \'Data\' data frame \'QoS\' field'
def get_QoS(self):
b = self.header.get_word(22, '<') return b
'Set the 802.11 \'Data\' data frame \'QoS\' field'
def set_QoS(self, value):
nb = (value & 65535) self.header.set_word(22, nb, '<')
'Return 802.11 \'Data\' data frame 48 bit \'Address4\' field as a 6 bytes array'
def get_address4(self):
return self.header.get_bytes()[22:28]
'Set 802.11 \'Data\' data frame 48 bit \'Address4\' field as a 6 bytes array'
def set_address4(self, value):
for i in range(0, 6): self.header.set_byte((22 + i), value[i])
'Return 802.11 \'Data\' data frame \'QoS\' field'
def get_QoS(self):
b = self.header.get_word(28, '<') return b