Browse Source

Scanner._scan_udp: send a "real" payload.

This tricks the server into sending a valid answer, making our lives easier.
Cyril Roelandt 8 years ago
parent
commit
539537fa23
1 changed files with 6 additions and 1 deletions
  1. 6 1
      vpneverywhere/port_scanner.py

+ 6 - 1
vpneverywhere/port_scanner.py

@@ -108,7 +108,12 @@ class Scanner(object):
         try:
         try:
             s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
             s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
             s.settimeout(TIMEOUT)
             s.settimeout(TIMEOUT)
-            s.sendto(b'x', (self.host, port))
+            # The message is a valid payload sent to OpenVPN in order to
+            # trigger an answer from the server, and is computed like this:
+            # msg = '38 36 d9 fc 5f e3 fe f7 09 00 00 00 00'
+            # msg = bytes.fromhex(msg.replace(' ', ''))
+            msg = b'86\xd9\xfc_\xe3\xfe\xf7\t\x00\x00\x00\x00'
+            s.sendto(msg, (self.host, port))
             s.recvfrom(1)
             s.recvfrom(1)
         except socket.timeout:
         except socket.timeout:
             return False
             return False