[or-cvs] [torbutton/master] Made option for custom referrer spoofing.
mikeperry at seul.org
mikeperry at seul.org
Wed Sep 23 23:49:10 UTC 2009
Author: Kory Kork <kory at korykirk.com>
Date: Wed, 12 Aug 2009 19:58:13 +0000
Subject: Made option for custom referrer spoofing.
Commit: 1cd200313ecb76ef5d9757fccc37e92c2404443f
Made UI for cookie manager, and populated it with cookies (protection does not work yet).
svn:r20274
svn:r20275
---
src/chrome/content/popup.xul | 6 ++
src/chrome/content/preferences.js | 5 ++-
src/chrome/content/preferences.xul | 4 +-
src/chrome/content/torbutton.js | 5 +-
src/chrome/content/torcookie.js | 82 +++++++++++++++++++++++++++++++
src/chrome/content/torcookiedialog.xul | 41 +++++++++++++++
src/components/torRefSpoofer.js | 10 ++--
src/defaults/preferences/preferences.js | 3 +-
8 files changed, 147 insertions(+), 9 deletions(-)
create mode 100644 src/chrome/content/torcookie.js
create mode 100644 src/chrome/content/torcookiedialog.xul
diff --git a/src/chrome/content/popup.xul b/src/chrome/content/popup.xul
index afe4578..7691cf5 100644
--- a/src/chrome/content/popup.xul
+++ b/src/chrome/content/popup.xul
@@ -22,6 +22,12 @@
accesskey="&torbutton.context_menu.preferences.key;"
insertafter="context-stop"
oncommand="torbutton_open_prefs_dialog()"/>
+ <menuitem id="torbutton-cookies"
+ label="Cookie Manager"
+ accesskey="C"
+ insertafter="context-stop"
+ oncommand="window.openDialog('chrome://torbutton/content/torcookiedialog.xul','Cookie Manager',
+ 'centerscreen,chrome,dialog,modal,resizable')"/>
<menuitem id="torbutton-about"
label="&torbutton.context_menu.about;"
accesskey="&torbutton.context_menu.about.key;"
diff --git a/src/chrome/content/preferences.js b/src/chrome/content/preferences.js
index 5c6d7b9..ee1a843 100644
--- a/src/chrome/content/preferences.js
+++ b/src/chrome/content/preferences.js
@@ -244,7 +244,8 @@ function torbutton_prefs_init(doc) {
break;
}
- doc.getElementById('torbutton_refererSpoofGroup').selectedIndex = o_torprefs.getIntPref('refererspoof');
+ if ((doc.getElementById('torbutton_refererSpoofGroup').selectedIndex = o_torprefs.getIntPref('refererspoof'))==4)
+ doc.getElementById('torbutton_CustomRef').value = o_torprefs.getCharPref('customref');
doc.getElementById('torbutton_torSessionStore').checked = !o_torprefs.getBoolPref('notor_sessionstore');
doc.getElementById('torbutton_nonTorSessionStore').checked = !o_torprefs.getBoolPref('nonontor_sessionstore');
@@ -436,6 +437,8 @@ function torbutton_prefs_save(doc) {
o_torprefs.setBoolPref('locked_mode', doc.getElementById('torbutton_lockedMode').checked);
o_torprefs.setIntPref('refererspoof',doc.getElementById('torbutton_refererSpoofGroup').selectedIndex);
+ if (doc.getElementById('torbutton_CustomReferer').selected)
+ o_torprefs.setCharPref('customref',doc.getElementById('torbutton_CustomRef').value);
/*
o_torprefs.setBoolPref('jar_certs', doc.getElementById('torbutton_jarCerts').checked);
o_torprefs.setBoolPref('jar_ca_certs',
diff --git a/src/chrome/content/preferences.xul b/src/chrome/content/preferences.xul
index e8f4012..5fa6989 100644
--- a/src/chrome/content/preferences.xul
+++ b/src/chrome/content/preferences.xul
@@ -334,12 +334,14 @@
oncommand="torbutton_prefs_set_field_attributes(document)"/>
-->
<checkbox id="torbutton_spoofRefresh" label="&torbutton.prefs.spoofreresh;" oncommand="torbutton_prefs_set_field_attributes(document)" />
- <radiogroup id="torbutton_refererSpoofGroup" label="&torbutton.prefs.refereroptions;">
+ <radiogroup id="torbutton_refererSpoofGroup" label="&torbutton.prefs.refereroptions;" oncommand="document.getElementById('torbutton_CustomRef').disabled = !document.getElementById('torbutton_CustomReferer').selected;">
<radio id="torbutton_noRefSpoof" label="&torbutton.prefs.nospoof;" oncommand="torbutton_prefs_set_field_attributes(document)" />
<radio id="torbutton_SpoofRoot" label="&torbutton.prefs.spoofroot;" selected="true" oncommand="torbutton_prefs_set_field_attributes(document)" />
<radio id="torbutton_SpoofDomain" label="&torbutton.prefs.spoofdomain;" oncommand="torbutton_prefs_set_field_attributes(document)" />
<radio id="torbutton_BlankReferer" label="&torbutton.prefs.spoofblank;" oncommand="torbutton_prefs_set_field_attributes(document)" />
+ <radio id="torbutton_CustomReferer" label="Custom Referer" />
</radiogroup>
+ <textbox id="torbutton_CustomRef" value="" disabled="!document.getElementById('torbutton_CustomReferer').selected"/>
</vbox>
</tabpanel>
</tabpanels>
diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index e31e18e..1a35c65 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -443,8 +443,9 @@ function torbutton_init() {
//if it is, then we show the two context menu items
function torbutton_check_contextmenu() {
var torurl = document.getElementById("torcontext-copyurl");
- var tortab = document.getElementById("torcontext-opentorurl");
- torurl.hidden = tortab.hidden = (document.popupNode.localName != "A")
+ var tortab = document.getElementById("torcontext-opentortab");
+ var torwin = document.getElementById("torcontext-opentorwin");
+ torurl.hidden = tortab.hidden = torwin.hidden = (document.popupNode.localName != "A")
}
function torbutton_copy_link() {
var element = document.popupNode;
diff --git a/src/chrome/content/torcookie.js b/src/chrome/content/torcookie.js
new file mode 100644
index 0000000..b9e286a
--- /dev/null
+++ b/src/chrome/content/torcookie.js
@@ -0,0 +1,82 @@
+var cookiesTree = null;
+var prefs = null;
+var cookies = [];
+var protectedcookies = [];
+//custom tree view, this is how we dynamically add the cookies
+var cookiesTreeView = {
+ rowCount : 0,
+ setTree : function(tree){},
+ getImageSrc : function(row,column) {},
+ getProgressMode : function(row,column) {},
+ getCellValue : function(row,column) {},
+ getCellText : function(row,column){
+ var rv="";
+ switch (column.id) {
+ case "domainCol" : rv = cookies[row].rawHost; break;
+ case "nameCol" : rv = cookies[row].name; break;
+ case "lockCol" : rv = cookies[row].isProtected;
+ }
+ return rv;
+ },
+ isSeparator : function(index) {return false;},
+ isSorted: function() { return false; },
+ isContainer : function(index) {return false;},
+ cycleHeader : function(column, aElt) {},
+ getRowProperties : function(row,column,prop){},
+ getColumnProperties : function(column,columnElement,prop){},
+ getCellProperties : function(row,column,prop) {}
+ };
+
+function Cookie(number,name,value,isDomain,host,rawHost,path,isSecure,expires,
+ isProtected) {
+ this.number = number;
+ this.name = name;
+ this.value = value;
+ this.isDomain = isDomain;
+ this.host = host;
+ this.rawHost = rawHost;
+ this.path = path;
+ this.isSecure = isSecure;
+ this.expires = expires;
+ this.isProtected = isProtected;
+}
+
+function initDialog() {
+ cookiesTree = document.getElementById("cookiesTree");
+ prefs =Components.classes["@mozilla.org/preferences-service;1"]
+ .getService(Components.interfaces.nsIPrefBranch);
+ var tor_enabled = prefs.getBoolPref("extensions.torbutton.tor_enabled");
+ //init cookie manager
+ var cookiemanager = Components.classes["@mozilla.org/cookiemanager;1"].getService();
+ cookiemanager = cookiemanager.QueryInterface(Components.interfaces.nsICookieManager);
+ var enumerator = cookiemanager.enumerator;
+ var count = 0;
+ while (enumerator.hasMoreElements()) {
+ var nextCookie = enumerator.getNext();
+ if (!nextCookie) break;
+ nextCookie = nextCookie.QueryInterface(Components.interfaces.nsICookie);
+ var host = nextCookie.host;
+ var isProt = checkIfProtected(nextCookie.name, host, nextCookie.path);
+ //populate list
+ cookies[count] =
+ new Cookie(count++, nextCookie.name, nextCookie.value, nextCookie.isDomain, host,
+ (host.charAt(0)==".") ? host.substring(1,host.length) : host,
+ nextCookie.path, nextCookie.isSecure, nextCookie.expires,
+ isProt);
+ }
+ //apply custom view
+ cookiesTreeView.rowCount = cookies.length;
+ cookiesTree.treeBoxObject.view = cookiesTreeView;
+
+ //grab data from xml files
+ //add protected tag
+}
+function checkIfProtected(name, host, path)
+{
+
+ return false;
+}
+function itemSelected() {
+ var item = document.getElementById("cookiesTree").selectedItemIndex;
+
+}
\ No newline at end of file
diff --git a/src/chrome/content/torcookiedialog.xul b/src/chrome/content/torcookiedialog.xul
new file mode 100644
index 0000000..3f39780
--- /dev/null
+++ b/src/chrome/content/torcookiedialog.xul
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://torbutton/skin/torbutton.css" type="text/css"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+
+<!DOCTYPE overlay SYSTEM "chrome://torbutton/locale/torbutton.dtd">
+
+<dialog id="TorCookieDialog"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ title="Manage Cookies"
+ buttons="accept,cancel"
+ style="width: 30em;"
+ onload="initDialog();"
+ ondialogaccept="return;"
+ persist="screenX screenY width height">
+ <script src="chrome://torbutton/content/torbutton.js" type="application/x-javascript"/>
+ <script src="chrome://torbutton/content/torcookie.js" type="application/x-javascript"/>
+ <stringbundleset id="torbutton-stringbundleset">
+ <stringbundle id="torbutton-bundle" src="chrome://torbutton/locale/torbutton.properties"/>
+ </stringbundleset>
+
+ <label value=""/>
+ <separator class="thin"/>
+ <vbox flex="1">
+ <tree id="cookiesTree" flex="1" style="height: 10em;"
+ onkeypress="return;//do this later"
+ onselect="itemSelected();"
+ hidecolumnpicker="true">
+ <treecols>
+ <treecol id="lockCol" label="Protected" flex="1"
+ onclick="CookieColumnSort('isProtected', true);" persist="width"/>
+ <splitter class="tree-splitter"/>
+ <treecol id="domainCol" label="Host" flex="2"
+ onclick="CookieColumnSort('rawHost', true);" persist="width"/>
+ <splitter class="tree-splitter"/>
+ <treecol id="nameCol" label="Name" flex="1"
+ onclick="CookieColumnSort('name', true);" persist="width"/>
+ </treecols>
+ <treechildren/>
+ </tree>
+ </vbox>
+</dialog>
diff --git a/src/components/torRefSpoofer.js b/src/components/torRefSpoofer.js
index 0e23a0a..13c2269 100644
--- a/src/components/torRefSpoofer.js
+++ b/src/components/torRefSpoofer.js
@@ -1,12 +1,11 @@
-
function LOG(text)
{
var logger = Components.classes["@torproject.org/torbutton-logger;1"].getService(Components.interfaces.nsISupports).wrappedJSObject;
logger.log("RefSpoof " + text);
/*var prompt = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
- prompt.alert(null, "debug", text);*/
-
+ prompt.alert(null, "debug", text);
+ */
}
@@ -62,7 +61,10 @@ var refObserver = {
//spoof no referer
case 3:
this.adjustRef(oHttpChannel, "");
- break;
+ break;
+ case 4:
+ this.adjustRef(oHttpChannel, prefs.getCharPref("extensions.torbutton.customref"));
+ break;
}
if (fake_refresh)
oHttpChannel.setRequestHeader("If-Modified-Since","Sat, 29 Oct 1989 19:43:31 GMT",false);
diff --git a/src/defaults/preferences/preferences.js b/src/defaults/preferences/preferences.js
index b7207cf..9308837 100644
--- a/src/defaults/preferences/preferences.js
+++ b/src/defaults/preferences/preferences.js
@@ -139,8 +139,9 @@ pref("extensions.torbutton.tor_memory_jar",false);
pref("extensions.torbutton.nontor_memory_jar",false);
pref("extensions.torbutton.tz_string","");
pref("extensions.torbutton.launch_warning",true);
-pref("extensions.torbutton.refererspoof", 0); //0=no spoof, 1=root spoof, 2=domain spoof, 3=blank spoof
+pref("extensions.torbutton.refererspoof", 0); //0=no spoof, 1=root spoof, 2=domain spoof, 3=blank spoof, 4=custom spoof
pref("extensions.torbutton.fakerefresh", false);
+pref("extensions.torbutton.customeref","");
// User agent prefs:
pref("extensions.torbutton.appname_override","Netscape");
--
1.5.6.5
More information about the tor-commits
mailing list