diff options
| author | David M. Syzdek <david@syzdek.net> | 2022-05-01 22:25:08 -0800 |
|---|---|---|
| committer | David M. Syzdek <david@syzdek.net> | 2022-05-01 22:25:08 -0800 |
| commit | cb8d43a27e975f17818dc2dd0881c1e535dd9cac (patch) | |
| tree | 94e27423fdfc88285db99c6018a28164edee6525 | |
| parent | 77499b0a8d300ac1fa094fb35e012a40069f1bee (diff) | |
| download | tinytac-cb8d43a27e975f17818dc2dd0881c1e535dd9cac.tar.gz tinytac-cb8d43a27e975f17818dc2dd0881c1e535dd9cac.tar.bz2 tinytac-cb8d43a27e975f17818dc2dd0881c1e535dd9cac.tar.xz tinytac-cb8d43a27e975f17818dc2dd0881c1e535dd9cac.zip | |
libtinytac: adding tinytac_pckt_hexdump()
| -rw-r--r-- | include/tinytac.h | 12 | ||||
| -rw-r--r-- | lib/libtinytac/libtinytac.sym | 1 | ||||
| -rw-r--r-- | lib/libtinytac/lproto.c | 64 |
3 files changed, 77 insertions, 0 deletions
diff --git a/include/tinytac.h b/include/tinytac.h index 68e1f46..c4c7e3b 100644 --- a/include/tinytac.h +++ b/include/tinytac.h | |||
| @@ -310,6 +310,18 @@ tinytac_send( | |||
| 310 | //---------------------// | 310 | //---------------------// |
| 311 | #pragma mark protocol prototypes | 311 | #pragma mark protocol prototypes |
| 312 | 312 | ||
| 313 | /// prints hexdump of packet to file stream | ||
| 314 | /// | ||
| 315 | /// @param[in] fs write hexdump to file stream 'fs' | ||
| 316 | /// @param[in] pckt packet used to generate psuedo-random pad | ||
| 317 | /// @param[in] prefix string to prepend to each line | ||
| 318 | void | ||
| 319 | tinytac_pckt_hexdump( | ||
| 320 | FILE * fs, | ||
| 321 | tinytac_pckt_t * pckt, | ||
| 322 | const char * prefix ); | ||
| 323 | |||
| 324 | |||
| 313 | /// generates pseudo-random pad used to obfuscate the packet body | 325 | /// generates pseudo-random pad used to obfuscate the packet body |
| 314 | /// | 326 | /// |
| 315 | /// @param[in] pckt packet used to generate psuedo-random pad | 327 | /// @param[in] pckt packet used to generate psuedo-random pad |
diff --git a/lib/libtinytac/libtinytac.sym b/lib/libtinytac/libtinytac.sym index 16ddb84..732ba86 100644 --- a/lib/libtinytac/libtinytac.sym +++ b/lib/libtinytac/libtinytac.sym | |||
| @@ -39,6 +39,7 @@ tinytac_recv | |||
| 39 | tinytac_send | 39 | tinytac_send |
| 40 | # | 40 | # |
| 41 | # protocol functions | 41 | # protocol functions |
| 42 | tinytac_pckt_hexdump | ||
| 42 | tinytac_pckt_md5pad | 43 | tinytac_pckt_md5pad |
| 43 | tinytac_pckt_obfuscate | 44 | tinytac_pckt_obfuscate |
| 44 | # end of symbol export file | 45 | # end of symbol export file |
diff --git a/lib/libtinytac/lproto.c b/lib/libtinytac/lproto.c index 0ed365e..75ee6ea 100644 --- a/lib/libtinytac/lproto.c +++ b/lib/libtinytac/lproto.c | |||
| @@ -75,6 +75,70 @@ | |||
| 75 | //------------------// | 75 | //------------------// |
| 76 | #pragma mark packet functions | 76 | #pragma mark packet functions |
| 77 | 77 | ||
| 78 | void | ||
| 79 | tinytac_pckt_hexdump( | ||
| 80 | FILE * fs, | ||
| 81 | tinytac_pckt_t * pckt, | ||
| 82 | const char * prefix ) | ||
| 83 | { | ||
| 84 | uint8_t * bytes; | ||
| 85 | unsigned line; | ||
| 86 | unsigned pos; | ||
| 87 | unsigned pckt_len; | ||
| 88 | const char * str; | ||
| 89 | |||
| 90 | bytes = (void *)pckt; | ||
| 91 | pckt_len = ntohl(pckt->pckt_length) + sizeof(tinytac_pckt_t); | ||
| 92 | prefix = ((prefix)) ? prefix : ""; | ||
| 93 | |||
| 94 | fprintf(fs, "%spacket: version: %u.%u;", prefix, (pckt->pckt_version >> 4), (pckt->pckt_version & 0x0f)); | ||
| 95 | switch(pckt->pckt_type) | ||
| 96 | { | ||
| 97 | case TAC_PLUS_TYPE_AUTHEN: str = "authen"; break; | ||
| 98 | case TAC_PLUS_TYPE_AUTHOR: str = "author"; break; | ||
| 99 | case TAC_PLUS_TYPE_ACCT: str = "acct"; break; | ||
| 100 | default: str = "unknown"; break; | ||
| 101 | }; | ||
| 102 | fprintf(fs, " type: %s;", str); | ||
| 103 | fprintf(fs, " seq_no: %u;", pckt->pckt_seq_no); | ||
| 104 | fprintf(fs, " session_id: %08x;", ntohl(pckt->pckt_session_id)); | ||
| 105 | fprintf(fs, "\n%spacket: length: %u (0x%x);", prefix, pckt_len, pckt_len); | ||
| 106 | fprintf(fs, " flags:"); | ||
| 107 | if (!(pckt->pckt_flags)) | ||
| 108 | fprintf(fs, " NONE"); | ||
| 109 | if ((pckt->pckt_flags & TAC_PLUS_FLAG_SINGLE_CONNECT)) | ||
| 110 | fprintf(fs, " SINGLE-CONNECT"); | ||
| 111 | if ((pckt->pckt_flags & TAC_PLUS_FLAG_UNENCRYPTED)) | ||
| 112 | fprintf(fs, " UNENCRYPTED"); | ||
| 113 | fprintf(fs, ";"); | ||
| 114 | fprintf(fs, "\n"); | ||
| 115 | |||
| 116 | |||
| 117 | fprintf(fs, "%s offset 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef\n", prefix); | ||
| 118 | for(line = 0; (line < pckt_len); line += 0x10) | ||
| 119 | { | ||
| 120 | fprintf(fs, "%s%08x", prefix, line); | ||
| 121 | for(pos = line; (pos < (line+0x10)); pos++) | ||
| 122 | { | ||
| 123 | if ((pos & 0x03) == 0) | ||
| 124 | fprintf(fs, " "); | ||
| 125 | if (pos < pckt_len) | ||
| 126 | fprintf(fs, " %02x", bytes[pos]); | ||
| 127 | else | ||
| 128 | fprintf(fs, " "); | ||
| 129 | }; | ||
| 130 | fprintf(fs, " "); | ||
| 131 | for(pos = line; ((pos < (line+0x10)) && (pos < pckt_len)); pos++) | ||
| 132 | fprintf(fs, "%c", ((bytes[pos] < 0x20) || (bytes[pos] > 0x7e)) ? '.' : bytes[pos]); | ||
| 133 | fprintf(fs, "\n"); | ||
| 134 | if ((line & 0xf0) == 0xf0) | ||
| 135 | fprintf(fs, "\n"); | ||
| 136 | }; | ||
| 137 | |||
| 138 | return; | ||
| 139 | } | ||
| 140 | |||
| 141 | |||
| 78 | int | 142 | int |
| 79 | tinytac_pckt_md5pad( | 143 | tinytac_pckt_md5pad( |
| 80 | tinytac_pckt_t * pckt, | 144 | tinytac_pckt_t * pckt, |
