Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
UnityPy/UnityPyBoost/ArchiveStorageDecryptor.cpp at master · zzy-hacker/UnityPy · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
zzy-hacker
UnityPy
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
UnityPy
/
UnityPyBoost
/
ArchiveStorageDecryptor.cpp
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
90 lines (74 loc) · 3.06 KB
master
Breadcrumbs
UnityPy
/
UnityPyBoost
/
ArchiveStorageDecryptor.cpp
Copy path
Top
File metadata and controls
Code
Blame
90 lines (74 loc) · 3.06 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
based on https://github.com/RazTools/Studio/blob/main/AssetStudio/Crypto/UnityCN.cs
#
include
"
ArchiveStorageDecryptor.hpp
"
#
include
<
Python.h
>
inline
unsigned
char
decrypt_byte
(
unsigned
char
*bytes,
uint64_t
& offset,
uint64_t
& index,
const
unsigned
char
*index_data,
const
unsigned
char
*substitute_data)
{
unsigned
char
count_byte = substitute_data[((index >>
2
) &
3
) +
4
]
+ substitute_data[index &
3
]
+ substitute_data[((index >>
4
) &
3
) +
8
]
+ substitute_data[((
unsigned
char
)index >>
6
) +
12
];
bytes[offset] = (
unsigned
char
)(((index_data[bytes[offset] &
0xF
] - count_byte) &
0xF
) |
0x10
* (index_data[bytes[offset] >>
4
] - count_byte));
count_byte = bytes[offset++];
index++;
return
count_byte;
}
inline
uint64_t
decrypt
(
unsigned
char
*bytes,
uint64_t
index,
uint64_t
remaining,
const
unsigned
char
*index_data,
const
unsigned
char
*substitute_data)
{
uint64_t
offset =
0
;
unsigned
char
current_byte =
decrypt_byte
(bytes, offset, index, index_data, substitute_data);
uint64_t
current_byte_high = current_byte >>
4
;
uint64_t
current_byte_low = current_byte &
0xF
;
if
(current_byte_high ==
0xF
)
{
unsigned
char
count_byte;
do
{
count_byte =
decrypt_byte
(bytes, offset, index, index_data, substitute_data);
current_byte_high += count_byte;
}
while
(count_byte ==
0xFF
);
}
offset += current_byte_high;
if
(offset < remaining)
{
decrypt_byte
(bytes, offset, index, index_data, substitute_data);
decrypt_byte
(bytes, offset, index, index_data, substitute_data);
if
(current_byte_low ==
0xF
)
{
unsigned
char
count_byte;
do
{
count_byte =
decrypt_byte
(bytes, offset, index, index_data, substitute_data);
}
while
(count_byte ==
0xFF
);
}
}
return
offset;
}
PyObject *
decrypt_block
(PyObject *self, PyObject *args) {
Py_buffer index_data;
Py_buffer substitute_data;
Py_buffer data;
uint64_t
index;
if
(!
PyArg_ParseTuple
(args,
"
y*y*y*K
"
, &index_data, &substitute_data, &data, &index)) {
if
(index_data.
buf
)
PyBuffer_Release
(&index_data);
if
(substitute_data.
buf
)
PyBuffer_Release
(&substitute_data);
if
(data.
buf
)
PyBuffer_Release
(&data);
return
nullptr
;
}
PyObject *result =
PyBytes_FromStringAndSize
(
nullptr
, data.
len
);
if
(result ==
nullptr
) {
PyBuffer_Release
(&index_data);
PyBuffer_Release
(&substitute_data);
PyBuffer_Release
(&data);
return
nullptr
;
}
unsigned
char
*result_raw = (
unsigned
char
*)
PyBytes_AS_STRING
(result);
memcpy
(result_raw, data.
buf
, data.
len
);
Py_ssize_t offset =
0
;
while
(offset < data.
len
) {
offset +=
decrypt
(result_raw + offset, index++, data.
len
- offset, (
unsigned
char
*)index_data.
buf
, (
unsigned
char
*)substitute_data.
buf
);
}
PyBuffer_Release
(&index_data);
PyBuffer_Release
(&substitute_data);
PyBuffer_Release
(&data);
return
result;
}
You can’t perform that action at this time.