[20151008]8i-10g口令密码的加密算法.txt

简介: [20151008]8i-10g口令密码的加密算法.txt --昨天晚上写了1篇关于11g密码问题,想看看8i-10g口令密码的加密算法,google半天竟然没找到。

[20151008]8i-10g口令密码的加密算法.txt

--昨天晚上写了1篇关于11g密码问题,想看看8i-10g口令密码的加密算法,google半天竟然没找到。
--翻了一个电子文档找到相关内容做一个记录:

Apress.Expert.Oracle.Practices.Jan.2010.pdf

1.  Concatenate the username and password while also making the string Unicode for instance, for SYSTEM/MANAGER this
    would be S0Y0S0T0E0M0M0A0N0A0G0E0R0.
2.  Pad out the string with zeros to be a multiple of eight characters. This is not necessary if the memory holding the
    string is zeroed first, because it is then implicitly padded.
3.  Using an encryption key of 0123456789ABCDEF, use Data Encryption Standard Cypher Block Checksum (DES CBC) mode to
    encrypt the username/password string. Note that CBC mode means that the first 8 bytes are encrypted and the result
    is XOR'd with the next 8 bytes, and then that is encrypted, and so on. When completed, the last input vector (the
    last XOR result) is used as the new encryption key for the second round.
4.  Repeat all the preceding steps but use the encryption key extracted in step 3. This time, the last input vector is
    the result; the password hash stored in SYS.USER$.PASSWORD. The result is a "hash," not an encrypted value, even
    though a very popular encryption algorithm is used. This is because of the two stages used that make the final
    output nonrevisable, that is, it cannot be decrypted.

--看看www.petefinnigan.com/testpwd.sql written in PL/SQL确定加密算法.

-- -----------------------------------------------------------------------------
--                 WWW.PETEFINNIGAN.COM LIMITED
-- -----------------------------------------------------------------------------
-- Script Name : testpwd.sql
-- Author      : Pete Finnigan
-- Date        : May 2009
-- -----------------------------------------------------------------------------
-- Description : This script can be used to test users passwords in databases
--               of versions 7 - 10gR2
-- -----------------------------------------------------------------------------
-- Maintainer  : Pete Finnigan (http://www.petefinnigan.com)
-- Copyright   : Copyright (C) 2008, 2009, PeteFinnigan.com Limited. All rights
--               reserved. All registered trademarks are the property of their
--               respective owners and are hereby acknowledged.
-- -----------------------------------------------------------------------------
-- License     : This software is free software BUT it is not in the public
--               domain. This means that you can use it for personal or
--               commercial work but you cannot remove this notice or copyright
--               notices or the banner output by the program or edit them in any
--               way at all. You also cannot host/distribute/copy or in anyway
--               make this script available through any means either in original
--               form or any derivitive work based on it. The script is
--               only available from its own webpage
--               http://www.petefinnigan.com/testpwd.sql or any other page that
--               PeteFinnigan.com Limited hosts it from.
--               This script cannot be incorporated into any other free or
--               commercial tools without permission from PeteFinnigan.com
--               Limited.
--
--               In simple terms use it for free but dont make it available in
--               any way or build it into any other tools.
-- -----------------------------------------------------------------------------
-- Version History
-- ===============
--
-- Who         version     Date      Description
-- ===         =======     ======    ======================
-- P.Finnigan  1.0         May 2009  First Issue.
-- P.Finnigan  1.1         May 2009  Added calls to upper for username/password
--                                   Thanks to Kennie Nybo Pontoppidan.
--
-- -----------------------------------------------------------------------------

create or replace function testpwd(username in varchar2, password in varchar2)
return char
authid current_user
is
   --
   raw_key raw(128):= hextoraw('0123456789ABCDEF');
   --
   raw_ip raw(128);
   pwd_hash varchar2(16);
   --
   cursor c_user (cp_name in varchar2) is
   select    password
   from sys.user$
   where password is not null
   and name=cp_name;
   --
   procedure unicode_str(userpwd in varchar2, unistr out raw)
   is
      enc_str varchar2(124):='';
      tot_len number;
      curr_char char(1);
      padd_len number;
      ch char(1);
      mod_len number;
      debugp varchar2(256);
   begin
      tot_len:=length(userpwd);
      for i in 1..tot_len loop
         curr_char:=substr(userpwd,i,1);
         enc_str:=enc_str||chr(0)||curr_char;
      end loop;
      mod_len:= mod((tot_len*2),8);
      if (mod_len = 0) then
         padd_len:= 0;
      else
         padd_len:=8 - mod_len;
      end if;
      for i in 1..padd_len loop
         enc_str:=enc_str||chr(0);
      end loop;
      unistr:=utl_raw.cast_to_raw(enc_str);
   end;
   --
   function crack (userpwd in raw) return varchar2
   is
      enc_raw raw(2048);
      --
      raw_key2 raw(128);
      pwd_hash raw(2048);
      --
      hexstr varchar2(2048);
      len number;
      password_hash varchar2(16);  
   begin
      dbms_obfuscation_toolkit.DESEncrypt(input => userpwd,
             key => raw_key, encrypted_data => enc_raw );
      hexstr:=rawtohex(enc_raw);
      len:=length(hexstr);
      raw_key2:=hextoraw(substr(hexstr,(len-16+1),16));
      dbms_obfuscation_toolkit.DESEncrypt(input => userpwd,
             key => raw_key2, encrypted_data => pwd_hash );
      hexstr:=hextoraw(pwd_hash);
      len:=length(hexstr);
      password_hash:=substr(hexstr,(len-16+1),16);
      return(password_hash);
   end;
begin
   open c_user(upper(username));
   fetch c_user into pwd_hash;
   close c_user;
   unicode_str(upper(username)||upper(password),raw_ip);
   if( pwd_hash = crack(raw_ip)) then
      return ('Y');
   else
      return ('N');
   end if;
end;
/

--他的算法是检测口令是否猜测正确的,我改一下看看:

create or replace function testpwd(username in varchar2, password in varchar2)
return char
authid current_user
is
   --
   raw_key raw(128):= hextoraw('0123456789ABCDEF');
   --
   raw_ip raw(128);
   pwd_hash varchar2(16);

   procedure unicode_str(userpwd in varchar2, unistr out raw)
   is
      enc_str varchar2(124):='';
      tot_len number;
      curr_char char(1);
      padd_len number;
      ch char(1);
      mod_len number;
      debugp varchar2(256);
   begin
      tot_len:=length(userpwd);
      for i in 1..tot_len loop
         curr_char:=substr(userpwd,i,1);
         enc_str:=enc_str||chr(0)||curr_char;
      end loop;
      mod_len:= mod((tot_len*2),8);
      if (mod_len = 0) then
         padd_len:= 0;
      else
         padd_len:=8 - mod_len;
      end if;
      for i in 1..padd_len loop
         enc_str:=enc_str||chr(0);
      end loop;
      unistr:=utl_raw.cast_to_raw(enc_str);
   end;
   --
   function crack (userpwd in raw) return varchar2
   is
      enc_raw raw(2048);
      --
      raw_key2 raw(128);
      pwd_hash raw(2048);
      --
      hexstr varchar2(2048);
      len number;
      password_hash varchar2(16);  
   begin
      dbms_obfuscation_toolkit.DESEncrypt(input => userpwd,
             key => raw_key, encrypted_data => enc_raw );
      hexstr:=rawtohex(enc_raw);
      len:=length(hexstr);
      raw_key2:=hextoraw(substr(hexstr,(len-16+1),16));
      dbms_obfuscation_toolkit.DESEncrypt(input => userpwd,
             key => raw_key2, encrypted_data => pwd_hash );
      hexstr:=hextoraw(pwd_hash);
      len:=length(hexstr);
      password_hash:=substr(hexstr,(len-16+1),16);
      return(password_hash);
   end;
begin
   unicode_str(upper(username)||upper(password),raw_ip);
   return crack(raw_ip);
end;
/


-- 测试看看:

SYS@test> select name,password,spare4 from sys.user$ where name='SCOTT';
NAME                 PASSWORD             SPARE4
-------------------- -------------------- --------------------------------------------------------------
SCOTT                57964D8CE8DC6EB2     S:F67125C76865130EB899ABB60A06C3D063A9A26CA2C95D76078DB11F1F0A

SYS@test> select testpwd('scott','btbtms') c20 from dual ;
C20
--------------------
57964D8CE8DC6EB2

目录
相关文章
|
机器学习/深度学习 存储 算法
解锁文件共享软件背后基于 Python 的二叉搜索树算法密码
文件共享软件在数字化时代扮演着连接全球用户、促进知识与数据交流的重要角色。二叉搜索树作为一种高效的数据结构,通过有序存储和快速检索文件,极大提升了文件共享平台的性能。它依据文件名或时间戳等关键属性排序,支持高效插入、删除和查找操作,显著优化用户体验。本文还展示了用Python实现的简单二叉搜索树代码,帮助理解其工作原理,并展望了该算法在分布式计算和机器学习领域的未来应用前景。
|
存储 NoSQL 数据库
认证服务---整合短信验证码,用户注册和登录 ,密码采用MD5加密存储 【二】
这篇文章讲述了在分布式微服务系统中添加用户注册和登录功能的过程,重点介绍了用户注册时通过远程服务调用第三方服务获取短信验证码、使用Redis进行验证码校验、对密码进行MD5加密后存储到数据库,以及用户登录时的远程服务调用和密码匹配校验的实现细节。
认证服务---整合短信验证码,用户注册和登录 ,密码采用MD5加密存储 【二】
|
存储 缓存 Java
java语言后台管理ruoyi后台管理框架-登录提示“无效的会话,或者会话已过期,请重新登录。”-扩展知识数据库中密码加密的方法-问题如何解决-以及如何重置若依后台管理框架admin密码-优雅草卓伊凡
java语言后台管理ruoyi后台管理框架-登录提示“无效的会话,或者会话已过期,请重新登录。”-扩展知识数据库中密码加密的方法-问题如何解决-以及如何重置若依后台管理框架admin密码-优雅草卓伊凡
2635 3
java语言后台管理ruoyi后台管理框架-登录提示“无效的会话,或者会话已过期,请重新登录。”-扩展知识数据库中密码加密的方法-问题如何解决-以及如何重置若依后台管理框架admin密码-优雅草卓伊凡
|
存储 算法 Java
解锁“分享文件”高效密码:探秘 Java 二叉搜索树算法
在信息爆炸的时代,文件分享至关重要。二叉搜索树(BST)以其高效的查找性能,为文件分享优化提供了新路径。本文聚焦Java环境下BST的应用,介绍其基础结构、实现示例及进阶优化。BST通过有序节点快速定位文件,结合自平衡树、多线程和权限管理,大幅提升文件分享效率与安全性。代码示例展示了文件插入与查找的基本操作,适用于大规模并发场景,确保分享过程流畅高效。掌握BST算法,助力文件分享创新发展。
|
存储 人工智能 算法
解锁分布式文件分享的 Java 一致性哈希算法密码
在数字化时代,文件分享成为信息传播与协同办公的关键环节。本文深入探讨基于Java的一致性哈希算法,该算法通过引入虚拟节点和环形哈希空间,解决了传统哈希算法在分布式存储中的“哈希雪崩”问题,确保文件分配稳定高效。文章还展示了Java实现代码,并展望了其在未来文件分享技术中的应用前景,如结合AI优化节点布局和区块链增强数据安全。
|
JavaScript 算法 安全
深度剖析:共享文件怎么设置密码和权限的 Node.js 进阶算法
在数字化时代,共享文件的安全性至关重要。本文聚焦Node.js环境,介绍如何通过JavaScript对象字面量构建数据结构管理文件安全信息,包括使用`bcryptjs`库加密密码和权限校验算法,确保高效且安全的文件共享。通过实例代码展示加密与权限验证过程,帮助各行业实现严格的信息资产管理与协作。
|
存储 Java 数据库
密码专辑:对密码加盐加密,对密码进行md5加密,封装成密码工具类
这篇文章介绍了如何在Java中通过加盐和加密算法(如MD5和SHA)安全地存储密码,并提供了一个密码工具类PasswordUtils和密码编码类PasswordEncoder的实现示例。
616 10
密码专辑:对密码加盐加密,对密码进行md5加密,封装成密码工具类
|
存储 算法 测试技术
【狂热算法篇】探秘图论之 Floyd 算法:解锁最短路径的神秘密码(通俗易懂版)
【狂热算法篇】探秘图论之 Floyd 算法:解锁最短路径的神秘密码(通俗易懂版)
|
算法 安全 调度
【动态规划篇】穿越算法迷雾:约瑟夫环问题的奇幻密码
【动态规划篇】穿越算法迷雾:约瑟夫环问题的奇幻密码
|
存储 人工智能 算法
【深度优先搜索篇】走迷宫的魔法:算法如何破解迷宫的神秘密码
【深度优先搜索篇】走迷宫的魔法:算法如何破解迷宫的神秘密码