~ubuntu-branches/ubuntu/utopic/suricata/utopic

« back to all changes in this revision

Viewing changes to src/app-layer-ssh.h

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Chifflier
  • Date: 2010-09-29 10:02:52 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20100929100252-2ak252422dwsqs7e
Tags: 1.0.2-1
New Upstream version 1.0.2 (Closes: #598389)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2007-2010 Open Information Security Foundation
 
2
 *
 
3
 * You can copy, redistribute or modify this Program under the terms of
 
4
 * the GNU General Public License version 2 as published by the Free
 
5
 * Software Foundation.
 
6
 *
 
7
 * This program is distributed in the hope that it will be useful,
 
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
 * GNU General Public License for more details.
 
11
 *
 
12
 * You should have received a copy of the GNU General Public License
 
13
 * version 2 along with this program; if not, write to the Free Software
 
14
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
15
 * 02110-1301, USA.
 
16
 */
 
17
 
 
18
/**
 
19
 * \file
 
20
 *
 
21
 * \author Pablo Rincon <pablo.rincon.crespo@gmail.com>
 
22
 */
 
23
 
 
24
#ifndef __APP_LAYER_SSH_H__
 
25
#define __APP_LAYER_SSH_H__
 
26
 
 
27
#define SSH_FLAG_SERVER_CHANGE_CIPHER_SPEC   0x01    /**< Flag to indicate that
 
28
                                                     server will now on sends
 
29
                                                     encrypted msgs. */
 
30
#define SSH_FLAG_CLIENT_CHANGE_CIPHER_SPEC   0x02    /**< Flag to indicate that
 
31
                                                     client will now on sends
 
32
                                                     encrypted msgs. */
 
33
 
 
34
#define SSH_FLAG_CLIENT_VERSION_PARSED       0x01
 
35
#define SSH_FLAG_SERVER_VERSION_PARSED       0x02
 
36
 
 
37
/* This flags indicate that the rest of the communication
 
38
 * must be ciphered, so the parsing finish here */
 
39
#define SSH_FLAG_PARSER_DONE                 0x04
 
40
 
 
41
/* MSG_CODE */
 
42
#define SSH_MSG_NEWKEYS             21
 
43
 
 
44
enum {
 
45
    SSH_FIELD_NONE = 0,
 
46
    SSH_FIELD_SERVER_VER_STATE_LINE,
 
47
    SSH_FIELD_CLIENT_VER_STATE_LINE,
 
48
    SSH_FIELD_SERVER_PKT_LENGTH,
 
49
    SSH_FIELD_CLIENT_PKT_LENGTH,
 
50
    SSH_FIELD_SERVER_PADDING_LENGTH,
 
51
    SSH_FIELD_CLIENT_PADDING_LENGTH,
 
52
    SSH_FIELD_SERVER_PAYLOAD,
 
53
    SSH_FIELD_CLIENT_PAYLOAD,
 
54
 
 
55
    /* must be last */
 
56
    SSH_FIELD_MAX,
 
57
};
 
58
 
 
59
/** From SSH-TRANSP rfc
 
60
 
 
61
    SSH Bunary packet structure:
 
62
      uint32    packet_length
 
63
      byte      padding_length
 
64
      byte[n1]  payload; n1 = packet_length - padding_length - 1
 
65
      byte[n2]  random padding; n2 = padding_length
 
66
      byte[m]   mac (Message Authentication Code - MAC); m = mac_length
 
67
 
 
68
    So we are going to do a header struct to store
 
69
    the lenghts and msg_code (inside payload, if any)
 
70
*/
 
71
 
 
72
typedef struct SSHHeader_ {
 
73
    uint32_t pkt_len;
 
74
    uint8_t padding_len;
 
75
    uint8_t msg_code;
 
76
} SshHeader;
 
77
 
 
78
/** structure to store the SSH state values */
 
79
typedef struct SshState_ {
 
80
    uint8_t client_msg_code;    /**< Client content type storage field */
 
81
    uint8_t *client_proto_version;        /**< Client SSH version storage field */
 
82
    uint8_t *client_software_version;        /**< Client SSH version storage field */
 
83
 
 
84
    uint8_t server_msg_code;    /**< Server content type storage field */
 
85
    uint8_t *server_proto_version;        /**< Server SSH version storage field */
 
86
    uint8_t *server_software_version;        /**< Server SSH version storage field */
 
87
 
 
88
    uint8_t flags;                  /**< Flags to indicate the current SSH
 
89
                                         sessoin state */
 
90
    SshHeader srv_hdr;
 
91
    SshHeader cli_hdr;
 
92
} SshState;
 
93
 
 
94
void RegisterSSHParsers(void);
 
95
void SSHParserRegisterTests(void);
 
96
 
 
97
#endif /* __APP_LAYER_SSH_H__ */
 
98