Explorar o código

* Port [3317] to 1.2.14
* Fix MD5() to return from an array of buffers
* Change DETECTED_SIGCONT to DETECTED_HIJACK



svn: 3318

Bryan Drewery %!s(int64=19) %!d(string=hai) anos
pai
achega
53e4db37b9
Modificáronse 5 ficheiros con 32 adicións e 6 borrados
  1. 7 2
      src/crypt.c
  2. 22 1
      src/debug.c
  3. 1 1
      src/debug.h
  4. 1 1
      src/shell.c
  5. 1 1
      src/shell.h

+ 7 - 2
src/crypt.c

@@ -306,15 +306,20 @@ void Decrypt_File(char *infile, char *outfile)
 
 
 char *MD5(const char *string) 
 char *MD5(const char *string) 
 {
 {
-  static char	  md5string[MD5_HASH_LENGTH + 1] = "";
+  static int n = 0;
+  static char ret[5][MD5_HASH_LENGTH + 1];
+  char* md5string = ret[n++];
   unsigned char   md5out[MD5_HASH_LENGTH + 1] = "";
   unsigned char   md5out[MD5_HASH_LENGTH + 1] = "";
   MD5_CTX ctx;
   MD5_CTX ctx;
 
 
   MD5_Init(&ctx);
   MD5_Init(&ctx);
   MD5_Update(&ctx, string, strlen(string));
   MD5_Update(&ctx, string, strlen(string));
   MD5_Final(md5out, &ctx);
   MD5_Final(md5out, &ctx);
-  strlcpy(md5string, btoh(md5out, MD5_DIGEST_LENGTH), sizeof(md5string));
+  strlcpy(md5string, btoh(md5out, MD5_DIGEST_LENGTH), MD5_HASH_LENGTH + 1);
   OPENSSL_cleanse(&ctx, sizeof(ctx));
   OPENSSL_cleanse(&ctx, sizeof(ctx));
+
+  if (n == 5) n = 0;
+
   return md5string;
   return md5string;
 }
 }
 
 

+ 22 - 1
src/debug.c

@@ -105,6 +105,27 @@ void sdprintf (const char *format, ...)
   }
   }
 }
 }
 
 
+char* hexize(const unsigned char* data, size_t len) {
+  static char buffers[5][513] = { "", "", "", "", "" };
+  static int n = 0;
+  char *buf = buffers[n++];
+
+  buf[0] = 0;
+
+  for (size_t i = 0; i < len; ++i) {
+    if (i == 0)
+      sprintf(buf, "%.2X", (int) (data[i]));
+    else
+      sprintf(buf, "%s %.2X", buf, (int) (data[i]));
+  }
+
+  buf[len * 3] = 0;
+
+  if (n == 5) n = 0;
+  return buf;
+}
+
+
 void printstr(unsigned char *str, int len)
 void printstr(unsigned char *str, int len)
 {
 {
 #ifdef no
 #ifdef no
@@ -347,7 +368,7 @@ static void got_abort(int z)
 #ifndef CYGWIN_HACKS
 #ifndef CYGWIN_HACKS
 static void got_cont(int z)
 static void got_cont(int z)
 {
 {
-  detected(DETECT_SIGCONT, "POSSIBLE HIJACK DETECTED (!! MAY BE BOX REBOOT !!)");
+  detected(DETECT_HIJACK, "POSSIBLE HIJACK DETECTED (!! MAY BE BOX REBOOT !!)");
 }
 }
 #endif /* !CYGWIN_HACKS */
 #endif /* !CYGWIN_HACKS */
 
 

+ 1 - 1
src/debug.h

@@ -40,5 +40,5 @@ void init_debug();
 void eggContext(const char *, int);
 void eggContext(const char *, int);
 void eggContextNote(const char *, int, const char *);
 void eggContextNote(const char *, int, const char *);
 void printstr(unsigned char *, int);
 void printstr(unsigned char *, int);
-
+char* hexize(const unsigned char*, size_t);
 #endif /* !_DEBUG_H */
 #endif /* !_DEBUG_H */

+ 1 - 1
src/shell.c

@@ -618,7 +618,7 @@ void detected(int code, char *msg)
   if (code == DETECT_PROCESS)
   if (code == DETECT_PROCESS)
     act = badprocess;
     act = badprocess;
 #endif
 #endif
-  if (code == DETECT_SIGCONT)
+  if (code == DETECT_HIJACK)
     act = hijack;
     act = hijack;
 
 
   switch (act) {
   switch (act) {

+ 1 - 1
src/shell.h

@@ -31,7 +31,7 @@
 #define DETECT_TRACE 	2
 #define DETECT_TRACE 	2
 #define DETECT_PROMISC 	3
 #define DETECT_PROMISC 	3
 #define DETECT_PROCESS 	4		/* NOT USED */
 #define DETECT_PROCESS 	4		/* NOT USED */
-#define DETECT_SIGCONT 	5
+#define DETECT_HIJACK 	5
 
 
 #define DET_IGNORE 	0
 #define DET_IGNORE 	0
 #define DET_WARN 	1
 #define DET_WARN 	1