Spaces:
Runtime error
Runtime error
Commit
·
edab27e
1
Parent(s):
d0f659d
description
Browse files
app.py
CHANGED
|
@@ -9,7 +9,22 @@ import huggingface_hub
|
|
| 9 |
|
| 10 |
import prep_decompiled
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
hf_key = os.environ["HF_TOKEN"]
|
| 15 |
huggingface_hub.login(token=hf_key)
|
|
@@ -21,8 +36,6 @@ vardecoder_model = AutoModelForCausalLM.from_pretrained(
|
|
| 21 |
"ejschwartz/resym-vardecoder", torch_dtype=torch.bfloat16, device_map="auto"
|
| 22 |
)
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
example = """{
|
| 27 |
"input": "What are the original name and data type of variables `a1`, `a2`, `k`, `j`, `i`?\n```\n_BYTE *__fastcall sub_4022CD(_BYTE *a1, __int64 a2)\n{\n_BYTE *result; // rax\n__int16 v4; // [rsp+1Ch] [rbp-14h]\nunsigned __int16 v5; // [rsp+1Eh] [rbp-12h]\nunsigned __int16 v6; // [rsp+20h] [rbp-10h]\nunsigned __int16 v7; // [rsp+22h] [rbp-Eh]\nunsigned int k; // [rsp+24h] [rbp-Ch]\nunsigned int j; // [rsp+28h] [rbp-8h]\nunsigned int i; // [rsp+2Ch] [rbp-4h]\n\nfor ( i = 0; i <= 2; ++i )\n{\nfor ( j = 0; j <= 0x3F; ++j )\n{\nfor ( k = 0; k <= 3; ++k )\n{\n*(&v4 + k) = *(_WORD *)(a2 + 2 * (k + 4 * j + ((unsigned __int64)i << 8)));\n*(&v4 + k) += (*(&v4 + k) >> 15) & 0xD01;\n*(&v4 + k) = ((((unsigned __int16)*(&v4 + k) << 10) + 1664) / 0xD01u) & 0x3FF;\n}\n*a1 = v4;\na1[1] = (4 * v5) | HIBYTE(v4);\na1[2] = (16 * v6) | (v5 >> 6);\na1[3] = ((_BYTE)v7 << 6) | (v6 >> 4);\nresult = a1 + 4;\na1[4] = v7 >> 2;\na1 += 5;\n}\n}\nreturn result;\n}\n```",
|
| 28 |
"output": "a1: r, uint8_t*\na2: a, const polyvec*\nk: t, uint16_t\nj: -, -\ni: k, unsigned int",
|
|
@@ -80,5 +93,6 @@ demo = gr.Interface(
|
|
| 80 |
gr.Textbox(lines=10, value=json.loads(example)['input']),
|
| 81 |
],
|
| 82 |
outputs=gr.Text(label="Var Decoder Output"),
|
|
|
|
| 83 |
)
|
| 84 |
demo.launch()
|
|
|
|
| 9 |
|
| 10 |
import prep_decompiled
|
| 11 |
|
| 12 |
+
description = """# ReSym Test Space
|
| 13 |
+
|
| 14 |
+
This is a test space of the models from the [ReSym
|
| 15 |
+
artifacts](https://github.com/lt-asset/resym). Sadly, at the time I am writing
|
| 16 |
+
this, not all of ReSym is publicly available; specifically, the Prolog component
|
| 17 |
+
is [not available](https://github.com/lt-asset/resym/issues/2).
|
| 18 |
+
|
| 19 |
+
This space simply performs inference on the two pretrained models available as
|
| 20 |
+
part of the ReSym artifacts. It takes a variable name and some decompiled code
|
| 21 |
+
as input, and outputs the variable type and other information.
|
| 22 |
+
|
| 23 |
+
## Todo
|
| 24 |
+
|
| 25 |
+
* Add support for FieldDecoder model
|
| 26 |
+
|
| 27 |
+
"""
|
| 28 |
|
| 29 |
hf_key = os.environ["HF_TOKEN"]
|
| 30 |
huggingface_hub.login(token=hf_key)
|
|
|
|
| 36 |
"ejschwartz/resym-vardecoder", torch_dtype=torch.bfloat16, device_map="auto"
|
| 37 |
)
|
| 38 |
|
|
|
|
|
|
|
| 39 |
example = """{
|
| 40 |
"input": "What are the original name and data type of variables `a1`, `a2`, `k`, `j`, `i`?\n```\n_BYTE *__fastcall sub_4022CD(_BYTE *a1, __int64 a2)\n{\n_BYTE *result; // rax\n__int16 v4; // [rsp+1Ch] [rbp-14h]\nunsigned __int16 v5; // [rsp+1Eh] [rbp-12h]\nunsigned __int16 v6; // [rsp+20h] [rbp-10h]\nunsigned __int16 v7; // [rsp+22h] [rbp-Eh]\nunsigned int k; // [rsp+24h] [rbp-Ch]\nunsigned int j; // [rsp+28h] [rbp-8h]\nunsigned int i; // [rsp+2Ch] [rbp-4h]\n\nfor ( i = 0; i <= 2; ++i )\n{\nfor ( j = 0; j <= 0x3F; ++j )\n{\nfor ( k = 0; k <= 3; ++k )\n{\n*(&v4 + k) = *(_WORD *)(a2 + 2 * (k + 4 * j + ((unsigned __int64)i << 8)));\n*(&v4 + k) += (*(&v4 + k) >> 15) & 0xD01;\n*(&v4 + k) = ((((unsigned __int16)*(&v4 + k) << 10) + 1664) / 0xD01u) & 0x3FF;\n}\n*a1 = v4;\na1[1] = (4 * v5) | HIBYTE(v4);\na1[2] = (16 * v6) | (v5 >> 6);\na1[3] = ((_BYTE)v7 << 6) | (v6 >> 4);\nresult = a1 + 4;\na1[4] = v7 >> 2;\na1 += 5;\n}\n}\nreturn result;\n}\n```",
|
| 41 |
"output": "a1: r, uint8_t*\na2: a, const polyvec*\nk: t, uint16_t\nj: -, -\ni: k, unsigned int",
|
|
|
|
| 93 |
gr.Textbox(lines=10, value=json.loads(example)['input']),
|
| 94 |
],
|
| 95 |
outputs=gr.Text(label="Var Decoder Output"),
|
| 96 |
+
description=description
|
| 97 |
)
|
| 98 |
demo.launch()
|