Skip to content

Commit

Permalink
more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ttwj committed Oct 13, 2013
1 parent a0d8c0f commit ba6e8d2
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 15 deletions.
36 changes: 27 additions & 9 deletions Brake/AppHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public static void Debug(String debugString) {
Console.WriteLine ("Debug: " + debugString);
}
}
public bool setupDirectory(String location) {
public Container getIPAs(String location) {
DirectoryInfo di = new DirectoryInfo(location);
Container container = new Container ();
FileInfo[] files;
//byte[] data;

if (!di.Exists) {
Console.WriteLine ("Error: Directory not found?");
return false;
return null;
}
try
{
Expand All @@ -36,7 +36,7 @@ public bool setupDirectory(String location) {
{
Console.WriteLine ("Error: Exception occured, perhaps no permissions for directory?");
Console.WriteLine (e.ToString ());
return false;
return null;
}
foreach (FileInfo file in files) {
Debug ("IPA found: " + file.Name);
Expand All @@ -54,7 +54,7 @@ public bool setupDirectory(String location) {
string plistLocation = Path.Combine (GetTemporaryDirectory(), e.FileName);
//unpackDirectory + "/" + e.FileName;

Dictionary<string, object> plist = (Dictionary<string,object>)Plist.readPlist (unpackDirectory + "/" + e.FileName);
Dictionary<string, object> plist = (Dictionary<string,object>)Plist.readPlist (plistLocation);
Debug ("plist data: " + plist.ToString ());
Debug ("Bundle Name: " + plist ["CFBundleExecutable"]);
IPAInfo info = new IPAInfo ();
Expand All @@ -73,19 +73,37 @@ public bool setupDirectory(String location) {
serializer.Serialize (writer, container);
Debug ("serializing data");
}
Directory.Delete (GetTemporaryDirectory());
return true;
DeleteDirectory (GetTemporaryDirectory ());
return container;
}

private string tempDir;
public string GetTemporaryDirectory()
private static string tempDir;
public static string GetTemporaryDirectory()
{
if (tempDir == null) {
tempDir = Path.Combine (Path.GetTempPath (), Path.GetRandomFileName ());
Directory.CreateDirectory (tempDir);
}
return tempDir;
}
public static void DeleteDirectory(string target_dir)
{
string[] files = Directory.GetFiles(target_dir);
string[] dirs = Directory.GetDirectories(target_dir);

foreach (string file in files)
{
File.SetAttributes(file, FileAttributes.Normal);
File.Delete(file);
}

foreach (string dir in dirs)
{
DeleteDirectory(dir);
}

Directory.Delete(target_dir, false);
}
}
}

32 changes: 26 additions & 6 deletions Brake/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,38 @@ public static void Main (string[] args)
location = Environment.GetEnvironmentVariable ("HOME") + "/Music/iTunes/iTunes Media/Mobile Applications";
break;
}
case Platform.Windows:
{
//windows sucks
break;
}
case Platform.Windows: {
//windows sucks
string path = Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%");
path = Path.Combine (path, "My Music\\iTunes\\iTunes Media\\Mobile Applications\\");
break;
}
default:
{
Console.WriteLine ("Unknown operating system!");
return;
}
}
appHelper.setupDirectory (location);
Container IPAs = appHelper.getIPAs (location);
int i = 1;
int a;
foreach (IPAInfo ipaInfo in IPAs.Items) {
Console.WriteLine (i + ". >> " + ipaInfo.AppName + " (" + ipaInfo.AppVersion + ")");
i++;
}
Console.WriteLine ("");
Console.Write ("Please enter your selection: ");
if (int.TryParse(Console.ReadLine(), out a)) {
try {
IPAInfo ipaInfo = IPAs.Items [a - 1];
Console.WriteLine ("Cracking " + ipaInfo.AppName);
}
catch (IndexOutOfRangeException) {
Console.WriteLine ("Invalid input, out of range");
}
} else {
Console.WriteLine ("Invalid input");
}

}
}
Expand Down

0 comments on commit ba6e8d2

Please sign in to comment.