亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問板塊 發(fā)新帖
查看: 2395 | 回復(fù): 4
打印 上一主題 下一主題

[系統(tǒng)管理] Linux SUID提權(quán)失。 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2016-02-18 10:20 |只看該作者 |倒序?yàn)g覽
本帖最后由 dxcheng 于 2016-02-18 10:20 編輯

最近讀到《The Shellcoder's Handbook》一書的"Using an Exploit to Get Root Privileges"這一部分使用SUID獲取Root權(quán)限。但是我這邊試了一下卻還是沒有得到Root權(quán)限,請(qǐng)大神們指教,謝謝!
  1. // shell.c
  2. int main(){
  3.         char *name[2];
  4.         name[0] = “/bin/sh”;
  5.         name[1] = 0x0;
  6.         execve(name[0], name, 0x0);
  7.         exit(0);
  8. }
復(fù)制代碼
If we compile this code and run it, we can see that it will spawn a shell for us.
[jack@0day local]$ gcc shell.c -o shell
[jack@0day local]$ sudo chown root shell
[jack@0day local]$ sudo chmod +s shell
[jack@0day local]$ ./shell
sh-2.05b#

我這邊的結(jié)果還是普通用戶的權(quán)限:
$./shell
sh-4.1$

系統(tǒng)環(huán)境如下:
$uname -a
Linux centos_12 2.6.32-279.el6.i686 #1 SMP Fri Jun 22 10:59:55 UTC 2012 i686 i686 i386 GNU/Linux

論壇徽章:
84
每日論壇發(fā)貼之星
日期:2015-12-29 06:20:00每日論壇發(fā)貼之星
日期:2016-01-16 06:20:00每周論壇發(fā)貼之星
日期:2016-01-17 22:22:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-20 06:20:00每日論壇發(fā)貼之星
日期:2016-01-20 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-21 06:20:00每日論壇發(fā)貼之星
日期:2016-01-21 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-23 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-31 06:20:00數(shù)據(jù)庫(kù)技術(shù)版塊每日發(fā)帖之星
日期:2016-01-16 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-16 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-14 06:20:00
2 [報(bào)告]
發(fā)表于 2016-02-18 15:09 |只看該作者
http://unix.stackexchange.com/qu ... e-no-effect-on-bash

If the shell is started with the effective user (group) id not equal to the real user (group) id, and the -p option is not supplied, no startup files are read, shell functions are not inherited from the environment, the SHELLOPTS, BASHOPTS, CDPATH, and GLOBIGNORE variables, if they appear in the environment, are ignored, and the effective user id is set to the real user id. If the -p option is supplied at invocation, the startup behavior is the same, but the effective user id is not reset.

論壇徽章:
84
每日論壇發(fā)貼之星
日期:2015-12-29 06:20:00每日論壇發(fā)貼之星
日期:2016-01-16 06:20:00每周論壇發(fā)貼之星
日期:2016-01-17 22:22:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-20 06:20:00每日論壇發(fā)貼之星
日期:2016-01-20 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-21 06:20:00每日論壇發(fā)貼之星
日期:2016-01-21 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-23 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-31 06:20:00數(shù)據(jù)庫(kù)技術(shù)版塊每日發(fā)帖之星
日期:2016-01-16 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-16 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-14 06:20:00
3 [報(bào)告]
發(fā)表于 2016-02-18 15:26 |只看該作者
  1. cat shell.c
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <unistd.h>
  5. #include <sys/types.h>

  6. // shell.c
  7. int main(){
  8.         char *name[2];
  9.         name[0] = "/usr/bin/id";
  10.         name[1] = 0x0;
  11.         printf("%d %d\n", getuid(), geteuid());
  12.         execve(name[0], name, 0x0);
  13.         exit(0);
  14. }
  15. $ ./shell
  16. 1000 0
  17. uid=1000(yjh) gid=1000(yjh) euid=0(root) groups=1000(yjh),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
復(fù)制代碼
看結(jié)果只是euid變了。

論壇徽章:
84
每日論壇發(fā)貼之星
日期:2015-12-29 06:20:00每日論壇發(fā)貼之星
日期:2016-01-16 06:20:00每周論壇發(fā)貼之星
日期:2016-01-17 22:22:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-20 06:20:00每日論壇發(fā)貼之星
日期:2016-01-20 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-21 06:20:00每日論壇發(fā)貼之星
日期:2016-01-21 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-23 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-31 06:20:00數(shù)據(jù)庫(kù)技術(shù)版塊每日發(fā)帖之星
日期:2016-01-16 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-16 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-14 06:20:00
4 [報(bào)告]
發(fā)表于 2016-02-18 15:28 |只看該作者
more clear info:

First and foremost, setuid bit simply allows a script to set the uid. The script still needs to call setuid() or setreuid() to run in the the real uid or effective uid respectively. Without calling setuid() or setreuid(), the script will still run as the user who invoked the script.

論壇徽章:
0
5 [報(bào)告]
發(fā)表于 2016-02-18 16:56 |只看該作者
回復(fù) 4# yjh777


You are right, thanks a lot.

Seems to be due to the security reason, the system and exec drop this privileges.
I add a invoking setuid(0) before the execve, and then I get the expected result.
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP