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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
|
/* $OpenBSD: packet.h,v 1.66 2015/01/30 01:13:33 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
* All rights reserved
* Interface for the packet protocol functions.
*
* As far as I am concerned, the code I have written for this software
* can be used freely for any purpose. Any derived versions of this
* software must be clearly marked as such, and if the derived work is
* incompatible with the protocol description in the RFC file, it must be
* called by a name other than "ssh" or "Secure Shell".
*/
#ifndef PACKET_H
#define PACKET_H
#ifdef WIN32
#include "winfixssh.h"
#endif
#include "opensshlib.h"
#ifndef WIN32
#include <termios.h>
#endif
#ifdef WITH_OPENSSL
# include <openssl/bn.h>
# ifdef OPENSSL_HAS_ECC
# include <openssl/ec.h>
# else /* OPENSSL_HAS_ECC */
# define EC_KEY void
# define EC_GROUP void
# define EC_POINT void
# endif /* OPENSSL_HAS_ECC */
#else /* WITH_OPENSSL */
# define BIGNUM void
# define EC_KEY void
# define EC_GROUP void
# define EC_POINT void
#endif /* WITH_OPENSSL */
#ifndef WIN32
#include <signal.h>
#endif
#include "sys-queue.h"
#ifdef __cplusplus
extern "C" {
#endif
struct kex;
struct sshkey;
struct sshbuf;
struct session_state; /* private session data */
#include "dispatch.h" /* typedef, DISPATCH_MAX */
struct key_entry {
TAILQ_ENTRY(key_entry) next;
struct sshkey *key;
};
struct ssh {
/* Session state */
struct session_state *state;
/* Key exchange */
struct kex *kex;
/* cached remote ip address and port*/
char *remote_ipaddr;
int remote_port;
/* Dispatcher table */
// dispatch_fn *dispatch[DISPATCH_MAX];
/* number of packets to ignore in the dispatcher */
int dispatch_skip_packets;
/* datafellows */
int compat;
/* Lists for private and public keys */
TAILQ_HEAD(, key_entry) private_keys;
TAILQ_HEAD(, key_entry) public_keys;
/* APP data */
void *app_data;
};
struct ssh *ssh_alloc_session_state(void);
//struct ssh *ssh_packet_set_connection(struct ssh *, int, int);
int ssh_packet_set_connection(ncrack_ssh_state *nstate);
void ssh_packet_set_timeout(struct ssh *, int, int);
int ssh_packet_stop_discard(ncrack_ssh_state *);
int ssh_packet_connection_af(struct ssh *);
void ssh_packet_set_nonblocking(struct ssh *);
int ssh_packet_get_connection_in(struct ssh *);
int ssh_packet_get_connection_out(struct ssh *);
void ssh_packet_close(struct ssh *);
void ssh_packet_set_encryption_key(struct ssh *, const u_char *, u_int, int);
void ssh_packet_set_protocol_flags(struct ssh *, u_int);
u_int ssh_packet_get_protocol_flags(struct ssh *);
int ssh_packet_start_compression(struct ssh *, int);
void ssh_packet_set_tos(struct ssh *, int);
void ssh_packet_set_interactive(struct ssh *, int, int, int);
int ssh_packet_is_interactive(struct ssh *);
void ssh_packet_set_server(struct ssh *);
void ssh_packet_set_authenticated(struct ssh *);
int ssh_packet_send1(ncrack_ssh_state *);
int ssh_packet_send2_wrapped(ncrack_ssh_state *);
int ssh_packet_send2(ncrack_ssh_state *);
int ssh_packet_read(struct ssh *);
int ssh_packet_read_expect(struct ssh *, u_int type);
int ssh_packet_read_poll(struct ssh *);
int ssh_packet_read_poll1(ncrack_ssh_state *, u_char *);
int ssh_packet_read_poll2(ncrack_ssh_state *nstate, u_char *, u_int32_t *seqnr_p);
int ssh_packet_process_incoming(ncrack_ssh_state *, const char *buf, u_int len);
int ssh_packet_read_seqnr(struct ssh *, u_char *, u_int32_t *seqnr_p);
int ssh_packet_read_poll_seqnr(ncrack_ssh_state *, u_char *, u_int32_t *seqnr_p);
const void *ssh_packet_get_string_ptr(ncrack_ssh_state *, u_int *length_ptr);
void ssh_packet_disconnect(ncrack_ssh_state *, const char *fmt, ...)
__attribute__((format(printf, 2, 3)))
__attribute__((noreturn));
void ssh_packet_send_debug(struct ssh *, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
int ssh_set_newkeys(ncrack_ssh_state *nstate, int mode);
void ssh_packet_get_bytes(struct ssh *, u_int64_t *, u_int64_t *);
typedef void *(ssh_packet_comp_alloc_func)(void *, u_int, u_int);
typedef void (ssh_packet_comp_free_func)(void *, void *);
void ssh_packet_set_compress_hooks(struct ssh *, void *,
ssh_packet_comp_alloc_func *, ssh_packet_comp_free_func *);
int ssh_packet_write_poll(ncrack_ssh_state *);
int ssh_packet_write_wait(ncrack_ssh_state *);
int ssh_packet_have_data_to_write(struct ssh *);
int ssh_packet_not_very_much_data_to_write(struct ssh *);
int ssh_packet_connection_is_on_socket(struct ssh *);
int ssh_packet_remaining(ncrack_ssh_state *);
void ssh_packet_send_ignore(struct ssh *, int);
void tty_make_modes(int, struct termios *);
void tty_parse_modes(int, int *);
void ssh_packet_set_alive_timeouts(struct ssh *, int);
int ssh_packet_inc_alive_timeouts(struct ssh *);
int ssh_packet_set_maxsize(struct ssh *, u_int);
u_int ssh_packet_get_maxsize(struct ssh *);
int ssh_packet_get_state(struct ssh *, struct sshbuf *);
int ssh_packet_set_state(struct ssh *, struct sshbuf *);
const char *ssh_remote_ipaddr(struct ssh *);
int ssh_packet_need_rekeying(ncrack_ssh_state *nstate);
void ssh_packet_set_rekey_limits(struct ssh *, u_int32_t, time_t);
time_t ssh_packet_get_rekey_timeout(struct ssh *);
/* XXX FIXME */
void ssh_packet_backup_state(struct ssh *, struct ssh *);
void ssh_packet_restore_state(struct ssh *, struct ssh *);
void *ssh_packet_get_input(struct ssh *);
void *ssh_packet_get_output(struct ssh *);
/* new API */
//int sshpkt_start(struct ssh *ssh, u_char type);
int sshpkt_start(ncrack_ssh_state *nstate, u_char type);
int sshpkt_send(ncrack_ssh_state *ssh);
int sshpkt_disconnect(ncrack_ssh_state *, const char *fmt, ...)
__attribute__((format(printf, 2, 3)));
int sshpkt_add_padding(ncrack_ssh_state *, u_char);
void sshpkt_fatal(struct ssh *ssh, const char *tag, int r);
//int sshpkt_put(struct ssh *ssh, const void *v, size_t len);
int sshpkt_put(ncrack_ssh_state *nstate, const void *v, size_t len);
//int sshpkt_putb(struct ssh *ssh, const struct sshbuf *b);
int sshpkt_putb(ncrack_ssh_state *nstate, const struct sshbuf *b);
int sshpkt_put_u8(ncrack_ssh_state *nstate, u_char val);
int sshpkt_put_u32(ncrack_ssh_state *nstate, u_int32_t val);
int sshpkt_put_u64(ncrack_ssh_state *nstate, u_int64_t val);
int sshpkt_put_string(ncrack_ssh_state *nstate, const void *v, size_t len);
int sshpkt_put_cstring(ncrack_ssh_state *nstate, const void *v);
int sshpkt_put_stringb(ncrack_ssh_state *nstate, const struct sshbuf *v);
int sshpkt_put_ec(ncrack_ssh_state *nstate, const EC_POINT *v, const EC_GROUP *g);
int sshpkt_put_bignum1(ncrack_ssh_state *nstate, const BIGNUM *v);
int sshpkt_put_bignum2(ncrack_ssh_state *nstate, const BIGNUM *v);
int sshpkt_get(ncrack_ssh_state *nstate, void *valp, size_t len);
int sshpkt_get_u8(ncrack_ssh_state *nstate, u_char *valp);
int sshpkt_get_u32(ncrack_ssh_state *nstate, u_int32_t *valp);
int sshpkt_get_u64(ncrack_ssh_state *nstate, u_int64_t *valp);
int sshpkt_get_string(ncrack_ssh_state *nstate, u_char **valp, size_t *lenp);
int sshpkt_get_string_direct(ncrack_ssh_state *nstate, const u_char **valp, size_t *lenp);
int sshpkt_get_cstring(ncrack_ssh_state *nstate, char **valp, size_t *lenp);
int sshpkt_get_ec(ncrack_ssh_state *nstate, EC_POINT *v, const EC_GROUP *g);
int sshpkt_get_bignum1(ncrack_ssh_state *nstate, BIGNUM *v);
int sshpkt_get_bignum2(ncrack_ssh_state *nstate, BIGNUM *v);
int sshpkt_get_end(ncrack_ssh_state *nstate);
const u_char *sshpkt_ptr(ncrack_ssh_state *, size_t *lenp);
int ncrackssh_ssh_packet_read(ncrack_ssh_state *nstate);
/* OLD API */
extern struct ssh *active_state;
#include "opacket.h"
#if !defined(WITH_OPENSSL)
# undef BIGNUM
# undef EC_KEY
# undef EC_GROUP
# undef EC_POINT
#elif !defined(OPENSSL_HAS_ECC)
# undef EC_KEY
# undef EC_GROUP
# undef EC_POINT
#endif
#ifdef __cplusplus
} /* End of 'extern "C"' */
#endif
#endif /* PACKET_H */
|