Compiling (or maybe something else) from within a go application?

blov · 2018-03-19 13:30:13 · 667 次点击    
这是一个分享于 2018-03-19 13:30:13 的资源,其中的信息可能已经有所发展或是发生改变。

First off for some context, I am a sophomore in college looking to take a security track in computer science and I thought it would be a fun project to create a RAT in go. Taking inspiration from other RAT’s I noticed when you “build” the client executable you can add your own settings and what-not. How do they accomplish this? Are they compiling an executable from within their program or are they adding some sort of config file to an already compiled one?

Any tips on how to accomplish something like this? Thanks a ton!


评论:

pdffs:

You can set vars at build time like so:

package main
var buildTimeVar string

.

go build -ldflags "-X main.buildTimeVar='value'"
DevFolks:

I may have worded it poorly, but I mean I already have my “main” executable compiled but when I want to create the stub with custom settings from within my main executable, how would I go about adding those settings to the stub?

An example would be Quasar RAT’s “build” button.

outroot:

How I did this back in the day in C, is the server would have a global static char* variable that would have data like:

"---===--===START===--===---
port:12345
key1:value1
key2:value2
\0\0\0\0\0\0
---===--===END===--===---
"

Then in your server editor, it would open the binary, find that section, parse the values, and be able to save it to the same location. I had padding at the end to make sure it could hold larger values if the user put them in there. This was a basic way to do it and it's not very stealth.

In go, you can do something similar with a const byte slice, or maybe even appending a zip to the server that contains the configuration data in a file. The method is described here: https://github.com/golang/go/wiki/GcToolchainTricks#bundle-data-into-go-binary


入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

667 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传