1
0
Fork 0
forked from len0rd/rockbox

Zenutils:

* Make update_extract work again
 * Add other players to zen_crypt
 * Change stricmp() calls to strcasecmp() in zen_crypt


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18264 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Maurus Cuelenaere 2008-08-12 23:51:04 +00:00
parent 1e3ed74479
commit bc628fe5ce
2 changed files with 61 additions and 17 deletions

View file

@ -99,6 +99,24 @@ bool zen::find_firmware_archive(const std::string& filename, dword& va, dword& p
bool zen::crypt_firmware(const char* key, byte* buffer, size_t len) bool zen::crypt_firmware(const char* key, byte* buffer, size_t len)
{ {
#if 1
char key_cpy[255];
unsigned int i;
unsigned int tmp = 0;
int key_length = strlen(key);
strcpy(key_cpy, key);
for(i=0; i < strlen(key); i++)
key_cpy[i] = key[i] - 1;
for(i=0; i < len; i++)
{
buffer[i] ^= key_cpy[tmp] | 0x80;
tmp = (tmp + 1) % key_length;
}
return true;
#else
// Determine if the key length is dword aligned. // Determine if the key length is dword aligned.
int keylen = strlen(key); int keylen = strlen(key);
int keylen_rem = keylen % sizeof(dword); int keylen_rem = keylen % sizeof(dword);
@ -148,4 +166,5 @@ bool zen::crypt_firmware(const char* key, byte* buffer, size_t len)
} }
return true; return true;
#endif
} }

View file

@ -47,23 +47,35 @@ struct player_info_t
{ {
const char* name; const char* name;
const char* null_key; // HMAC-SHA1 key const char* null_key; // HMAC-SHA1 key
const char* fresc_key; // BlowFish key const char* fresc_key_v1; // BlowFish key
const char* tl_key; // BlowFish key const char* tl_key; // BlowFish key
bool big_endian; bool big_endian;
}; };
}; //namespace }; //namespace
static const char VERSION[] = "0.1"; static const char VERSION[] = "0.2";
static const char null_key_v1[] = "CTL:N0MAD|PDE0.SIGN."; static const char null_key_v1[] = "CTL:N0MAD|PDE0.SIGN.";
static const char null_key_v2[] = "CTL:N0MAD|PDE0.DPMP."; static const char null_key_v2[] = "CTL:N0MAD|PDE0.DPMP.";
static const char null_key_v3[] = "CTL:N0MAD|PDE0.DPFP.";
static const char null_key_v4[] = "CTL:Z3N07|PDE0.DPMP.";
static const char fresc_key[] = "Copyright (C) CTL. -" static const char fresc_key_v1[] = "Copyright (C) CTL. -"
" zN0MAD iz v~p0wderful!"; " zN0MAD iz v~p0wderful!";
static const char fresc_key_v2[] = ""; /* Unknown atm */
static const char tl_zvm_key[] = "1sN0TM3D az u~may th1nk*" static const char tl_zvm_key[] = "1sN0TM3D az u~may th1nk*"
"Creative Zen Vision:M"; "Creative Zen Vision:M";
static const char tl_zvm60_key[] = "1sN0TM3D az u~may th1nk*"
"Creative Zen Vision:M (D"
"VP-HD0004)";
static const char tl_zen_key[] = "1sN0TM3D az u~may th1nk*"
"Creative ZEN";
static const char tl_zenxf_key[] = "1sN0TM3D az u~may th1nk*"
"Creative ZEN X-Fi";
static const char tl_zv_key[] = "1sN0TM3D az u~may th1nk*"
"Creative Zen Vision";
static const char tl_zvw_key[] = "1sN0TM3D az u~may th1nk*" static const char tl_zvw_key[] = "1sN0TM3D az u~may th1nk*"
"Creative ZEN Vision W"; "Creative ZEN Vision W";
static const char tl_zm_key[] = "1sN0TM3D az u~may th1nk*" static const char tl_zm_key[] = "1sN0TM3D az u~may th1nk*"
@ -78,16 +90,29 @@ static const char tl_zt_key[] = "1sN0TM3D az u~may th1nk*"
"Creative Zen Touch"; "Creative Zen Touch";
static const char tl_zx_key[] = "1sN0TM3D az u~may th1nk*" static const char tl_zx_key[] = "1sN0TM3D az u~may th1nk*"
"NOMAD Jukebox Zen Xtra"; "NOMAD Jukebox Zen Xtra";
static const char tl_zenv_key[] = "1sN0TM3D az u~may th1nk*"
"Creative ZEN V";
static const char tl_zenvp_key[] = "1sN0TM3D az u~may th1nk*"
"Creative ZEN V Plus";
static const char tl_zenvv_key[] = "1sN0TM3D az u~may th1nk*"
"Creative ZEN V (Video)";
player_info_t players[] = { player_info_t players[] = {
{"Vision:M", null_key_v2, fresc_key, tl_zvm_key, false}, {"Zen Vision:M", null_key_v2, fresc_key_v1, tl_zvm_key, false},
{"Vision W", null_key_v2, fresc_key, tl_zvw_key, false}, {"Zen Vision:M 60GB", null_key_v2, fresc_key_v1, tl_zvm60_key, false},
{"Micro", null_key_v1, fresc_key, tl_zm_key, true}, {"ZEN", null_key_v4, fresc_key_v2, tl_zen_key, false},
{"MicroPhoto", null_key_v1, fresc_key, tl_zmp_key, true}, {"ZEN X-Fi", null_key_v4, fresc_key_v2, tl_zenxf_key, false},
{"Sleek", null_key_v1, fresc_key, tl_zs_key, true}, {"Zen Vision", null_key_v2, fresc_key_v1, tl_zv_key, false},
{"SleekPhoto", null_key_v1, fresc_key, tl_zsp_key, true}, {"Zen Vision W", null_key_v2, fresc_key_v1, tl_zvw_key, false},
{"Touch", null_key_v1, fresc_key, tl_zt_key, true}, {"Zen Micro", null_key_v1, fresc_key_v1, tl_zm_key, true},
{"Xtra", null_key_v1, fresc_key, tl_zx_key, true}, {"Zen MicroPhoto", null_key_v1, fresc_key_v1, tl_zmp_key, true},
{"Zen Sleek", null_key_v1, fresc_key_v1, tl_zs_key, true},
{"Zen SleekPhoto", null_key_v1, fresc_key_v1, tl_zsp_key, true},
{"Zen Touch", null_key_v1, fresc_key_v1, tl_zt_key, true},
{"Zen Xtra", null_key_v1, fresc_key_v1, tl_zx_key, true},
{"Zen V", null_key_v3, fresc_key_v1, tl_zenv_key, false},
{"Zen V Plus", null_key_v3, fresc_key_v1, tl_zenvp_key, false},
{"Zen V Video", null_key_v3, fresc_key_v1, tl_zenvv_key, false},
{NULL, NULL, NULL, NULL, false} {NULL, NULL, NULL, NULL, false}
}; };
@ -96,7 +121,7 @@ player_info_t* find_player_info(std::string player)
{ {
for (int i = 0; players[i].name != NULL; i++) for (int i = 0; players[i].name != NULL; i++)
{ {
if (!stricmp(players[i].name, player.c_str())) if (!strcasecmp(players[i].name, player.c_str()))
{ {
return &players[i]; return &players[i];
} }
@ -444,8 +469,8 @@ bool decrypt(shared::bytes& data, int mode, player_info_t* pi,
std::cout << "[*] Decrypting input file..." << std::endl; std::cout << "[*] Decrypting input file..." << std::endl;
dword iv[2] = {shared::swap(data.size()), 0}; dword iv[2] = {shared::swap(data.size()), 0};
if (!zen::bf_cbc_decrypt((const byte*)pi->fresc_key, if (!zen::bf_cbc_decrypt((const byte*)pi->fresc_key_v1,
strlen(pi->fresc_key)+1, &data[0], strlen(pi->fresc_key_v1)+1, &data[0],
data.size(), (const byte*)iv)) data.size(), (const byte*)iv))
{ {
std::cerr << "Failed to decrypt the input file." << std::endl; std::cerr << "Failed to decrypt the input file." << std::endl;
@ -555,11 +580,11 @@ int process_arguments(int argc, char*argv[])
std::string name = cl.next(""); std::string name = cl.next("");
if (!name.empty()) if (!name.empty())
{ {
if (!stricmp(name.c_str(), "CENC")) if (!strcasecmp(name.c_str(), "CENC"))
mode = mode_cenc; mode = mode_cenc;
else if (!stricmp(name.c_str(), "FRESC")) else if (!strcasecmp(name.c_str(), "FRESC"))
mode = mode_fresc; mode = mode_fresc;
else if (!stricmp(name.c_str(), "TL")) else if (!strcasecmp(name.c_str(), "TL"))
mode = mode_tl; mode = mode_tl;
} }
if (mode == mode_none) if (mode == mode_none)