~ubuntu-branches/ubuntu/precise/ettercap/precise

« back to all changes in this revision

Viewing changes to src/ec_dissector_msn.c

  • Committer: Bazaar Package Importer
  • Author(s): Murat Demirten
  • Date: 2003-06-21 19:57:18 UTC
  • Revision ID: james.westby@ubuntu.com-20030621195718-qqbbfk18e1djchd9
Tags: upstream-0.6.b
ImportĀ upstreamĀ versionĀ 0.6.b

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    ettercap -- dissector MSN -- TCP 1863
 
3
 
 
4
    Copyright (C) 2001  ALoR <alor@users.sourceforge.net>, NaGA <crwm@freemail.it>
 
5
 
 
6
    This program is free software; you can redistribute it and/or modify
 
7
    it under the terms of the GNU General Public License as published by
 
8
    the Free Software Foundation; either version 2 of the License, or
 
9
    (at your option) any later version.
 
10
 
 
11
    This program is distributed in the hope that it will be useful,
 
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
    GNU General Public License for more details.
 
15
 
 
16
    You should have received a copy of the GNU General Public License
 
17
    along with this program; if not, write to the Free Software
 
18
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
19
 
 
20
    $Id: ec_dissector_msn.c,v 1.3 2002/04/16 18:35:11 alor Exp $
 
21
*/
 
22
 
 
23
#include "include/ec_main.h"
 
24
 
 
25
#include "include/ec_dissector.h"
 
26
#include "include/ec_decodedata.h"
 
27
#include "include/ec_inet_structures.h"
 
28
 
 
29
// protos
 
30
 
 
31
FUNC_DISSECTOR(Dissector_msn);
 
32
 
 
33
// --------------------
 
34
 
 
35
FUNC_DISSECTOR(Dissector_msn)
 
36
{
 
37
 
 
38
   TCP_header *tcp;
 
39
   u_char *payload;
 
40
   u_char collector[MAX_DATA];
 
41
   ONLY_CONNECTION;
 
42
 
 
43
   tcp = (TCP_header *) data;
 
44
 
 
45
   if (data_to_ettercap->datalen == 0) return 0;      // no data...
 
46
 
 
47
   payload = (char *)((int)tcp + tcp->doff * 4);
 
48
 
 
49
   memset(collector, 0, MAX_DATA);
 
50
   memcpy(collector, payload, data_to_ettercap->datalen);
 
51
 
 
52
   /* the client send its username (email) */
 
53
   
 
54
   if ( (Dissector_StateMachine_GetStatus(data_to_ettercap, NULL) == 0) && ntohs(tcp->dest) == SERV_PORT)  {
 
55
      char *p;
 
56
 
 
57
      p = strstr(collector, "MD5 I");
 
58
      if (!p) return 0;
 
59
      
 
60
      DEBUG_MSG("MSN username");
 
61
      
 
62
      p = p + strlen("MD5 I ");
 
63
      
 
64
      snprintf(data_to_ettercap->user, sizeof(data_to_ettercap->user), "%s\n", p);
 
65
      data_to_ettercap->user[sizeof(data_to_ettercap->user)-2] = '\n';
 
66
      data_to_ettercap->user[sizeof(data_to_ettercap->user)-1] = '\0';
 
67
      
 
68
      sprintf(data_to_ettercap->type, "MSN messenger");
 
69
      
 
70
      Dissector_StateMachine_SetStatus(data_to_ettercap, 1, NULL);
 
71
      return 0; 
 
72
   }
 
73
   
 
74
   /* server messages... collect the MD5 challenge */
 
75
           
 
76
   if ( (Dissector_StateMachine_GetStatus(data_to_ettercap, NULL) == 1) && ntohs(tcp->source) == SERV_PORT) {
 
77
 
 
78
      char *p;
 
79
      int i;
 
80
 
 
81
      p = strstr(collector, "MD5 S");
 
82
      if (!p) return 0;
 
83
      
 
84
      DEBUG_MSG("MSN challenge");
 
85
      
 
86
      p = p + strlen("MD5 S ");
 
87
      
 
88
      for(i=0; i<strlen(p); i++)
 
89
         if (p[i] == '\r')
 
90
            p[i] = '\0';
 
91
      
 
92
      snprintf(data_to_ettercap->info, sizeof(data_to_ettercap->info), "Server MD5 challenge : %s\n", p);
 
93
      data_to_ettercap->info[sizeof(data_to_ettercap->info)-2] = '\n';
 
94
      data_to_ettercap->info[sizeof(data_to_ettercap->info)-1] = '\0';
 
95
      
 
96
      Dissector_StateMachine_SetStatus(data_to_ettercap, 2, NULL);
 
97
      return 0;
 
98
   } 
 
99
   
 
100
   /* the client reply with the MD5 password */
 
101
 
 
102
   if ( (Dissector_StateMachine_GetStatus(data_to_ettercap, NULL) == 2) && ntohs(tcp->dest) == SERV_PORT) {
 
103
      
 
104
      char *p;
 
105
 
 
106
      p = strstr(collector, "MD5 S");
 
107
      if (!p) return 0;
 
108
      
 
109
      DEBUG_MSG("MSN password");
 
110
      
 
111
      p = p + strlen("MD5 S ");
 
112
      
 
113
      snprintf(data_to_ettercap->pass, sizeof(data_to_ettercap->pass), "%s\n", p);
 
114
      data_to_ettercap->pass[sizeof(data_to_ettercap->pass)-2] = '\n';
 
115
      data_to_ettercap->pass[sizeof(data_to_ettercap->pass)-1] = '\0';
 
116
      
 
117
      Dissector_StateMachine_SetStatus(data_to_ettercap, 0, NULL);
 
118
      return 0;
 
119
    }
 
120
 
 
121
    return 0;
 
122
}
 
123
 
 
124
/* EOF */
 
125
 
 
126
// vim:ts=3:expandtab
 
127