예제 #1
0
def get_vnc_hash(password):
    passpadd = (password + "\x00" * 8)[:8]
    strkey = "".join([chr(x) for x in d.vnckey])
    ekey = d.deskey(strkey, False)

    hashed = d.desfunc(passpadd, ekey)
    return hashed.encode("hex")
예제 #2
0
def get_vnc_hash(password):
    '''
        Given a password, return a UltraVNC compatible hash from its first
        eight chars.
        Arguments:
            password
        Returns:
            hash string.
        Requires:
            d3des module to be available.
            http://vnc2flv.googlecode.com/svn-history/r2/trunk/vnc2flv/vnc2flv/d3des.py
    '''
    hashstr = None
    try:
        import d3des as d
    except ImportError:
        _log.warn(
            'Hash algorithm module not found, skipping VNC password set.')
    else:
        passpadd = (password + '\x00' * 8)[:8]
        strkey = ''.join([chr(x) for x in d.vnckey])
        ekey = d.deskey(strkey, False)

        hashed = d.desfunc(passpadd, ekey)
        hashstr = hashed.encode('hex')
        _log.info('VNC password hash: ' + hashstr)
    return hashstr
예제 #3
0
파일: install.py 프로젝트: autovmnet/kvm
def generate_key(password):
  c_password = (password + '\x00' * 8)[:8]
  encrypted = deskey(c_password, False)
  encrypted_bytes = struct.pack('i' * 32, *encrypted)
  encrypted_string = base64.b64encode(encrypted_bytes)
  key = (encrypted_string)
  return key
예제 #4
0
def get_vnc_hash(password):
    passpadd = (password + '\x00' * 8)[:8]
    strkey = ''.join([chr(x) for x in d.vnckey])
    ekey = d.deskey(strkey, False)

    hashed = d.desfunc(passpadd, ekey)
    return hashed.encode('hex')
예제 #5
0
def get_vnc_hash(password):
    '''
        Given a password, return a UltraVNC compatible hash from its first
        eight chars.
        Arguments:
            password
        Returns:
            hash string.
        Requires:
            d3des module to be available.
            http://vnc2flv.googlecode.com/svn-history/r2/trunk/vnc2flv/vnc2flv/d3des.py
    '''
    hashstr = None
    try:
        import d3des as d
    except ImportError:
        _log.warn('Hash algorithm module not found, skipping VNC password set.')
    else:
        passpadd = (password + '\x00'*8)[:8]
        strkey = ''.join([ chr(x) for x in d.vnckey ])
        ekey = d.deskey(strkey, False)

        hashed = d.desfunc(passpadd, ekey)
        hashstr = hashed.encode('hex')
        _log.info('VNC password hash: ' + hashstr)
    return hashstr
예제 #6
0
 def get_vnc_enc(password):
     import d3des
     passpadd = (password + '\x00' * 8)[:8]
     strkey = ''.join([chr(x) for x in d3des.vnckey])
     ekey = d3des.deskey(strkey, False)
     ctext = d3des.desfunc(passpadd, ekey)
     return ctext.encode('hex')
예제 #7
0
파일: vnc_pass.py 프로젝트: maizy/vnc-me
def encode_password(password):
    if not isinstance(password, bytes):
        raise ValueError('Password should be passed as bytes')
    passpadd = (password + b'\x00' * 8)[:8]
    strkey = bytes(d3des.vnckey)
    ekey = d3des.deskey(strkey, False)
    ctext = d3des.desfunc(passpadd, ekey)
    return ctext
예제 #8
0
def generate_vmware_vncpassword(password):
    # Passwords are 8 characters max, unused bytes are filled with null
    c_password = (password + '\x00'*8)[:8]
    encrypted = deskey(c_password, False)
    # The result is an array of 32 32-bit numbers, aka 1024 bits
    # Using struct.pack, we convert each 32-bit integer into 4 bytes (for a total of 128 bytes/characters)
    encrypted_bytes = struct.pack('i'*32, *encrypted)
    # Convert to base64 encoding
    encrypted_string = base64.b64encode(encrypted_bytes)
    return 'RemoteDisplay.vnc.key = "' + encrypted_string
예제 #9
0
def generate_vncpassword(password):
    # Passwords are 8 characters max, unused bytes are filled with null
    c_password = (password + '\x00'*8)[:8]
    encrypted = deskey(c_password, False)
    # Convert bytes to raw buffer
    encrypted_bytes = struct.pack('i'*32, *encrypted)
    # Convert to base64 encoding
    encrypted_string = base64.b64encode(encrypted_bytes)
    # Print resulting ecrypted string encases in double quotes
    print '"%s"' % encrypted_string
예제 #10
0
def generate_vncpassword(password):
    # Passwords are 8 characters max, unused bytes are filled with null
    c_password = (password + '\x00' * 8)[:8]
    encrypted = deskey(c_password, False)
    # Convert bytes to raw buffer
    encrypted_bytes = struct.pack('i' * 32, *encrypted)
    # Convert to base64 encoding
    encrypted_string = base64.b64encode(encrypted_bytes)
    # Print resulting ecrypted string encases in double quotes
    print '"%s"' % encrypted_string
예제 #11
0
def apply_vncpasswd_configuration(item, value, root_path):
    file = item.get("file")
    if not file: return
    check_pathelement_security(file)

    ek = d3des.deskey(pack('8B', *d3des.vnckey), False)
    encrypted = d3des.desfunc((value + '\x00' * 8)[:8], ek)

    target_file = "%s/%s" % (root_path, file)
    with open(target_file, "w") as vncpasswd:
        vncpasswd.write(encrypted)

    os.chmod(target_file, stat.S_IRUSR | stat.S_IWUSR)
예제 #12
0
def apply_vncpasswd_configuration(item, value, root_path):
    file = item.get("file")
    if not file:
        return
    check_pathelement_security(file)

    ek = d3des.deskey(pack("8B", *d3des.vnckey), False)
    encrypted = d3des.desfunc((value + "\x00" * 8)[:8], ek)

    target_file = "%s/%s" % (root_path, file)
    with open(target_file, "w") as vncpasswd:
        vncpasswd.write(encrypted)

    os.chmod(target_file, stat.S_IRUSR | stat.S_IWUSR)
예제 #13
0
def vnc_crypt(vncpass, decrypt=False):
    if decrypt:
        try:
            passpadd = vncpass.decode("hex")
        except TypeError as e:
            if e.message == "Odd-length string":
                module_logger.warning('WARN: %s . Chopping last char off... "%s"' % (e.message, vncpass[:-1]))
                passpadd = vncpass[:-1].decode("hex")
            else:
                raise
    else:
        passpadd = (vncpass + "\x00" * 8)[:8]
    strkey = "".join([chr(x) for x in d3des.vnckey])
    key = d3des.deskey(strkey, decrypt)
    crypted = d3des.desfunc(passpadd, key)
    if decrypt:
        return crypted.encode("hex").decode("hex")
    else:
        return crypted.encode("hex")
예제 #14
0
    def obfuscate(self):
        """Obfuscate a plaintext password in VNC format"""
        password = self
        # pad password up to 8 chars, truncate anything over 8
        passpadd = (password + '\x00' * 8)[:8]

        # load the vnckey from library and change encoding to ascii
        strkey = ''.join([chr(x) for x in d3des.vnckey])
        ekey = d3des.deskey(bytearray(strkey, encoding="ascii"), False)

        # encrypt the passpadd section from above
        ctext = d3des.desfunc(bytearray(passpadd, encoding="ascii"), ekey)

        # if the password was longer than 8 chars, then recurse, this will chunk the
        # password into 8 character obfuscated sections. versions older than 5 will ignore 8+
        # this method is used by RealVNC but most other implementations truncate at 8

        # if len(password) > 8:
        #	ctext += self.obfuscate(password[8:])
        return ctext
예제 #15
0
파일: rcm_utils.py 프로젝트: diegopiacc/RCM
def vnc_crypt(vncpass, decrypt=False):
    if (decrypt):
        try:
            passpadd = vncpass.decode('hex')
        except TypeError as e:
            if e.message == 'Odd-length string':
                module_logger.warning(
                    'WARN: %s . Chopping last char off... "%s"' %
                    (e.message, vncpass[:-1]))
                passpadd = vncpass[:-1].decode('hex')
            else:
                raise
    else:
        passpadd = (vncpass + '\x00' * 8)[:8]
    strkey = ''.join([chr(x) for x in d3des.vnckey])
    key = d3des.deskey(strkey, decrypt)
    crypted = d3des.desfunc(passpadd, key)
    if (decrypt):
        return crypted.encode('hex').decode('hex')
    else:
        return crypted.encode('hex')
예제 #16
0
def do_crypt(password, decrypt):
    passpadd = (password + '\x00'*8)[:8]
    strkey = ''.join([ chr(x) for x in d.vnckey ])
    key = d.deskey(strkey, decrypt)
    crypted = d.desfunc(passpadd, key)
    return crypted
예제 #17
0
파일: vnc.py 프로젝트: zichie/GetPassword
 def do_crypt(self, password, decrypt):
     passpadd = (password + '\x00' * 8)[:8]
     strkey = ''.join([chr(x) for x in self.vnckey])
     key = d.deskey(strkey, decrypt)
     crypted = d.desfunc(passpadd, key)
     return crypted
예제 #18
0
def get_vnc_enc(password):
    passpadd = (password + '\x00' * 8)[:8]
    strkey = ''.join([chr(x) for x in d.vnckey])
    ekey = d.deskey(strkey, False)
    ctext = d.desfunc(passpadd, ekey)
    return ctext