2
ettercap -- dissector for SNMP (community names) -- UDP 161
4
Copyright (C) 2001 ALoR <alor@users.sourceforge.net>, NaGA <crwm@freemail.it>
6
Additional Copyright for this file: LnZ Lorenzo Porro <lporro@libero.it>
8
This program is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 2 of the License, or
11
(at your option) any later version.
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with this program; if not, write to the Free Software
20
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
23
$Id: ec_dissector_snmp.c,v 1.8 2002/04/27 17:48:27 alor Exp $
27
#include "include/ec_main.h"
29
#include "include/ec_dissector.h"
30
#include "include/ec_inet_structures.h"
32
/* Protocol version numbers */
33
/* for further implementation
34
#define SNMP_VERSION_1 0
35
#define SNMP_VERSION_2c 1
36
#define SNMP_VERSION_2u 2
37
#define SNMP_VERSION_3 3
39
static const value_string versions[] = {
40
{ SNMP_VERSION_1, "1" },
41
{ SNMP_VERSION_2c, "2C" },
42
{ SNMP_VERSION_2u, "2U" },
43
{ SNMP_VERSION_3, "3" },
46
//------------------------------------
50
FUNC_DISSECTOR(Dissector_snmp);
51
char *com_name(unsigned char *buf);
52
// --------------------
54
char *com_name(unsigned char *buf)
56
unsigned int i=0, ssize=0;
59
while(buf[i++] != '\x04' && i < 500);
61
if(buf[i-1] == '\x04' && buf[i] != '\x00')
68
else if(buf[i] == 130)
70
if(buf[i+1]=='\x01'&&buf[i+2]=='\x00')
81
if (ssize>100) return NULL; // Another little check
83
name = (char *)calloc(ssize+5,1);
84
memcpy(name, (char *)&buf[i+1], ssize);
92
FUNC_DISSECTOR(Dissector_snmp)
98
udp = (UDP_header *) data;
99
payload = (char *) ((int)udp + UDP_HEADER);
101
DEBUG_MSG("\tDissector_SNMP");
103
if (data_to_ettercap->datalen == 0) return 0; // No data...
105
dname = com_name(payload);
109
sprintf(data_to_ettercap->user, "\n");
110
snprintf(data_to_ettercap->pass, sizeof(data_to_ettercap->pass), "%s\n", dname);
119
// vim:ts=3:expandtab