Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # Copyright 2013, 2014 Philipp Winter <phw@nymity.ch>
- #
- # This file is part of exitmap.
- #
- # exitmap is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # exitmap is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with exitmap. If not, see <http://www.gnu.org/licenses/>.
- """
- Module to detect SSL stripping by Tor exit nodes.
- """
- import urllib2
- import log
- logger = log.get_logger()
- # exitmap needs this variable to figure out which relays can exit to the given
- # destination(s).
- destinations = [("blockchain.info", 80)]
- def probe(exit_fpr, cmd):
- """
- Probe the given exit relay and look for check.tp.o false negatives.
- """
- logger.debug("Now probing exit relay "
- "<https://globe.torproject.org/#/relay/%s>." % exit_fpr)
- newurl = None
- try:
- newurl = urllib2.urlopen("http://blockchain.info",
- timeout=10).geturl()
- except Exception as err:
- logger.debug("urllib2.urlopen says: %s" % err)
- if not newurl:
- return
- if newurl.rstrip("/") != "https://blockchain.info":
- logger.error("Detected SSL stripping on"
- "<https://globe.torproject.org/#/relay/%s>: got %r" % (exit_fpr, newurl))
- else:
- logger.debug("Exit relay <https://globe.torproject.org/#/relay/%s> "
- "passed SSL stripping test." % exit_fpr)
- def main():
- """
- Entry point when invoked over the command line.
- """
- probe("n/a", None)
- return 0
- if __name__ == "__main__":
- exit(main())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement