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_nntp.c
Go to the documentation of this file.
1 /*
2  * decode_nntp.c
3  *
4  * Network News Transport Protocol.
5  *
6  * Copyright (c) 2000 Felix von Leitner <felix@convergence.de>
7  * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
8  *
9  * $Id: decode_nntp.c,v 1.5 2001/03/15 08:33:01 dugsong Exp $
10  */
11 
12 #include "config.h"
13 
14 #include <sys/types.h>
15 
16 #include <stdio.h>
17 #include <string.h>
18 
19 #include "base64.h"
20 #include "decode.h"
21 
22 int
23 decode_nntp(u_char *buf, int len, u_char *obuf, int olen)
24 {
25  char *p;
26  int i, simple, dpa;
27 
28  obuf[0] = '\0';
29  simple = dpa = 0;
30 
31  for (p = strtok(buf, "\r\n"); p != NULL; p = strtok(NULL, "\r\n")) {
32  if (simple == 1) {
33  strlcat(obuf, p, olen);
34  strlcat(obuf, "\n", olen);
35  simple = 0;
36  }
37  else if (strncasecmp(p, "AUTHINFO ", 9) == 0) {
38  strlcat(obuf, p, olen);
39 
40  if (strncasecmp(p + 9, "SIMPLE", 6) == 0) {
41  simple = 1;
42  }
43  else if (strncasecmp(p + 9, "GENERIC ", 8) == 0) {
44  if (strncasecmp(p + 17, "DPA", 3) == 0) {
45  dpa = 1;
46  }
47  else if (dpa == 1) {
48  p += 17;
49  i = base64_pton(p, p, strlen(p));
50  p[i] = '\0';
51  i = strlen(obuf);
52  snprintf(obuf + i, olen - i,
53  " [%s]", p);
54  }
55  }
56  strlcat(obuf, "\n", olen);
57  }
58  }
59  return (strlen(obuf));
60 }
61 
decode.h
buf
Definition: buf.h:14
base64.h
base64_pton
int base64_pton(char const *src, u_char *target, size_t targsize)
Definition: base64.c:128
decode_nntp
int decode_nntp(u_char *buf, int len, u_char *obuf, int olen)
Definition: decode_nntp.c:23
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