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: ...
'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 SessionErro...
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 ...
'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: rai...
'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(...
'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 err...
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.l...
'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://'):...
'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 i...
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 im...
'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 (pass...
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'] = ...
'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