mirror of
https://github.com/martravi/wiiqt.git
synced 2024-11-25 18:46:56 +01:00
* add a few more things to get from keys.bin
* remove some junk left over from testing
This commit is contained in:
parent
36d930ebe2
commit
1313326925
23
WiiQt/ec.cpp
23
WiiQt/ec.cpp
@ -428,24 +428,15 @@ int check_ec(quint8 *ng, quint8 *ap, quint8 *sig, quint8 *sig_hash)
|
|||||||
void make_ec_cert( quint8 *cert, quint8 *sig, char *signer, char *name, quint8 *priv, quint32 key_id )
|
void make_ec_cert( quint8 *cert, quint8 *sig, char *signer, char *name, quint8 *priv, quint32 key_id )
|
||||||
{
|
{
|
||||||
//qDebug() << "make_ec_cert";
|
//qDebug() << "make_ec_cert";
|
||||||
memset( cert, 0, 0x180 );
|
memset( cert, 0, 0x180 );
|
||||||
//qDebug() << "1";
|
|
||||||
quint32 tmp = qFromBigEndian( (quint32)0x10002 );
|
quint32 tmp = qFromBigEndian( (quint32)0x10002 );
|
||||||
memcpy( (char*)cert, (const void*)&tmp, 4 );
|
memcpy( (char*)cert, (const void*)&tmp, 4 );
|
||||||
//qDebug() << "2";
|
memcpy( cert + 4, sig, 60 );
|
||||||
memcpy( cert + 4, sig, 60 );
|
strcpy( (char*)cert + 0x80, signer );
|
||||||
//qDebug() << "3";
|
|
||||||
strcpy( (char*)cert + 0x80, signer );
|
|
||||||
//qDebug() << "4";
|
|
||||||
tmp = qFromBigEndian( (quint32)2 );
|
tmp = qFromBigEndian( (quint32)2 );
|
||||||
memcpy( (char*)cert + 0xc0, (const void*)&tmp, 4 );
|
memcpy( (char*)cert + 0xc0, (const void*)&tmp, 4 );
|
||||||
//qDebug() << "5";
|
strcpy( (char*)cert + 0xc4, name );
|
||||||
//wbe32( cert + 0xc0, 2 );
|
|
||||||
strcpy( (char*)cert + 0xc4, name );
|
|
||||||
//qDebug() << "6";
|
|
||||||
tmp = qFromBigEndian( key_id );
|
tmp = qFromBigEndian( key_id );
|
||||||
memcpy( (char*)cert + 0x104, (const void*)&tmp, 4 );
|
memcpy( (char*)cert + 0x104, (const void*)&tmp, 4 );
|
||||||
//qDebug() << "7";
|
|
||||||
//wbe32( cert + 0x104, key_id );
|
|
||||||
ec_priv_to_pub( priv, cert + 0x108 );
|
ec_priv_to_pub( priv, cert + 0x108 );
|
||||||
}
|
}
|
||||||
|
@ -50,3 +50,38 @@ const QByteArray KeysBin::HMac()
|
|||||||
return QByteArray();
|
return QByteArray();
|
||||||
return data.mid( 0x144, 0x14 );
|
return data.mid( 0x144, 0x14 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QByteArray KeysBin::Boot1Hash()
|
||||||
|
{
|
||||||
|
if( data.size() != 0x400 )
|
||||||
|
return QByteArray();
|
||||||
|
return data.mid( 0x100, 0x14 );
|
||||||
|
}
|
||||||
|
|
||||||
|
const QByteArray KeysBin::CommonKey()
|
||||||
|
{
|
||||||
|
if( data.size() != 0x400 )
|
||||||
|
return QByteArray();
|
||||||
|
return data.mid( 0x114, 0x10 );
|
||||||
|
}
|
||||||
|
|
||||||
|
const QByteArray KeysBin::RngKey()
|
||||||
|
{
|
||||||
|
if( data.size() != 0x400 )
|
||||||
|
return QByteArray();
|
||||||
|
return data.mid( 0x168, 0x10 );
|
||||||
|
}
|
||||||
|
|
||||||
|
const QByteArray KeysBin::Otp()
|
||||||
|
{
|
||||||
|
if( data.size() != 0x400 )
|
||||||
|
return QByteArray();
|
||||||
|
return data.mid( 0x100, 0x80 );
|
||||||
|
}
|
||||||
|
|
||||||
|
const QByteArray KeysBin::Seeprom()
|
||||||
|
{
|
||||||
|
if( data.size() != 0x400 )
|
||||||
|
return QByteArray();
|
||||||
|
return data.mid( 0x200, 0x100 );
|
||||||
|
}
|
||||||
|
@ -4,12 +4,17 @@
|
|||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
|
|
||||||
//quick class for grabbing some stuff from a keys.bin from bootmii ( should be 0x400 bytes )
|
//quick class for grabbing some stuff from a keys.bin from bootmii ( should be 0x400 bytes )
|
||||||
// TODO - this isnt complete at all
|
|
||||||
class KeysBin
|
class KeysBin
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KeysBin( QByteArray stuff = QByteArray() );
|
KeysBin( QByteArray stuff = QByteArray() );
|
||||||
|
|
||||||
|
const QByteArray Otp();
|
||||||
|
const QByteArray Seeprom();
|
||||||
|
|
||||||
|
const QByteArray Boot1Hash();
|
||||||
|
const QByteArray CommonKey();
|
||||||
|
const QByteArray RngKey();
|
||||||
const QByteArray NG_ID();
|
const QByteArray NG_ID();
|
||||||
const QByteArray NG_key_ID();
|
const QByteArray NG_key_ID();
|
||||||
const QByteArray NG_Sig();
|
const QByteArray NG_Sig();
|
||||||
|
@ -16,7 +16,9 @@ NandBin::~NandBin()
|
|||||||
{
|
{
|
||||||
if( f.isOpen() )
|
if( f.isOpen() )
|
||||||
{
|
{
|
||||||
|
#ifdef NAND_BIN_CAN_WRITE
|
||||||
f.flush();
|
f.flush();
|
||||||
|
#endif
|
||||||
f.close();
|
f.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,18 +383,7 @@ bool NandBin::InitNand( const QIcon &dirs, const QIcon &files )
|
|||||||
keyIcon = files;
|
keyIcon = files;
|
||||||
|
|
||||||
root = new QTreeWidgetItem( QStringList() << nandPath );
|
root = new QTreeWidgetItem( QStringList() << nandPath );
|
||||||
AddChildren( root, 0 );
|
AddChildren( root, 0 );
|
||||||
/*#ifdef NAND_BIN_CAN_WRITE
|
|
||||||
CreateEntry( "/testDir", 0, 0, NAND_DIR, NAND_RW, NAND_RW, NAND_RW );
|
|
||||||
quint16 pp = CreateEntry( "/testDir/testFile", 0, 0, NAND_FILE, NAND_RW, NAND_RW, NAND_RW );
|
|
||||||
qDebug() << "created entry" << pp;
|
|
||||||
Delete( "/testDir/testFile" );
|
|
||||||
pp = CreateEntry( "/testDir/testFile", 0, 0, NAND_FILE, NAND_RW, NAND_RW, NAND_RW );
|
|
||||||
qDebug() << "created entry" << pp;
|
|
||||||
SetData( pp, QByteArray( 0x10000, '\x0' ) );
|
|
||||||
|
|
||||||
WriteMetaData();
|
|
||||||
#endif*/
|
|
||||||
|
|
||||||
//checkout the blocks for boot1&2
|
//checkout the blocks for boot1&2
|
||||||
QList<QByteArray>blocks;
|
QList<QByteArray>blocks;
|
||||||
@ -1069,13 +1060,11 @@ bool NandBin::WriteDecryptedCluster( quint32 pageNo, const QByteArray &data, fst
|
|||||||
|
|
||||||
bool NandBin::WritePage( quint32 pageNo, const QByteArray &data )
|
bool NandBin::WritePage( quint32 pageNo, const QByteArray &data )
|
||||||
{
|
{
|
||||||
//return true;
|
|
||||||
#ifndef NAND_BIN_CAN_WRITE
|
#ifndef NAND_BIN_CAN_WRITE
|
||||||
qWarning() << __FILE__ << "was built without write support";
|
qWarning() << __FILE__ << "was built without write support";
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
//qDebug() << "NandBin::WritePage(" << hex << pageNo << ")";
|
//qDebug() << "NandBin::WritePage(" << hex << pageNo << ")";
|
||||||
//return true;
|
|
||||||
quint32 n_pagelen[] = { 0x800, 0x840, 0x840 };
|
quint32 n_pagelen[] = { 0x800, 0x840, 0x840 };
|
||||||
if( (quint32)data.size() != n_pagelen[ type ] )
|
if( (quint32)data.size() != n_pagelen[ type ] )
|
||||||
{
|
{
|
||||||
@ -1091,7 +1080,7 @@ bool NandBin::WritePage( quint32 pageNo, const QByteArray &data )
|
|||||||
f.seek( (quint64)pageNo * (quint64)n_pagelen[ type ] ); //seek to the beginning of the page to write
|
f.seek( (quint64)pageNo * (quint64)n_pagelen[ type ] ); //seek to the beginning of the page to write
|
||||||
//qDebug() << "writing page at:" << f.pos() << hex << (quint32)f.pos();
|
//qDebug() << "writing page at:" << f.pos() << hex << (quint32)f.pos();
|
||||||
//hexdump( data, 0, 0x20 );
|
//hexdump( data, 0, 0x20 );
|
||||||
return f.write( data );
|
return ( f.write( data ) == data.size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
quint16 NandBin::CreateNode( const QString &name, quint32 uid, quint16 gid, quint8 attr, quint8 user_perm, quint8 group_perm, quint8 other_perm )
|
quint16 NandBin::CreateNode( const QString &name, quint32 uid, quint16 gid, quint8 attr, quint8 user_perm, quint8 group_perm, quint8 other_perm )
|
||||||
@ -1411,12 +1400,8 @@ bool NandBin::SetData( quint16 idx, const QByteArray &data )
|
|||||||
|
|
||||||
//grab a random cluster from the list
|
//grab a random cluster from the list
|
||||||
quint16 idx = qrand() % freeClusters.size();
|
quint16 idx = qrand() % freeClusters.size();
|
||||||
quint16 cl = freeClusters.takeAt( idx ); //remove this number from the list
|
quint16 cl = freeClusters.takeAt( idx ); //remove this number from the list
|
||||||
/*if( freeClusters.contains( cl ) )
|
|
||||||
{
|
|
||||||
qDebug() << "wtf4";
|
|
||||||
return false;
|
|
||||||
}*/
|
|
||||||
fts << cl; //add this one to the clusters that will be used to hold the data
|
fts << cl; //add this one to the clusters that will be used to hold the data
|
||||||
quint16 block = cl / 8; //try to find other clusters in the same block
|
quint16 block = cl / 8; //try to find other clusters in the same block
|
||||||
for( quint16 i = block * 8; i < ( ( block + 1 ) * 8 ) && fts.size() < clCnt; i++ )
|
for( quint16 i = block * 8; i < ( ( block + 1 ) * 8 ) && fts.size() < clCnt; i++ )
|
||||||
@ -1427,12 +1412,7 @@ bool NandBin::SetData( quint16 idx, const QByteArray &data )
|
|||||||
if( fats.at( i ) == 0xfffe ) //theres more free clusters in this same block, grab them
|
if( fats.at( i ) == 0xfffe ) //theres more free clusters in this same block, grab them
|
||||||
{
|
{
|
||||||
fts << i;
|
fts << i;
|
||||||
freeClusters.removeAt( freeClusters.indexOf( i, 0 ) );
|
freeClusters.removeAt( freeClusters.indexOf( i, 0 ) );
|
||||||
/*if( freeClusters.contains( i ) )
|
|
||||||
{
|
|
||||||
qDebug() << "wtf5";
|
|
||||||
return false;
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//read the spare data to see that the cluster is good - removed for now. but its probably not a bad idea to do this
|
//read the spare data to see that the cluster is good - removed for now. but its probably not a bad idea to do this
|
||||||
@ -1462,76 +1442,24 @@ bool NandBin::SetData( quint16 idx, const QByteArray &data )
|
|||||||
}
|
}
|
||||||
//qDebug() << "done writing shit, fix the fats now" << clCnt << fts.size();
|
//qDebug() << "done writing shit, fix the fats now" << clCnt << fts.size();
|
||||||
//all the data has been written, now make sure the fats are correct
|
//all the data has been written, now make sure the fats are correct
|
||||||
fsts[ idx ].sub = fts.at( 0 );
|
fsts[ idx ].sub = fts.at( 0 );
|
||||||
|
|
||||||
/*QList<quint16>bugFix = fts;
|
|
||||||
for( quint16 i = 0; i < fts.size(); i++ )
|
|
||||||
{
|
|
||||||
if( bugFix.at( i ) != fts.at( i ) )
|
|
||||||
{
|
|
||||||
qDebug() << "wwwwtttf?" << i << hex << bugFix.at( i ) << fts.at( i );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
quint16 te = fsts[ idx ].sub;*/
|
|
||||||
|
|
||||||
for( quint16 i = 0; i < clCnt - 1; i++ )
|
for( quint16 i = 0; i < clCnt - 1; i++ )
|
||||||
{
|
{
|
||||||
fats.replace( fts.at( 0 ), fts.at( 1 ) );
|
fats.replace( fts.at( 0 ), fts.at( 1 ) );
|
||||||
/*qDebug() << "replacing fat" << hex << fts.at( 0 ) << "to point to" << fts.at( 1 ) << "actual:" << fats.at( fts.at( 0 ) );
|
fts.takeFirst();
|
||||||
if( te != fts.at( 0 ) || te != bugFix.at( i ) )
|
|
||||||
{
|
|
||||||
qDebug() << "failed" << i << hex << te << fts.at( 0 ) << bugFix.at( i );
|
|
||||||
return false;
|
|
||||||
}*/
|
|
||||||
fts.takeFirst();
|
|
||||||
//te = GetFAT( te );
|
|
||||||
}
|
|
||||||
//follow the fat chain and make sure it is as expected
|
|
||||||
/*quint16 num = 0;
|
|
||||||
te = fsts[ idx ].sub;
|
|
||||||
while( te < 0xfff0 )
|
|
||||||
{
|
|
||||||
if( te != bugFix.at( num ) )
|
|
||||||
{
|
|
||||||
qDebug() << "mismatch" << num << hex << te << bugFix.at( num );
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
te = GetFAT( te );
|
|
||||||
num++;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//qDebug() << "1 followed the chain to" << num << "items. expected" << clCnt;
|
//qDebug() << "1 followed the chain to" << num << "items. expected" << clCnt;
|
||||||
//qDebug() << "loop is done";
|
|
||||||
fats.replace( fts.at( 0 ), 0xfffb );//last cluster in chain
|
fats.replace( fts.at( 0 ), 0xfffb );//last cluster in chain
|
||||||
fts.takeFirst();
|
fts.takeFirst();
|
||||||
//qDebug() << "fixed the last one" << hex << fts;
|
//qDebug() << "fixed the last one" << hex << fts;
|
||||||
// if the new data uses less clusters than the previous data, mark the extra ones as free
|
// if the new data uses less clusters than the previous data, mark the extra ones as free
|
||||||
//if( !fts.isEmpty() )
|
|
||||||
//qDebug() << "need to mark" << fts.size() << "clusters free";
|
|
||||||
|
|
||||||
while( !fts.isEmpty() )
|
while( !fts.isEmpty() )
|
||||||
{
|
{
|
||||||
fats.replace( fts.at( 0 ), 0xfffe );
|
fats.replace( fts.at( 0 ), 0xfffe );
|
||||||
fts.takeFirst();
|
fts.takeFirst();
|
||||||
}
|
|
||||||
//qDebug() << "2nd loop is done";
|
|
||||||
|
|
||||||
//follow the fat chain and make sure it is as expected
|
|
||||||
/*num = 0;
|
|
||||||
te = fsts[ idx ].sub;
|
|
||||||
while( te < 0xfff0 )
|
|
||||||
{
|
|
||||||
if( te != bugFix.at( num ) )
|
|
||||||
{
|
|
||||||
qDebug() << "mismatch" << num << hex << te << bugFix.at( num );
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
te = GetFAT( te );
|
|
||||||
num++;
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << "2 followed the chain to" << num << "items. expected" << clCnt;*/
|
|
||||||
|
|
||||||
fsts[ idx ].size = data.size();
|
fsts[ idx ].size = data.size();
|
||||||
|
|
||||||
@ -1542,8 +1470,7 @@ bool NandBin::SetData( quint16 idx, const QByteArray &data )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
i->setText( 2, QString( "%1" ).arg( data.size(), 0, 16 ) );
|
i->setText( 2, QString( "%1" ).arg( data.size(), 0, 16 ) );
|
||||||
//f.flush();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,13 +76,15 @@ macx{
|
|||||||
message("mac build")
|
message("mac build")
|
||||||
LIBS += -L./quazip/lib/mac -lquazip
|
LIBS += -L./quazip/lib/mac -lquazip
|
||||||
}
|
}
|
||||||
else unix {
|
else {
|
||||||
!contains(QMAKE_HOST.arch, x86_64) {
|
unix {
|
||||||
|
!contains(QMAKE_HOST.arch, x86_64) {
|
||||||
message("x86 build")
|
message("x86 build")
|
||||||
LIBS += -L./quazip/lib/linux_x86 -lquazip
|
LIBS += -L./quazip/lib/linux_x86 -lquazip
|
||||||
} else {
|
} else {
|
||||||
message("x86_64 build")
|
message("x86_64 build")
|
||||||
LIBS += -L./quazip/lib/linux_x64 -lquazip
|
LIBS += -L./quazip/lib/linux_x64 -lquazip
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user