Answer the question
In order to leave comments, you need to log in
How to declare a function object in JS?
An obfuscated js file came to the mail, in fact a virus loader. It became interesting what it does, I decided to debug using script.google.com, it's safer.
All work in the script goes through the ActiveX object. Clearly, Google does not have such an object, but it is to our advantage, we will announce our own. Classes could not be used, so through the function.
function cFields() {
this.append = function(a,b,c){Logger.log('ActiveXObject ('+this.fileName+'.fields) append('+a+','+b+','+c+')');return 'fields.append'};
}
function ActiveXObject(file_name) {
this.fileName = file_name;
Logger.log('ActiveXObject ('+this.fileName+') NEW');
this.Status = 200;
this.fields = new cFields();
this.open = function(a,b,c){Logger.log('ActiveXObject ('+this.fileName+') open: ('+a+','+b+','+c+')');return 'open'};
this.send = function(a,b,c){Logger.log('ActiveXObject ('+this.fileName+') send()');return 'send'};
this.GetSpecialFolder = function(a){Logger.log('ActiveXObject ('+this.fileName+') GetSpecialFolder('+a+')'); return 'SpecFolder'};
this.GetTempName = function(a){Logger.log("ActiveXObject ("+this.fileName+") GetTempName()"); return 'TempName'};
this.Open = function(){Logger.log('ActiveXObject ('+this.fileName+') Open()');return 'Open'};
this.Write = function(a){Logger.log('ActiveXObject ('+this.fileName+') Write('+a+')');return 'Write'};
this.Read = function(a){Logger.log('ActiveXObject ('+this.fileName+') Read('+a+')');return 'Read'};
this.addNew = function(a){Logger.log('ActiveXObject ('+this.fileName+'.fields) addNew('+a+')');return 'fields.addNew'};
}
TypeError: [object Object] is not a function but an object.
uKi = new ActiveXObject('ADODB.Recordset')
St = 'appendChunk'
q = 'Read'
uKi(Z)[St](q);
Answer the question
In order to leave comments, you need to log in
So add it.
this.appendChunk = function(a){Logger.log('ActiveXObject ('+this.fileName+') appendChunk('+a+')');return 'appendChunk'};
like so
function ActiveXObject() {
// ...
return Object.assign(() => {
// ...
}, this);
}
Actually, functions are objects.
function func() {
alert("Hello world");
}
func.prop1 = "prop";
func.prop2 = "prop";
func(); // Hello world
console.warn(func.prop1); // prop
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question