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 scan_host(host, port, **kwargs): regex = kwargs.get("regex", None) if regex is not None: regex = re.compile(regex, re.I) smb = safe_smbconnect(host, port) if smb is None: return if not safe_smblogin(smb, **kwargs): return sharenames = safe_enumshares(smb) if sharenames is None: return if verbose: logger.info("Found {0:d} shares: {1:s}".format(len(sharenames), sharenames)) for share in sharenames: if share in BLACKLISTED_SHARES: continue smbwalk(smb, share, regex) smb.logoff() del (smb) return
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_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 scan_host(host, port, **kwargs): regex = kwargs.get("regex", None) if regex is not None: regex = re.compile(regex, re.I) smb = safe_smbconnect(host, port) if smb is None: return if not safe_smblogin(smb, **kwargs): return sharenames = safe_enumshares(smb) if sharenames is None: return if verbose: logger.info("Found {0:d} shares: {1:s}".format(len(sharenames), sharenames)) for share in sharenames: if share in BLACKLISTED_SHARES: continue smbwalk(smb, share, regex) smb.logoff() del(smb) return
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_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_loginKerberosAES(self): lmhash, nthash = self.hashes.split(':') smb = SMBConnection('*SMBSERVER', self.machine, preferredDialect = self.dialects) smb.kerberosLogin(self.username, '', self.domain, '', '', self.aesKey) credentials = smb.getCredentials() self.assertTrue( credentials == (self.username, '', self.domain, '','',self.aesKey, None, None) ) UNC = '\\\\%s\\%s' % (self.machine, self.share) tid = smb.connectTree(UNC) smb.logoff()
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_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 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 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_getServerName(self): smb = SMBConnection("*SMBSERVER", self.machine, preferredDialect=self.dialects) smb.login(self.username, self.password) 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.upper() == self.domain.upper()) 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_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()