def test_getSessionKey(self): smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect=self.dialects) smb.login(self.username, self.password, self.domain) smb.getSessionKey() smb.logoff
def safe_smblogin(smb, **kwargs): username = kwargs.get("user") password = kwargs.get("pwd") domain = kwargs.get("domain") lmhash = kwargs.get("lmhash") nthash = kwargs.get("nthash") try: if lmhash and nthash: if verbose: logger.debug("Logging using Pass-The-Hash") smb.login(username, '', domain=domain, lmhash=lmhash, nthash=nthash) else: if verbose: logger.debug("Logging using password") smb.login(username, password, domain=domain) if verbose: if smb.isGuestSession() > 0: logger.debug("GUEST Session Granted") else: logger.debug("USER Session Granted") except Exception as e: if verbose: logger.error("Failed to login: %s" % e) return False return True
def test_listPath(self): smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect=self.dialects) smb.login(self.username, self.password, self.domain) smb.listPath(self.share, '*') smb.logoff()
def test_connection(self): smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect = self.dialects) smb.login(self.username, self.password, self.domain) credentials = smb.getCredentials() self.assertTrue( credentials == (self.username, self.password, self.domain, '','')) smb.logoff() del(smb)
def safe_smblogin(smb, **kwargs): username = kwargs.get("user") password = kwargs.get("pwd") domain = kwargs.get("domain") lmhash = kwargs.get("lmhash") nthash = kwargs.get("nthash") try: if lmhash and nthash: if verbose: logger.debug("Logging using Pass-The-Hash") smb.login(username, "", domain=domain, lmhash=lmhash, nthash=nthash) else: if verbose: logger.debug("Logging using password") smb.login(username, password, domain=domain) if verbose: if smb.isGuestSession() > 0: logger.debug("GUEST Session Granted") else: logger.debug("USER Session Granted") except Exception as e: if verbose: logger.error("Failed to login: %s" % e) return False return True
def test_loginHashes(self): lmhash, nthash = self.hashes.split(':') smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect = self.dialects) smb.login(self.username, '', self.domain, lmhash, nthash) credentials = smb.getCredentials() self.assertTrue( credentials == (self.username, '', self.domain, lmhash.decode('hex'), nthash.decode('hex')) ) smb.logoff()
def test_connection(self): smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect=self.dialects) smb.login(self.username, self.password) smb.logoff() del (smb)
def test_loginHashes(self): lmhash, nthash = self.hashes.split(':') smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect = self.dialects) smb.login(self.username, '', self.domain, lmhash, nthash) credentials = smb.getCredentials() self.assertTrue( credentials == (self.username, '', self.domain, lmhash.decode('hex'), nthash.decode('hex'), '', None, None) ) smb.logoff()
def test_connection(self): smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect = self.dialects) 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)
def test_createdeleteDirectory(self): smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect=self.dialects) smb.login(self.username, self.password, self.domain) smb.createDirectory(self.share, self.directory) smb.deleteDirectory(self.share, self.directory) smb.logoff()
def test_getDialect(self): smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect=self.dialects) smb.login(self.username, self.password, self.domain) dialect = smb.getDialect() self.assertTrue(dialect == self.dialects) smb.logoff()
def test_connectTree(self): smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect=self.dialects) smb.login(self.username, self.password, self.domain) tid = smb.connectTree(self.share) UNC = '\\\\%s\\%s' % (self.machine, self.share) tid = smb.connectTree(UNC)
def test_createFile(self): smb = SMBConnection("*SMBSERVER", self.machine, preferredDialect=self.dialects) smb.login(self.username, self.password) tid = smb.connectTree(self.share) fid = smb.createFile(tid, self.file) smb.closeFile(tid, fid) smb.deleteFile(self.share, self.file) smb.disconnectTree(tid) smb.logoff()
def test_createFile(self): smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect = self.dialects) 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()
def test_getData(self): smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect = self.dialects) smb.login(self.username, self.password, self.domain) smb.getDialect() smb.getServerName() smb.getRemoteHost() smb.getServerDomain() smb.getServerOS() smb.doesSupportNTLMv2() smb.isLoginRequired() smb.logoff()
def test_uploadDownload(self): smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect = self.dialects) 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', 'w+') smb.getFile(self.share, self.file, f.write) f.close() smb.deleteFile(self.share, self.file) smb.logoff()
def smb_connect(ip,username,password): crack =0 try: smb = SMBConnection('*SMBSERVER', ip) smb.login(username,password) smb.logoff() crack =1 except Exception, e: lock.acquire() print "%s smb 's %s:%s login fail " %(ip,username,password) lock.release() pass
def smb_connect(ip, username, password): crack = 0 try: smb = SMBConnection('*SMBSERVER', ip) smb.login(username, password) smb.logoff() crack = 1 except Exception, e: lock.acquire() print "%s smb 's %s:%s login fail " % (ip, username, password) lock.release() pass
def test_readwriteFile(self): smb = SMBConnection("*SMBSERVER", self.machine, preferredDialect=self.dialects) smb.login(self.username, self.password) 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) smb.deleteFile(self.share, self.file) smb.disconnectTree(tid) smb.logoff()
def test_readwriteFile(self): smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect=self.dialects) smb.login(self.username, self.password) 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) smb.deleteFile(self.share, self.file) smb.disconnectTree(tid) smb.logoff()
def test_getServerDomain(self): smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect = self.dialects) smb.login(self.username, self.password, self.domain) serverDomain = smb.getServerDomain() self.assertTrue( serverDomain == self.domain) smb.logoff()
def test_createdeleteDirectory(self): smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect = self.dialects) smb.login(self.username, self.password, self.domain) smb.createDirectory(self.share, self.directory) smb.deleteDirectory(self.share, self.directory) smb.logoff()
def test_listPath(self): smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect = self.dialects ) smb.login(self.username, self.password, self.domain) smb.listPath(self.share, '*') smb.logoff()
def test_getSessionKey(self): smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect = self.dialects) smb.login(self.username, self.password, self.domain) smb.getSessionKey() smb.logoff
def test_getRemoteHost(self): smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect = self.dialects) smb.login(self.username, self.password, self.domain) remoteHost = smb.getRemoteHost() self.assertTrue( remoteHost == self.machine) smb.logoff()
def test_listPath(self): smb = SMBConnection("*SMBSERVER", self.machine, preferredDialect=self.dialects) smb.login(self.username, self.password) smb.listPath(self.share, "*") smb.logoff()
def test_getServerName(self): smb = SMBConnection("*SMBSERVER", self.machine, preferredDialect=self.dialects) smb.login(self.username, self.password) smb.logoff()
def test_connectTree(self): smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect = self.dialects) smb.login(self.username, self.password, self.domain) tid = smb.connectTree(self.share) UNC = '\\\\%s\\%s' % (self.machine, self.share) tid = smb.connectTree(UNC)
def test_getServerDomain(self): smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect = self.dialects) smb.login(self.username, self.password, self.domain) serverDomain = smb.getServerDomain() self.assertTrue( serverDomain.upper() == self.domain.upper()) smb.logoff()