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

blov · · 476 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>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?</p> <p>Any tips on how to accomplish something like this? Thanks a ton! </p> <hr/>**评论:**<br/><br/>pdffs: <pre><p>You can set vars at build time like so:</p> <pre><code>package main var buildTimeVar string </code></pre> <p>.</p> <pre><code>go build -ldflags &#34;-X main.buildTimeVar=&#39;value&#39;&#34; </code></pre></pre>DevFolks: <pre><p>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? </p> <p>An example would be Quasar RAT’s “build” button. </p></pre>outroot: <pre><p>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:</p> <pre><code>&#34;---===--===START===--===--- port:12345 key1:value1 key2:value2 \0\0\0\0\0\0 ---===--===END===--===--- &#34; </code></pre> <p>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&#39;s not very stealth.</p> <p>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: <a href="https://github.com/golang/go/wiki/GcToolchainTricks#bundle-data-into-go-binary" rel="nofollow">https://github.com/golang/go/wiki/GcToolchainTricks#bundle-data-into-go-binary</a></p></pre>

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

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