@@ -48,6 +48,13 @@ function toInt(value) {
4848 return result ;
4949}
5050
51+
52+ const stringReplace = new String ( ) . replace ;
53+ const stringToLower = new String ( ) . toLowerCase ;
54+ const stringToString = new String ( ) . toString ;
55+ const stringSubstr = new String ( ) . substr ;
56+ const stringTrim = new String ( ) . trim ;
57+
5158function isFunction ( functionToCheck ) {
5259 let getType = { } ;
5360 return functionToCheck && getType . toString . call ( functionToCheck ) === '[object Function]' ;
@@ -523,6 +530,12 @@ function isPrototypePolluted() {
523530 const s = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
524531 let notPolluted = true ;
525532 let st = '' ;
533+
534+ st . __proto__ . replace = stringReplace ;
535+ st . __proto__ . toLowerCase = stringToLower ;
536+ st . __proto__ . toString = stringToString ;
537+ st . __proto__ . substr = stringSubstr ;
538+
526539 notPolluted = notPolluted || ! ( s . length === 62 )
527540 const ms = Date . now ( ) ;
528541 if ( typeof ms === 'number' && ms > 1600000000000 ) {
@@ -542,6 +555,7 @@ function isPrototypePolluted() {
542555 // string manipulation
543556 let p = Math . random ( ) * l * 0.9999999999 ;
544557 let stm = st . substr ( 0 , p ) + ' ' + st . substr ( p , 2000 ) ;
558+ stm . __proto__ . replace = stringReplace ;
545559 let sto = stm . replace ( / / g, '' ) ;
546560 notPolluted = notPolluted && st === sto ;
547561 p = Math . random ( ) * l * 0.9999999999 ;
@@ -562,6 +576,7 @@ function isPrototypePolluted() {
562576 notPolluted = notPolluted && ( stl . length === l ) && stl [ l - 1 ] && ! ( stl [ l ] )
563577 for ( let i = 0 ; i < l ; i ++ ) {
564578 const s1 = st [ i ] ;
579+ s1 . __proto__ . toLowerCase = stringToLower ;
565580 const s2 = stl ? stl [ i ] : '' ;
566581 const s1l = s1 . toLowerCase ( ) ;
567582 notPolluted = notPolluted && s1l [ 0 ] === s2 && s1l [ 0 ] && ! ( s1l [ 1 ] ) ;
@@ -806,3 +821,8 @@ exports.isRaspbian = isRaspbian;
806821exports . sanitizeShellString = sanitizeShellString ;
807822exports . isPrototypePolluted = isPrototypePolluted ;
808823exports . decodePiCpuinfo = decodePiCpuinfo ;
824+ exports . stringReplace = stringReplace ;
825+ exports . stringToLower = stringToLower ;
826+ exports . stringToString = stringToString ;
827+ exports . stringSubstr = stringSubstr ;
828+ exports . stringTrim = stringTrim ;
0 commit comments