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_rlogin.c
Go to the documentation of this file.
1 /*
2  * decode_rlogin.c
3  *
4  * Berkeley remote login/shell/exec.
5  *
6  * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
7  *
8  * $Id: decode_rlogin.c,v 1.6 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 "options.h"
19 #include "decode.h"
20 
21 int
22 decode_rlogin(u_char *buf, int len, u_char *obuf, int olen)
23 {
24  u_char *p, *q;
25 
26  /* Skip first NULL, or rexec stderr port */
27  for (p = buf; p - buf < len && *p == '\0'; p++)
28  ; /* VOID */
29 
30  strlcpy(obuf, "[", olen);
31  strlcat(obuf, p, olen); /* Local username */
32  strlcat(obuf, ":", olen);
33  p += strlen(p) + 1;
34 
35  strlcat(obuf, p, olen); /* Remote username */
36  strlcat(obuf, "]\n", olen);
37  p += strlen(p) + 1;
38 
39  p += strlen(p) + 1; /* Skip term info */
40 
41  if ((q = strstr(p, "\xff\xffss")) != NULL) /* Skip window size */
42  p += 12;
43 
44  for (p = strtok(p, "\r\n"); p != NULL; p = strtok(NULL, "\r\n")) {
45  strlcat(obuf, p, olen);
46  strlcat(obuf, "\n", olen);
47  }
48  if (!strip_lines(obuf, Opt_lines))
49  return (0);
50 
51  return (strlen(obuf));
52 }
53 
strlcpy
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: strlcpy.c:43
options.h
strip_lines
int strip_lines(char *buf, int max_lines)
Definition: decode.c:159
decode.h
Opt_lines
int Opt_lines
Definition: dsniff.c:43
buf
Definition: buf.h:14
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
decode_rlogin
int decode_rlogin(u_char *buf, int len, u_char *obuf, int olen)
Definition: decode_rlogin.c:22