def login(self, module='', user='', passwd=''): if not user: user = '******' if not passwd: passwd = 'www' if not module: module = 'www' self.putline(self.server_protocol_version) # self.putline('@RSYNCD: 28.0') # self.protocol_version = 28 resp = self.sendcmd(module) challenge = resp[resp.find('AUTHREQD ') + 9:] if self.protocol_version >= 30: md5 = hashlib.md5() md5.update(passwd) md5.update(challenge) hash = base64.b64encode(md5.digest()) else: md4 = hashlib.new('md4') tmp = '\0\0\0\0' + passwd + challenge md4.update(tmp) hash = base64.b64encode(md4.digest()) response, number = re.subn(r'=+$', '', hash) print response resp = self.sendcmd(user + ' ' + response) if resp.find('OK') == -1: raise Error, resp return resp
def login(self, module='', user = '', passwd = ''): if not user: user = '******' if not passwd: passwd = 'www' if not module: module = 'www' self.putline(self.server_protocol_version) # self.putline('@RSYNCD: 28.0') # self.protocol_version = 28 resp = self.sendcmd(module) challenge = resp[resp.find('AUTHREQD ')+9:] if self.protocol_version >= 30: md5=hashlib.md5() md5.update(passwd) md5.update(challenge) hash = base64.b64encode(md5.digest()) else: md4=hashlib.new('md4') tmp = '\0\0\0\0' + passwd + challenge md4.update(tmp) hash = base64.b64encode(md4.digest()) response, number = re.subn(r'=+$','',hash) resp = self.sendcmd(user + ' ' + response) if resp.find('OK') == -1: raise Error, resp return resp
def GetHash(m): md4 = md4.MD4() md4.update(m) return md4.digest()