fix decode error and write some doc

This commit is contained in:
yyc12345 2020-04-13 15:36:37 +08:00
parent 4f941f606b
commit 71885d70ba
8 changed files with 90 additions and 16 deletions

View File

@ -1,12 +1,14 @@
# Super Script Materializer # Super Script Materializer
Advanced Virtools Script Materializer. [中文文档](./README_ZH.md)
Export all script into a SQLite database file. Super Virtools Script Materializer.
Some code come from [BearKidsTeam/Script-Materializer](https://github.com/BearKidsTeam/Script-Materializer) (this project export specific script into a JSON file) Export all script into a SQLite database file. And provide a web page to broswer graph.
WIP Some code come from [BearKidsTeam/Script-Materializer](https://github.com/BearKidsTeam/Script-Materializer)(this project export specific script into a JSON file) and [BearKidsTeam/VirtoolsScriptDeobfuscation](https://github.com/BearKidsTeam/VirtoolsScriptDeobfuscation).
WIP. It still lack some function and have some bugs, but it can be used for some normal deobfiscation.
## Install ## Install

37
README_ZH.md Normal file
View File

@ -0,0 +1,37 @@
# Super Script Materializer
[English document](./README.md)
超级Virtools脚本物化器机翻确信
将Virtools文档中的所有脚本导出成一个SQLite数据库文件然后经过Python进行排布处理最后提供一个本地Web前端查看脚本。这同样适用于`Script Hidden`的Virtools脚本也适用于其中含有不可展开的`Behavior Graph`的脚本。
物化器不能完全恢复脚本的原有排布无论原有排布是否存在物化器都将重新自动生成脚本中的各个元素的位置。某些结构的关系可能会改变例如Export parameter但是逻辑思路将不会改变。同时物化器不能将已经生成的结构回写成Virtools可接受的格式因此物化器只能提供无视脚本隐藏的分析功能。
本工程代码源于另两个工程:[BearKidsTeam/Script-Materializer](https://github.com/BearKidsTeam/Script-Materializer)该工程用于将指定脚本导出为JSON文档和[BearKidsTeam/VirtoolsScriptDeobfuscation](https://github.com/BearKidsTeam/VirtoolsScriptDeobfuscation)该工程能够在Virtools 3.5中提供内置的隐藏脚本解析功能将解析结果解析为可以被Virtools识别的格式
本项目分为2个部分`SuperScriptMaterializer`是一个C++工程将生成一个Virtools界面插件用于导出初步数据`SuperScriptViewer`是一个Python工程将解析导出的数据然后使用Flask提供一个本地Web界面进行脚本查看。
此项目仍在开发。
## 使用方法
### 基本方法
将Virtools插件投入`InterfacePlugins`目录下,将`sqlite3.dll`和`Dev.exe`放在同一目录。然后启动Virtools打开需要解析的文档点击菜单栏的`Super Script Materializer`-`Export all script`选择要保存到的文件然后等待Virtools提示你已经导出完成。
将导出文件重命名为`export.db`并和`SuperScriptViewer.py`放在一起。然后在此目录中运行`python ./SuperScriptViewer.py`等待Python交互界面提示可以打开本地的网页即可。
### 使用注意
- 您需要先安装Virtools, Python和任意一种浏览器才能使用本工程。Python需要先安装`Flask`库。
- 导出插件目前只支持Virtools 5后期会支持Virtools 3.5
- 导出插件选择完文件后卡住或者Python交互界面弹出错误堆栈这可能是设计失误请附带您引起bug的文件提交bug
- 如果Python交互界面提示数据库`TEXT`类型解码失败,那么可能您需要手动在`DecoratorCore.py`中指定数据库文本解码方式。因为Virtools使用多字节编码依赖于当前操作系统的代码页`DecoratorCore.py`做了特殊获取以保证大多数计算机可以直接运行,但仍然不能排除一些特殊情况。
- 如果您使用本工程的Release页面中提供的已编译好的Virtools界面插件现在因为仍然在开发所以没有您需要放入的`sqlite3.dll`版本应为`sqlite-dll-win32-x86-3310100`
## 编译
只有Virtools界面插件需要编译其余均为解释性语言无需编译。
需要手动配置Virtools插件的编译参数例如包含路径等需要指向您自己的Virtools SDK。对于SQLite SDK您可以从[sqlite.org](http://www.sqlite.org/)下载然后使用Visual C++的工具集执行`LIB /DEF:sqlite3.def /machine:IX86`以获取可以用于编译的文件。

View File

@ -1,9 +1,11 @@
import sqlite3 import sqlite3
import DecoratorConstValue as dcv import DecoratorConstValue as dcv
import json import json
import locale
def run(): def run():
exportDb = sqlite3.connect('export.db') exportDb = sqlite3.connect('export.db')
exportDb.text_factory = lambda x: x.decode(locale.getpreferredencoding())
decorateDb = sqlite3.connect('decorate.db') decorateDb = sqlite3.connect('decorate.db')
# init table # init table

View File

@ -3,6 +3,7 @@ from flask import g
from flask import render_template from flask import render_template
from flask import url_for from flask import url_for
from flask import request from flask import request
from flask import abort
from functools import reduce from functools import reduce
import sqlite3 import sqlite3
@ -47,6 +48,10 @@ def indexHandle():
@app.route('/<path:scriptPath>', methods=['GET']) @app.route('/<path:scriptPath>', methods=['GET'])
def scriptHandle(scriptPath): def scriptHandle(scriptPath):
# fuck favition.ico
if '.' in scriptPath:
abort(404)
# comput hamburger # comput hamburger
pathSlice = scriptPath.split('/') pathSlice = scriptPath.split('/')
cur = get_db().cursor() cur = get_db().cursor()

View File

@ -15,17 +15,23 @@ function highlightLink(target) {
}); });
} }
//apply new highlight // double one-click, only cancel highlight and don't apply any hightlight
$(realTarget).each(function() { if (realTarget == previousHighlight) {
if ($(this).hasClass("link-blink")) { previousHighlight = "";
$(this).attr("stroke", "yellow") } else {
} //apply new highlight
if ($(this).hasClass("link-blinkDelay")) { $(realTarget).each(function() {
$(this).attr("fill", "yellow") if ($(this).hasClass("link-blink")) {
} $(this).attr("stroke", "yellow")
}); }
if ($(this).hasClass("link-blinkDelay")) {
$(this).attr("fill", "yellow")
}
});
previousHighlight = realTarget
}
previousHighlight = realTarget
//cancel event seperate //cancel event seperate
event.stopPropagation(); event.stopPropagation();
} }

View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Super Script Viewer Help</title>
</head>
<body>
<h1>Super Script Viewer Help</h1>
<p>In this file, I will introduce how to use this viewer.</p>
<br />
<br />
<!-- todo: finish this-->
</body>
</html>

View File

@ -19,7 +19,12 @@
{% endfor %} {% endfor %}
</ol> </ol>
{% endfor %} {% endfor %}
<br />
<br />
<p>Generated by <a href="https://github.com/yyc12345/SuperScriptMaterializer">SuperScriptMaterializer</a>. All codes are under GPLv3.<br />
Powered by <a href="https://github.com/pallets/flask">Flask</a>.<br />
Ancestor projects: <a href="https://github.com/BearKidsTeam/VirtoolsScriptDeobfuscation">BearKidsTeam/VirtoolsScriptDeobfuscation</a> and <a href="https://github.com/BearKidsTeam/Script-Materializer">BearKidsTeam/Script-Materializer</a>.<br />
Thank <a href="https://github.com/chirs241097">chirs241097</a> and <a href="https://github.com/instr3">2jjy</a>.</p>
</body> </body>
</html> </html>

View File

@ -25,7 +25,7 @@
</div> </div>
<div style="width: 100px;"> <div style="width: 100px;">
<button style="width: 100px; height: 50px;">LEGEND</button> <button style="width: 100px; height: 50px;">Help</button>
</div> </div>
</div> </div>
<div style="background: #7f7f7f; width: 100%; height: 100%; overflow: scroll; position: relative;"> <div style="background: #7f7f7f; width: 100%; height: 100%; overflow: scroll; position: relative;">