1

我有这个简单的代码测试代码:

#include <Windows.h>
#include <stdio.h>

/* Declare new sections to store encrypted code and shellcode data */
#pragma section(".code", execute, read, write)
#pragma comment(linker,"/SECTION:.code,ERW")

// From here executable code will go in .code section
#pragma code_seg(".code")


int test()
{
    printf("prova");
    return 0;
}

// .stub SECTION
#pragma section(".stub", execute, read, write)
#pragma code_seg(".stub")

int main(int argc, char *argv[]){
    test(); /* Call function which executes shellcode now that it is decrypted */
    return 0;
}

谁能告诉我为什么如果我转储这个文件我只得到这个默认部分:

  • 。数据
  • .rdata
  • .reloc
  • .rsrc
  • 。存根
  • 。文本

它没有生成的 .code 段。我想我曾经在一些以前的项目中这样做过,我做错了什么吗?

-- 进一步测试 --

  • 转储.obj文件.code部分显示。
  • .stub显示倾销.exe.obj
  • 删除#pragma comment(linker,"/SECTION:.code,ERW")不起作用
  • 添加#pragma comment(linker,"/SECTION:.stub,ERW")并没有改变dumpbin结果.exe.stub仍然显示
  • 将名称从 更改.code.somethingelse也不起作用,结果相同
4

1 回答 1

0

使用以下指令,我能够将所有代码/变量/成本限制在.code使用 dubin 命令可见的段中。

#pragma section(".code", execute, read)
#pragma section(".codedata", read, write)
#pragma comment(linker,"/SECTION:.code,ERW")
#pragma comment(linker,"/SECTION:.codedata,ERW")
#pragma comment(linker, "/MERGE:.codedata=.code")

#pragma code_seg(".code")
#pragma data_seg(".codedata")
#pragma const_seg(".codedata")
于 2018-09-12T17:25:14.253 回答