@@ -4,79 +4,82 @@ const iconv = require("iconv-lite");
44/* Includes code (ADODBStream.writetext, .loadfromfile) from
55 * https://github.com/HynekPetrak/malware-jail. The license follows.
66
7- The MIT License (MIT)
7+ The MIT License (MIT)
88
9- Copyright (c) 2016 Hynek Petrak
9+ Copyright (c) 2016 Hynek Petrak
1010
11- Permission is hereby granted, free of charge, to any person obtaining a copy
12- of this software and associated documentation files (the "Software"), to deal
13- in the Software without restriction, including without limitation the rights
14- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15- copies of the Software, and to permit persons to whom the Software is
16- furnished to do so, subject to the following conditions:
11+ Permission is hereby granted, free of charge, to any person obtaining a copy
12+ of this software and associated documentation files (the "Software"), to deal
13+ in the Software without restriction, including without limitation the rights
14+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15+ copies of the Software, and to permit persons to whom the Software is
16+ furnished to do so, subject to the following conditions:
1717
18- The above copyright notice and this permission notice shall be included in all
19- copies or substantial portions of the Software.
18+ The above copyright notice and this permission notice shall be included in all
19+ copies or substantial portions of the Software.
2020
21- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27- SOFTWARE.
21+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27+ SOFTWARE.
2828*/
2929
3030function ADODBStream ( ) {
31- this . virtual_filename = "(undefined)" ;
32- this . charset = "" ;
33- this . position = 0 ;
34- this . open = ( ) => { } ;
35- this . savetofile = function ( filename ) {
36- this . virtual_filename = filename ;
37- lib . writeFile ( filename , this . buffer ) ;
38- lib . logResource ( lib . getUUID ( ) , this . virtual_filename , this . buffer , true ) ;
39- } ;
40- this . close = ( ) => { } ;
41- this . read = ( ) => this . buffer ;
42-
43- this . write = this . writetext = function ( text ) {
44- if ( this . charset )
45- this . buffer = iconv . encode ( text , this . charset ) ;
46- else
47- this . buffer = text ;
48- } ;
49- this . loadfromfile = function ( filename ) {
50- if ( this . charset )
51- this . buffer = iconv . decode ( lib . readFile ( filename ) , this . charset ) ;
52- else
53- this . buffer = lib . readFile ( filename ) ;
54- } ;
55- this . copyto = ( target ) => target . write ( this . buffer ) ;
31+ this . virtual_filename = "(undefined)" ;
32+ this . charset = "" ;
33+ this . position = 0 ;
34+ this . open = ( ) => { } ;
35+ this . savetofile = function ( filename ) {
36+ this . virtual_filename = filename ;
37+ lib . writeFile ( filename , this . buffer ) ;
38+ lib . logResource ( lib . getUUID ( ) , this . virtual_filename , this . buffer , true ) ;
39+ } ;
40+ this . close = ( ) => { } ;
41+ this . read = this . readtext = function ( ) {
42+ return this . buffer ;
43+ } ;
44+ this . write = this . writetext = function ( text ) {
45+ if ( this . charset )
46+ this . buffer = iconv . encode ( text , this . charset ) ;
47+ else
48+ this . buffer = text ;
49+ } ;
50+ this . loadfromfile = function ( filename ) {
51+ if ( this . charset )
52+ this . buffer = iconv . decode ( lib . readFile ( filename ) , this . charset ) ;
53+ else
54+ this . buffer = lib . readFile ( filename ) ;
55+ } ;
56+ this . tojson = function ( data ) {
57+ console . log ( data ) ;
58+ return "[1]" ;
59+ }
60+ this . copyto = ( target ) => target . write ( this . buffer ) ;
5661}
5762
5863module . exports = function ( ) {
59- return new Proxy ( new ADODBStream ( ) , {
60- get : function ( target , name ) {
61- name = name . toLowerCase ( ) ;
62- switch ( name ) {
63- case "size" :
64- case "length" :
65- return target . buffer . length ;
66- case "readtext" :
67- return target . buffer ;
68- default :
69- if ( name in target ) return target [ name ] ;
70- lib . kill ( `ADODBStream.${ name } not implemented!` ) ;
71- }
72- } ,
73- set : function ( a , b , c ) {
74- b = b . toLowerCase ( ) ;
75- /* if (c.length < 1024)
76- console.log(`ADODBStream[${b}] = ${c};`);
77- */
78- a [ b ] = c ;
79- return true ;
80- } ,
81- } ) ;
64+ return new Proxy ( new ADODBStream ( ) , {
65+ get : function ( target , name ) {
66+ name = name . toLowerCase ( ) ;
67+ switch ( name ) {
68+ case "size" :
69+ case "length" :
70+ return target . buffer . length ;
71+ default :
72+ if ( name in target ) return target [ name ] ;
73+ lib . kill ( `ADODBStream.${ name } not implemented!` ) ;
74+ }
75+ } ,
76+ set : function ( a , b , c ) {
77+ b = b . toLowerCase ( ) ;
78+ /* if (c.length < 1024)
79+ console.log(`ADODBStream[${b}] = ${c};`);
80+ */
81+ a [ b ] = c ;
82+ return true ;
83+ } ,
84+ } ) ;
8285} ;
0 commit comments