[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stegotorus/master] git-svn-id: svn+ssh://spartan.csl.sri.com/svn/private/DEFIANCE@129 a58ff0ac-194c-e011-a152-003048836090



commit 8afedcde7390e7515f35dd07f84af91015aa0b7e
Author: Vinod Yegneswaran <vinod@xxxxxxxxxxx>
Date:   Mon Nov 7 20:35:29 2011 +0000

    git-svn-id: svn+ssh://spartan.csl.sri.com/svn/private/DEFIANCE@129 a58ff0ac-194c-e011-a152-003048836090
---
 src/steg/payloads.c |  152 ++++++++++++---------------------------------------
 src/steg/payloads.h |    1 -
 2 files changed, 36 insertions(+), 117 deletions(-)

diff --git a/src/steg/payloads.c b/src/steg/payloads.c
index 0cae234..a3e2f65 100644
--- a/src/steg/payloads.c
+++ b/src/steg/payloads.c
@@ -546,48 +546,51 @@ unsigned int find_client_payload(char* buf, int len, int type) {
 
 
 
-int skipJSPattern(char *cp, int len) {
-  int i,j;
+/* int skipJSPattern(char *cp, int len) { */
+/*   int i,j; */
 
-  char keywords [21][10]= {"function", "return", "var", "int", "random", "Math", "while", 
-			   "else", "for", "document", "write", "writeln", "true", 
-			   "false", "True", "False", "window", "indexOf", "navigator", "case", "if"};
 
-  if (len < 1) return 0;
+/*   char keywords [21][10]= {"function", "return", "var", "int", "random", "Math", "while",  */
+/* 			   "else", "for", "document", "write", "writeln", "true",  */
+/* 			   "false", "True", "False", "window", "indexOf", "navigator", "case", "if"}; */
 
-  // change the limit to 21 to enable if as a keyword
-  for (i=0; i < 20; i++) {
-    char* word = keywords[i];
-    
-    if (len <= (int) strlen(word))
-      continue;
 
-    if (word[0] != cp[0])
-      continue;
+/*   return 0; */
+/*   if (len < 1) return 0; */
 
-    for (j=1; j < (int) strlen(word); j++) {
-      if (isxdigit(word[j])) {
-	if (!isxdigit(cp[j]))
-	  goto next_word;
-	else
-	  continue;
-      }
+/*   // change the limit to 21 to enable if as a keyword */
+/*   for (i=0; i < 20; i++) { */
+/*     char* word = keywords[i]; */
+    
+/*     if (len <= (int) strlen(word)) */
+/*       continue; */
+
+/*     if (word[0] != cp[0]) */
+/*       continue; */
+
+/*     for (j=1; j < (int) strlen(word); j++) { */
+/*       if (isxdigit(word[j])) { */
+/* 	if (!isxdigit(cp[j])) */
+/* 	  goto next_word; */
+/* 	else */
+/* 	  continue; */
+/*       } */
       
-      if (cp[j] != word[j])
-	goto next_word;
-    }
-    if (!isalnum(cp[j]))
-      return strlen(word)+1;
+/*       if (cp[j] != word[j]) */
+/* 	goto next_word; */
+/*     } */
+/*     if (!isalnum(cp[j])) */
+/*       return strlen(word)+1; */
       
-  next_word:
-    continue;
-  }
+/*   next_word: */
+/*     continue; */
+/*   } */
+
+/*   return 0; */
+/* } */
 
-  return 0;
-}
 
 
-/*
 
 int skipJSPattern (char *cp, int len) {
 
@@ -649,7 +652,7 @@ int skipJSPattern (char *cp, int len) {
 
   return 0;
 }
-*/
+
 
 
 int isalnum_ (char c) {
@@ -753,89 +756,6 @@ int offset2Hex (char *p, int range, int isLastCharHex) {
 }
 
 /*
- * capacityJS returns the number of usable hex char 
- * in the input HTTP message for data encoding
- *
- * Input:
- * buf - pointer to HTTP message
- * len - sizeof buf
- * mode - 
- *   CONTENT_JAVASCRIPT (case 1); HTTP message body is a JavaScript 
- *     (e.g., Content-Type: {text/javascript, application/x-javascript,
- *     application/javascript})
- *   CONTENT_HTML_JAVASCRIPT (case 2)
- *     Content-Type: text/html and HTTP message body contains
- *     <script type="text/javascript"> ... </script>
- *
- * Output:
- * capacityJS returns the number of usable hex char that can be embedded
- * in the HTTP message
- *
- * Note:
- * This is a prototype for the simple version (all hex char are usable)
- * will refine this to skip JavaScript keywords in the next iteration
- *
- */
-
-
-
-unsigned int capacityJS (char* buf, int len, int mode) {
-  char *hEnd, *bp, *jsStart, *jsEnd;
-  int cnt=0;
-
-  // jump to the beginning of the body of the HTTP message
-  hEnd = strstr(buf, "\r\n\r\n");
-  if (hEnd == NULL) {
-    // cannot find the separator between HTTP header and HTTP body
-    return 0;
-  }
-  bp = hEnd + 4;
-
-  if (mode == CONTENT_JAVASCRIPT) {
-     while (bp < (buf+len)) {
-       if (isxdigit(*bp)) {
-         cnt++;
-#ifdef DEBUG
-         printf("%c", *bp);
-#endif
-       }
-       bp++;
-     }
-#ifdef DEBUG
-     printf("\n");
-#endif
-     return cnt;
-  } else if (mode == CONTENT_HTML_JAVASCRIPT) {
-     while (bp < (buf+len)) {
-       jsStart = strstr(bp, "<script type=\"text/javascript\">");
-       if (jsStart == NULL) break;
-       bp = jsStart+31;
-       jsEnd = strstr(bp, "</script>");
-       if (jsEnd == NULL) break;
-       // count the number of usable hex char between jsStart+31 and jsEnd
-       while (bp < jsEnd) {
-         if (isxdigit(*bp)) {
-           cnt++;
-#ifdef DEBUG
-           printf("%c", *bp);
-#endif
-         }
-         bp++;
-       }
-       bp += 9;
-     }
-#ifdef DEBUG
-     printf("\n");
-#endif
-     return cnt;
-  } else {
-    fprintf(stderr, "Unknown mode (%d) for capacityJS() ... \n", mode);
-    return 0;
-  }
-
-}
-
-/*
  * capacityJS3 is the next iteration for capacityJS
  */
 unsigned int capacityJS3 (char* buf, int len, int mode) {
diff --git a/src/steg/payloads.h b/src/steg/payloads.h
index 56729fe..7d66bbf 100644
--- a/src/steg/payloads.h
+++ b/src/steg/payloads.h
@@ -143,7 +143,6 @@ int skipJSPattern (char *cp, int len);
 int isalnum_ (char c);
 int offset2Alnum_ (char *p, int range);
 int offset2Hex (char *p, int range, int isLastCharHex);
-unsigned int capacityJS (char* buf, int len, int mode);
 unsigned int capacityJS3 (char* buf, int len, int mode);
 unsigned int get_max_JS_capacity(void);
 unsigned int get_max_HTML_capacity(void);



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits