예제 #1
0
파일: domain.py 프로젝트: gonicus/clacks
    def setSambaPassword(self, user, object_dn, password):
        """
        Set a new samba-password for a user
        """

        # Do we have read permissions for the requested attribute
        env = Environment.getInstance()
        topic = "%s.objects.%s.attributes.%s" % (env.domain, "User", "sambaNTPassword")
        aclresolver = PluginRegistry.getInstance("ACLResolver")
        if not aclresolver.check(user, topic, "w", base=object_dn):
            self.__log.debug(
                "user '%s' has insufficient permissions to write %s on %s, required is %s:%s"
                % (user, "isLocked", object_dn, topic, "w")
            )
            raise ACLException(C.make_error("PERMISSION_ACCESS", topic, target=object_dn))

        topic = "%s.objects.%s.attributes.%s" % (env.domain, "User", "sambaLMPassword")
        aclresolver = PluginRegistry.getInstance("ACLResolver")
        if not aclresolver.check(user, topic, "w", base=object_dn):
            self.__log.debug(
                "user '%s' has insufficient permissions to write %s on %s, required is %s:%s"
                % (user, "isLocked", object_dn, topic, "w")
            )
            raise ACLException(C.make_error("PERMISSION_ACCESS", topic, target=object_dn))

        # Set the password and commit the changes
        lm, nt = smbpasswd.hash(password)
        user = ObjectProxy(object_dn)
        user.sambaNTPassword = nt
        user.sambaLMPassword = lm
        user.commit()
예제 #2
0
파일: hash.py 프로젝트: gonicus/clacks
    def process(self, obj, key, valDict):
        if len(valDict[key]['value']) and type(valDict[key]['value'][0]) in [str, unicode]:
            lm, nt = smbpasswd.hash(valDict[key]['value'][0])
            valDict['sambaNTPassword']['value'] = [nt]
            valDict['sambaLMPassword']['value'] = [lm]
        else:
            raise ValueError(C.make_error("TYPE_UNKNOWN", self.__class__.__name__, type=type(valDict[key]['value'])))

        return key, valDict
예제 #3
0
파일: utils.py 프로젝트: lhm-limux/gosa
    def process(self, obj, key, valDict):
        if len(valDict[key]['value']) and type(valDict[key]['value'][0]) in [str, unicode]:
            lm, nt = smbpasswd.hash(valDict[key]['value'][0])
            valDict['sambaNTPassword'] = GOsaObjectFactory.createNewProperty(valDict[key]['backend'], 'String', value=[nt])
            valDict['sambaLMPassword'] = GOsaObjectFactory.createNewProperty(valDict[key]['backend'], 'String', value=[lm])
        else:
            raise ValueError("Unknown input type for filter %s. Type is '%s'!" % (
                self.__class__.__name__, type(valDict[key]['value'])))

            return key, valDict
예제 #4
0
파일: utils.py 프로젝트: lhm-limux/gosa
    def mksmbhash(self, password):
        """
        Generate samba lm:nt hash combination.

        ========== ============
        Parameter  Description
        ========== ============
        password   Password to hash
        ========== ============

        ``Return:`` lm:nt hash combination
        """
        return '%s:%s' % smbpasswd.hash(password)
예제 #5
0
def generateHashLM(username):
    if randomNumber <= 3:  # 3%
        password = pass_Username(username)
        print username + ':' + str(random.randint(
            1000, 2000)) + ':' + '%s:%s:::' % smbpasswd.hash(password)
    else:
        if randomNumber <= 6:  # 3%
            password = pass_Password()
            print username + ':' + str(random.randint(
                1000, 2000)) + ':' + '%s:%s:::' % smbpasswd.hash(password)
        else:
            if randomNumber <= 12:  # 6%
                password = pass_DictWord_DigitsFirst()
                print username + ':' + str(random.randint(
                    1000, 2000)) + ':' + '%s:%s:::' % smbpasswd.hash(password)
            else:
                if randomNumber <= 64:  # 52%
                    password = pass_DictWord()
                    print username + ':' + str(random.randint(
                        1000,
                        2000)) + ':' + '%s:%s:::' % smbpasswd.hash(password)
                else:
                    if randomNumber <= 74:  # 10%
                        password = random_Password_ULD()
                        print username + ':' + str(
                            random.randint(1000, 2000)
                        ) + ':' + '%s:%s:::' % smbpasswd.hash(password)
                    else:
                        if randomNumber <= 80:  # 6%
                            password = random_ShittyWord()
                            print username + ':' + str(
                                random.randint(1000, 2000)
                            ) + ':' + '%s:%s:::' % smbpasswd.hash(password)
                        else:
                            if randomNumber <= 87:  # 7%
                                password = random_Password_LD()
                                print username + ':' + str(
                                    random.randint(1000, 2000)
                                ) + ':' + '%s:%s:::' % smbpasswd.hash(password)
                            else:
                                if randomNumber <= 88:  # 1%
                                    password = ""
                                    print username + ':' + str(
                                        random.randint(1000, 2000)
                                    ) + ':' + '%s:%s:::' % smbpasswd.hash(
                                        password)
                                else:
                                    if randomNumber <= 89:  # 1%
                                        password = "******"
                                        print username + ':' + str(
                                            random.randint(1000, 2000)
                                        ) + ':' + '%s:%s:::' % smbpasswd.hash(
                                            password)
                                    else:
                                        if randomNumber <= 98:  # 9%
                                            password = pass_DictWord_Upper()
                                            try:
                                                print username + ':' + str(
                                                    random.randint(1000, 2000)
                                                ) + ':' + '%s:%s:::' % smbpasswd.hash(
                                                    password)
                                            except AttributeError:  # This is in case the word starts with something other than a letter
                                                print username + ':' + str(
                                                    random.randint(1000, 2000)
                                                ) + ':' + '%s:%s:::' % smbpasswd.hash(
                                                    password)
                                        else:
                                            if randomNumber <= 100:  # 2%
                                                password = random_Password_ULDS(
                                                )
                                                print username + ':' + str(
                                                    random.randint(1000, 2000)
                                                ) + ':' + '%s:%s:::' % smbpasswd.hash(
                                                    password)
예제 #6
0
파일: pug.py 프로젝트: bupt007/PUG
def generateHashLM(username):
	if randomNumber <=3: # 3%
		password = pass_Username(username)
		print username+':'+str(random.randint(1000,2000))+':'+'%s:%s:::' % smbpasswd.hash(password)
	else:
		if randomNumber <=6: # 3%
			password = pass_Password()
			print username+':'+str(random.randint(1000,2000))+':'+'%s:%s:::' % smbpasswd.hash(password)
		else:
			if randomNumber <=12: # 6%
				password = pass_DictWord_DigitsFirst()
				print username+':'+str(random.randint(1000,2000))+':'+'%s:%s:::' % smbpasswd.hash(password)
			else:
				if randomNumber <=64: # 52%
					password = pass_DictWord()
					print username+':'+str(random.randint(1000,2000))+':'+'%s:%s:::' % smbpasswd.hash(password)
				else:
					if randomNumber <=74: # 10%
						password = random_Password_ULD()
						print username+':'+str(random.randint(1000,2000))+':'+'%s:%s:::' % smbpasswd.hash(password)
					else:
						if randomNumber <=80: # 6%
							password = random_ShittyWord()
							print username+':'+str(random.randint(1000,2000))+':'+'%s:%s:::' % smbpasswd.hash(password)
						else:
							if randomNumber <=87: # 7%
								password = random_Password_LD()
								print username+':'+str(random.randint(1000,2000))+':'+'%s:%s:::' % smbpasswd.hash(password)
							else:
								if randomNumber <=88: # 1%
									password = ""
									print username+':'+str(random.randint(1000,2000))+':'+'%s:%s:::' % smbpasswd.hash(password)
								else:
									if randomNumber <=89: # 1%
										password = "******"
										print username+':'+str(random.randint(1000,2000))+':'+'%s:%s:::' % smbpasswd.hash(password)
									else:
										if randomNumber <=98: # 9%
											password = pass_DictWord_Upper()
											try: print username+':'+str(random.randint(1000,2000))+':'+'%s:%s:::' % smbpasswd.hash(password)
											except AttributeError: # This is in case the word starts with something other than a letter
												print username+':'+str(random.randint(1000,2000))+':'+'%s:%s:::' % smbpasswd.hash(password)
										else:
											if randomNumber <=100: # 2%
												password = random_Password_ULDS()
												print username+':'+str(random.randint(1000,2000))+':'+'%s:%s:::' % smbpasswd.hash(password)
예제 #7
0
파일: models.py 프로젝트: laqie/rcroadmin
def create_or_change_user(username,
                          full_name=None,
                          gecos=None,
                          clear_password=None,
                          mail=None,
                          phone_number=None,
                          mobile=None,
                          shell=None,
                          *args, **kwargs):
    user = SambaUser.objects.filter(username=username)
    if user:
        user, create = user[0], False
    else:
        user, create = SambaUser(), True

    if not create:
        if full_name:
            user.change_full_name(full_name)
        if clear_password:
            user.change_password(clear_password)

        user.gecos = gecos if gecos else user.gecos
        user.mail = [mail] if mail else user.mail
        user.phone = phone_number if phone_number else user.phone
        user.mobile = mobile if mobile else user.mobile
        user.login_shell = shell if shell else user.login_shell
        user.save()

    else:
        _, domain_sid, domain_next_uid, domain_last_rid = get_domain_info()
        never = 2147483647

        user.username = username
        user.cn = username
        user.given_name = ' '.join(full_name.split(' ')[1:])
        user.display_name = ' '.join(
            (full_name.split(' ')[0], '%s.' % full_name.split(' ')[1][0], '%s.' % full_name.split(' ')[2][0])) if len(full_name.split()) == 3 else full_name
        user.last_name = full_name.split(' ')[0]
        user.uid_number = int(domain_next_uid)
        user.gid_number = 513
        user.home_dir = u'/home/%s/' % username
        user.login_shell = shell
        user.gecos = gecos
        user.mail = [mail]

        user.organization = u'РЦРО'
        user.city = u'Томск'
        user.mobile = mobile
        user.phone = phone_number

        user.shadow_last_change = int(time.time())
        user.shadow_max = 900

        user.samba_pwd_last_set = int(time.time())
        user.samba_pwd_can_change = 0
        user.samba_pwd_must_change = never
        user.samba_logon_time = 0
        user.samba_logoff_time = never
        user.samba_kickoff_time = never
        user.samba_acct_flags = u'[UX]'
        user.samba_sid = '%s-%s' % (domain_sid, int(domain_last_rid) + 1)
        user.samba_home_path = r'\\%s\%s' % (settings.SERVER_NAME, username)

        user.samba_nt_password = smbpasswd.hash(clear_password)[1]
        user.user_password = u'{MD5}' + get_base64_md5(clear_password)
        user.save()
        increase_samba_rid()

    return user
예제 #8
0
파일: models.py 프로젝트: laqie/rcroadmin
 def change_password(self, new_password):
     self.samba_nt_password = smbpasswd.hash(new_password)[1]
     self.user_password = u'{MD5}' + get_base64_md5(new_password)
     self.samba_pwd_last_set = int(time.time())
     self.shadow_last_change = int(time.time())
     self.samba_pwd_must_change = 2147483647
예제 #9
0
'''
Created on Oct 12, 2012

@author: tivalat
'''
 
import smbpasswd

passwd = 'mypassword'

print 'LANMAN hash is', smbpasswd.lmhash(passwd)               
print 'NT hash is', smbpasswd.nthash(passwd)

print 'both hashes at once = %s:%s (lm:nt)' % smbpasswd.hash(passwd)
예제 #10
0
import smbpasswd

passwd = 'mypassword'

#print 'LANMAN hash is', smbpasswd.lmhash(passwd)
print 'NT hash is', smbpasswd.nthash(passwd)

print 'both hashes at once = %s:%s' % smbpasswd.hash(passwd)
예제 #11
0
파일: pug.py 프로젝트: colin-morrell/PUG
def generateHashLM(username, randomWords):

    password = generatePassword(username, randomWords)
    print username+':'+str(random.randint(1000,2000))+':'+'%s:%s:::' % smbpasswd.hash(password)
예제 #12
0
파일: nthash.py 프로젝트: bAndie91/tools
#!/usr/bin/env python

import smbpasswd
import sys

passwd = sys.argv[1]

print 'LANMAN hash is', smbpasswd.lmhash(passwd)
print 'NT hash is', smbpasswd.nthash(passwd)

print 'both hashes at once = %s:%s (lm:nt)' % smbpasswd.hash(passwd)