Debian Codegraph @

testsuite/systemtap.examples/io/capture_ssl_master_secrets.stp

raw
1 #!/usr/bin/env stap
2
3 function cast_char_to_unsigned_char (val:long)
4 {
5 if (val < 0) {
6 return val + 256;
7 } else {
8 return val;
9 }
10 }
11
12 function print_buffer (buf:long, len:long)
13 {
14 for (i = 0; i < len; i++) {
15 printf("%02x", cast_char_to_unsigned_char(user_char(buf + i)));
16 }
17 }
18
19 probe process("/usr/lib*/libssl.so.*").function("tls1_generate_master_secret").return !,
20 process("/usr/lib/*/libssl.so.*").function("tls1_generate_master_secret").return
21 {
22 printf("# %d %s %s (%d)\n", gettimeofday_us(), pp(), execname(), pid());
23 printf("CLIENT_RANDOM ");
24 print_buffer(@entry($s->s3->client_random), 32);
25 printf(" ");
26 print_buffer(@entry($out), $return);
27 printf("\n");
28 }
29
30 probe process("/usr/lib*/libgnutls.so.*").function("generate_normal_master").return !,
31 process("/usr/lib/*/libgnutls.so.*").function("generate_normal_master").return
32 {
33 printf("# %d %s %s (%d)\n", gettimeofday_us(), pp(), execname(), pid());
34 printf("CLIENT_RANDOM ");
35 print_buffer(@entry($session) + 72, 32);
36 printf(" ");
37 print_buffer(@entry($session) + 24, 48);
38 printf("\n");
39 }