mirror of
https://github.com/luzhisheng/js_reverse.git
synced 2025-04-21 21:10:21 +08:00
zy-补环境框架-实现-window补环境
This commit is contained in:
parent
71808525cb
commit
d01ecdf3b0
40
志远js逆向学习/zy-补环境框架-实现-window补环境/CatVm2/catvm2.node.js
Normal file
40
志远js逆向学习/zy-补环境框架-实现-window补环境/CatVm2/catvm2.node.js
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import fs from 'fs'
|
||||||
|
|
||||||
|
// 框架的工具模块
|
||||||
|
import vmtools from './tools/node.js'
|
||||||
|
import htmlElements from './browser/HTMLElements/htmlElements.node.js'
|
||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
|
export default function GetCode(config,fun_text){
|
||||||
|
let code = ''
|
||||||
|
// 引入框架的工具代码
|
||||||
|
code += vmtools() +'\r\n'
|
||||||
|
|
||||||
|
// 引入用户框架配置
|
||||||
|
for (let item in config) {
|
||||||
|
code += 'catvm.memory.config.' + item + '=' + config[item] + '\r\n'
|
||||||
|
}
|
||||||
|
|
||||||
|
// 引入浏览器相关,引入尽量按浏览器顺序执行
|
||||||
|
code += fs.readFileSync(`${__dirname}/browser/eventTarget.js`) + '\r\n'
|
||||||
|
code += fs.readFileSync(`${__dirname}/browser/windowProperties.js`) + '\r\n'
|
||||||
|
code += fs.readFileSync(`${__dirname}/browser/window.js`) + '\r\n'
|
||||||
|
code += fs.readFileSync(`${__dirname}/browser/location.js`) + '\r\n'
|
||||||
|
code += fs.readFileSync(`${__dirname}/browser/navigator.js`) + '\r\n'
|
||||||
|
code += fs.readFileSync(`${__dirname}/browser/history.js`) + '\r\n'
|
||||||
|
code += fs.readFileSync(`${__dirname}/browser/screen.js`) + '\r\n'
|
||||||
|
code += fs.readFileSync(`${__dirname}/browser/storage.js`) + '\r\n'
|
||||||
|
code += fs.readFileSync(`${__dirname}/browser/mimeType.js`) + '\r\n'
|
||||||
|
code += fs.readFileSync(`${__dirname}/browser/plugin.js`) + '\r\n'
|
||||||
|
code += fs.readFileSync(`${__dirname}/browser/pluginArray.js`) + '\r\n'
|
||||||
|
code += fs.readFileSync(`${__dirname}/browser/mimeTypeArray.js`) + '\r\n'
|
||||||
|
code += htmlElements() + '\r\n'
|
||||||
|
code += fs.readFileSync(`${__dirname}/browser/document.js`) + '\r\n'
|
||||||
|
|
||||||
|
// 引入用户自定义环境
|
||||||
|
code += 'debugger;\r\n'
|
||||||
|
return code
|
||||||
|
}
|
9
志远js逆向学习/zy-补环境框架-实现-window补环境/CatVm2/tools/memory.js
Normal file
9
志远js逆向学习/zy-补环境框架-实现-window补环境/CatVm2/tools/memory.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
global.catvm = {}
|
||||||
|
|
||||||
|
// 框架运行内存
|
||||||
|
catvm.memory = {
|
||||||
|
config: {print: false, proxy: false},
|
||||||
|
}
|
||||||
|
catvm.memory.htmlElements = {}
|
||||||
|
catvm.memory.listeners = {}
|
||||||
|
catvm.memory.PluginArray = {}
|
15
志远js逆向学习/zy-补环境框架-实现-window补环境/CatVm2/tools/node.js
Normal file
15
志远js逆向学习/zy-补环境框架-实现-window补环境/CatVm2/tools/node.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
|
export default function GetCode(){
|
||||||
|
let code = ''
|
||||||
|
code += fs.readFileSync(`${__dirname}/memory.js`) + '\r\n'
|
||||||
|
code += fs.readFileSync(`${__dirname}/safefunction.js`) + '\r\n'
|
||||||
|
code += fs.readFileSync(`${__dirname}/print.js`) + '\r\n'
|
||||||
|
code += fs.readFileSync(`${__dirname}/proxy.js`) + '\r\n'
|
||||||
|
|
||||||
|
return code
|
||||||
|
}
|
15
志远js逆向学习/zy-补环境框架-实现-window补环境/CatVm2/tools/print.js
Normal file
15
志远js逆向学习/zy-补环境框架-实现-window补环境/CatVm2/tools/print.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// 框架日志功能
|
||||||
|
catvm.print = {}
|
||||||
|
catvm.memory.print = []
|
||||||
|
|
||||||
|
// 是否输出日志
|
||||||
|
catvm.print.log = function(){
|
||||||
|
if (catvm.memory.config.print){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获得所有日志
|
||||||
|
catvm.print.getall = function(){
|
||||||
|
|
||||||
|
}
|
22
志远js逆向学习/zy-补环境框架-实现-window补环境/CatVm2/tools/proxy.js
Normal file
22
志远js逆向学习/zy-补环境框架-实现-window补环境/CatVm2/tools/proxy.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 框架代理功能
|
||||||
|
catvm.proxy = function(o){
|
||||||
|
if(catvm.memory.config.proxy == false){return o}
|
||||||
|
return new Proxy(o,{
|
||||||
|
set(target,key,value)
|
||||||
|
{
|
||||||
|
console.log('set',target,key,value);
|
||||||
|
return Reflect.set(...arguments);
|
||||||
|
},
|
||||||
|
get(target,key,receiver)
|
||||||
|
{
|
||||||
|
console.log('get',target,key,target[key]);
|
||||||
|
return target[key];
|
||||||
|
},
|
||||||
|
deleteProperty:function(target,key){
|
||||||
|
console.log('delete',target,key);
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
27
志远js逆向学习/zy-补环境框架-实现-window补环境/CatVm2/tools/safefunction.js
Normal file
27
志远js逆向学习/zy-补环境框架-实现-window补环境/CatVm2/tools/safefunction.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
// 补环境的自定义方法,通过toString方法被检测
|
||||||
|
;(() => {
|
||||||
|
'use strict';
|
||||||
|
const $toString = Function.toString
|
||||||
|
const myFunction_toString_symbol = Symbol('('.concat('', ')_', (Math.random() + '').toString(36)))
|
||||||
|
const myToString = function () {
|
||||||
|
return typeof this == 'function' && this[myFunction_toString_symbol] || $toString.call(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_native(func, key, value) {
|
||||||
|
Object.defineProperty(func, key, {
|
||||||
|
"enumerable": false,
|
||||||
|
'configurable': true,
|
||||||
|
'writable': true,
|
||||||
|
'value': value
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
delete Function.prototype['toString'];// 删除原型链上的toString
|
||||||
|
set_native(Function.prototype, 'toString', myToString);// 自己定义一个getter方法
|
||||||
|
// 套娃给 toString 方法设置一个 toString
|
||||||
|
set_native(Function.prototype.toString, myFunction_toString_symbol, 'function toString(){ [native code] }')
|
||||||
|
this.catvm.safefunction = (func) => {
|
||||||
|
set_native(func, myFunction_toString_symbol, `function ${myFunction_toString_symbol, func.name || ''}() { [native code] }`)
|
||||||
|
}
|
||||||
|
}).call(this);
|
5
志远js逆向学习/zy-补环境框架-实现-window补环境/CatVm2/tools/tools.js
Normal file
5
志远js逆向学习/zy-补环境框架-实现-window补环境/CatVm2/tools/tools.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
//更改浏览器某些参数
|
||||||
|
|
||||||
|
catvm.AddPlugin = function(data){
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user