首页 > 解决方案 > 读取系统文件

问题描述

所以,我不得不在 linux 上读取系统文件(主机名和其他)并得到有趣的结果。我尝试以普通用户身份读取文件并得到加密结果,如果我以超级用户身份读取文件,我得到正常结果。

我了解,这是安全性,但我在哪里可以找到有关 Linux 操作系统安全性的更多信息?官方资源可取。谢谢你的答案。我使用 ubuntu 18.04 x64。

另外,请附上有关 OS Linux(功能)安全性的更多信息。开发人员需要的信息。我通过 nasm 汇编编写代码。

global _start

section .data
file db "/proc/sys/kernel/hostname",0

section .bss
buf resb 1024
descriptor resb 4
len equ 1024


section .text
_start:

    mov eax, 5
    mov ebx, file
    mov ecx, 2
    int 80h
    mov [descriptor], eax

read:
    mov eax, 3  ;read text
    mov ebx, [descriptor];  
    mov ecx, buf    ;read to variable buf
    mov edx, len    ;size of bug
    int 80h     ;interrupt

print_text:
    mov edx, eax
    mov eax, 4
    mov ebx, 1
    mov ecx, buf
    int 80h

close_file:
    mov eax, 6
    mov ebx, [descriptor]
    int 80h

exit:
    mov eax, 1
    mov ebx, 0
    int 80h

例如,如果我在没有管理员权限的情况下执行代码,我会得到

����

如果以超级用户身份执行,我会得到

oleg

因此,当我阅读其他文件(osrelease、版本和其他)时,我得到空结果。我想明白,为什么会这样?

标签: linuxassembly

解决方案


推荐阅读