【问题标题】:Bash permission denied on Linux [duplicate]Linux上的Bash权限被拒绝[重复]
【发布时间】:2018-06-23 19:20:05
【问题描述】:

我在http://pwnable.kr/play.php 上做“bof”问题 我下载了“bof”文件。但是当我使用gdb时,它是这样说的:

Starting program: /home/henry/Downloads/bof 
/bin/bash: /home/henry/Downloads/bof: Permission denied
/bin/bash: line 0: exec: /home/henry/Downloads/bof: cannot execute: Permission denied
During startup program exited with code 126.

bof.c:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void func(int key){
    char overflowme[32];
    printf("overflow me : ");
    gets(overflowme);   // smash me!
    if(key == 0xcafebabe){
        system("/bin/sh");
    }
    else{
        printf("Nah..\n");
    }
}
int main(int argc, char* argv[]){
    func(0xdeadbeef);
    return 0;
}

【问题讨论】:

  • 确保bof 不包含DOS 行尾(例如dos2unix /path/to/bof),然后确保您有执行权限(chmod +x /path/to/bof)。如果您在 Win10 WSL 下使用“Linux”,文件必须位于 WSL 文件系统中。 NTFS 没有 Linux 文件权限的概念。但是,/home/henry/Downloads/bof 看起来位于正常的 Linux FHS 位置。

标签: c bash ubuntu


【解决方案1】:

这是您的权限的问题。您目前没有执行 bof 文件的权限。

要解决此问题,请打开终端并使用chmod 命令。

chmod +x /home/henry/Downloads/bof

这将授予您执行文件的权限。您也可以使用 chmod 744 /path/to/file 之类的东西作为替代方案。这将授予您在您的帐户上读取、写入和执行的权限。

查看 linode 文档以了解 file permissions

【讨论】:

  • 但我使用该方法后显示“没有这样的文件或目录”。
  • 通用命令是chmod +x /path/to/file。您必须修改/path/to/file,具体取决于您拥有该文件的目录。你确定你没有打错什么? @亨利
猜你喜欢
  • 2023-04-03
  • 2021-12-11
  • 2016-02-27
  • 2021-12-31
  • 1970-01-01
  • 2021-10-08
  • 2016-01-15
  • 2011-08-20
  • 2014-06-21
相关资源
最近更新 更多