decode_hex.c
来自「一个网络工具包,可以嗅探email和http等数据包中的密码等信息.注意要先把l」· C语言 代码 · 共 63 行
C
63 行
/* decode_hex.c Hex dump, for debugging. Copyright (c) 2000 Dug Song <dugsong@monkey.org> $Id: decode_hex.c,v 1.4 2000/11/09 22:29:39 dugsong Exp $*/#include "config.h"#include <sys/param.h>#include <sys/types.h>#include <stdio.h>#include <string.h>#include <ctype.h>#include "buf.h"#include "decode.h"/* adapted from OpenBSD tcpdump: dump the buffer in emacs-hexl format */intdecode_hex(u_char *buf, int len, u_char *obuf, int olen){ struct buf inbuf, outbuf; u_int i, j, k; u_char c; buf_init(&inbuf, buf, len); buf_init(&outbuf, obuf, olen); while ((i = buf_len(&inbuf)) > 0) { i = i < 16 ? i : 16; k = buf_tell(&inbuf); buf_putf(&outbuf, " %04x: ", k); for (j = 0; j < i; j++) { buf_get(&inbuf, &c, 1); buf_putf(&outbuf, "%02x", (u_int)c); if ((j % 2) == 1) buf_put(&outbuf, " ", 1); } for (; j < 16; j++) { buf_put(&outbuf, " ", (j % 2) + 2); } buf_put(&outbuf, " ", 1); buf_seek(&inbuf, k, SEEK_SET); for (j = 0; j < i; j++) { buf_get(&inbuf, &c, 1); c = isprint(c) ? c : '.'; buf_putf(&outbuf, "%c", c); } buf_put(&outbuf, "\n", 1); } buf_end(&outbuf); return (buf_len(&outbuf));}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?