dsniff  2.4b2
About: A collection of tools for network auditing
  Fossies Dox: dsniff-2.4b2.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

decode_smtp.c
Go to the documentation of this file.
1 /*
2  * decode_smtp.c
3  *
4  * Simple Mail Transfer Protocol.
5  *
6  * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
7  *
8  * $Id: decode_smtp.c,v 1.3 2001/03/15 08:33:02 dugsong Exp $
9  */
10 
11 #include "config.h"
12 
13 #include <sys/types.h>
14 
15 #include <stdio.h>
16 #include <string.h>
17 
18 #include "base64.h"
19 #include "options.h"
20 #include "decode.h"
21 
22 int
23 decode_smtp(u_char *buf, int len, u_char *obuf, int olen)
24 {
25  char *p;
26  int i, j, login = 0;
27 
28  obuf[0] = '\0';
29 
30  for (p = strtok(buf, "\r\n"); p != NULL; p = strtok(NULL, "\r\n")) {
31  if (login == 1) {
32  strlcat(obuf, p, olen);
33  i = base64_pton(p, p, strlen(p));
34  p[i] = '\0';
35  j = strlen(obuf);
36  snprintf(obuf + j, olen - j, " [%s]\n", p);
37  login = 0;
38  }
39  else if (strncmp(p, "AUTH LOGIN ", 11) == 0) {
40  strlcat(obuf, p, olen);
41  p += 11;
42  i = base64_pton(p, p, strlen(p));
43  p[i] = '\0';
44  j = strlen(obuf);
45  snprintf(obuf + j, olen - j, " [%s]\n", p);
46  login = 1;
47  }
48  else if (strncmp(p, "MAIL ", 5) == 0 ||
49  strncmp(p, "RCPT ", 5) == 0 ||
50  strncmp(p, "DATA", 4) == 0) {
51  break;
52  }
53  }
54  return (strlen(obuf));
55 }
options.h
decode.h
buf
Definition: buf.h:14
base64.h
decode_smtp
int decode_smtp(u_char *buf, int len, u_char *obuf, int olen)
Definition: decode_smtp.c:23
base64_pton
int base64_pton(char const *src, u_char *target, size_t targsize)
Definition: base64.c:128
config.h
obuf
static char obuf[4096]
Definition: trigger.c:43
strlcat
size_t strlcat(char *dst, const char *src, size_t siz)
Definition: strlcat.c:44