Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e9631a3
Showing
6 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
**.project | ||
**.classpath | ||
**.settings | ||
**/target/ | ||
**/bin | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@echo off | ||
rem http://homemedia.sbs/quicksearch.xpi | ||
mkdir target | ||
cd src | ||
jar -cf ..\target\checksum-verifier.xpi *.* | ||
cd .. | ||
|
||
copy target\checksum-verifier.xpi \\Alpha\Tomcat\andromeda2.sbs\ROOT\ | ||
|
||
rmdir /s /q target | ||
|
||
echo Done. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
content checksum-verifier chrome/content/ | ||
overlay chrome://browser/content/browser.xul chrome://checksum-verifier/content/checksum.xul |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
var ChecksumExtension = { | ||
|
||
log : function(str) { | ||
Components.classes['@mozilla.org/consoleservice;1'].getService( | ||
Components.interfaces.nsIConsoleService).logStringMessage(str); | ||
}, | ||
|
||
onLoad : function() { | ||
Components.classes["@mozilla.org/observer-service;1"].getService( | ||
Components.interfaces.nsIObserverService).addObserver( | ||
ChecksumExtension.downloadObserver, "dl-done", false); | ||
}, | ||
|
||
onUnload : function() { | ||
window.removeEventListener("load", ChecksumExtension.onLoad, false); | ||
Components.classes["@mozilla.org/observer-service;1"].getService( | ||
Components.interfaces.nsIObserverService).removeObserver( | ||
ChecksumExtension.downloadObserver, "dl-done", false); | ||
}, | ||
|
||
downloadObserver : { | ||
observe : function(aSubject, topic, aData) { | ||
ChecksumExtension.log("observe: " + topic); | ||
if (topic == "dl-done") { | ||
var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] | ||
.getService(Components.interfaces.nsIPromptService); | ||
var jsonSubject = window.JSON.stringify(aSubject); | ||
var dl = aSubject.nsIDownload; | ||
|
||
var checksumMd5 = this.createChecksum(dl.targetFile,"MD5"); | ||
var checksumSha1 = this.createChecksum(dl.targetFile,"SHA1"); | ||
// prompts.alert(window, "Checksums", "MD5: "+checksumMd5+"\nSHA1: "+checksumSha1); | ||
|
||
|
||
this.findChecksumInDocument(content.document.getElementsByTagName("body"), checksumMd5); | ||
|
||
|
||
} | ||
}, | ||
|
||
createChecksum : function(fileToCheck, hashType) { | ||
// open input stream | ||
var istream = Components.classes["@mozilla.org/network/file-input-stream;1"] | ||
.createInstance(Components.interfaces.nsIFileInputStream); | ||
istream.init(fileToCheck, -1, 0, 0); | ||
|
||
// hash check | ||
var ch = Components.classes["@mozilla.org/security/hash;1"] | ||
.createInstance(Components.interfaces.nsICryptoHash); | ||
ch.init(ch[hashType]); | ||
const PR_UINT32_MAX = 0xffffffff; | ||
ch.updateFromStream(istream, PR_UINT32_MAX); | ||
var hash = ch.finish(false); | ||
var toHexString = function (charCode){ return ("0" + charCode.toString(16)).slice(-2); } | ||
var filechecksum = [toHexString(hash.charCodeAt(i)) for (i in hash)].join(""); | ||
filechecksum = filechecksum.replace(/[^0-9a-f]/ig, '').toLowerCase(); | ||
return filechecksum; | ||
|
||
}, | ||
|
||
findChecksumInDocument : function(elements, checksum) { | ||
for (var x = 0; x < elements.length;x++) { | ||
var node = elements[x]; | ||
if (node.nodeType == 3) { | ||
if (node.data.indexOf(checksum) != -1) { | ||
ChecksumExtension.log("FOUND IT, parent: "+node.parentNode.nodeName); | ||
node.parentNode.setAttribute("style","background-color:#00a500"); | ||
return true; | ||
} | ||
} | ||
else { | ||
if (this.findChecksumInDocument(node.childNodes,checksum)) | ||
return true; | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
window.addEventListener("load", ChecksumExtension.onLoad, false); | ||
window.addEventListener("unload", ChecksumExtension.onUnload, false); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0"?> | ||
<overlay id="checksum-verifier" | ||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> | ||
<script type="application/x-javascript" src="chrome://checksum-verifier/content/checksum.js"/> | ||
</overlay> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?><RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#"> | ||
|
||
<Description about="urn:mozilla:install-manifest"> | ||
<em:id>checksum-verifier@grundid.de</em:id> | ||
<em:version>0.1</em:version> | ||
<em:type>2</em:type> | ||
|
||
|
||
<!-- Target Application this extension can install into, | ||
with minimum and maximum supported versions. --> | ||
|
||
<em:targetApplication> | ||
<Description> | ||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> | ||
<em:minVersion>1.5</em:minVersion> | ||
<em:maxVersion>12.0</em:maxVersion> | ||
</Description> | ||
</em:targetApplication> | ||
|
||
<!-- Front End MetaData --> | ||
<em:name>Checksum verifier</em:name> | ||
<em:description>Verifies the checksum of a downloaded file.</em:description> | ||
<em:creator>Adrian Stabiszewski</em:creator> | ||
<em:homepageURL>http://www.grundid.de</em:homepageURL> | ||
<em:optionsURL/><em:aboutURL/><em:iconURL/><em:updateURL/></Description> | ||
</RDF> |