Skip to contentSkip to conversation

the XOR obfuscation

Openvpn-devel 李夏润 2 participants 4 messages Feb 3, 2015 – Feb 4, 2015

lore
Share & tools
lore

李夏润

author
#0 lore raw

It is not secret encryption but it is enough to cheat GFW.
It works well while both peer are x86_64, But I meet problem while a peer is mips which is big endian. I don't what cause that, please give me any idea about that. Thank you

---
 src/openvpn/Makefile.am |  1 +
 src/openvpn/Makefile.in | 12 ++++----
 src/openvpn/forward.c   | 12 +++++---
 src/openvpn/options.c   |  5 ++++
 src/openvpn/options.h   |  1 +
 src/openvpn/xor.c       | 73 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/openvpn/xor.h       | 55 +++++++++++++++++++++++++++++++++++++
 7 files changed, 150 insertions(+), 9 deletions(-)
 create mode 100644 src/openvpn/xor.c
 create mode 100644 src/openvpn/xor.h
src/openvpn/Makefile.am +1 -0
index 2e602f1..0e9b682 100644
@@ -111,6 +111,7 @@ openvpn_SOURCES = \
 	syshead.h \
 	tun.c tun.h \
 	win32.h win32.c \
+	xor.c xor.h \
 	cryptoapi.h cryptoapi.c
 openvpn_LDADD = \
 	$(top_builddir)/src/compat/libcompat.la \
src/openvpn/Makefile.in +7 -5
index 686f79b..9fd5d9d 100644
@@ -149,8 +149,8 @@ am__openvpn_SOURCES_DIST = base64.c base64.h basic.h buffer.c buffer.h \
 	ssl_verify.c ssl_verify.h ssl_verify_backend.h \
 	ssl_verify_openssl.c ssl_verify_openssl.h \
 	ssl_verify_polarssl.c ssl_verify_polarssl.h status.c status.h \
-	syshead.h tun.c tun.h win32.h win32.c cryptoapi.h cryptoapi.c \
-	openvpn_win32_resources.rc
+	syshead.h tun.c tun.h win32.h win32.c xor.c xor.h cryptoapi.h \
+	cryptoapi.c openvpn_win32_resources.rc
 @[email protected]... = openvpn_win32_resources.$(OBJEXT)
 am_openvpn_OBJECTS = base64.$(OBJEXT) buffer.$(OBJEXT) \
 	clinat.$(OBJEXT) crypto.$(OBJEXT) crypto_openssl.$(OBJEXT) \
@@ -174,7 +174,8 @@ am_openvpn_OBJECTS = base64.$(OBJEXT) buffer.$(OBJEXT) \
 	ssl_openssl.$(OBJEXT) ssl_polarssl.$(OBJEXT) \
 	ssl_verify.$(OBJEXT) ssl_verify_openssl.$(OBJEXT) \
 	ssl_verify_polarssl.$(OBJEXT) status.$(OBJEXT) tun.$(OBJEXT) \
-	win32.$(OBJEXT) cryptoapi.$(OBJEXT) $(am__objects_1)
+	win32.$(OBJEXT) xor.$(OBJEXT) cryptoapi.$(OBJEXT) \
+	$(am__objects_1)
 openvpn_OBJECTS = $(am_openvpn_OBJECTS)
 am__DEPENDENCIES_1 =
 openvpn_DEPENDENCIES = $(top_builddir)/src/compat/libcompat.la \
@@ -450,8 +451,8 @@ openvpn_SOURCES = base64.c base64.h basic.h buffer.c buffer.h \
 	ssl_verify.c ssl_verify.h ssl_verify_backend.h \
 	ssl_verify_openssl.c ssl_verify_openssl.h \
 	ssl_verify_polarssl.c ssl_verify_polarssl.h status.c status.h \
-	syshead.h tun.c tun.h win32.h win32.c cryptoapi.h cryptoapi.c \
-	$(am__append_2)
+	syshead.h tun.c tun.h win32.h win32.c xor.c xor.h cryptoapi.h \
+	cryptoapi.c $(am__append_2)
 openvpn_LDADD = $(top_builddir)/src/compat/libcompat.la \
 	$(SOCKETS_LIBS) $(OPTIONAL_LZO_LIBS) \
 	$(OPTIONAL_PKCS11_HELPER_LIBS) $(OPTIONAL_CRYPTO_LIBS) \
@@ -620,6 +621,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @[email protected].../$(DEPDIR)/[email protected]...@
 @AMDEP_TRUE@@am__include@ @[email protected].../$(DEPDIR)/[email protected]...@
 @AMDEP_TRUE@@am__include@ @[email protected].../$(DEPDIR)/[email protected]...@
+@AMDEP_TRUE@@am__include@ @[email protected].../$(DEPDIR)/[email protected]...@
 
 .c.o:
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
src/openvpn/forward.c +8 -4
index 7f0d083..0f5ff78 100644
@@ -39,6 +39,7 @@
 #include "ps.h"
 #include "dhcp.h"
 #include "common.h"
+#include "xor.h"
 
 #include "memdbg.h"
 
@@ -671,10 +672,12 @@ read_incoming_link (struct context *c)
   c->c2.buf = c->c2.buffers->read_link_buf;
   ASSERT (buf_init (&c->c2.buf, FRAME_HEADROOM_ADJ (&c->c2.frame, FRAME_HEADROOM_MARKER_READ_LINK)));
 
-  status = link_socket_read (c->c2.link_socket,
+  status = link_socket_read_xor (c->c2.link_socket,
 			     &c->c2.buf,
 			     MAX_RW_SIZE_LINK (&c->c2.frame),
-			     &c->c2.from);
+			     &c->c2.from,
+			     c->options.xor_secret
+			     );
 
   if (socket_connection_reset (c->c2.link_socket, status))
     {
@@ -1148,9 +1151,10 @@ process_outgoing_link (struct context *c)
 	    socks_preprocess_outgoing_link (c, &to_addr, &size_delta);
 #endif
 	    /* Send packet */
-	    size = link_socket_write (c->c2.link_socket,
+	    size = link_socket_write_xor (c->c2.link_socket,
 				      &c->c2.to_link,
-				      to_addr);
+				      to_addr,
+				      c->options.xor_secret);
 
 #ifdef ENABLE_SOCKS
 	    /* Undo effect of prepend */
src/openvpn/options.c +5 -0
index 5bddca4..c3dc2f1 100644
@@ -6537,6 +6537,11 @@ add_option (struct options *options,
 	  options->cert_file_inline = p[2];
 	}
     }
+  else if (streq (p[0], "xor-secret") && p[1])
+    {
+      VERIFY_PERMISSION (OPT_P_GENERAL);
+      options->xor_secret = p[1];
+    }
   else if (streq (p[0], "extra-certs") && p[1])
     {
       VERIFY_PERMISSION (OPT_P_GENERAL);
src/openvpn/options.h +1 -0
index af9a47f..186302e 100644
@@ -521,6 +521,7 @@ struct options
   char *priv_key_file_inline;
   const char *dh_file_inline;
   const char *pkcs12_file_inline; /* contains the base64 encoding of pkcs12 file */
+  const char *xor_secret;
 
   int ns_cert_type; /* set to 0, NS_CERT_CHECK_SERVER, or NS_CERT_CHECK_CLIENT */
   unsigned remote_cert_ku[MAX_PARMS];
src/openvpn/xor.c new file +73 -0

73 lines not on this page · raw message

src/openvpn/xor.h new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
2.1.0
#1 lore raw
Quoted 1 line · 李夏润

+ size_t keylen = sizeof(key);

Perhaps you meant that to be strlen(key), and the problem isn't really that one peer is big-endian, but that sizeof(char *) is different between the two.

Signature · 1 line
dwmw2
author
#2 lore raw
Quoted 11 lines

Subject: Re: [Openvpn-devel] the XOR obfuscation
From: [email protected]...
To: [email protected]...
CC: [email protected]
Date: Tue, 3 Feb 2015 20:48:33 +0000

Quoted 1 line · Ayaka

+ size_t keylen = sizeof(key);

I have fixed this place, thank you, but I doesn't work.
Also I have tried the signal character. As the C standard, I thought the char is always 8-bits.

Quoted 3 lines

Perhaps you meant that to be strlen(key), and the problem isn't really that one peer is big-endian, but that sizeof(char *) is different between the two.

I may should check the assembly code as dazo said in irc, but it is too hard for me :)

Authenticate/Decrypt packet error: packet HMAC authentication failed really is awful. Thank you

Quoted 3 lines
Signature · 2 lines
-- 
dwmw2
author
#3 lore raw

I have fix the problem, I used the wrong size in link_socket_write_xor. Thank you.

---
 src/openvpn/Makefile.am |  1 +
 src/openvpn/Makefile.in | 12 +++++----
 src/openvpn/forward.c   | 12 ++++++---
 src/openvpn/options.c   |  5 ++++
 src/openvpn/options.h   |  1 +
 src/openvpn/xor.c       | 72 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/openvpn/xor.h       | 48 +++++++++++++++++++++++++++++++++
 7 files changed, 142 insertions(+), 9 deletions(-)
 create mode 100644 src/openvpn/xor.c
 create mode 100644 src/openvpn/xor.h
src/openvpn/Makefile.am +1 -0
index 2e602f1..0e9b682 100644
@@ -111,6 +111,7 @@ openvpn_SOURCES = \
     syshead.h \
     tun.c tun.h \
     win32.h win32.c \
+    xor.c xor.h \
     cryptoapi.h cryptoapi.c
 openvpn_LDADD = \
     $(top_builddir)/src/compat/libcompat.la \
src/openvpn/Makefile.in +7 -5
index 686f79b..9fd5d9d 100644
@@ -149,8 +149,8 @@ am__openvpn_SOURCES_DIST = base64.c base64.h basic.h buffer.c buffer.h \
     ssl_verify.c ssl_verify.h ssl_verify_backend.h \
     ssl_verify_openssl.c ssl_verify_openssl.h \
     ssl_verify_polarssl.c ssl_verify_polarssl.h status.c status.h \
-    syshead.h tun.c tun.h win32.h win32.c cryptoapi.h cryptoapi.c \
-    openvpn_win32_resources.rc
+    syshead.h tun.c tun.h win32.h win32.c xor.c xor.h cryptoapi.h \
+    cryptoapi.c openvpn_win32_resources.rc
 @[email protected]... = openvpn_win32_resources.$(OBJEXT)
 am_openvpn_OBJECTS = base64.$(OBJEXT) buffer.$(OBJEXT) \
     clinat.$(OBJEXT) crypto.$(OBJEXT) crypto_openssl.$(OBJEXT) \
@@ -174,7 +174,8 @@ am_openvpn_OBJECTS = base64.$(OBJEXT) buffer.$(OBJEXT) \
     ssl_openssl.$(OBJEXT) ssl_polarssl.$(OBJEXT) \
     ssl_verify.$(OBJEXT) ssl_verify_openssl.$(OBJEXT) \
     ssl_verify_polarssl.$(OBJEXT) status.$(OBJEXT) tun.$(OBJEXT) \
-    win32.$(OBJEXT) cryptoapi.$(OBJEXT) $(am__objects_1)
+    win32.$(OBJEXT) xor.$(OBJEXT) cryptoapi.$(OBJEXT) \
+    $(am__objects_1)
 openvpn_OBJECTS = $(am_openvpn_OBJECTS)
 am__DEPENDENCIES_1 =
 openvpn_DEPENDENCIES = $(top_builddir)/src/compat/libcompat.la \
@@ -450,8 +451,8 @@ openvpn_SOURCES = base64.c base64.h basic.h buffer.c buffer.h \
     ssl_verify.c ssl_verify.h ssl_verify_backend.h \
     ssl_verify_openssl.c ssl_verify_openssl.h \
     ssl_verify_polarssl.c ssl_verify_polarssl.h status.c status.h \
-    syshead.h tun.c tun.h win32.h win32.c cryptoapi.h cryptoapi.c \
-    $(am__append_2)
+    syshead.h tun.c tun.h win32.h win32.c xor.c xor.h cryptoapi.h \
+    cryptoapi.c $(am__append_2)
 openvpn_LDADD = $(top_builddir)/src/compat/libcompat.la \
     $(SOCKETS_LIBS) $(OPTIONAL_LZO_LIBS) \
     $(OPTIONAL_PKCS11_HELPER_LIBS) $(OPTIONAL_CRYPTO_LIBS) \
@@ -620,6 +621,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @[email protected].../$(DEPDIR)/[email protected]...@
 @AMDEP_TRUE@@am__include@ @[email protected].../$(DEPDIR)/[email protected]...@
 @AMDEP_TRUE@@am__include@ @[email protected].../$(DEPDIR)/[email protected]...@
+@AMDEP_TRUE@@am__include@ @[email protected].../$(DEPDIR)/[email protected]...@
 
 .c.o:
 @am__fastdepCC_TRUE@    $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
src/openvpn/forward.c +8 -4
index 7f0d083..0f5ff78 100644
@@ -39,6 +39,7 @@
 #include "ps.h"
 #include "dhcp.h"
 #include "common.h"
+#include "xor.h"
 
 #include "memdbg.h"
 
@@ -671,10 +672,12 @@ read_incoming_link (struct context *c)
   c->c2.buf = c->c2.buffers->read_link_buf;
   ASSERT (buf_init (&c->c2.buf, FRAME_HEADROOM_ADJ (&c->c2.frame, FRAME_HEADROOM_MARKER_READ_LINK)));
 
-  status = link_socket_read (c->c2.link_socket,
+  status = link_socket_read_xor (c->c2.link_socket,
                  &c->c2.buf,
                  MAX_RW_SIZE_LINK (&c->c2.frame),
-                 &c->c2.from);
+                 &c->c2.from,
+                 c->options.xor_secret
+                 );
 
   if (socket_connection_reset (c->c2.link_socket, status))
     {
@@ -1148,9 +1151,10 @@ process_outgoing_link (struct context *c)
         socks_preprocess_outgoing_link (c, &to_addr, &size_delta);
 #endif
         /* Send packet */
-        size = link_socket_write (c->c2.link_socket,
+        size = link_socket_write_xor (c->c2.link_socket,
                       &c->c2.to_link,
-                      to_addr);
+                      to_addr,
+                      c->options.xor_secret);
 
 #ifdef ENABLE_SOCKS
         /* Undo effect of prepend */
src/openvpn/options.c +5 -0
index 5bddca4..c3dc2f1 100644
@@ -6537,6 +6537,11 @@ add_option (struct options *options,
       options->cert_file_inline = p[2];
     }
     }
+  else if (streq (p[0], "xor-secret") && p[1])
+    {
+      VERIFY_PERMISSION (OPT_P_GENERAL);
+      options->xor_secret = p[1];
+    }
   else if (streq (p[0], "extra-certs") && p[1])
     {
       VERIFY_PERMISSION (OPT_P_GENERAL);
src/openvpn/options.h +1 -0
index af9a47f..186302e 100644
@@ -521,6 +521,7 @@ struct options
   char *priv_key_file_inline;
   const char *dh_file_inline;
   const char *pkcs12_file_inline; /* contains the base64 encoding of pkcs12 file */
+  const char *xor_secret;
 
   int ns_cert_type; /* set to 0, NS_CERT_CHECK_SERVER, or NS_CERT_CHECK_CLIENT */
   unsigned remote_cert_ku[MAX_PARMS];
src/openvpn/xor.c new file +72 -0

72 lines not on this page · raw message

src/openvpn/xor.h new file +48 -0

48 lines not on this page · raw message

Signature · 8 lines
2.1.0


From: [email protected]...
To: [email protected]
Date: Wed, 4 Feb 2015 05:08:38 +0800
CC: [email protected]...
Subject: Re: [Openvpn-devel] the XOR obfuscation
Quoted 9 lines

Subject: Re: [Openvpn-devel] the XOR obfuscation
From: [email protected]...
To: [email protected]...
CC: [email protected]
Date: Tue, 3 Feb 2015 20:48:33 +0000

Quoted 1 line · Ayaka

+ size_t keylen = sizeof(key);

I have fixed this place, thank you, but I doesn't work.
Also I have tried the signal character. As the C standard, I thought the char is always 8-bits.

Quoted 3 lines

Perhaps you meant that to be strlen(key), and the problem isn't really that one peer is big-endian, but that sizeof(char *) is different between the two.

I may should check the assembly code as dazo said in irc, but it is too hard for me :)

Authenticate/Decrypt packet error: packet HMAC authentication failed really is awful. Thank you

Quoted 3 lines
Signature · 2 lines
-- 
dwmw2

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel