Commit 2e2c8da8 authored by wangmingming's avatar wangmingming

7777

parent 954d1d03
This diff is collapsed.
var _random = Math.random
var v_saf;
!function () {
var n = Function.toString, t = [], i = [], o = [].indexOf.bind(t), e = [].push.bind(t), r = [].push.bind(i);
......@@ -52,8 +54,8 @@ print = console.log
dtavm.log = console.log
con3 = console.log
con4 = console.log
// con3 = function (){}
// con4 = function (){}
con3 = function (){}
con4 = function (){}
......@@ -720,39 +722,7 @@ requestAnimationFrame = v_saf(function requestAnimationFrame() {
})
File = v_saf(function File() {
})
webkitRTCPeerConnection = v_saf(function webkitRTCPeerConnection() {
;
});
_inherits(webkitRTCPeerConnection, EventTarget)
Object.defineProperties(webkitRTCPeerConnection.prototype, {
onicecandidate: {
set() {
print(" [*] webkitRTCPeerConnection -> onicecandidate[set]", [].slice.call(arguments));
}
},
createDataChannel: {
value: v_saf(function createDataChannel() {
print(" [*] webkitRTCPeerConnection -> createDataChannel[func]", [].slice.call(arguments));
})
},
createOffer: {
value: v_saf(function createOffer() {
print(" [*] webkitRTCPeerConnection -> createOffer[func]", [].slice.call(arguments));
})
},
setLocalDescription: {
value: v_saf(function setLocalDescription() {
print(" [*] webkitRTCPeerConnection -> setLocalDescription[func]", [].slice.call(arguments));
})
},
[Symbol.toStringTag]: {value: "webkitRTCPeerConnection", writable: false, enumerable: false, configurable: true},
})
RTCPeerConnection = v_saf(function RTCPeerConnection() {
;
});
_inherits(RTCPeerConnection, EventTarget)
RTCDataChannel = v_saf(function RTCDataChannel() {
;
});
......@@ -3619,34 +3589,37 @@ Object.defineProperties(Image.prototype, {
[Symbol.toStringTag]: {value: "Image", writable: false, enumerable: false, configurable: true},
})
publicDescription = undefined;
class RTCPeerConnection {
constructor(args) {
console.log('RTCPeerConnection.new', args)
}
}
Object.defineProperties(RTCPeerConnection.prototype, {
localDescription: {
value: {
get: v_saf(function get() {
print('get localDescription')
return publicDescription
})
return this._publicDescription
}),
set: function (arg) {
this._publicDescription = arg
}
}
},
onicecandidate: {
set() {
print(" [*] RTCPeerConnection -> onicecandidate[set]", [].slice.call(arguments));
this._onicecandidate = arguments[0]
}
},
createDataChannel: {
value: v_saf(function createDataChannel(label, option) {
print(" [*] RTCPeerConnection -> createDataChannel[func]", [].slice.call(arguments));
return {
'onopen': function onopen() {
print(" [*] RTCPeerConnection -> createDataChannel[func] onopen", [].slice.call(arguments));
},
'onmessage': function onmessage() {
print(" [*] RTCPeerConnection -> createDataChannel[func] onmessage", [].slice.call(arguments));
},
}
let res = new RTCDataChannel(label);
return proxy(res, 'dataChannel')
})
},
createOffer: {
......@@ -3654,18 +3627,22 @@ Object.defineProperties(RTCPeerConnection.prototype, {
print(" [*] RTCPeerConnection -> createOffer[func]", [].slice.call(arguments));
let p = new Promise(function (resolve, reject) {
// 2. 执行异步操作任务
print('RTCPeerConnection createOffer');
let res = v_new(RTCSessionDescription)
res.sdp = RTCSessionDescription.prototype.sdp
res.type = RTCSessionDescription.prototype.type
resolve(res)
print('RTCPeerConnection createOffer', resolve, reject);
let res = new RTCSessionDescription()
// resolve(proxy(res, 'newRTCSessionDescription'))
resolve({
then: function (arg1, arg2) {
arg1(proxy(res, 'newRTCSessionDescription'))
arg2(proxy(res, 'newRTCSessionDescription'))
}
})
})
return p;
// return {
// then: function (func, func2) {
// v_console_log(" [*] RTCPeerConnection -> createOffer[func] then", [].slice.call(arguments));
// // func2(v_new(RTCSessionDescription));
// // func(v_new(RTCSessionDescription));
// func2(v_new(RTCSessionDescription));
// func(v_new(RTCSessionDescription));
// return func(v_new(RTCSessionDescription));
// }, catch: function () {
// }
......@@ -3674,27 +3651,26 @@ Object.defineProperties(RTCPeerConnection.prototype, {
},
setLocalDescription: {
value: v_saf(function setLocalDescription() {
// print(" [*] RTCPeerConnection -> setLocalDescription[func]", [].slice.call(arguments));
var _this = this;
print(" [*] RTCPeerConnection -> setLocalDescription[func]", [].slice.call(arguments));
_this._onicecandidate(new RTCPeerConnectionIceEvent())
this.localDescription = arguments[0]
_this._onicecandidate(this.localDescription)
let p = new Promise(function (resolve, reject) {
// 2. 执行异步操作任务
// let res = this.setLocalDescription(v_new(RTCSessionDescription))
// console.log('RTCPeerConnection create',res);
_this._onicecandidate(new RTCPeerConnectionIceEvent())
print(" [*] RTCPeerConnection -> setLocalDescription[func] then", [].slice.call(arguments));
publicDescription = arguments[0]
// window.debug = true
resolve(publicDescription)
resolve(new RTCSessionDescription())
// return res
})
return p;
// return {
// then: function (func, func2) {
// print(" [*] RTCPeerConnection -> setLocalDescription[func] then", [].slice.call(arguments));
//
// return this
// }, catch: function () {
// }
// }
})
}),
enumerable: true,
configurable: true
},
[Symbol.toStringTag]: {value: "RTCPeerConnection", writable: false, enumerable: false, configurable: true},
})
......@@ -3763,14 +3739,52 @@ Object.defineProperties(WebSocket.prototype, {
CLOSED: {"value": 3, "writable": false, "enumerable": true, "configurable": false},
[Symbol.toStringTag]: {value: "WebSocket", writable: false, enumerable: false, configurable: true},
})
let t1 = parseInt(_random() * 2430043322 / 2 + 1430043322);
let t2 = parseInt(_random() * 2430043322 / 2 + 1430043322);
let t3 = parseInt(_random() * 5000 + 60199);
let ip = `192.168.${parseInt(_random() * 150 + 1)}.${parseInt(_random() * 150 + 1)}`
function guid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = _random() * 16 | 0,
v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
var candidateGetTimes = 0;
Object.defineProperties(RTCPeerConnectionIceEvent.prototype, {
candidate: {
get() {
v_console_log(" [*] RTCPeerConnectionIceEvent -> candidate[get]", {});
return {}
}
get: function () {
let res = `candidate:${t1} 1 udp ${t2} ${guid()}.local ${t3} typ host generation 0 ufrag MiWK network-cost 999`
res = `candidate:${t1} 1 udp ${t2} ${ip} ${t3} typ host generation 0 ufrag 5M7j network-id 1`
// res = `candidate:${t1} 1 tcp ${t2} ${ip} 9 typ host tcptype active generation 0 ufrag ZZHV network-id 1`
// res = 'candidate:2594513701 1 udp 2122260223 192.168.50.235 54336 typ host generation 0 ufrag 5M7j network-id 1 '
// res = 'candidate:1678768049 1 tcp 1518280447 192.168.50.235 9 typ host tcptype active generation 0 ufrag 5M7j network-id 1 '
console.log('RTCPeerConnectionIceEvent.candidate.get', res)
let rrr = proxy(new RTCIceCandidate(
ip, res, "rtp", t1, t2, t3, 'tcp', null, null, 0, "0", 'active', 'host', '5M7j'
), 'candidate[new]');
candidateGetTimes++
if (candidateGetTimes > 3) {
rrr.candidate = null
// return null
}
return rrr;
},
enumerable: true, configurable: true
},
type: {
value: 'icecandidate'
},
isTrusted: {
value: true,
},
[Symbol.toStringTag]: {value: "RTCPeerConnectionIceEvent", writable: false, enumerable: false, configurable: true},
})
Object.defineProperties(MessageEvent.prototype, {
data: {
......@@ -5712,8 +5726,7 @@ window.Document = Document;
window.DOMException = DOMException;
window.DOMMatrixReadOnly = DOMMatrixReadOnly;
window.RTCPeerConnection = RTCPeerConnection;
window.webkitRTCPeerConnection = webkitRTCPeerConnection;
window.mozRTCPeerConnection = mozRTCPeerConnection;
window.webkitRTCPeerConnection = RTCPeerConnection;
window.DOMParser = DOMParser;
window.FileReader = FileReader;
window.FormData = FormData;
......@@ -5977,3 +5990,4 @@ let reProxy = function (tt, name) {
};
No preview for this file type
var _random = Math.random
var v_saf;
!function () {
var n = Function.toString, t = [], i = [], o = [].indexOf.bind(t), e = [].push.bind(t), r = [].push.bind(i);
......@@ -52,8 +54,8 @@ print = console.log
dtavm.log = console.log
con3 = console.log
con4 = console.log
// con3 = function (){}
// con4 = function (){}
con3 = function (){}
con4 = function (){}
......@@ -720,39 +722,7 @@ requestAnimationFrame = v_saf(function requestAnimationFrame() {
})
File = v_saf(function File() {
})
webkitRTCPeerConnection = v_saf(function webkitRTCPeerConnection() {
;
});
_inherits(webkitRTCPeerConnection, EventTarget)
Object.defineProperties(webkitRTCPeerConnection.prototype, {
onicecandidate: {
set() {
print(" [*] webkitRTCPeerConnection -> onicecandidate[set]", [].slice.call(arguments));
}
},
createDataChannel: {
value: v_saf(function createDataChannel() {
print(" [*] webkitRTCPeerConnection -> createDataChannel[func]", [].slice.call(arguments));
})
},
createOffer: {
value: v_saf(function createOffer() {
print(" [*] webkitRTCPeerConnection -> createOffer[func]", [].slice.call(arguments));
})
},
setLocalDescription: {
value: v_saf(function setLocalDescription() {
print(" [*] webkitRTCPeerConnection -> setLocalDescription[func]", [].slice.call(arguments));
})
},
[Symbol.toStringTag]: {value: "webkitRTCPeerConnection", writable: false, enumerable: false, configurable: true},
})
RTCPeerConnection = v_saf(function RTCPeerConnection() {
;
});
_inherits(RTCPeerConnection, EventTarget)
RTCDataChannel = v_saf(function RTCDataChannel() {
;
});
......@@ -3619,34 +3589,37 @@ Object.defineProperties(Image.prototype, {
[Symbol.toStringTag]: {value: "Image", writable: false, enumerable: false, configurable: true},
})
publicDescription = undefined;
class RTCPeerConnection {
constructor(args) {
console.log('RTCPeerConnection.new', args)
}
}
Object.defineProperties(RTCPeerConnection.prototype, {
localDescription: {
value: {
get: v_saf(function get() {
print('get localDescription')
return publicDescription
})
return this._publicDescription
}),
set: function (arg) {
this._publicDescription = arg
}
}
},
onicecandidate: {
set() {
print(" [*] RTCPeerConnection -> onicecandidate[set]", [].slice.call(arguments));
this._onicecandidate = arguments[0]
}
},
createDataChannel: {
value: v_saf(function createDataChannel(label, option) {
print(" [*] RTCPeerConnection -> createDataChannel[func]", [].slice.call(arguments));
return {
'onopen': function onopen() {
print(" [*] RTCPeerConnection -> createDataChannel[func] onopen", [].slice.call(arguments));
},
'onmessage': function onmessage() {
print(" [*] RTCPeerConnection -> createDataChannel[func] onmessage", [].slice.call(arguments));
},
}
let res = new RTCDataChannel(label);
return proxy(res, 'dataChannel')
})
},
createOffer: {
......@@ -3654,18 +3627,22 @@ Object.defineProperties(RTCPeerConnection.prototype, {
print(" [*] RTCPeerConnection -> createOffer[func]", [].slice.call(arguments));
let p = new Promise(function (resolve, reject) {
// 2. 执行异步操作任务
print('RTCPeerConnection createOffer');
let res = v_new(RTCSessionDescription)
res.sdp = RTCSessionDescription.prototype.sdp
res.type = RTCSessionDescription.prototype.type
resolve(res)
print('RTCPeerConnection createOffer', resolve, reject);
let res = new RTCSessionDescription()
// resolve(proxy(res, 'newRTCSessionDescription'))
resolve({
then: function (arg1, arg2) {
arg1(proxy(res, 'newRTCSessionDescription'))
arg2(proxy(res, 'newRTCSessionDescription'))
}
})
})
return p;
// return {
// then: function (func, func2) {
// v_console_log(" [*] RTCPeerConnection -> createOffer[func] then", [].slice.call(arguments));
// // func2(v_new(RTCSessionDescription));
// // func(v_new(RTCSessionDescription));
// func2(v_new(RTCSessionDescription));
// func(v_new(RTCSessionDescription));
// return func(v_new(RTCSessionDescription));
// }, catch: function () {
// }
......@@ -3674,27 +3651,26 @@ Object.defineProperties(RTCPeerConnection.prototype, {
},
setLocalDescription: {
value: v_saf(function setLocalDescription() {
// print(" [*] RTCPeerConnection -> setLocalDescription[func]", [].slice.call(arguments));
var _this = this;
print(" [*] RTCPeerConnection -> setLocalDescription[func]", [].slice.call(arguments));
_this._onicecandidate(new RTCPeerConnectionIceEvent())
this.localDescription = arguments[0]
_this._onicecandidate(this.localDescription)
let p = new Promise(function (resolve, reject) {
// 2. 执行异步操作任务
// let res = this.setLocalDescription(v_new(RTCSessionDescription))
// console.log('RTCPeerConnection create',res);
_this._onicecandidate(new RTCPeerConnectionIceEvent())
print(" [*] RTCPeerConnection -> setLocalDescription[func] then", [].slice.call(arguments));
publicDescription = arguments[0]
// window.debug = true
resolve(publicDescription)
resolve(new RTCSessionDescription())
// return res
})
return p;
// return {
// then: function (func, func2) {
// print(" [*] RTCPeerConnection -> setLocalDescription[func] then", [].slice.call(arguments));
//
// return this
// }, catch: function () {
// }
// }
})
}),
enumerable: true,
configurable: true
},
[Symbol.toStringTag]: {value: "RTCPeerConnection", writable: false, enumerable: false, configurable: true},
})
......@@ -3763,14 +3739,52 @@ Object.defineProperties(WebSocket.prototype, {
CLOSED: {"value": 3, "writable": false, "enumerable": true, "configurable": false},
[Symbol.toStringTag]: {value: "WebSocket", writable: false, enumerable: false, configurable: true},
})
let t1 = parseInt(_random() * 2430043322 / 2 + 1430043322);
let t2 = parseInt(_random() * 2430043322 / 2 + 1430043322);
let t3 = parseInt(_random() * 5000 + 60199);
let ip = `192.168.${parseInt(_random() * 150 + 1)}.${parseInt(_random() * 150 + 1)}`
function guid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = _random() * 16 | 0,
v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
var candidateGetTimes = 0;
Object.defineProperties(RTCPeerConnectionIceEvent.prototype, {
candidate: {
get() {
v_console_log(" [*] RTCPeerConnectionIceEvent -> candidate[get]", {});
return {}
}
get: function () {
let res = `candidate:${t1} 1 udp ${t2} ${guid()}.local ${t3} typ host generation 0 ufrag MiWK network-cost 999`
res = `candidate:${t1} 1 udp ${t2} ${ip} ${t3} typ host generation 0 ufrag 5M7j network-id 1`
// res = `candidate:${t1} 1 tcp ${t2} ${ip} 9 typ host tcptype active generation 0 ufrag ZZHV network-id 1`
// res = 'candidate:2594513701 1 udp 2122260223 192.168.50.235 54336 typ host generation 0 ufrag 5M7j network-id 1 '
// res = 'candidate:1678768049 1 tcp 1518280447 192.168.50.235 9 typ host tcptype active generation 0 ufrag 5M7j network-id 1 '
console.log('RTCPeerConnectionIceEvent.candidate.get', res)
let rrr = proxy(new RTCIceCandidate(
ip, res, "rtp", t1, t2, t3, 'tcp', null, null, 0, "0", 'active', 'host', '5M7j'
), 'candidate[new]');
candidateGetTimes++
if (candidateGetTimes > 3) {
rrr.candidate = null
// return null
}
return rrr;
},
enumerable: true, configurable: true
},
type: {
value: 'icecandidate'
},
isTrusted: {
value: true,
},
[Symbol.toStringTag]: {value: "RTCPeerConnectionIceEvent", writable: false, enumerable: false, configurable: true},
})
Object.defineProperties(MessageEvent.prototype, {
data: {
......@@ -5712,8 +5726,7 @@ window.Document = Document;
window.DOMException = DOMException;
window.DOMMatrixReadOnly = DOMMatrixReadOnly;
window.RTCPeerConnection = RTCPeerConnection;
window.webkitRTCPeerConnection = webkitRTCPeerConnection;
window.mozRTCPeerConnection = mozRTCPeerConnection;
window.webkitRTCPeerConnection = RTCPeerConnection;
window.DOMParser = DOMParser;
window.FileReader = FileReader;
window.FormData = FormData;
......
// Create a new isolate limited to 128MB
const ivm = require('isolated-vm');
const isolate = new ivm.Isolate({ memoryLimit: 128 });
// Create a new context within this isolate. Each context has its own copy of all the builtin
// Objects. So for instance if one context does Object.prototype.foo = 1 this would not affect any
// other contexts.
const context = isolate.createContextSync();
// Get a Reference{} to the global object within the context.
const jail = context.global;
// And let's test it out:
// > hello world
// Let's see what happens when we try to blow the isolate's memory
const hostile = isolate.compileScriptSync(`
const storage = [];
const twoMegabytes = 1024 * 1024 * 2;
while (true) {
const array = new Uint8Array(twoMegabytes);
for (let ii = 0; ii < twoMegabytes; ii += 4096) {
array[ii] = 1; // we have to put something in the array to flush to real memory
}
storage.push(array);
log('I\\'ve wasted '+ (storage.length * 2)+ 'MB');
}
`);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment