Author Topic: JS Property Filters  (Read 2436 times)

sidki3003

  • Sr. Member
  • ****
  • Posts: 476
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
JS Property Filters
« on: June 28, 2002, 09:43:07 PM »
Hi all,

Here is another pair of JavaScript filters, they are for faking certain object properties.
I wrote an extra one for HTML files, since i don't want to have any accidental replacements outside the script bounds.
The comments on these filters are in JSProperties.txt
(Thanks, JD for testing and pointing me to the docs )

[Blocklists]
List.JSProperties = "..ListsJSProperties.txt"

[Patterns]
Name = "JS Properties HTM"
Active = TRUE
Multi = TRUE
URL = "$TYPE(htm)"
Bounds = "<script*</script*>"
Limit = 8000
Match = "(#.$LST(JSProperties))+#"
Replace = "@"

Name = "JS Properties JS"
Active = TRUE
URL = "($TYPE(js)|$TYPE(oth))"
Limit = 32
Match = ".$LST(JSProperties)"
Replace = "@"



------------ JSProperties.txt ------------
# List for "JS Properties" filters: Fake listed object properties.
# For HTML files search for strings within <script> tags only,
# for JS files search everywhere.
# The list is hashable, that's why no regexp is used.
#
# The filters are quite aggressive, some ways to tame them:
# Replace "($TYPE(js)|$TYPE(oth))" by "$TYPE(js)"
#
# Make an exception list and append it to the URL match:
# URL = "($TYPE(js)|$TYPE(oth))(^$LST(Bypass_JS_Props))"
#
# Comment out the offending property.
# If "appName" and "platform" causes too much trouble you might try this.
# It's for sites that do an indexOf() check:
#
#appName$SET(#=.appName.substr(0,0)+'XMSIE')
#platform$SET(#=.platform.substr(0,0)+'XWin')
#
# Some notes on the "JS Properties HTM" filter:
# It matches *all* script bounds. Adding something like
# "<script*(.$LST(JSProperties))*</script*>" will make it slower.
#
# ?NEST or $INEST in the filter bounds match will fail sometimes, e.g. here:
# hea-www.harvard.edu/~fine/CFA/browser_type.html
#
# sidki 2002-6-28


# "navigator" object, property attributes readonly for IE,
# it needs this hard way to change them.
#
#userAgent$SET(#=.userAgent.substr(0,0)+"NOYB")
#userAgent$SET(#=.userAgent.substr(0,0)+"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)")
userAgent$SET(#=.userAgent.substr(0,0)+"Opera/6.03 (Linux 2.4.34 i886) [en]")

#appName$SET(#=.appName.substr(0,0)+"NOYB")
#appName$SET(#=.appName.substr(0,0)+"Microsoft Internet Explorer")
appName$SET(#=.appName.substr(0,0)+"Opera")

#appVersion$SET(#=.appVersion.substr(0,0)+"NOYB")
#appVersion$SET(#=.appVersion.substr(0,0)+"4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)")
appVersion$SET(#=.appVersion.substr(0,0)+"6.03 (Linux 2.4.34 i886) [en]")

#platform$SET(#=.platform.substr(0,0)+"NOYB")
#platform$SET(#=.platform.substr(0,0)+"Win32")
platform$SET(#=.platform.substr(0,0)+"Linux")

#appMinorVersion$SET(#=.appMinorVersion.substr(0,0)+"NOYB")
appMinorVersion$SET(#=.appMinorVersion.substr(0,0)+"undefined")

appCodeName$SET(#=.appCodeName.substr(0,0)+"NOYB")
#appCodeName$SET(#=.appCodeName.substr(0,0)+"Mozilla")

#language$SET(#=.language.substr(0,0)+"NOYB")
language$SET(#=.language.substr(0,0)+"en")

#browserLanguage$SET(#=.browserLanguage.substr(0,0)+"NOYB")
browserLanguage$SET(#=.browserLanguage.substr(0,0)+"en")

#systemLanguage$SET(#=.systemLanguage.substr(0,0)+"NOYB")
systemLanguage$SET(#=.systemLanguage.substr(0,0)+"en")

#userLanguage$SET(#=.userLanguage.substr(0,0)+"NOYB")
userLanguage$SET(#=.userLanguage.substr(0,0)+"en")

#cpuClass$SET(#=.cpuClass.substr(0,0)+"NOYB")
#cpuClass$SET(#=.cpuClass.substr(0,0)+"x86")
#cpuClass$SET(#=.cpuClass.substr(0,0)+"other")
cpuClass$SET(#=.cpuClass.substr(0,0)+"alpha")

#cookieEnabled$SET(#=.cookieEnabled.substr(0,0)+"false")
cookieEnabled$SET(#=.plugins.length)

#javaEnabled()$SET(#=.javaEnabled.substr(0,0)+"false")
javaEnabled()$SET(#=.plugins.length)

# rarely used, IE only.
#
connectionType$SET(#=.connectionType.substr(0,0)+"offline")
userProfile$SET(#=.cpuClass)
onLine$SET(#=.onLine.substr(0,0)+"false")
 
# "document" object
#
referrer$SET(#=.referrer.substr(0,0)+"http://h/")
cookie(^[a-z0-9])$SET(#=.cookieGFN)
-----------------------------------------


regards, sidki


Edited by - sidki3003 on 02 Jul 2002  17:41:37
 

sidki3003

  • Sr. Member
  • ****
  • Posts: 476
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
JS Property Filters
« Reply #1 on: July 02, 2002, 04:44:32 PM »
Quite a few sites don't like us being none of their business.
Therefore i changed the list (see above) to return something more useful.

sidki


 
 

altosax

  • Sr. Member
  • ****
  • Posts: 328
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
JS Property Filters
« Reply #2 on: July 02, 2002, 07:00:45 PM »
hi sidki,
we have worked on the same filter the same day ;) but i came to this version:

Name = "Hide Browser's Properties from JS"
Active = TRUE
URL = "$TYPE(htm)|$TYPE(js)"
Limit = 64
Match = "navigator.$LST(JSProperties)"
Replace = "1"

and this is the list:

# Proxomitron4 URL killfile: $LST(JSProperties)
# Created by sidki on June 28, 2002
# Modified by altosax on July 02, 2002
#
# List for "Hide Browser's Properties from JS" filter.
# It fakes listed navigator properties and methods.
#
# If you think that this filter is quite aggressive,
# make an exception list and append it to the URL match:
# URL = "($TYPE(htm)|$TYPE(js))(^$LST(BypassJSProperties))"
# or comment out the offending line of code.
#
# If "appName" and "platform" causes too much troubles try this:
# appName$SET(1='XMSIE')
# platform$SET(1='XWin')
#
# All credits to sidki for the original idea.


# Note: these are not all navigator properties and methods.
#
userAgent$SET(1='Opera/5.02 (Win32; U)')
appName$SET(1='Opera')
appCodeName$SET(1='Opera')
appVersion$SET(1='5.02')
appMinorVersion$SET(1='0')
platform$SET(1='Win32')
language$SET(1='en')
browserLanguage$SET(1='en')
systemLanguage$SET(1='en')
userLanguage$SET(1='en')
cpuClass$SET(1='x86')
plugins.length$SET(1='0')
plugins.refresh(true)$SET(1=plugins.refresh(false))
cookieEnabled$SET(1='false')
onLine$SET(1='false')
userProfile$SET(1='false')
connectionType$SET(1='offline')
javaEnabled()$SET(1='false')


that's all, let me know what do you think about it.

regards,
altosax.

 
 

sidki3003

  • Sr. Member
  • ****
  • Posts: 476
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
JS Property Filters
« Reply #3 on: July 02, 2002, 07:32:20 PM »
Hi altosax,

Your version is for sure easier to read than mine .
An extra HTML version is only really needed if you often visit pages containing code.
In most cases navigator.* will match. Exceptions are scripts that turn it into a function, like here:
http://developer.apple.com/internet/javascript/sniffer.html (the script arrives as text/plain)

BTW, it's interesting to see how often the filter matches (esp. external scripts).

regards, sidki


 
 

altosax

  • Sr. Member
  • ****
  • Posts: 328
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
JS Property Filters
« Reply #4 on: July 02, 2002, 08:54:01 PM »
two little corrections to my version:

appCodeName$SET(1='Mozilla')
plugins.refresh(true)$SET(1=navigator.plugins.refresh(false))

i'm still testing it :)

regards,
altosax.