Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How to run your code on the dark web (full version)

luke crouch
November 03, 2017

How to run your code on the dark web (full version)

Tor is an open anonymized network and web browser. Millions of users connect with Tor every day. Is your code ready for them? This talk introduces Tor, provides an overview of how it works and the adversaries and attacks its designed to stop, and shows that optimizing your code for Tor is quite practical, and improves your code for everyone.

luke crouch

November 03, 2017
Tweet

More Decks by luke crouch

Other Decks in Technology

Transcript

  1. IP, DNS, & HTTP threats • Hackers-in-the-middle • ISPs snooping

    on customers’ online activity • Governments censoring sites • Corporations scanning web logs for their competitors’ IP addresses • Criminal sites scanning web logs for law enforcement IP address
  2. IP, DNS, & HTTP threats • Hackers-in-the-middle • ISPs snooping

    on customers’ online activity • Governments censoring sites • Corporations scanning web logs for their competitors’ IP addresses • Criminal sites scanning web logs for law enforcement IP address
  3. –Christopher Soghoian, “Your smartphone is a civic rights issue” TED

    Summit “… there is now increasingly a gap between the privacy and security of the rich, who can afford devices that secure their data by default, and of the poor, whose devices do very little to protect them by default.” https://www.ted.com/talks/glenn_greenwald_why_privacy_matters
  4. Tor protection from DNS + HTTP internet threats • Hackers-in-the-middle

    • ISPs snooping on customers’ online activity • Governments censoring sites • Corporations scanning web logs for their competitors’ IP addresses • Criminal sites scanning web logs for law enforcement IP address
  5. Help the browser with Resource hints (You should do this

    anyway) https://w3c.github.io/resource-hints
  6. Use rel=“preload” when you know sprite images will be included

    https://developer.mozilla.org/docs/Web/HTML/Preloading_content
  7. Use rel=“prefetch” when a resource is likely to be included

    in a future navigation page1.html page2.html https://w3c.github.io/resource-hints/#dfn-prefetch
  8. Use rel=“preconnect” when you know a domain may be contacted

    https://w3c.github.io/resource-hints/#dfn-preconnect
  9. exit node threats = Man-in-the-Middle threats • exit node snooping

    on unencrypted data:
 user/password, PII, etc. • Hook browsers with BeEF • Backdoor binaries
  10. +

  11. Please deploy a DNS TXT record under the name _acme-challenge.www.codesy.io

    with the following value: CxYdvM…5WvXR0 Once this is deployed, Press ENTER to continue
  12. Summary • Optimize for latency • Make it work in

    Firefox (ESR) • (Optional) WITHOUT:
 JavaScript, MathML, SVG, Web Fonts
  13. Yay! Your code works* fast* and secure* for users *

    for some definition of “works|fast|secure”
  14. Optimize for latency • Minimize Requests • Prefer fewer, larger

    asset bundles • Use CSS Sprites for images • Use Data URIs for small images • Use Icon Fonts • Use Resource Hints • Allow CDN access from Tor nodes
  15. Optimize for latency • Minimize Requests • Use Resource Hints

    • Only use public CDNs • Probably just don’t use a CDN
  16. More Checks Apache mod_status leak Open directories Server fingerprints Analytics

    IDs PGP IDs SSH fingerprints FTP & SMTP banners Cryptocurrency clients IRC, XMPP, VNC, Ricochet
  17. proxychains4 \ mitmproxy \ -p 20081 \ -R http://dstormer6em3i4km.onion \

    —anticache \ -s “replace_btc.py 19m9yEChBSPuzCzEMmg1dNbPvdLdWA59rS 1CU5YgjquupDw6UeXEyA9VEBH34R7fZ19b” --replace ":~hq .:dstormer65alxsqn.onion:dstormer6em3i4 km.onion" /etc/tor/torrc
 HiddenServiceDir /var/lib/tor/hidden_service/ HiddenServicePort 80 127.0.0.1:20081 /etc/proxychains.conf
 [ProxyList] socks4 127.0.0.1 9050
  18. Writing code for the dark web makes your code better

    faster more secure more compatible
  19. “In February a presentation by INTELLIAGG and DARKSUM reported that

    they had classified 29,532 onion services and reported that 52% of these sites contained illegal content. … taking into account a 29% duplication rate and at least 10% of traffic being SSH (not to mention the various other protocols) - then we have to conclude that the amount of crime is far lower than the reported 52% figure.” https://mascherari.press/onionscan-report-april-2016-the-tor-network-security-and-crime/
  20. Hardware • Run your own physical machines to prevent in-memory

    access by adversaries with physical access • 2 computers for SecureDrop application • 1 computer each for Admin, Journalist, and Secure Viewing Station • 2FA devices (smartphone or yubikey) • Network firewall & 3 ethernet cables • Plenty of USB sticks • Writeable DVD/CD-R discs
  21. Create Tails USB sticks • Create Tails USB sticks •

    Secure Viewing Station • Admin Workstation • Label them immediately
  22. Set up secure viewing station • Insert & run Secure

    Viewing Station Tails USB • air-gapped from internet • physically remove other storage & networking • fill ports with epoxy • remove speakers to prevent
 exfiltration of data via ultrasonic audio
 (yes, it’s a thing)
  23. Set up transfer device • encrypt the drive • plug

    into secure viewing station and journalist station; • check box to remember passphrase
  24. Use CD-R/DVD, because BadUSB • “Very widely spread USB controller

    chips, including those in thumb drives, have no protection from … being reprogrammed” to … • emulate a keyboard and issue commands on behalf of the logged-in user, for example to exfiltrate files or install malware. Such malware, in turn, can infect the controller chips of other USB devices connected to the computer. • detects that the computer is starting up – boot a small virus, which infects the computer’s operating system prior to boot • Once infected, computers and their USB peripherals can never be trusted again.
  25. Generate Submission Key (For/from secure viewing station) • Correct system

    time (to prevent some brute-force shortcuts based on time) • Create the RSA 4096 key (gpg —full-generate-key) • Export public key to transfer device
  26. Set up admin workstation • Insert & run Admin Workstation

    Tails USB • Connected to internet via Tor • Download SecureDrop
 git clone https://github.com/freedomofpress/securedrop.git • Download & verify SecureDrop Release Signing Key
 gpg --recv-key "2224 5C81 E3BA EB41 38B3 6061 310F 5612 00F4 AD77" • Verify release tag
 git tag -v 0.4.3
 Good signature from "SecureDrop Release Signing Key" • Create Admin Passphrase Database (KeePassX)
  27. Set up (pfSense) firewalls • Admin subnet • Application subnet

    • Monitor subnet • No DHCP • Static IP for Admin workstation
  28. –Trisha Salas @ Thunder Plains 2016 “I want to try

    Tor … but I heard it puts you on some kind of list … and I plan to travel soon.”
  29. –Glenn Greenwald, “Why Privacy Matters” @ TED 2014 “There are

    dozens of psychological studies that prove that when somebody knows that they might be watched, the behavior they engage in is vastly more conformist and compliant.” https://www.ted.com/talks/glenn_greenwald_why_privacy_matters
  30. –Glenn Greenwald, “Why Privacy Matters” @ TED 2014 https://www.ted.com/talks/glenn_greenwald_why_privacy_matters “This

    realization was exploited most powerfully for pragmatic ends by the 18th-century philosopher Jeremy Bentham, who set out to resolve an important problem ushered in by the industrial age. Where, for the first time, institutions had become so large and centralized that they were no longer able to monitor and therefore control each one of their individual members. And the solution that he devised was an architectural design - originally intended to be implemented in prisons - that he called the panopticon.”
  31. –Glenn Greenwald, “Why Privacy Matters” @ TED 2014 https://www.ted.com/talks/glenn_greenwald_why_privacy_matters “The

    primary attribute of which was the construction of an enormous tower in the center of the institution where whoever controlled the institution could, at any moment, watch any of the inmates, although they couldn’t watch all of them at all times. And crucial to this design was that the inmates could not see into the panopticon, into the tower, and so they never knew if they were being watched.”
  32. –Glenn Greenwald, “Why Privacy Matters” @ TED 2014 https://www.ted.com/talks/glenn_greenwald_why_privacy_matters “And

    what made him so excited about this discovery was that would mean the prisoners would have to assume that they were being watched at any given moment, which would be the ultimate enforcer for obedience and compliance.”
  33. –Glenn Greenwald, “Why Privacy Matters” @ TED 2014 https://www.ted.com/talks/glenn_greenwald_why_privacy_matters “The

    20th-century French philosopher Michel Foucault realized that model could be used not just for prisons but for every institution that seeks to control human behavior - schools, hospitals, factories, workplaces.”
  34. –Glenn Greenwald, “Why Privacy Matters” @ TED 2014 https://www.ted.com/talks/glenn_greenwald_why_privacy_matters “And

    what he said was that this mindset, this framework discovered by Bentham, was the key means of societal control for modern western societies which no longer need the overt weapons of tyranny - punishing or imprisoning or killing dissidents; or legally compelling loyalty to a particular party … because mass surveillance creates a prison in the mind that is a much more subtle but much more effective means of fostering compliance … much more effective than brute force could ever be.”
  35. “There’s a strong physiological basis for privacy. Biologist Peter Watts

    makes the point that a desire for privacy is innate: mammals in particular don’t respond well to surveillance. We consider it a physical threat, because animals in the natural world are surveilled by predators. –Data and Goliath, by Bruce Schneier
  36. “Surveillance makes us feel like prey, just as it makes

    surveyors act like predators.” –Data and Goliath, by Bruce Schneier
  37. “… information collection takes place in asymmetrical power relationships: we

    rarely have a choice as to whether or not we are monitored, what is done with any information that is gathered, or what is done to us on the basis of conclusions drawn from that information.”
  38. “One of the benefits of running a Tor relay is

    the additional layer of confusion it creates: is this traffic starting with you, or are you just passing it along for someone else?”
  39. –me “I have done many weird things with/on Tor and

    I’ve had no problems traveling.
 
 In fact, using Tor is quite empowering.”
  40. Questions? • Optimize for latency • Use HTTPS • Make

    it work in Firefox ESR • Set up your .onion • OnionScan • Privacy • torproject.org • eff.org • onionscan.org • mascherari.press • speakerdeck.com/ groovecoder