示例#1
0
 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()
示例#2
0
 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)
示例#3
0
文件: smbwalk.py 项目: hugsy/stuff
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
示例#4
0
 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()
示例#5
0
 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)
示例#6
0
 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()
示例#7
0
 def test_connection(self):
     smb = SMBConnection('*SMBSERVER',
                         self.machine,
                         preferredDialect=self.dialects)
     smb.login(self.username, self.password)
     smb.logoff()
     del (smb)
示例#8
0
文件: smbwalk.py 项目: hugsy/stuff
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
示例#9
0
 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()
示例#10
0
 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()
示例#11
0
 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()
示例#12
0
 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()
示例#13
0
 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()
示例#14
0
 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()
示例#15
0
 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()
示例#16
0
 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()
示例#17
0
 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()
示例#18
0
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
示例#19
0
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
示例#20
0
    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()
示例#21
0
    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()
示例#22
0
 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()
示例#23
0
 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()
示例#24
0
 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()
示例#25
0
 def test_getServerName(self):
     smb = SMBConnection("*SMBSERVER", self.machine, preferredDialect=self.dialects)
     smb.login(self.username, self.password)
     smb.logoff()
示例#26
0
 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()
示例#27
0
 def test_listPath(self):
     smb = SMBConnection("*SMBSERVER", self.machine, preferredDialect=self.dialects)
     smb.login(self.username, self.password)
     smb.listPath(self.share, "*")
     smb.logoff()
示例#28
0
 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()