Exemple #1
0
def importDb(input, password = None):
    dbSysInst = dbSys.dbSysSmart()
    sf = open(input, 'r')
    package = json.load(sf)
    en = enc.encryptorBase64Out(password)
    l = package["add"]
    if (password is None) and package.has_key("encPass"):
        print 'need password for importing'
        return
    if (not (password is None)):
        if unicode(str(md5.new(password).hexdigest())) != package["encPass"]:
            print 'pass not match:', unicode(str(md5.new(password+package["time-duration"]).hexdigest())), package["encPass"]
            return
        else:
            l = listEncryptor.dictListDecryptor(l, en)
    l = listEncryptor.dictListEncryptor(l)
    dbSysInst.importDb(l)
Exemple #2
0
def decryptBackup(sourceFullPath, target, password = None):
    sf = open(sourceFullPath, 'r')
    l = json.load(sf)
    if l.has_key("encPass"):
        if password is None:
            print 'need password'
            return
        else:
            en = enc.encryptorBase64Out(password)
            if str(md5.new(password+l["time-duration"]).hexdigest()) != l["encPass"]:
                print 'pass not match:', str(md5.new(password+l["time-duration"]).hexdigest()), l["encPass"]
                return
            res = dbExporterV3.dictListDecryptor(l["add"], en)
    else:
        res = l["add"]
    l["add"] = res
    del l["encPass"]
    s = json.dumps(l, sort_keys=True, indent=4)
    f = open(target,'w')
    f.write(s)
    f.close()
Exemple #3
0
def importDb(input, username, targetPasswd, password = None):
    dbSysInst = dbSys.dbSysSmart()
    sf = open(input, 'r')
    package = json.load(sf)
    en = enc.encryptorBase64Out(password)
    l = package["add"]
    if (password is None) and package.has_key("encPass"):
        print 'need password for importing'
        return
    if (not (password is None)):
        if unicode(str(md5.new(password).hexdigest())) != package["encPass"]:
            print 'pass not match:', unicode(str(md5.new(password+package["time-duration"]).hexdigest())), package["encPass"]
            return
        else:
            l = listEncryptor.dictListDecryptor(l, en)
    sysUser = service.ufsUser(u'system.user', u'system.pass')
    if userMan.userManager().verifyPasswd(username, targetPasswd, dbSys.dbSysSmart(sysUser).getDb("passwdDb")):
        print 'importing'
        l = listEncryptor.dictListEncryptor(l, xorEnc.encryptorTxtOut(targetPasswd))
        #print l
        l = listEncryptor.setUser(l, username)
        #print l
        dbSysInst.importDb(l)