Skip to content

Instantly share code, notes, and snippets.

@MikuAuahDark
Created October 30, 2016 09:16
Show Gist options
  • Save MikuAuahDark/3cf3094f1cda3df213e71c4dab5e426b to your computer and use it in GitHub Desktop.
Save MikuAuahDark/3cf3094f1cda3df213e71c4dab5e426b to your computer and use it in GitHub Desktop.
Asteria Decrypter (requires HonokaMiku v4.0.2)
#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <exception>
#include <stdexcept>
#include "HonokaMiku-4.0.2/DecrypterContext.h"
using namespace HonokaMiku;
class asteria_decrypter: public V2_Dctx
{
protected:
asteria_decrypter():V2_Dctx() {}
public:
asteria_decrypter(const void* a, const char* b):V2_Dctx("dpQwjV9rp3g5", a, b) {}
inline static asteria_decrypter* encrypt_setup(const char* filename, void* hdr_out)
{
asteria_decrypter* dctx = new asteria_decrypter();
setupEncryptV2(dctx, "dpQwjV9rp3g5", filename, hdr_out);
return dctx;
}
};
int main(int argc, char* argv[])
{
FILE* fptr = NULL;
FILE* newfptr = NULL;
char temp_buffer[1024];
char new_filename[260];
if(argc < 2)
{
printf("Usage: %s <file in>\nResult file is named \"decrypted_<filein>\"\n", argv[0]);
return 1;
}
sprintf(new_filename, "decrypted_%s", __DctxGetBasename(argv[1]));
fptr = fopen(argv[1], "rb");
newfptr = fopen(new_filename, "wb");
assert(fptr && newfptr);
fread(temp_buffer, 1, 4, fptr);
Dctx* dctx = NULL;
try
{
dctx = new asteria_decrypter(temp_buffer, argv[1]);
}
catch(std::runtime_error)
{
printf("Invalid header\n");
return 1;
}
size_t readed_size = 1024;
while(readed_size == 1024)
{
readed_size = fread(temp_buffer, 1, 1024, fptr);
dctx->decrypt_block(temp_buffer, readed_size);
fwrite(newfptr, 1, readed_size, newfptr);
}
fclose(fptr);
fclose(newfptr);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment