Пример #1
0
 def test_connection(self):
     smb = self.create_connection()
     smb.login(self.username, self.password, self.domain)
     credentials = smb.getCredentials()
     self.assertTrue( credentials == (self.username, self.password, self.domain, '','','', None, None))
     smb.logoff()
     del(smb)
Пример #2
0
 def test_loginHashes(self):
     lmhash, nthash = self.hashes.split(':')
     smb = self.create_connection()
     smb.login(self.username, '', self.domain, lmhash, nthash)
     credentials = smb.getCredentials()
     self.assertTrue( credentials == (self.username, '', self.domain, unhexlify(lmhash), unhexlify(nthash), '', None, None) )
     smb.logoff()
Пример #3
0
 def test_reconnect(self):
     smb = self.create_connection()
     smb.login(self.username, self.password, self.domain)
     smb.listPath(self.share, '*')
     smb.logoff()
     smb.reconnect()
     smb.listPath(self.share, '*')
     smb.logoff()
Пример #4
0
 def test_close_connection(self):
     smb = self.create_connection()
     smb.login(self.username, self.password, self.domain)
     smb_connection_socket = smb.getSMBServer().get_socket()
     self.assertTrue(self.__is_socket_opened(smb_connection_socket) == True)
     smb.close()
     self.assertTrue(self.__is_socket_opened(smb_connection_socket) == False)
     del(smb)
Пример #5
0
 def test_createFile(self):
     smb = self.create_connection()
     smb.login(self.username, self.password, self.domain)
     tid = smb.connectTree(self.share)
     fid = smb.createFile(tid, self.file)
     smb.closeFile(tid,fid)
     smb.rename(self.share, self.file, self.file + '.bak')
     smb.deleteFile(self.share, self.file + '.bak')
     smb.disconnectTree(tid)
     smb.logoff()
Пример #6
0
 def test_getData(self):
     smb = self.create_connection()
     smb.login(self.username, self.password, self.domain)
     smb.getDialect()
     smb.getServerName()
     smb.getRemoteHost()
     smb.getServerDomain()
     smb.getServerOS()
     smb.doesSupportNTLMv2()
     smb.isLoginRequired()
     smb.logoff()
Пример #7
0
 def test_uploadDownload(self):
     smb = self.create_connection()
     smb.login(self.username, self.password, self.domain)
     f = open(self.upload)
     smb.putFile(self.share, self.file, f.read)
     f.close()
     f = open(self.upload + '2', 'wb+')
     smb.getFile(self.share, self.file, f.write)
     f.close()
     os.unlink(self.upload + '2')
     smb.deleteFile(self.share, self.file)
     smb.logoff()
Пример #8
0
 def test_createdeleteDirectory(self):
     smb = self.create_connection()
     smb.login(self.username, self.password, self.domain)
     smb.createDirectory(self.share, self.directory)
     smb.deleteDirectory(self.share, self.directory)
     smb.createDirectory(self.share, self.directory)
     nested_dir = "%s\\%s" %(self.directory, self.directory)
     smb.createDirectory(self.share, nested_dir)
     try:
         smb.deleteDirectory(self.share, self.directory)
     except Exception as e:
         if e.error == nt_errors.STATUS_DIRECTORY_NOT_EMPTY:
             smb.deleteDirectory(self.share, nested_dir)
             smb.deleteDirectory(self.share, self.directory)
     smb.logoff()
Пример #9
0
 def test_readwriteFile(self):
     smb = self.create_connection()
     smb.login(self.username, self.password, self.domain)
     tid = smb.connectTree(self.share)
     fid = smb.createFile(tid, self.file)
     smb.writeFile(tid, fid, "A"*65535)
     data = smb.readFile(tid,fid, 0, 65535)
     self.assertTrue(len(data) == 65535)
     self.assertTrue(data == "A"*65535)
     smb.closeFile(tid,fid)
     fid = smb.openFile(tid, self.file)
     smb.closeFile(tid, fid)
     smb.deleteFile(self.share, self.file)
     smb.disconnectTree(tid)
     
     smb.logoff()
Пример #10
0
 def test_readwriteFile(self):
     smb = self.create_connection()
     smb.login(self.username, self.password, self.domain)
     tid = smb.connectTree(self.share)
     fid = smb.createFile(tid, self.file)
     smb.writeFile(tid, fid, "A"*65535)
     data = b''
     offset = 0
     remaining = 65535
     while remaining>0:
         data += smb.readFile(tid,fid, offset, remaining)
         remaining = 65535 - len(data)
     self.assertTrue(len(data) == 65535)
     self.assertTrue(data == b"A"*65535)
     smb.closeFile(tid,fid)
     fid = smb.openFile(tid, self.file)
     smb.closeFile(tid, fid)
     smb.deleteFile(self.share, self.file)
     smb.disconnectTree(tid)
     
     smb.logoff()
Пример #11
0
 def test_getRemoteHost(self):
     smb = self.create_connection()
     smb.login(self.username, self.password, self.domain)
     remoteHost = smb.getRemoteHost()
     self.assertTrue( remoteHost == self.machine)
     smb.logoff()
Пример #12
0
 def test_connectTree(self):
     smb = self.create_connection()
     smb.login(self.username, self.password, self.domain)
     smb.connectTree(self.share)
     UNC = '\\\\%s\\%s' % (self.machine, self.share)
     smb.connectTree(UNC)
Пример #13
0
 def test_aliasconnection(self):
     smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect=self.dialects, sess_port=self.sessPort)
     smb.login(self.username, self.password, self.domain)
     smb.listPath(self.share, '*')
     smb.logoff()
Пример #14
0
 def test_getServerName(self):
     smb = self.create_connection()
     smb.login(self.username, self.password, self.domain)
     serverName = smb.getServerName()
     self.assertTrue( serverName.upper() == self.serverName.upper() )
     smb.logoff()
Пример #15
0
 def test_getSessionKey(self):
     smb = self.create_connection()
     smb.login(self.username, self.password, self.domain)
     smb.getSessionKey()
     smb.logoff
Пример #16
0
 def test_listShares(self):
     smb = self.create_connection()
     smb.login(self.username, self.password, self.domain)
     smb.listShares()
     smb.logoff()
Пример #17
0
 def test_getServerDomain(self):
     smb = self.create_connection()
     smb.login(self.username, self.password, self.domain)
     serverDomain = smb.getServerDomain()
     self.assertTrue( serverDomain.upper() == self.domain.upper().split('.')[0])
     smb.logoff()
Пример #18
0
 def test_getDialect(self):
     smb = self.create_connection()
     smb.login(self.username, self.password, self.domain)
     dialect = smb.getDialect()
     self.assertTrue( dialect == self.dialects)
     smb.logoff()
Пример #19
0
 def test_createdeleteDirectory(self):
     smb = self.create_connection()
     smb.login(self.username, self.password, self.domain)
     smb.createDirectory(self.share, self.directory)
     smb.deleteDirectory(self.share, self.directory) 
     smb.logoff()