[Tails-dev] Patch for #9412 (Add SOCKS support to WhisperBac…

Delete this message

Reply to this message
Autore: Romeo Papa
Data:  
To: The Tails public development discussion list
Oggetto: [Tails-dev] Patch for #9412 (Add SOCKS support to WhisperBack)
https://labs.riseup.net/code/issues/9412#note-11

Hi,

Here's the updated patch, with which I've been able to successfully send
a message earlier today.

I've also published the branch on gitlab, on a clone of whisperback's
repo. Maybe it's more convenient for you:
https://gitlab.com/romeopapa/whisperback/commits/feature/python3-9412-add-socks-support-to-whisperback

Take care,
>From 6d195d8dc68514266c991753f1759f6b359f17b6 Mon Sep 17 00:00:00 2001
From: Romeo Papa <romeopapa@???>
Date: Tue, 11 Aug 2015 16:49:32 +0200
Subject: [PATCH] Monkeypatching the entire connection through the SOCKS proxy

---
 debian/control      | 2 +-
 whisperBack/mail.py | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)


diff --git a/debian/control b/debian/control
index 2ffd571..877d6ad 100644
--- a/debian/control
+++ b/debian/control
@@ -13,7 +13,7 @@ X-Python3-Version: >= 3.4
Package: whisperback
Architecture: all
Depends: ${misc:Depends}, ${python3:Depends}, python3-gnupg, python3-gi,
- gir1.2-gtk-3.0, gir1.2-webkit-3.0, gir1.2-glib-2.0
+ python3-pysocks, gir1.2-gtk-3.0, gir1.2-webkit-3.0, gir1.2-glib-2.0
Description: send feedback using encrypted email
WhisperBack is designed to allow Live system users to be able to report bugs
or issues in a simple yet secure manner.
diff --git a/whisperBack/mail.py b/whisperBack/mail.py
index 1947dc7..139b988 100644
--- a/whisperBack/mail.py
+++ b/whisperBack/mail.py
@@ -28,6 +28,8 @@
import smtplib
import ssl
import time
+import socket
+import socks

 #pylint: disable=R0913
 def send_message_tls (from_address, to_address, message, host="localhost",
@@ -45,6 +47,10 @@ def send_message_tls (from_address, to_address, message, host="localhost",
     @param tls_cafile Certificate authority file used to create the SSLContext
     """


+    # Monkeypatching the entire connection through the SOCKS proxy
+    socks.set_default_proxy(socks.SOCKS5, "127.0.0.1", 9050)
+    socket.socket = socks.socksocket
+
     ssl_context = ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH,
                                             cafile=tls_cafile)
     # We set a long timeout because Tor is slow
-- 
2.1.4