-
Notifications
You must be signed in to change notification settings - Fork 1
/
MultSrcTaintLogic.js
93 lines (92 loc) · 1.82 KB
/
MultSrcTaintLogic.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
(function (sandbox) {
const Utils = sandbox.dtaUtils;
function TaintUnit(config)
{
this.config = config;
}
TaintUnit.prototype.noTaint = 0;
TaintUnit.prototype.taintSource = function (id)
{
return 1 << id;
};
TaintUnit.prototype.arithmetic = function(left, right, op, pos)
{
return left | right;
};
TaintUnit.prototype.unaryArithmetic = function(left)
{
return left;
};
TaintUnit.prototype.toStringTaint = function(a,t,f)
{
var ret;
if (f !== 'undefined')
ret = Utils.fillArray(t, (String(a)).length);
else
ret = Utils.fillArray(t, f(a).length);
return ret;
};
TaintUnit.prototype.compressTaint = function (shadow)
{//todo, make it more generic
var ret;
if (typeof shadow == 'number')
{
ret = shadow;
}
else if (Array.isArray(shadow))
{
if (shadow.length === 0)
ret = 0;
else
ret = shadow.reduce((a, b) => a | b);
}
return ret;
};
TaintUnit.prototype.ordTaint = function (t)
{
var ret;
ret = t[0];
return ret;
};
TaintUnit.prototype.chrTaint = function (t)
{
var ret;
ret = [t];
return ret;
};
TaintUnit.prototype.escapeTaint = function (t ,type)
{
var ret;
ret = t;
return ret;
};
TaintUnit.prototype.unescapeTaint = function (ts)
{
return ts.reduce((a,b) => a | b);
};
TaintUnit.prototype.getFieldTaint = function (elemT, idxT)
{//todo: maybe need to be changed for more option
var ret;
ret = elemT;
return ret;
};
TaintUnit.prototype.getStringCharTaint = function (baseT, offsetT)
{
return [baseT];
};
TaintUnit.prototype.strIdxOfTaint = function (baseTaintArr, argTaintArr, startIdx, end)
{
const ss = argTaintArr.reduce((a, b) => a | b);
if (ss !== 0)
{
return ss;
}
var acc = 0;
for (var i = startIdx; i < end; i++)
{
acc |= baseTaintArr[i]
}
return acc;
};
sandbox.dtaTaintLogic = new TaintUnit();
})(J$);