Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //------------------------------------------------------------------------------------------
- //DEFINING 3 STRUCTURES HERE
- //------------------------------------------------------------------------------------------
- typedef struct _SslDecryptSession {
- guchar _master_secret[SSL_MASTER_SECRET_LENGTH];
- guchar _session_id[256];
- guchar _client_random[32];
- guchar _server_random[32];
- StringInfo session_id;
- StringInfo session_ticket;
- StringInfo server_random;
- StringInfo client_random;
- StringInfo master_secret;
- StringInfo handshake_data;
- /* the data store for this StringInfo must be allocated explicitly with a capture lifetime scope */
- StringInfo pre_master_secret;
- guchar _server_data_for_iv[24];
- StringInfo server_data_for_iv;
- guchar _client_data_for_iv[24];
- StringInfo client_data_for_iv;
- gint state;
- SslCipherSuite cipher_suite;
- SslDecoder *server;
- SslDecoder *client;
- SslDecoder *server_new;
- SslDecoder *client_new;
- #if defined(HAVE_LIBGNUTLS) && defined(HAVE_LIBGCRYPT)
- gcry_sexp_t private_key;
- #endif
- StringInfo psk;
- guint16 version_netorder;
- StringInfo app_data_segment;
- SslSession session;
- } SslDecryptSession;
- /* XXX Should we use GByteArray instead? */
- typedef struct _StringInfo {
- guchar *data; /* Backing storage which may be larger than data_len */
- guint data_len; /* Length of the meaningful part of data */
- } StringInfo
- typedef struct _SslSession {
- gint cipher;
- gint compression;
- guint32 version;
- gint8 client_cert_type;
- gint8 server_cert_type;
- /* The address/proto/port of the server as determined from heuristics
- * (e.g. ClientHello) or set externally (via ssl_set_master_secret()). */
- address srv_addr;
- port_type srv_ptype;
- guint srv_port;
- /* The Application layer protocol if known (for STARTTLS support) */
- dissector_handle_t app_handle;
- guint32 last_nontls_frame;
- gboolean is_session_resumed;
- } SslSession;
- //------------------------------------------------------------------------------------------
- //Somewhere in the main function, The piece of code I am executing
- //------------------------------------------------------------------------------------------
- SslDecryptSession *ssl_session = malloc(sizeof(struct _SslDecryptSession ));
- ssl_session->client_random.data = NULL;
- ssl_session->server_random.data= NULL;
- const u_char *payload; /* Packet payload */
- //Case for client random
- printf("Client Random ");
- for (cs_id = 11; cs_id < 43; cs_id++){
- printf("%hhX", payload[cs_id] );
- }
- printf("\n");
- cs_id=11;
- ssl_session->client_random.data_len=32;
- // Segmentation fault here
- memcpy(ssl_session->client_random.data, payload[cs_id], 32);
- /* More error debug from gdb
- b 1985 // Putting a break point at line 1985 in my source code.
- //Here this is eqvialent to line 83, that is "ssl_session->client_random.data_len=32;"
- Breakpoint 1 at 0x403878: file Newversion.c, line 1985.
- run //run the code in gdb
- At breakpoint 1 the following info is in the variables
- p ssl_session
- $1 = (SslDecryptSession *) 0x60fc50 // I put some data in ssl_session->version_netorder earlier. So it is not null here. Everything works fine here
- p ssl_session->client_random.data
- $2 = (guchar *) 0x0
- p ssl_session->client_random.data_len
- $3 = 32
- step // Execute 1 more line in the code
- // I reach at the memcpy line and I get this error then
- Breakpoint 1, got_packet (args=0x0, header=0x7fffffffe2c0, packet=0x7ffff6939086 "P=\345\203\376\177") at Newversion.c:1995
- 1995 memcpy(ssl_session->client_random.data, payload[cs_id], 32);
- (gdb)
- (gdb) s
- __memcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:27
- 27 ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S: No such file or directory.
- (gdb)
- 28 in ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S
- (gdb)
- 29 in ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S
- (gdb)
- 30 in ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S
- (gdb)
- 31 in ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S
- (gdb)
- 32 in ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S
- (gdb)
- 33 in ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S
- (gdb)
- 34 in ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S
- (gdb)
- 35 in ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S
- (gdb)
- Program received signal SIGSEGV, Segmentation fault.
- __memcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:35
- 35 in ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement