将十六进制代码(在数据包中)转换为UTF-8

时间:2017-02-22 07:11:47

标签: c linux utf-8 packet smb

sturct ptr info

struct ptr {                  // packet struct
unsigned long srcip;
unsigned long dstip;
unsigned short srcport;
unsigned short dstport;
unsigned char *str;       // payload data of packet
unsigned short len;       // payload length
unsigned long ts;
};

查找文件路径并保存模块代码

char *msg = NULL;             // to save file path
int j = 0;
/* find file path and save */
for (i=84; i < ptr->len; i++) {
    if (ptr->str[i] > 0x00 && ptr->str[i] < 0x7f) {
        msg[j] = ptr->str[i];
        j++;
    }
    if (ptr->str[i] > 0x7f) {
        msg[j] = 0x23;
        j++;
    }
}

这是SMB数据包中的文件路径,我在Wireshark上捕获。

0000   5c 00 e0 ac c8 b2 5c 00 73 00 65 00 63 00 72 00  \.....\.s.e.c.r.
0010   65 00 74 00 5c 00 78 c7 ac c0 2e 00 74 00 78 00  e.t.\.x.....t.x.
0020   74 00 00 00                                      t...

当前结果=

msg : \####\secret\x###.txt

我暂时把'#'(0x23)放了..

这就是我想要的东西=

msg : \고니\secret\인사.txt

我刚发现“e0 ac”是字母'고'的一部分,“c8 b2”是字母'니'的一部分

但我不知道如何转换..

总之,我希望将十六进制代码(在数据包中)转换为UTF-8。

0 个答案:

没有答案
相关问题