当前位置:首页 > > 充电吧
[导读]首先从nebula开始,nebula设置了19个level,level00-level19,每一个level对应系统中的一个登陆账号,每一个level也对应home目录下的flag00-flag19这

首先从nebula开始,nebula设置了19个level,level00-level19,每一个level对应系统中的一个登陆账号,每一个level也对应home目录下的flag00-flag19这些账号。

一般来说如果你能用levelXX登陆,经过提权你的账号变成了flagXX,就表示你过关了。

下面会将每一个level的要求以及相关的代码列出来,我自己的解决办法和涉及到得知识点也会列出来,如果解决不了的那么会说明为什么解决不了。

level00

This level requires you to find a Set User ID program that will run as the "flag00" account. You could also find this by carefully looking in top level directories in / for suspicious looking directories.

Alternatively, look at the find man page.

To access this level, log in as level00 with the password of level00.

source code

There is no source code available for this level


首先用用户名level00 和 密码level00登陆nebula的测试系统。

根据题目的意思是查找一个二进制文件,可以用flag00这个账号来运行,并且设置了set-user-id位。你可以通过从根目录下挨个查找文件夹来找到,也可以通过find命令来查找。在这里肯定是通过find命令来查找。如果不懂的可以通过man find来查看find命令的使用方法。

首先我们应该明白什么是set-user-id 位,以及为什么要设置set-user-id位,设置了这个位之后我们能干什么,以及linux下Real UID,Effective UID和Saved UID之间的区别以及作用是什么。下面是从http://en.allexperts.com/q/Unix-Linux-OS-1064/real-effective-user-id.htm上找到的一个关于这三个UID的解说,相信已经相当明了了,如果还不懂,就去翻看APUE。

Each UNIX proces has 3 UIDs associated to it. Superuser privilege is UID=0.

Real UID
--------

This is the UID of the user/process that created THIS process. It can be changed only if the running process has EUID=0.

Effective UID
-------------

This UID is used to evaluate privileges of the process to perform a particular action. EUID can be change either to RUID, or SUID if EUID!=0. If EUID=0, it can be changed to anything.

Saved UID
---------

If the binary image file, that was launched has a Set-UID bit on, SUID will be the UID of the owner of the file. Otherwise, SUID will be the RUID.

What is the idea behind this?

Normal programs, like "ls", "cat", "echo" will be run by a normal user, under that users UID. Special programs that allow user to have controlled access to protected data, can have Set-UID bit to allow the program to be run under privileged UID.

An example of such program is "passwd". If you list it in full, you will see that it has Set-UID bit and the owner is "root". When a normal user, say "ananta", runs "passwd", passwd starts with:

Real-UID = ananta
Effective-UID = ananta
Saved-UID = root

The the program calls a system call "seteuid( 0 )" and since SUID=0, the call will succede and the UIDs will be:

Real-UID = ananta
Effective-UID = root
Saved-UID = root

After that, "passwd" process will be able to access /etc/passwd and change password for user "ananta". Note that user "ananta" cannot write to /etc/passwd on it's own. Note one other thing, setting a Set-UID on a executable file is not enough to make it run as privileged process. The program itself must make a system call.

下面的信息来自http://www.zzee.com/solutions/linux-permissions.shtml#setuid

set user id, set group id ,sticky id

In addition to the basic permissions discussed above, there are also threebits of information defined for files in Linux:

SUID or setuid: change user ID on execution. If setuid bit is set, when the file will be executed by a user, the process will have the same rights as the owner of the file being executed.SGID or setgid: change group ID on execution. Same as above, but inherits rights of the group of the owner of the file on execution. For directories it also may mean that when a new file is created in the directory it will inherit the group of the directory (and not of the user who created the file).Sticky bit. It was used to trigger process to "stick" in memory after it is finished, now this usage is obsolete. Currently its use is system dependant and it is mostly used to suppress deletion of the files that belong to other users in the folder where you have "write" access to.

Octal digit Binary value Meaning 0 000 setuid, setgid, sticky bits are cleared 1 001 sticky bit is set 2 010 setgid bit is set 3 011 setgid and sticky bits are set 4 100 setuid bit is set 5 101 setuid and sticky bits are set 6 110 setuid and setgid bits are set 7 111 setuid, setgid, sticky bits are set SUID If set, then replaces "x" in the owner permissions to "s", if owner has execute permissions, or to "S" otherwise. Examples:
-rws------ both owner execute and SUID are set
-r-S------ SUID is set, but owner execute is not set SGID If set, then replaces "x" in the group permissions to "s", if group has execute permissions, or to "S" otherwise. Examples:
-rwxrws--- both group execute and SGID are set
-rwxr-S--- SGID is set, but group execute is not set Sticky If set, then replaces "x" in the others permissions to "t", if others have execute permissions, or to "T" otherwise. Examples:
-rwxrwxrwt both others execute and sticky bit are set
-rwxrwxr-T sticky bit is set, but others execute is not set

具有root权限的用户赋予程序setuid特权的两种方法:

sudo chmod 4755 myprog

sudo chmod u+s myprog2

ls -l my*

输出:

-rwsr-xr-x 1root  other    24152  Apr 29 16:30  myprog

-rwsr-xr-x 1root  other    24152  Apr 29 16:30  myprog2


好的,下面就使用find命令来查找这个文件。

在终端下运行 find / -perm -4000 -type f -user flag00 -ls


我们会看到打印出来一个/bin/.../flag00的可执行文件。

运行这个可执行文件,然后再运行getflag命令。

如果屏幕上打印出

you have successfully executed getflag on a target account

那么就说明level00已经顺利过关了。

个人感觉:level00算是最基本最简单了,但是用到的知识点却很多,也可以从中学到不少的东西,一定要彻底弄明白这三个UID以及linux file的权限和permission flag的关系,否则后面的level将寸步难行。

本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除。
换一批
延伸阅读

LED驱动电源的输入包括高压工频交流(即市电)、低压直流、高压直流、低压高频交流(如电子变压器的输出)等。

关键字: 驱动电源

在工业自动化蓬勃发展的当下,工业电机作为核心动力设备,其驱动电源的性能直接关系到整个系统的稳定性和可靠性。其中,反电动势抑制与过流保护是驱动电源设计中至关重要的两个环节,集成化方案的设计成为提升电机驱动性能的关键。

关键字: 工业电机 驱动电源

LED 驱动电源作为 LED 照明系统的 “心脏”,其稳定性直接决定了整个照明设备的使用寿命。然而,在实际应用中,LED 驱动电源易损坏的问题却十分常见,不仅增加了维护成本,还影响了用户体验。要解决这一问题,需从设计、生...

关键字: 驱动电源 照明系统 散热

根据LED驱动电源的公式,电感内电流波动大小和电感值成反比,输出纹波和输出电容值成反比。所以加大电感值和输出电容值可以减小纹波。

关键字: LED 设计 驱动电源

电动汽车(EV)作为新能源汽车的重要代表,正逐渐成为全球汽车产业的重要发展方向。电动汽车的核心技术之一是电机驱动控制系统,而绝缘栅双极型晶体管(IGBT)作为电机驱动系统中的关键元件,其性能直接影响到电动汽车的动力性能和...

关键字: 电动汽车 新能源 驱动电源

在现代城市建设中,街道及停车场照明作为基础设施的重要组成部分,其质量和效率直接关系到城市的公共安全、居民生活质量和能源利用效率。随着科技的进步,高亮度白光发光二极管(LED)因其独特的优势逐渐取代传统光源,成为大功率区域...

关键字: 发光二极管 驱动电源 LED

LED通用照明设计工程师会遇到许多挑战,如功率密度、功率因数校正(PFC)、空间受限和可靠性等。

关键字: LED 驱动电源 功率因数校正

在LED照明技术日益普及的今天,LED驱动电源的电磁干扰(EMI)问题成为了一个不可忽视的挑战。电磁干扰不仅会影响LED灯具的正常工作,还可能对周围电子设备造成不利影响,甚至引发系统故障。因此,采取有效的硬件措施来解决L...

关键字: LED照明技术 电磁干扰 驱动电源

开关电源具有效率高的特性,而且开关电源的变压器体积比串联稳压型电源的要小得多,电源电路比较整洁,整机重量也有所下降,所以,现在的LED驱动电源

关键字: LED 驱动电源 开关电源

LED驱动电源是把电源供应转换为特定的电压电流以驱动LED发光的电压转换器,通常情况下:LED驱动电源的输入包括高压工频交流(即市电)、低压直流、高压直流、低压高频交流(如电子变压器的输出)等。

关键字: LED 隧道灯 驱动电源
关闭