php获取本机root,通过PHP执行root命令
慕村225694
在嘗試之前,請閱讀整個文章,然后進行選擇。使用二進制包裝器(帶有suid位)的解決方案1)創建一個腳本(最好是.sh),其中包含要作為root用戶運行的腳本。# cat > php_shell.sh < wrapper.c <? #include ? #include ? int? main (int argc, char *argv[])? {? ? ?setuid (0);? ? ?/* WARNING: Only use an absolute path to the script to execute,? ? ? *? ? ? ? ? a malicious user might fool the binary and execute? ? ? *? ? ? ? ? arbitary commands if not.? ? ? * */? ? ?system ("/bin/sh /path/to/php_shell.sh");? ? ?return 0;? ?}CONTENT4)編譯并設置適當的權限,包括suid位(假設它應以root特權運行):# gcc wrapper.c -o php_root# chown root php_root# chmod u=rwx,go=xr,+s php_rootphp_root現在將以root權限運行,并執行中指定的命令php_shell.sh。如果您不需要輕松更改將要執行的命令的選項,建議您直接在wrapper.c步驟4下編寫這些命令。然后,您無需讓二進制文件執行外部腳本來執行所討論的命令。在中wrapper.c,用于system ("your shell command here");指定您要執行的命令。
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的php获取本机root,通过PHP执行root命令的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: aoltsmon.exe是什么进程 ao
- 下一篇: php去除html属性,PHP如何去掉所