-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathssl-enum.h
More file actions
168 lines (152 loc) · 5.63 KB
/
ssl-enum.h
File metadata and controls
168 lines (152 loc) · 5.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
* SSL Enumerator (ssl-enum) is Copyright (C) 2009-2014 David Kierznowski
* (https://github.com/davidkierznowski/ssl-enum).
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version.
*
*/
#include <stdio.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <stdint.h>
#include <sys/types.h>
#include <time.h> //defines time() and is needed for randomize()
#include <netdb.h>
#define RCVBUFSIZE 5000 /* Size of receive buffer */
#define DEFAULT_TCP_CONNECT_TIMEOUT 10 /* TCP connect timeout in seconds */
#define DEFAULT_RECV_TIMEOUT 30 /* TCP recv timeout in seconds */
/*
Record Layer Protocol Types
20 (0x14) ChangeCipherSpec
21 (0x15) Alert
22 (0x16) Handshake
23 (0x17) Application Protocol data
*/
#define SSLCHANGECIPHERSPEC 20 /* We dont currently use this */
#define SSLALERT 21
#define SSLHANDSHAKE 22
#define SSLDATA 23 /* We dont currently use this */
/*
SSL2 differences
128 (0x80) Handshake
*/
#define SSL2_HANDSHAKE 128
#define SSL2_SVRHANDSHAKE 83
#define SSL2_CIPHERLEN 0x0003
#define SSL2_CHALLENGE_LEN 18
/* Protocol versions */
#define SSL2_VERSION 0x0002
#define SSL3_VERSION 0x0300
#define TLS1_VERSION 0x0301
/* Hello messages */
#define CLIENT_HELLO 0x01
#define SERVER_HELLO 0x02
/* Bytes of interest */
#define SSLALERTBYTE 06
#define SERVERHELLOBYTE 05
#define SSL2_SERVERHELLOBYTE 3
/* For clientHello struct */
#define SESSIONID 0x0000
#define CIPHER_LEN 0x0002
#define COMPRESSION_LEN 0x01
#define COMPRESSION_TYPE 0x00
/* Max cipher lines */
#define MAXLINE 255
/* Translate recv data into hex for parsing */
char *hexstring(const unsigned char*, size_t);
/* Allows us to timeout a connection */
void sig_alarm(int);
void process_ssl_hello(char *serverhello, char *c1, char *c2, char *c3, int verbose);
void process_ssl_alert(char *sslalert,char *c1, char *c2, char *c3, int verbose);
void DieWithError(char *errorMessage);
void make_ssl_debug(unsigned char *buf, char *msg, int len);
unsigned int hstr_i(const char *cptr);
unsigned char *build_ssl2_hello_msg(); // todo, stops -Wall errors
unsigned char *build_hello_msg(); // todo, stops -Wall errors
int new_socket(struct sockaddr_in *, struct hostent **, unsigned short sslPort);
void new_connect(struct sockaddr_in *, int sock);
void new_write(int sock, unsigned char *pkt_out, int struct_len);
void new_read(); // todo, stops -Wall errors
struct getBytes {
int totalBytesRcvd;
char *recv_data;
};
struct ssl2_client_hello
{
uint8_t rl_content_type;
uint8_t rl_len;
uint8_t client_handshake;
/*
todo: We can define client version 3.0
which will tell server to switch modes
if available.
*/
uint16_t client_version;
uint16_t cipher_len;
uint16_t sessionID;
uint16_t challenge_len;
/*
todo: We use a uint32 and then perform bitwise
shift later to get uint24, I'm not sure
how portable this will be.
*/
uint32_t CipherSuite;
char random[14];
};
struct tls1_ssl3_client_hello
{
uint8_t rl_content_type; /* Client Hello Handshake 22 (0x16) */
uint16_t rl_client_version; /* SSL/TLS version (0x0301) */
uint16_t rl_len; /* Length for rest of struct */
uint8_t client_handshake; /* handshake client hello 0x01 */
uint8_t client_len_pad;
uint16_t client_len; /* Length for rest of struct */
uint16_t client_version; /* SSL/TLS version (0x0301) */
//uint32_t gmt_unix_time; /* The current time and date in UNIX 32-bit format */
char random_bytes[32]; /* 28 bytes generated by random number generated */
uint8_t sessionID; /* opaque SessionID<0..32>, safe to leave as 0 */
uint16_t cipher_len; /* cipher len, 2 bytes per cipher */
uint16_t CipherSuite; /* Cryptographic suite selector 2 bytes */
uint8_t compression_len; /* compression length */
uint8_t compression_method; /* 0-255 safe to leave null or 00 */
};
/* cipher is 44 bytes in */
struct tls1_ssl3_server_hello
{
uint8_t content_type; /* handshake 22 (0x16) and message len */
uint16_t ssl_version; /* SSL/TLS version (0x0301) */
uint16_t hello_len; /* Server Hello len with handshake */
uint8_t server_hello; /* Server hello start */
uint32_t server_hello_len; /* Server hello len */
uint16_t ssl_version_hello; /* SSL/TLS version (0x0301) */
uint32_t gmt_unix_time; /* The current time and date in UNIX 32-bit format */
char random_bytes[28]; /* 28 bytes generated by random number generated */
uint8_t SessionID_len; /* opaque SessionID<0..32>, safe to leave as 0 */
unsigned char *SessionID;
uint16_t CipherSuite; /* Cryptographic suite selector 2 bytes */
uint8_t compression_method; /* 0-255 safe to leave null or 00 */
};