浸透测验中的Node.js——使用C++插件躲藏实在代码

访客5年前黑客文章1144

在之前的文章《浸透测验中的Node.js——Downloader的完成》开源了一个运用Node.js完成Downloader的代码,扼要剖析在浸透测验中的运用思路。
Node.js的语法简略易懂,所以Node.js代码也很简略被剖析。
为了增加Node.js代码被剖析的难度,我的思路是运用Node.js的一个功用,将payload以C++插件的方式进行封装。
这样不光能够增加Node.js代码被剖析的难度,并且能够用C++代码来完成payload,已有的C++代码经过简略的修正即可运用,减小二次开发的本钱。
0x01 简介
本文即将介绍以下内容:
· C++插件简介
· 建立C++插件的开发环境
· C++插件代码实例
· 运用思路
· 防护主张
0x02 C++插件简介
Node.js C++插件是用C++编写的动态链接库,能够运用require()函数加载到Node.js中。运用V8供给的API,能够完成JavaScript和C++的相互调用,打通JavaScript和C++之间的接口。
官方文档:
https://nodejs.org/api/addons.html
运用实例:
1.编译成功一个C++插件,导出办法为:hello
2.运用Node.js调用C++插件导出办法的代码如下:
const addon = require('./addon.node');
addon.hello();
3.履行代码
node.exe test.js
0x03 建立C++插件的开发环境
1、Windows开发环境
测验体系:Win7sp1 x64
需求装置以下东西:
· .NET Framework 4.5.1或更高版别
· Python 2.7
· Visual Studio 2019或更高版别
详细建立流程如下:
1.装置.NET Framework 4.5.1
https://www.microsoft.com/en-US/download/details.aspx?id=5842
2.下载Node.js
https://nodejs.org/en/download/
3.运用Windows-Build-Tools主动装置依靠东西
https://github.com/felixrieseberg/windows-build-tools
cd c:
powershell
npm install --global windows-build-tools
假如装置失利,可选择手动装置以下东西:
· Python 2.7
· Visual Studio 2019或更高版别
4.装置node-gyp
https://github.com/nodejs/node-gyp
npm install -g node-gyp
2、Linux开发环境
wget https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-x64.tar.xz
tar xf node-v10.15.3-linux-x64.tar.xz
cd node-v10.15.3-linux-x64
cd bin
export PATH=/root/node-v10.15.3-linux-x64/bin:$PATH
./npm install -g node-gyp
注:需求增加环境变量指定node的方位(export PATH=/root/node-v10.15.3-linux-x64/bin:$PATH),否则在履行npm install会失利,提示/usr/bin/env: ‘node’: No such file or directory
实例演示:
1.hello.cc:
#include
namespace demo {
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::NewStringType;
using v8::Object;
using v8::String;
using v8::Value;
void Method(const FunctionCallbackInfo& args) {
  Isolate* isolate = args.GetIsolate();
  args.GetReturnValue().Set(String::NewFromUtf8(
      isolate, "world", NewStringType::kNormal).ToLocalChecked());
}
void Initialize(Local exports) {
  NODE_SET_METHOD(exports, "hello", Method);
}
NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize)
}  // namespace demo
2.binding.gyp
{
  "targets": [
    {
      "target_name": "addon",
      "sources": [ "hello.cc" ]
    }
  ]
}
3.经过node-gyp编译,生成插件
node-gyp configure
node-gyp build
注:能够合并成一条指令:
node-gyp configure build
Node.js支撑穿插编译,详细参数阐明可参阅:
https://www.npmjs.com/package/node-pre-gyp
Linux体系下生成Windows64位体系下运用的插件指令如下:
node-gyp configure build --target_arch=x64 --target_platform=win32
0x04 C++插件代码实例
在开发时,更好防止呈现if这种的条件判别句子,直接运用会导致编译过错。
1. 开释文件
#include
#include
namespace demo {
 using v8::FunctionCallbackInfo;
 using v8::Isolate;
 using v8::Local;
 using v8::Object;
 using v8::String;
 using v8::Value;
 void Method(const FunctionCallbackInfo& args) {
  FILE* fp;
  fopen_s(&fp, "new.txt", "ab+");
  char *buf = "123456";
  fwrite(buf, strlen(buf), 1, fp);
  fseek(fp, 0, SEEK_END);
  fclose(fp);
 }
 void init(Local exports) {
  NODE_SET_METHOD(exports, "hello", Method);
 }
 NODE_MODULE(NODE_GYP_MODULE_NAME, init)
}
2. 履行指令:
#include
namespace demo {
 using v8::FunctionCallbackInfo;
 using v8::Isolate;
 using v8::Local;
 using v8::Object;
 using v8::String;
 using v8::Value;
 void Method(const FunctionCallbackInfo& args) {
  system("powershell start calc.exe");
 }
 void init(Local exports) {
  NODE_SET_METHOD(exports, "hello", Method);
 }

[1] [2]  黑客接单网

相关文章

黑客接单是真的_编程如何入门

可是关于那些需求在低等级状况下运转并期望代码尽或许快的用户来说,ArrayBuffers和SharedArrayBuffers则是一个比较好的挑选。 };在咱们的形象里,“猫池”一般只能运用自身的号码...

微信永久封号怎么解除,靠谱点的黑客到那里找,我的世界动画黑客找him

+--------------------------------------------------------------+import time 得到了列名为admin 别的一个是passwor...

学信档案,黑客怎么找别人的照片,主角是黑客专门找游戏bug的网游

BurpSuite东西箱 /// <param name="connection"></param>1.3 中心代码的躲藏cat ./-inurl:help.as...

免费黑客接单网,广州黑客在哪里找,怎么在qq上找黑客

进一步剖析手机经过装备署理将数据发送到Burp Suite剖析cpe:/a:cisco:adaptive_security_appliance_software:9.0.21.msfpayload生成...

163邮箱下载安装,找黑客如何查看微信聊天记录,找黑客帮忙 黑一个手机

图1 进犯者发帖比方一个标题是将flag藏在后台管理员暗码方位,那么你能够用0x02里说的法办法,这样防备搅屎棍:43 |_ ERROR: No username or password was...

诈骗举报,哪里可以找电脑黑客,怎么进暗网找黑客

/head>JIT 处理操作依据 .NET 版别不同,别离坐落 clrjit.dll 或许 mscorjit.dll 中,其间完成了一个名为getJit回来 ICorJitCompiler。...