现在简单的十六进制是简单的,我很好奇是否有一个工具来重命名变量的用法。例如:
http://pastebin.com/8m6bvaiu
是否有一个工具可以从数组中获取变量名,并在代码正文中重命名用法?
发布于 2016-06-22 20:51:00
使用这个网站,大部分代码都可以格式化并变得可读性:http://jsbeautifier.org/
然而,这在顶部留下了一个巨大的数组,其中包含了代码中使用的大多数变量/字符串。要在整个代码中插入其内容,可以使用以下JavaScript来搜索和替换每个实例:
for (var i=0; i<keywords.length; i++) {
if (keywords[i].match(/^[a-zA-Z][a-zA-Z0-9_]*$/)) { // Could be a standalone variable
// Replace any instances the string is used in an array accessor ['x'] with a dot .x
code = code.replace(new RegExp('\\['+arrayName+'\\['+i+'\\]\\]','g'),'.'+keywords[i]);
}
// Insert as strings throughout code, escaping anything necessary
code = code.replace(new RegExp(arrayName+'\\['+i+'\\]','g'),'\''+
keywords[i].replace(/\\/g,'\\\\').replace(/\r/g,'\\r').replace(/\n/g,'\\n').replace(/'/g,'\\\'')+
'\'');
} console.log(code);确保为该代码创建三个变量,arrayName ('_0x67a5'字符串)、keywords (数组)和code (数组后面的代码)。为了准确地包含字符串中的代码,我建议使用Notepad++替换所有反斜杠、引号和换行符(FindwithExtended/regex:\r\n,替换为:\\r\\n\\\r\n)。
这就留下了一些十六进制命名的变量,但是它们都是特定函数的本地变量,而且更容易理解。结果可以在这里看到:http://pastebin.com/kQjz2T0P
发布于 2018-07-02 09:28:43
如果您执行python,请使用以下方法处理顶部的大数组:
import re
#first open the file and read into the variable 'text'
result = re.sub(r"\\x([0-9A-F]{2})", lambda m: chr(int(m.group(1), 16)), text)发布于 2016-06-22 20:36:50
是。String.replace(regex,function(found,selected))法
h0=$('.de1').text();
h1=h0.split('$')[0].split('=')[1];
h2=h0.slice(h1.length+12);
eval('ar='+h1);
h3=h2.replace(/_0x67a5\[(\d*)\]/g,function(a,b){return '"'+ar[parseInt(b)]+'"'});
h4=h3.replace(/;(?!=['"])/g,';<br>').replace(/\\x(..)/g,function(a,b){return '&#x'+b+';'}).replace(/\\u(....)/g,function(a,b){return '&#x'+b+';'}).replace(/_0x(....)/g,function(a,b){return '&#x'+b+';'})
$('#abrpm').html(h4);
https://stackoverflow.com/questions/37976448
复制相似问题