首页
社区
课程
招聘
未解决 [求助]010编辑器怎么反转二进制并修改编码方式
发表于: 2020-8-29 23:38 3254

未解决 [求助]010编辑器怎么反转二进制并修改编码方式

2020-8-29 23:38
3254

我在做一个010编辑器的bt模板,数据文件中有很多字符串是unicode编码的字符串并且反转了对应的二进制,我写了如下代码

byte name[10] <read=readName>;

string readName(byte &name){
    return ~name
}

虽然似乎有ReadString之类的函数,但是在这里似乎用不了(或者我用的不对),有没有大佬能够赐教?


[课程]FART 脱壳王!加量不加价!FART作者讲授!

最后于 2020-8-29 23:38 被pengion编辑 ,原因: 标题多个了求助
收藏
免费 0
支持
分享
最新回复 (9)
雪    币: 7967
活跃值: (3604)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2

Wide Strings (Unicode Strings)

Regular strings above assume each character can be stored in 8-bits; however this character size is not appropriate for many languages so 010 Editor also supports wide strings (also called Unicode strings) where each character is a 16-bit unsigned short. Use the special 'wstring' type to define a wide string and each character of a wstring is assumed to be of type 'wchar_t' (a wchar_t is equivalent to an unsigned short).

The same operators '=', '+' and '+=' are supported for wstrings as for strings and a wide string constant can be declared by placing a 'L' character before a string or character constant. For example:

    wchar_t str1[15] = L"How now";
    wstring str2 = "brown cow";
    wstring str3 = str1 + L' ' + str2 + L'?';

Extended characters can be placed in string constants using the UTF-8 character encoding. Wide strings are assumed to be null-terminated and a list of functions available for working with wide strings is available in the String Functions help topic. Wide strings can be converted to regular strings using the WStringToString or StringToWString functions, or by casting. 


Unicode字符可以直接识别,反转是什么意思?

2020-8-30 16:05
0
雪    币: 7967
活跃值: (3604)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
或许你需要先用 BigEndian() 或者 LittleEndian() 指定一下大小头?
2020-8-30 16:10
0
雪    币: 0
能力值: ( LV1,RANK:0 )
在线值:
发帖
回帖
粉丝
4
arab 或许你需要先用 BigEndian() 或者 LittleEndian() 指定一下大小头?
反转就是把对应的二进制0变成1,1变成0,我想要的是在定义变量的struct里识别字符串,但是默认的识别方式为ascii(或者能否写一段代码看看),这个和大端小段无关,默认小端就可以
2020-8-30 17:59
0
雪    币: 0
能力值: ( LV1,RANK:0 )
在线值:
发帖
回帖
粉丝
5

比如 确定 这个字符串对应的二进制为

01101110 01111000 10011010 01011011

文件里做了反转,变成

10010001 10000111 01100101 10100100

bt模板的字符解析貌似默认是8位的ascaii,然后就会出现乱码,

2020-8-30 18:06
0
雪    币: 7967
活跃值: (3604)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6

用 read= 可以自定义输出方式。试试下面的代码(没试运行过,主要说明原理)

typedef struct (int size)
{
    wchar_t string[size];
} string_XOR <read=StringXORRead>;

string StringXORRead(string_XOR &str) {
    wstring s;
    int i;
 
    s = "";
    for (i = 0; i < WStrlen(str); i ++)
        s = s + (str[i] ^ 0xFFFF);
    return s;
}

然后用以下方式定义变量xxx(注意n是unicode的长度,不是byte的长度)

string_XOR xxx(n);

当然,如果是类pascal的字符的话,size可以放在结构里获取而不需要外界传入。

2020-8-31 00:27
0
雪    币: 0
能力值: ( LV1,RANK:0 )
在线值:
发帖
回帖
粉丝
7
arab 用 read= 可以自定义输出方式。试试下面的代码(没试运行过,主要说明原理)typedef&nbsp;struct&nbsp;(int&nbsp;size) { & ...
然而。。str[i] ^ 0xFFFF会报错,就是把str[i] 转为byte数组,byte数组也不能与wstring相加
2020-8-31 19:49
0
雪    币: 7967
活跃值: (3604)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
8
typedef struct (int size)
{
    wchar_t xorchar[size] <format=hex>;
} string_XOR <read=StringXORRead>;
 
string StringXORRead(string_XOR &str) {
    wstring s;
    int i;
  
    s = "";
    for (i = 0; i < WStrlen(str.xorchar); i ++)
   	{
		s = s + ~str.xorchar[i];
  	}
    return s;
}

LittleEndian();
string_XOR xxx(6);

这段代码我在10.0.1上跑通了。

最后于 2020-8-31 23:56 被arab编辑 ,原因:
2020-8-31 23:51
0
雪    币: 7967
活跃值: (3604)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
9
string StringXORRead(string_XOR &str) {
    wstring s;
    local wchar_t t;
    int i;
  
    s = "";
    for (i = 0; i < WStrlen(str.xorchar); i ++)
   	{
   		t = str.xorchar[i];
   		t ^= 0xFFFF;
		s = s + t;
  	}
    return s;
}

或者更通用的,可以把0xFFFF改成其它合适的值。

最后于 2020-8-31 23:57 被arab编辑 ,原因:
2020-8-31 23:55
0
雪    币: 0
能力值: ( LV1,RANK:0 )
在线值:
发帖
回帖
粉丝
10
成功了,非常感谢!!!
2020-9-1 11:57
0
游客
登录 | 注册 方可回帖
返回
//