-2

I was doing the "bof" problem on http://pwnable.kr/play.php I downloaded the "bof" file. But when I use gdb, it says as follows:

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;
}
Evgeny Smirnov
  • 2,886
  • 1
  • 12
  • 22
Henry
  • 9
  • 1
  • 1
  • 3
  • Make sure `bof` doesn't contain DOS line endings (e.g. `dos2unix /path/to/bof`) then make sure you have execute permissions (`chmod +x /path/to/bof`). And if you are using "Linux" under Win10 WSL, the file **must be located within the WSL filesystem**. NTFS has no concept of Linux file permissions. Howerver, `/home/henry/Downloads/bof` looks to be under a normal Linux FHS location. – David C. Rankin Jan 15 '18 at 07:31

1 Answers1

3

It's the issue with your permissions. You currently don't have the permissions to execute the bof file.

To fix this, open the terminal and use the chmod command.

chmod +x /home/henry/Downloads/bof

This will give you the permission to execute the file. You can also use something like chmod 744 /path/to/file as an alternative. This will give you the permission to read, write, and execute on your account.

Check out linode documentation to know about file permissions.

Utkarsh Bhatt
  • 1,536
  • 2
  • 14
  • 23
  • but it showed "No such file or directory" after I used that method. – Henry Jan 15 '18 at 07:13
  • The generic command is `chmod +x /path/to/file`. You must modify `/path/to/file` depending on which directory you have that file. Are you sure you didn't mistype something? @Henry – Utkarsh Bhatt Jan 15 '18 at 07:15