bug fix and feature
- Fix bug that a pTarget linked to a export pin will raise error. - Fix bug that a export pOut can't create shortcut correctly. - Add helper ui in viewer. - Use std lib rewrite entire exporter.
This commit is contained in:
@ -2,6 +2,7 @@ import sqlite3
|
||||
import DecoratorConstValue as dcv
|
||||
import json
|
||||
import CustomConfig
|
||||
import sys
|
||||
|
||||
def run():
|
||||
exportDb = sqlite3.connect(CustomConfig.export_db)
|
||||
@ -21,11 +22,24 @@ def run():
|
||||
# decorate each graph
|
||||
print('Generating graph...')
|
||||
currentGraphBlockCell = {}
|
||||
percentageAll = len(graphList)
|
||||
if percentageAll == 0:
|
||||
percentageAll = 1
|
||||
percentageNow = 0
|
||||
percentageCache = 0
|
||||
#debug
|
||||
graphList=graphList[int(percentageAll*3/4):]
|
||||
for i in graphList:
|
||||
sys.stdout.write('\r[{}{}]{}%'.format(int(percentageCache / 5) * '#',(20 - int(percentageCache / 5)) * '=', percentageCache))
|
||||
sys.stdout.flush()
|
||||
|
||||
currentGraphBlockCell.clear()
|
||||
buildBlock(exportDb, decorateDb, i, currentGraphBlockCell)
|
||||
graphPIO = buildCell(exportDb, decorateDb, i, currentGraphBlockCell)
|
||||
buildLink(exportDb, decorateDb, i, currentGraphBlockCell, graphPIO)
|
||||
|
||||
percentageNow += 1
|
||||
percentageCache = int(100 * percentageNow / percentageAll)
|
||||
|
||||
# export information
|
||||
print('Generating info...')
|
||||
@ -398,7 +412,7 @@ def buildCell(exDb, deDb, target, currentGraphBlockCell):
|
||||
|
||||
# query all links(don't need to consider export pIO, due to it will not add
|
||||
# any shortcut)
|
||||
# !! the same if framework in pLink generator function !! SHARED
|
||||
# !! the same if framework in pLink generator function !! SHARED
|
||||
createdShortcut = set()
|
||||
exCur.execute("SELECT * FROM pLink WHERE [belong_to] == ?", (target,))
|
||||
for i in exCur.fetchall():
|
||||
@ -420,7 +434,7 @@ def buildCell(exDb, deDb, target, currentGraphBlockCell):
|
||||
|
||||
elif (i[3] == dcv.dbPLinkInputOutputType.PIN):
|
||||
if i[2] == target:
|
||||
continue # ignore self pIn/pOut. it doesn't need any shortcut
|
||||
continue # ignore self pIn/pOut. it doesn't need any shortcut
|
||||
if i[2] not in blockSet:
|
||||
if i[0] not in createdShortcut:
|
||||
cache = dcv.LocalUsageItem(0, True, dcv.LocalUsageType.PIN)
|
||||
@ -461,7 +475,7 @@ def buildCell(exDb, deDb, target, currentGraphBlockCell):
|
||||
cache.lastIndex = i[5]
|
||||
else:
|
||||
if i[6] == target:
|
||||
continue # ignore self pIn/pOut. it doesn't need any shortcut
|
||||
continue # ignore self pIn/pOut. it doesn't need any shortcut
|
||||
if i[6] not in blockSet:
|
||||
if i[1] not in createdShortcut:
|
||||
cache = dcv.LocalUsageItem(0, True, dcv.LocalUsageType.POUT)
|
||||
@ -539,8 +553,13 @@ def buildLink(exDb, deDb, target, currentGraphBlockCell, graphPIO):
|
||||
exCur = exDb.cursor()
|
||||
deCur = deDb.cursor()
|
||||
|
||||
# prepare block set
|
||||
blockSet = set()
|
||||
for i in currentGraphBlockCell.keys():
|
||||
blockSet.add(i)
|
||||
|
||||
# bLink
|
||||
exCur.execute("SELECT * FROM bLink WHERE [belong_to] == ?", (target, ))
|
||||
exCur.execute("SELECT * FROM bLink WHERE [belong_to] == ?", (target,))
|
||||
for i in exCur.fetchall():
|
||||
if i[3] == target:
|
||||
(x1, y1) = computLinkBTerminal(i[0], 0, -1 ,currentGraphBlockCell)
|
||||
@ -567,7 +586,7 @@ def buildLink(exDb, deDb, target, currentGraphBlockCell, graphPIO):
|
||||
(target, i[2], i[0], i[1], bStartObj, bEndObj, bStartType, bEndType, bStartIndex, bEndIndex, x1, y1, x2, y2))
|
||||
|
||||
# pLink
|
||||
# !! the same if framework in cell generator function !! SHARED
|
||||
# !! the same if framework in cell generator function !! SHARED
|
||||
exCur.execute("SELECT * FROM pLink WHERE [belong_to] == ?", (target,))
|
||||
for i in exCur.fetchall():
|
||||
# analyse 5 chancee one by one
|
||||
@ -590,7 +609,11 @@ def buildLink(exDb, deDb, target, currentGraphBlockCell, graphPIO):
|
||||
(target, -1, i[0], i[1], i[2], i[6], 0, 0, i[5], i[9], x1, y1, x2, y2))
|
||||
|
||||
else:
|
||||
(x1, y1) = computLinkPTerminal(i[2], 1, i[5], currentGraphBlockCell)
|
||||
if i[2] in blockSet: # process protencial pOut(shortcut) (because plocal input/input_obj
|
||||
# output/output_obj is same, so don't need add for them)
|
||||
(x1, y1) = computLinkPTerminal(i[2], 1, i[5], currentGraphBlockCell)
|
||||
else:
|
||||
(x1, y1) = computLinkPTerminal(i[0], 1, i[5], currentGraphBlockCell)
|
||||
(x2, y2) = computLinkPTerminal(i[6], 0, i[9], currentGraphBlockCell)
|
||||
deCur.execute("INSERT INTO link VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
|
||||
(target, -1, i[0], i[1], i[2], i[6], 1, 0, i[5], i[9], x1, y1, x2, y2))
|
||||
@ -627,7 +650,9 @@ def computLinkBTerminal(obj, xtype, index, currentGraphBlockCell):
|
||||
cache.y if index == -1 else (cache.y + dcv.BB_BOFFSET + index * (dcv.BB_PBSIZE + dcv.BB_BSPAN)))
|
||||
|
||||
def computLinkPTerminal(obj, ytype, index, currentGraphBlockCell):
|
||||
# ytype is not database type. it have the same meaning of LinkBTerminal, indicating the position. 0 is keep origin position(for pIn and pTarget), 1 is consider height(for pOut)
|
||||
# ytype is not database type. it have the same meaning of LinkBTerminal,
|
||||
# indicating the position. 0 is keep origin position(for pIn and pTarget),
|
||||
# 1 is consider height(for pOut)
|
||||
cache = currentGraphBlockCell[obj]
|
||||
return (cache.x if index == -1 else (cache.x + dcv.BB_POFFSET + index * (dcv.BB_PBSIZE + dcv.BB_PSPAN)),
|
||||
cache.y if ytype == 0 else (cache.y + cache.h - dcv.BB_PBSIZE))
|
||||
|
@ -104,8 +104,8 @@ def viewerHandle(scriptPath):
|
||||
gWidth = width,
|
||||
gHeight = height,
|
||||
hamburgerHistory = hamburger,
|
||||
static_css = url_for('static', filename='site.css'),
|
||||
static_js = url_for('static', filename='site.js'),
|
||||
static_css = url_for('static', filename='viewer.css'),
|
||||
static_js = url_for('static', filename='viewer.js'),
|
||||
hamburgerCurrent = currentHamburger,
|
||||
blocks = dbBlocks,
|
||||
cells = dbCells,
|
||||
|
@ -9,11 +9,11 @@ try:
|
||||
opts, args = getopt.getopt(sys.argv, "hi:o:e:f")
|
||||
except getopt.GetoptError:
|
||||
print('Wrong arguments!')
|
||||
print('test.py -i <export.db> -o <decorated.db> -e <env.db> -f')
|
||||
print('python SuperScriptViewer.py -i <export.db> -o <decorated.db> -e <env.db> -f')
|
||||
sys.exit(1)
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print('test.py -i <export.db> -o <decorated.db> -e <env.db> -f')
|
||||
print('python SuperScriptViewer.py -i <export.db> -o <decorated.db> -e <env.db> -f')
|
||||
sys.exit(0)
|
||||
elif opt == '-i':
|
||||
CustomConfig.export_db = arg
|
||||
|
@ -16,6 +16,8 @@ So, let we crack all scripts and destroy close-source illusion.</p>
|
||||
Web interface is 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>
|
||||
<br />
|
||||
<p>Current Super Script Materializer version: 1.0</p>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -8,7 +8,21 @@
|
||||
|
||||
<body>
|
||||
<h1>Super Script Viewer Help</h1>
|
||||
<p>In this file, I will introduce how to use this viewer.</p>
|
||||
<p>This page is help center, providing useful link for some detailed help page. Choose what you want to use and enter corresponding page.</p>
|
||||
<br />
|
||||
<br />
|
||||
<h2>Help tools</h2>
|
||||
<ul>
|
||||
<li><a href="/help/converter">Converter</a>: The page containing converter which can convert the data with various style for some convenient operations.</li>
|
||||
</ul>
|
||||
<h2>Environment database query</h2>
|
||||
<ul>
|
||||
<li><a href="/help/env-attr">Attribute query</a>: The page which can query attribute environment.</li>
|
||||
<li><a href="/help/env-msg">Message query</a>: The page which can query message environment.</li>
|
||||
<li><a href="/help/env-op">Operation query</a>: The page which can query operation(param converter) environment.</li>
|
||||
<li><a href="/help/env-param">Parameter query</a>: The page which can query parameter environment.</li>
|
||||
<li><a href="/help/env-plugin">Plugin query</a>: The page which can query plugin environment.</li>
|
||||
</ul>
|
||||
<br />
|
||||
<br />
|
||||
<!-- todo: finish this-->
|
||||
|
50
SuperScriptViewer/templates/help/converter.html
Normal file
50
SuperScriptViewer/templates/help/converter.html
Normal file
@ -0,0 +1,50 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Help - Converter</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Converter</h1>
|
||||
<p>This page provide some useful converter for your decoding work. All converter is interactive..</p>
|
||||
<br />
|
||||
|
||||
<h2>Reverse C style byte array</h2>
|
||||
<p>This converter will reverse your inputed C style byte array. Actually, it take responsibility for the convert between big-endian and little-endian.<br />
|
||||
Typical and legal input just like this: <code>0x00, 0xBb, 0xff, 0xFF</code><br />
|
||||
Support multi-input. Use line break to split each input.</p>
|
||||
<p>Input:</p>
|
||||
<textarea style="width: 350px; height: 100px; resize: none;"></textarea>
|
||||
<p>Output:</p>
|
||||
<textarea style="width: 350px; height: 100px; resize: none;" readonly="true"></textarea>
|
||||
|
||||
<h2>C style byte array to HEX</h2>
|
||||
<p>This converter will converte provided C style byte array into HEX number. It is double interactive.<br />
|
||||
Acceptable byte array should follow little-endian format.<br />
|
||||
Support multi-input. Use line break to split each input.</p>
|
||||
<p>Byte array:</p>
|
||||
<textarea style="width: 350px; height: 100px; resize: none;"></textarea>
|
||||
<p>HEX number:</p>
|
||||
<textarea style="width: 350px; height: 100px; resize: none;"></textarea>
|
||||
|
||||
<h2>C style byte array to DEC</h2>
|
||||
<p>This converter will converte provided C style byte array into DEC number. It is double interactive.<br />
|
||||
Acceptable byte array should follow little-endian format.<br />
|
||||
Support multi-input. Use line break to split each input.</p>
|
||||
<p>Byte array:</p>
|
||||
<textarea style="width: 350px; height: 100px; resize: none;"></textarea>
|
||||
<p>DEC number:</p>
|
||||
<textarea style="width: 350px; height: 100px; resize: none;"></textarea>
|
||||
|
||||
<h2>Lowcase upcase converter</h2>
|
||||
<p>This converter will provide the convert between lowcase and upcase string. It is double interactive.</p>
|
||||
<p>Lowcase:</p>
|
||||
<textarea style="width: 350px; height: 100px; resize: none;"></textarea>
|
||||
<p>Upcase:</p>
|
||||
<textarea style="width: 350px; height: 100px; resize: none;"></textarea>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
0
SuperScriptViewer/templates/help/env_database.html
Normal file
0
SuperScriptViewer/templates/help/env_database.html
Normal file
Reference in New Issue
Block a user