svn path=/trunk/ipod-sharp/; revision=86025
This commit is contained in:
Aaron Bockover 2007-09-19 18:12:39 +00:00
Родитель 543bd17022
Коммит 90e47c46b7
2 изменённых файлов: 70 добавлений и 5 удалений

57
tools/Hash58.cs Normal file
Просмотреть файл

@ -0,0 +1,57 @@
using System;
using System.IO;
using System.Text;
namespace IPod
{
public static class Hash58Test
{
public static void Main(string [] args)
{
if(args.Length != 2) {
Console.WriteLine("Usage:");
Console.WriteLine(" mono hash58.exe iTunesDBPath Firewire-ID");
return;
}
string path = args[0];
string firewire_id = args[1];
byte [] hash = null;
byte [] original = new byte[20];
using(BinaryReader reader = new BinaryReader(File.Open(path, FileMode.Open))) {
byte [] contents = new byte[reader.BaseStream.Length];
reader.Read(contents, 0, contents.Length);
Array.Copy(contents, 0x58, original, 0, 20);
Zero(contents, 0x18, 8);
Zero(contents, 0x32, 20);
Zero(contents, 0x58, 20);
hash = Hash58.GenerateHash(firewire_id, contents);
}
Console.WriteLine("Original Hash: {0}", HashToString(original));
Console.WriteLine("Generated Hash: {0}", HashToString(hash));
}
private static string HashToString(byte [] buffer)
{
StringBuilder builder = new StringBuilder();
foreach(byte b in buffer) {
builder.AppendFormat("{0:X2}", b);
}
return builder.ToString();
}
private static void Zero(byte [] buffer, int index, int length)
{
for(int i = index; i < index + length; i++) {
buffer[i] = 0;
}
}
}
}

Просмотреть файл

@ -1,8 +1,13 @@
MCS_FLAGS = -debug
TOOLS = ipod-tool.exe dmg-iso-extract.exe ipod-firmware-extract.exe photo-adder.exe video-adder.exe
TOOLS = hash58.exe ipod-tool.exe dmg-iso-extract.exe ipod-firmware-extract.exe photo-adder.exe video-adder.exe
HASH58_SRC = \
$(srcdir)/Hash58.cs \
$(top_srcdir)/src/Hash58.cs
IPOD_TOOL_SRC = $(srcdir)/PodTool.cs
IPOD_TOOL_SOURCES = $(srcdir)/PodTool.cs
DMG_ISO_EXTRACT_SRC = \
$(srcdir)/DmgIsoExtract.cs \
$(top_builddir)/src/Firmware/DmgImage.cs \
@ -18,8 +23,11 @@ VIDEO_ADDER_SRC = $(srcdir)/VideoAdder.cs
all: $(TOOLS)
ipod-tool.exe: $(IPOD_TOOL_SOURCES)
$(MCS) $(MCS_FLAGS) -r:$(top_builddir)/src/ipod-sharp.dll -target:exe -out:$@ $(IPOD_TOOL_SOURCES)
hash58.exe: $(HASH58_SRC)
$(MCS) $(MCS_FLAGS) -target:exe -out:$@ $(HASH58_SRC)
ipod-tool.exe: $(IPOD_TOOL_SRC)
$(MCS) $(MCS_FLAGS) -r:$(top_builddir)/src/ipod-sharp.dll -target:exe -out:$@ $(IPOD_TOOL_SRC)
dmg-iso-extract.exe: $(DMG_ISO_EXTRACT_SRC)
$(MCS) $(MCS_FLAGS) -r:ICSharpCode.SharpZipLib -target:exe -out:$@ $(DMG_ISO_EXTRACT_SRC)
@ -33,7 +41,7 @@ photo-adder.exe: $(PHOTO_ADDER_SRC)
video-adder.exe: $(VIDEO_ADDER_SRC)
$(MCS) $(MCS_FLAGS) -target:exe -out:$@ $(VIDEO_ADDER_SRC) -r:$(top_builddir)/src/ipod-sharp.dll -pkg:gtk-sharp-2.0
EXTRA_DIST = $(IPOD_TOOL_SOURCES) $(DMG_ISO_EXTRACT_SRC) $(DMG_FIRMWARE_EXTRACT_SRC) $(PHOTO_ADDER_SRC) $(VIDEO_ADDER_SRC)
EXTRA_DIST = $(HASH58_SRC) $(IPOD_TOOL_SRC) $(DMG_ISO_EXTRACT_SRC) $(DMG_FIRMWARE_EXTRACT_SRC) $(PHOTO_ADDER_SRC) $(VIDEO_ADDER_SRC)
CLEANFILES = $(TOOLS) *.mdb
MAINTAINERCLEANFILES = Makefile.in