我从WWW.PETEFINNIGAN.COM找到了一个非常有用的PL / SQL脚本
显示匹配的用户名和密码!帮助我们识别数据库中的弱密码!
但是我得到了错误
ORA-06502: PL/SQL: numerisk feil eller verdifeil: character string buffer too small
ORA-06512: ved "SYS.TESTPWD", line 29
ORA-06512: ved "SYS.TESTPWD", line 71
.06502. 00000 - "PL/SQL: numeric or value error%s"
*Cause:
*Action:
脚本是:
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;