Remove outdated proof of concept demo programs

This commit is contained in:
Robert McRackan 2021-06-21 14:24:54 -04:00
parent c1f50a184a
commit 5ec6994da7
28 changed files with 0 additions and 1050 deletions

View File

@ -7,8 +7,6 @@ namespace AaxDecrypter
// OTHER EXTERNAL DEPENDENCIES
// ffprobe has these pre-req.s as I'm using it:
// avcodec-58.dll, avdevice-58.dll, avfilter-7.dll, avformat-58.dll, avutil-56.dll, postproc-54.dll, swresample-3.dll, swscale-5.dll, taglib-sharp.dll
//
// something else needs the cygwin files (cyg*.dll)
private static string appPath_ { get; } = Path.GetDirectoryName(Dinah.Core.Exe.FileLocationOnDisk);
private static string decryptLib_ { get; } = Path.Combine(appPath_, "DecryptLib");

View File

@ -54,10 +54,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibationWinForms", "Libatio
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsDesigner", "WinFormsDesigner\WinFormsDesigner.csproj", "{0807616A-A77A-4B08-A65A-1582B09E114B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ffmpeg decrypt", "_Demos\ffmpeg decrypt\ffmpeg decrypt.csproj", "{DF72740C-900A-45DA-A3A6-4DDD68F286F2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "inAudibleLite", "_Demos\inAudibleLite\inAudibleLite.csproj", "{74D02251-898E-4CAF-80C7-801820622903}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dinah.Core", "..\Dinah.Core\Dinah.Core\Dinah.Core.csproj", "{9E951521-2587-4FC6-AD26-FAA9179FB6C4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dinah.EntityFrameworkCore", "..\Dinah.Core\Dinah.EntityFrameworkCore\Dinah.EntityFrameworkCore.csproj", "{1255D9BA-CE6E-42E4-A253-6376540B9661}"
@ -152,14 +148,6 @@ Global
{0807616A-A77A-4B08-A65A-1582B09E114B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0807616A-A77A-4B08-A65A-1582B09E114B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0807616A-A77A-4B08-A65A-1582B09E114B}.Release|Any CPU.Build.0 = Release|Any CPU
{DF72740C-900A-45DA-A3A6-4DDD68F286F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DF72740C-900A-45DA-A3A6-4DDD68F286F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DF72740C-900A-45DA-A3A6-4DDD68F286F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DF72740C-900A-45DA-A3A6-4DDD68F286F2}.Release|Any CPU.Build.0 = Release|Any CPU
{74D02251-898E-4CAF-80C7-801820622903}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74D02251-898E-4CAF-80C7-801820622903}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74D02251-898E-4CAF-80C7-801820622903}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74D02251-898E-4CAF-80C7-801820622903}.Release|Any CPU.Build.0 = Release|Any CPU
{9E951521-2587-4FC6-AD26-FAA9179FB6C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9E951521-2587-4FC6-AD26-FAA9179FB6C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9E951521-2587-4FC6-AD26-FAA9179FB6C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -239,8 +227,6 @@ Global
{111420E2-D4F0-4068-B46A-C4B6DCC823DC} = {38E6C6D9-963A-4C5B-89F4-F2F14885ADFD}
{635F00E1-AAD1-45F7-BEB7-D909AD33B9F6} = {8679CAC8-9164-4007-BDD2-F004810EDA14}
{0807616A-A77A-4B08-A65A-1582B09E114B} = {8679CAC8-9164-4007-BDD2-F004810EDA14}
{DF72740C-900A-45DA-A3A6-4DDD68F286F2} = {F61184E7-2426-4A13-ACEF-5689928E2CE2}
{74D02251-898E-4CAF-80C7-801820622903} = {F61184E7-2426-4A13-ACEF-5689928E2CE2}
{9E951521-2587-4FC6-AD26-FAA9179FB6C4} = {43E3ACB3-E0BC-4370-8DBB-E3720C8C8FD1}
{1255D9BA-CE6E-42E4-A253-6376540B9661} = {43E3ACB3-E0BC-4370-8DBB-E3720C8C8FD1}
{35803735-B669-4090-9681-CC7F7FABDC71} = {7FBBB086-0807-4998-85BF-6D1A49C8AD05}

View File

@ -1,52 +0,0 @@
using System;
using System.Text.RegularExpressions;
namespace ffmpeg_decrypt
{
// from: http://csharptest.net/529/how-to-correctly-escape-command-line-arguments-in-c/index.html
public static class Escaper
{
/// <summary>
/// Quotes all arguments that contain whitespace, or begin with a quote and returns a single
/// argument string for use with Process.Start().
/// </summary>
/// <param name="args">A list of strings for arguments, may not contain null, '\0', '\r', or '\n'</param>
/// <returns>The combined list of escaped/quoted strings</returns>
/// <exception cref="System.ArgumentNullException">Raised when one of the arguments is null</exception>
/// <exception cref="System.ArgumentOutOfRangeException">Raised if an argument contains '\0', '\r', or '\n'</exception>
public static string EscapeArguments(params string[] args)
{
var arguments = new System.Text.StringBuilder();
var invalidChar = new Regex("[\x00\x0a\x0d]");// these can not be escaped
var needsQuotes = new Regex(@"\s|""");// contains whitespace or two quote characters
var escapeQuote = new Regex(@"(\\*)(""|$)");// one or more '\' followed with a quote or end of string
for (int carg = 0; args != null && carg < args.Length; carg++)
{
if (args[carg] == null)
throw new ArgumentNullException("args[" + carg + "]");
if (invalidChar.IsMatch(args[carg]))
throw new ArgumentOutOfRangeException("args[" + carg + "]");
if (args[carg] == string.Empty)
arguments.Append("\"\"");
else if (!needsQuotes.IsMatch(args[carg]))
arguments.Append(args[carg]);
else
{
arguments.Append('"');
arguments.Append(escapeQuote.Replace(args[carg], m =>
m.Groups[1].Value + m.Groups[1].Value +
(m.Groups[2].Value == "\"" ? "\\\"" : "")
));
arguments.Append('"');
}
if (carg + 1 < args.Length)
arguments.Append(' ');
}
return arguments.ToString();
}
}
}

View File

@ -1,34 +0,0 @@
using System;
using System.Windows.Forms;
namespace ffmpeg_decrypt
{
public static class StringExt
{
public static string SurroundWithQuotes(this string str) => "\"" + str + "\"";
public static string ExtractString(this string haystack, string before, int needleLength)
{
var index = haystack.IndexOf(before);
var needle = haystack.Substring(index + before.Length, needleLength);
return needle;
}
}
public static class ControlExt
{
/// <summary>
/// Executes the Action asynchronously on the UI thread, does not block execution on the calling thread.
/// </summary>
/// <param name="control"></param>
/// <param name="code"></param>
public static void UIThread(this Control control, Action code)
{
if (control.InvokeRequired)
control.BeginInvoke(code);
else
code.Invoke();
}
}
}

View File

@ -1,293 +0,0 @@
namespace ffmpeg_decrypt
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.inpbutton = new System.Windows.Forms.Button();
this.outpbutton = new System.Windows.Forms.Button();
this.inputdisplay = new System.Windows.Forms.TextBox();
this.outputdisplay = new System.Windows.Forms.TextBox();
this.convertbutton = new System.Windows.Forms.Button();
this.txtConsole = new System.Windows.Forms.TextBox();
this.qualityCombo = new System.Windows.Forms.ComboBox();
this.setQualityLbl = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.statuslbl = new System.Windows.Forms.Label();
this.rmp3 = new System.Windows.Forms.RadioButton();
this.raac = new System.Windows.Forms.RadioButton();
this.rflac = new System.Windows.Forms.RadioButton();
this.inputPnl = new System.Windows.Forms.Panel();
this.convertGb = new System.Windows.Forms.GroupBox();
this.decryptConvertPnl = new System.Windows.Forms.Panel();
this.convertRb = new System.Windows.Forms.RadioButton();
this.decryptRb = new System.Windows.Forms.RadioButton();
this.inputPnl.SuspendLayout();
this.convertGb.SuspendLayout();
this.decryptConvertPnl.SuspendLayout();
this.SuspendLayout();
//
// inpbutton
//
this.inpbutton.Location = new System.Drawing.Point(306, 0);
this.inpbutton.Name = "inpbutton";
this.inpbutton.Size = new System.Drawing.Size(99, 23);
this.inpbutton.TabIndex = 0;
this.inpbutton.Text = "Choose .aax ...";
this.inpbutton.UseVisualStyleBackColor = true;
this.inpbutton.Click += new System.EventHandler(this.inpbutton_Click);
//
// outpbutton
//
this.outpbutton.Location = new System.Drawing.Point(306, 29);
this.outpbutton.Name = "outpbutton";
this.outpbutton.Size = new System.Drawing.Size(99, 23);
this.outpbutton.TabIndex = 1;
this.outpbutton.Text = "Set extract dir...";
this.outpbutton.UseVisualStyleBackColor = true;
this.outpbutton.Click += new System.EventHandler(this.outpbutton_Click);
//
// inputdisplay
//
this.inputdisplay.Location = new System.Drawing.Point(0, 2);
this.inputdisplay.Name = "inputdisplay";
this.inputdisplay.Size = new System.Drawing.Size(300, 20);
this.inputdisplay.TabIndex = 2;
//
// outputdisplay
//
this.outputdisplay.Location = new System.Drawing.Point(0, 31);
this.outputdisplay.Name = "outputdisplay";
this.outputdisplay.Size = new System.Drawing.Size(300, 20);
this.outputdisplay.TabIndex = 3;
//
// convertbutton
//
this.convertbutton.Enabled = false;
this.convertbutton.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.convertbutton.Location = new System.Drawing.Point(306, 58);
this.convertbutton.Name = "convertbutton";
this.convertbutton.Size = new System.Drawing.Size(99, 107);
this.convertbutton.TabIndex = 6;
this.convertbutton.Text = "Convert Audible Audio File";
this.convertbutton.UseVisualStyleBackColor = true;
this.convertbutton.Click += new System.EventHandler(this.convertbutton_Click);
//
// txtConsole
//
this.txtConsole.BackColor = System.Drawing.Color.Black;
this.txtConsole.ForeColor = System.Drawing.Color.White;
this.txtConsole.Location = new System.Drawing.Point(12, 199);
this.txtConsole.Multiline = true;
this.txtConsole.Name = "txtConsole";
this.txtConsole.ReadOnly = true;
this.txtConsole.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtConsole.Size = new System.Drawing.Size(405, 184);
this.txtConsole.TabIndex = 7;
//
// qualityCombo
//
this.qualityCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.qualityCombo.FormattingEnabled = true;
this.qualityCombo.Items.AddRange(new object[] {
"32",
"80",
"96",
"128",
"160",
"192",
"256",
"320"});
this.qualityCombo.Location = new System.Drawing.Point(148, 41);
this.qualityCombo.Name = "qualityCombo";
this.qualityCombo.Size = new System.Drawing.Size(146, 21);
this.qualityCombo.TabIndex = 9;
//
// setQualityLbl
//
this.setQualityLbl.AutoSize = true;
this.setQualityLbl.Location = new System.Drawing.Point(145, 21);
this.setQualityLbl.Name = "setQualityLbl";
this.setQualityLbl.Size = new System.Drawing.Size(149, 13);
this.setQualityLbl.TabIndex = 10;
this.setQualityLbl.Text = "Set MP3/M4B Quality (kbit/s):";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 183);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(40, 13);
this.label1.TabIndex = 11;
this.label1.Text = "Status:";
//
// statuslbl
//
this.statuslbl.AutoSize = true;
this.statuslbl.Location = new System.Drawing.Point(58, 183);
this.statuslbl.Name = "statuslbl";
this.statuslbl.Size = new System.Drawing.Size(51, 13);
this.statuslbl.TabIndex = 12;
this.statuslbl.Text = "[statuslbl]";
//
// rmp3
//
this.rmp3.AutoSize = true;
this.rmp3.Location = new System.Drawing.Point(6, 19);
this.rmp3.Name = "rmp3";
this.rmp3.Size = new System.Drawing.Size(76, 17);
this.rmp3.TabIndex = 13;
this.rmp3.Text = "MP3 audio";
this.rmp3.UseVisualStyleBackColor = true;
//
// raac
//
this.raac.AutoSize = true;
this.raac.Checked = true;
this.raac.Location = new System.Drawing.Point(6, 42);
this.raac.Name = "raac";
this.raac.Size = new System.Drawing.Size(125, 17);
this.raac.TabIndex = 14;
this.raac.TabStop = true;
this.raac.Text = "AAC M4B Audiobook";
this.raac.UseVisualStyleBackColor = true;
//
// rflac
//
this.rflac.AutoSize = true;
this.rflac.Location = new System.Drawing.Point(6, 65);
this.rflac.Name = "rflac";
this.rflac.Size = new System.Drawing.Size(99, 17);
this.rflac.TabIndex = 15;
this.rflac.Text = "FLAC HQ audio";
this.rflac.UseVisualStyleBackColor = true;
//
// inputPnl
//
this.inputPnl.Controls.Add(this.convertGb);
this.inputPnl.Controls.Add(this.decryptConvertPnl);
this.inputPnl.Controls.Add(this.inputdisplay);
this.inputPnl.Controls.Add(this.inpbutton);
this.inputPnl.Controls.Add(this.outpbutton);
this.inputPnl.Controls.Add(this.outputdisplay);
this.inputPnl.Controls.Add(this.convertbutton);
this.inputPnl.Location = new System.Drawing.Point(12, 12);
this.inputPnl.Name = "inputPnl";
this.inputPnl.Size = new System.Drawing.Size(405, 168);
this.inputPnl.TabIndex = 16;
//
// convertGb
//
this.convertGb.Controls.Add(this.rmp3);
this.convertGb.Controls.Add(this.setQualityLbl);
this.convertGb.Controls.Add(this.rflac);
this.convertGb.Controls.Add(this.qualityCombo);
this.convertGb.Controls.Add(this.raac);
this.convertGb.Location = new System.Drawing.Point(0, 80);
this.convertGb.Name = "convertGb";
this.convertGb.Size = new System.Drawing.Size(300, 85);
this.convertGb.TabIndex = 14;
this.convertGb.TabStop = false;
this.convertGb.Text = "Convert options";
//
// decryptConvertPnl
//
this.decryptConvertPnl.Controls.Add(this.convertRb);
this.decryptConvertPnl.Controls.Add(this.decryptRb);
this.decryptConvertPnl.Location = new System.Drawing.Point(0, 58);
this.decryptConvertPnl.Name = "decryptConvertPnl";
this.decryptConvertPnl.Size = new System.Drawing.Size(266, 16);
this.decryptConvertPnl.TabIndex = 13;
//
// convertRb
//
this.convertRb.AutoSize = true;
this.convertRb.Location = new System.Drawing.Point(88, 0);
this.convertRb.Name = "convertRb";
this.convertRb.Size = new System.Drawing.Size(62, 17);
this.convertRb.TabIndex = 1;
this.convertRb.Text = "Convert";
this.convertRb.UseVisualStyleBackColor = true;
this.convertRb.CheckedChanged += new System.EventHandler(this.decryptConvertRb_CheckedChanged);
//
// decryptRb
//
this.decryptRb.AutoSize = true;
this.decryptRb.Location = new System.Drawing.Point(0, 0);
this.decryptRb.Name = "decryptRb";
this.decryptRb.Size = new System.Drawing.Size(82, 17);
this.decryptRb.TabIndex = 0;
this.decryptRb.Text = "Just decrypt";
this.decryptRb.UseVisualStyleBackColor = true;
this.decryptRb.CheckedChanged += new System.EventHandler(this.decryptConvertRb_CheckedChanged);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(429, 395);
this.Controls.Add(this.inputPnl);
this.Controls.Add(this.txtConsole);
this.Controls.Add(this.label1);
this.Controls.Add(this.statuslbl);
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Open Source Audible Converter";
this.inputPnl.ResumeLayout(false);
this.inputPnl.PerformLayout();
this.convertGb.ResumeLayout(false);
this.convertGb.PerformLayout();
this.decryptConvertPnl.ResumeLayout(false);
this.decryptConvertPnl.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button inpbutton;
private System.Windows.Forms.Button outpbutton;
private System.Windows.Forms.TextBox inputdisplay;
private System.Windows.Forms.TextBox outputdisplay;
private System.Windows.Forms.Button convertbutton;
private System.Windows.Forms.TextBox txtConsole;
private System.Windows.Forms.ComboBox qualityCombo;
private System.Windows.Forms.Label setQualityLbl;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label statuslbl;
private System.Windows.Forms.RadioButton rmp3;
private System.Windows.Forms.RadioButton raac;
private System.Windows.Forms.RadioButton rflac;
private System.Windows.Forms.Panel inputPnl;
private System.Windows.Forms.GroupBox convertGb;
private System.Windows.Forms.Panel decryptConvertPnl;
private System.Windows.Forms.RadioButton convertRb;
private System.Windows.Forms.RadioButton decryptRb;
}
}

View File

@ -1,131 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ffmpeg_decrypt
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
qualityCombo.SelectedIndex = 1; // value == 80
statuslbl.Text = "";
decryptRb.Checked = true;
}
private void inpbutton_Click(object sender, EventArgs e)
{
using var ofd = new OpenFileDialog { Filter = "Audible Audio Files|*.aax", Title = "Select an Audible Audio File", FileName = "" };
if (ofd.ShowDialog() == DialogResult.OK)
{
inputdisplay.Text = ofd.FileName;
outputdisplay.Text = Path.GetDirectoryName(ofd.FileName);
convertbutton.Enabled = true;
}
}
private void outpbutton_Click(object sender, EventArgs e)
{
using var fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
outputdisplay.Text = fbd.SelectedPath;
}
private async void convertbutton_Click(object sender, EventArgs e)
{
//var sw = Stopwatch.StartNew();
// disable UI
inputPnl.Enabled = false;
statuslbl.Text = "Getting File Hash...";
var checksum = await RCrack.GetChecksum(inputdisplay.Text);
statuslbl.Text = "Cracking Activation Bytes...";
var activation_bytes = await RCrack.GetActivationBytes(checksum);
statuslbl.Text = "Converting File...";
var encodeTo
= decryptRb.Checked ? EncodeTo.DecryptOnly
: rmp3.Checked ? EncodeTo.Mp3
: raac.Checked ? EncodeTo.M4b
: rflac.Checked ? EncodeTo.Flac
: throw new NotImplementedException();
await decryptAndSaveFile(activation_bytes, inputdisplay.Text, outputdisplay.Text, txtConsole, encodeTo, int.Parse(qualityCombo.Text));
// re-enable UI
inputPnl.Enabled = true;
//sw.Stop();
//var total = (int)sw.Elapsed.TotalSeconds;
statuslbl.Text = "Conversion Complete!";
}
// ProcessStartInfo.Arguments: use Escaper.EscapeArguments instead of .SurroundWithQuotes()
// see also: https://stackoverflow.com/questions/4291912/process-start-how-to-get-the-output
// top 2 answers show: easy, sync, async
enum EncodeTo
{
/// <summary>Decrypt only. Retain original encoding</summary>
DecryptOnly,
/// <summary>LAME MP3</summary>
Mp3,
/// <summary>M4B AAC</summary>
M4b,
/// <summary>FLAC HD</summary>
Flac
}
private static async Task decryptAndSaveFile(string activation_bytes, string inputPath, string outputPath, TextBoxBase debugWindow, EncodeTo encodeTo, int encodeQuality = 80)
{
Resources.Extract("ffmpeg.exe");
var fileBase = Path.Combine(outputPath, Path.GetFileNameWithoutExtension(inputPath));
string arguments;
// only decrypt. no re-encoding
if (encodeTo == EncodeTo.DecryptOnly)
{
var fileout = fileBase + ".m4b";
arguments = $"-activation_bytes {activation_bytes} -i {inputPath.SurroundWithQuotes()} -vn -c:a copy {fileout.SurroundWithQuotes()}";
}
// re-encode. encoding will be determined by file extension
else // if (convertRb.Checked)
{
var fileout = fileBase + "." + encodeTo.ToString().ToLower();
arguments = $"-y -activation_bytes {activation_bytes} -i {inputPath.SurroundWithQuotes()} -ab {encodeQuality} -map_metadata 0 -id3v2_version 3 -vn {fileout.SurroundWithQuotes()}";
}
// nothing in stdout. progress/debug info is in stderr
var startInfo = new ProcessStartInfo
{
FileName = Path.Combine(Resources.resdir, "ffmpeg.exe"),
Arguments = arguments,
CreateNoWindow = true,
RedirectStandardError = true,
UseShellExecute = false,
WorkingDirectory = Directory.GetCurrentDirectory()
};
using var ffm = new Process { StartInfo = startInfo, EnableRaisingEvents = true };
ffm.ErrorDataReceived += (s, ea) => debugWindow.UIThread(() => debugWindow.AppendText($"DEBUG: {ea.Data}\r\n"));
ffm.Start();
ffm.BeginErrorReadLine();
await Task.Run(() => ffm.WaitForExit());
ffm.Close();
}
private void decryptConvertRb_CheckedChanged(object sender, EventArgs e) => convertGb.Enabled = convertRb.Checked;
}
}

View File

@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ffmpeg_decrypt
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

View File

@ -1,85 +0,0 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
namespace ffmpeg_decrypt
{
public static class RCrack
{
public static async Task<string> GetChecksum(string aaxPath)
{
Resources.Extract("ffprobe.exe");
var startInfo = new ProcessStartInfo
{
FileName = Path.Combine(Resources.resdir, "ffprobe.exe"),
Arguments = aaxPath.SurroundWithQuotes(),
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
WorkingDirectory = Directory.GetCurrentDirectory()
};
using var ffp = new Process { StartInfo = startInfo };
ffp.Start();
// checksum is in the debug info. ffprobe's debug info is written to stderr, not stdout
var ffprobeStderr = ffp.StandardError.ReadToEnd();
await ffp.WaitForExitAsync();
ffp.Close();
// example checksum line:
// ... [aax] file checksum == 0c527840c4f18517157eb0b4f9d6f9317ce60cd1
var checksum = ffprobeStderr.ExtractString("file checksum == ", 40);
return checksum;
}
/// <summary>use checksum to get activation bytes. activation bytes are unique per audible customer. only have to do this 1x/customer</summary>
public static async Task<string> GetActivationBytes(string checksum)
{
Resources.Extract("rcrack.exe");
Resources.Extract("alglib1.dll");
// RainbowCrack files to recover your own Audible activation data (activation_bytes) in an offline manner
Resources.Extract("audible_byte#4-4_0_10000x789935_0.rtc");
Resources.Extract("audible_byte#4-4_1_10000x791425_0.rtc");
Resources.Extract("audible_byte#4-4_2_10000x790991_0.rtc");
Resources.Extract("audible_byte#4-4_3_10000x792120_0.rtc");
Resources.Extract("audible_byte#4-4_4_10000x790743_0.rtc");
Resources.Extract("audible_byte#4-4_5_10000x790568_0.rtc");
Resources.Extract("audible_byte#4-4_6_10000x791458_0.rtc");
Resources.Extract("audible_byte#4-4_7_10000x791707_0.rtc");
Resources.Extract("audible_byte#4-4_8_10000x790202_0.rtc");
Resources.Extract("audible_byte#4-4_9_10000x791022_0.rtc");
var startInfo = new ProcessStartInfo
{
FileName = Path.Combine(Resources.resdir, "rcrack.exe"),
Arguments = @". -h " + checksum,
CreateNoWindow = true,
RedirectStandardOutput = true,
UseShellExecute = false,
WorkingDirectory = Directory.GetCurrentDirectory()
};
using var rcr = new Process { StartInfo = startInfo };
rcr.Start();
var rcrackStdout = rcr.StandardOutput.ReadToEnd();
await rcr.WaitForExitAsync();
rcr.Close();
// example result
// 0c527840c4f18517157eb0b4f9d6f9317ce60cd1 \xbd\x89X\x09 hex:bd895809
var activation_bytes = rcrackStdout.ExtractString("hex:", 8);
return activation_bytes;
}
}
}

View File

@ -1,28 +0,0 @@
using System;
using System.IO;
namespace ffmpeg_decrypt
{
public static class Resources
{
public static string resdir { get; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "res");
/// <summary>extract embedded resource to file if it doesn't already exist</summary>
public static void Extract(string resourceName)
{
// first determine whether files exist already in res dir
if (File.Exists(Path.Combine(resdir, resourceName)))
return;
// extract embedded resource
// this technique works but there are easier ways:
// https://stackoverflow.com/questions/13031778/how-can-i-extract-a-file-from-an-embedded-resource-and-save-it-to-disk
Directory.CreateDirectory(resdir);
using var resource = System.Reflection.Assembly.GetCallingAssembly().GetManifestResourceStream($"{nameof(ffmpeg_decrypt)}.res." + resourceName);
using var reader = new BinaryReader(resource);
using var file = new FileStream(Path.Combine(resdir, resourceName), FileMode.OpenOrCreate);
using var writer = new BinaryWriter(file);
writer.Write(reader.ReadBytes((int)resource.Length));
}
}
}

View File

@ -1,65 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<RootNamespace>ffmpeg_decrypt</RootNamespace>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<None Remove="res\alglib1.dll" />
<None Remove="res\ffmpeg.exe" />
<None Remove="res\ffprobe.exe" />
<None Remove="res\rcrack.exe" />
</ItemGroup>
<ItemGroup>
<Content Include="res\alglib1.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="res\ffmpeg.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="res\ffprobe.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="res\rcrack.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Update="res\audible_byte#4-4_0_10000x789935_0.rtc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="res\audible_byte#4-4_1_10000x791425_0.rtc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="res\audible_byte#4-4_2_10000x790991_0.rtc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="res\audible_byte#4-4_3_10000x792120_0.rtc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="res\audible_byte#4-4_4_10000x790743_0.rtc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="res\audible_byte#4-4_5_10000x790568_0.rtc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="res\audible_byte#4-4_6_10000x791458_0.rtc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="res\audible_byte#4-4_7_10000x791707_0.rtc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="res\audible_byte#4-4_8_10000x790202_0.rtc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="res\audible_byte#4-4_9_10000x791022_0.rtc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

Binary file not shown.

Binary file not shown.

View File

@ -1,167 +0,0 @@
namespace inAudibleLite
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnConvert = new System.Windows.Forms.Button();
this.txtInputFile = new System.Windows.Forms.TextBox();
this.btnSelectFile = new System.Windows.Forms.Button();
this.txtOutputFile = new System.Windows.Forms.TextBox();
this.rtbLog = new System.Windows.Forms.RichTextBox();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.decryptKeyLbl = new System.Windows.Forms.Label();
this.decryptKeyTb = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// btnConvert
//
this.btnConvert.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.btnConvert.Location = new System.Drawing.Point(12, 306);
this.btnConvert.Name = "btnConvert";
this.btnConvert.Size = new System.Drawing.Size(600, 23);
this.btnConvert.TabIndex = 7;
this.btnConvert.Text = "Begin Conversion";
this.btnConvert.UseVisualStyleBackColor = true;
this.btnConvert.Click += new System.EventHandler(this.btnConvert_Click);
//
// txtInputFile
//
this.txtInputFile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtInputFile.Location = new System.Drawing.Point(47, 14);
this.txtInputFile.Name = "txtInputFile";
this.txtInputFile.Size = new System.Drawing.Size(565, 20);
this.txtInputFile.TabIndex = 1;
//
// btnSelectFile
//
this.btnSelectFile.Location = new System.Drawing.Point(12, 12);
this.btnSelectFile.Name = "btnSelectFile";
this.btnSelectFile.Size = new System.Drawing.Size(27, 23);
this.btnSelectFile.TabIndex = 0;
this.btnSelectFile.Text = "...";
this.btnSelectFile.UseVisualStyleBackColor = true;
this.btnSelectFile.Click += new System.EventHandler(this.btnSelectFile_Click);
//
// txtOutputFile
//
this.txtOutputFile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtOutputFile.Location = new System.Drawing.Point(47, 40);
this.txtOutputFile.Name = "txtOutputFile";
this.txtOutputFile.Size = new System.Drawing.Size(565, 20);
this.txtOutputFile.TabIndex = 2;
//
// rtbLog
//
this.rtbLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.rtbLog.Location = new System.Drawing.Point(12, 66);
this.rtbLog.Name = "rtbLog";
this.rtbLog.Size = new System.Drawing.Size(491, 205);
this.rtbLog.TabIndex = 5;
this.rtbLog.Text = "";
//
// progressBar1
//
this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.progressBar1.Location = new System.Drawing.Point(12, 277);
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(600, 23);
this.progressBar1.TabIndex = 6;
//
// pictureBox1
//
this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox1.Location = new System.Drawing.Point(512, 111);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(100, 100);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 6;
this.pictureBox1.TabStop = false;
//
// decryptKeyLbl
//
this.decryptKeyLbl.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.decryptKeyLbl.AutoSize = true;
this.decryptKeyLbl.Location = new System.Drawing.Point(509, 69);
this.decryptKeyLbl.Name = "decryptKeyLbl";
this.decryptKeyLbl.Size = new System.Drawing.Size(64, 13);
this.decryptKeyLbl.TabIndex = 3;
this.decryptKeyLbl.Text = "Decrypt key";
//
// decryptKeyTb
//
this.decryptKeyTb.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.decryptKeyTb.Location = new System.Drawing.Point(512, 85);
this.decryptKeyTb.Name = "decryptKeyTb";
this.decryptKeyTb.Size = new System.Drawing.Size(100, 20);
this.decryptKeyTb.TabIndex = 4;
this.decryptKeyTb.Text = "bd895809";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(624, 341);
this.Controls.Add(this.decryptKeyTb);
this.Controls.Add(this.decryptKeyLbl);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.progressBar1);
this.Controls.Add(this.rtbLog);
this.Controls.Add(this.txtOutputFile);
this.Controls.Add(this.btnSelectFile);
this.Controls.Add(this.txtInputFile);
this.Controls.Add(this.btnConvert);
this.Name = "Form1";
this.Text = "inAudibleLite 1.0";
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btnConvert;
private System.Windows.Forms.TextBox txtInputFile;
private System.Windows.Forms.Button btnSelectFile;
private System.Windows.Forms.TextBox txtOutputFile;
private System.Windows.Forms.RichTextBox rtbLog;
private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label decryptKeyLbl;
private System.Windows.Forms.TextBox decryptKeyTb;
}
}

View File

@ -1,121 +0,0 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
using AaxDecrypter;
using Dinah.Core.IO;
using Dinah.Core.Logging;
using Dinah.Core.Windows.Forms;
using Serilog;
namespace inAudibleLite
{
public partial class Form1 : Form
{
public const string APP_NAME = "inAudibleLite 1.0";
private ISimpleAaxToM4bConverter converter;
private Action<string> _conversionCompleteAction { get; }
public Form1(Action<string> conversionCompleteAction) : this() => _conversionCompleteAction = conversionCompleteAction;
public Form1()
{
InitializeComponent();
this.btnConvert.Enabled = false;
initSerilog();
redirectWriteLine();
}
private static void initSerilog()
{
// default. for reference. output example:
// 2019-11-26 08:48:40.224 -05:00 [DBG] Begin Libation
var default_outputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}";
// with class and method info. output example:
// 2019-11-26 08:48:40.224 -05:00 [DBG] (at LibationWinForms.Program.init()) Begin Libation
var code_outputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] (at {Caller}) {Message:lj}{NewLine}{Exception}";
var logPath = Path.Combine(Path.GetTempPath(), "Log.log");
Log.Logger = new LoggerConfiguration()
.Enrich.WithCaller()
.MinimumLevel.Debug()
.WriteTo.File(logPath,
rollingInterval: RollingInterval.Month,
outputTemplate: code_outputTemplate)
.CreateLogger();
Log.Logger.Debug("Begin Libation");
// .Here() captures debug info via System.Runtime.CompilerServices attributes. Warning: expensive
//var withLineNumbers_outputTemplate = "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message}{NewLine}in method {MemberName} at {FilePath}:{LineNumber}{NewLine}{Exception}{NewLine}";
//Log.Logger.Here().Debug("Begin Libation. Debug with line numbers");
}
private void redirectWriteLine()
{
// redirect Console.WriteLine to console, log file, textbox
var multiLogger = new MultiTextWriter(
Console.Out,
new RichTextBoxTextWriter(this.rtbLog),
new SerilogTextWriter());
Console.SetOut(multiLogger);
}
string aaxPath;
public async Task<string> getActivationBytes()
{
var checksum = await ffmpeg_decrypt.RCrack.GetChecksum(aaxPath);
var activationBytes = await ffmpeg_decrypt.RCrack.GetActivationBytes(checksum);
return activationBytes;
}
private async void btnSelectFile_Click(object sender, EventArgs e)
{
var openFileDialog = new OpenFileDialog { Filter = "Audible files (*.aax)|*.aax" };
if (openFileDialog.ShowDialog() != DialogResult.OK)
return;
this.rtbLog.Clear();
this.txtInputFile.Text = openFileDialog.FileName;
aaxPath = this.txtInputFile.Text;
converter = await AaxToM4bConverter.CreateAsync(this.txtInputFile.Text, this.decryptKeyTb.Text, getActivationBytes);
pictureBox1.Image = Dinah.Core.Drawing.ImageReader.ToImage(converter.coverBytes);
this.txtOutputFile.Text = converter.outputFileName;
this.btnConvert.Enabled = true;
}
private async void btnConvert_Click(object sender, EventArgs e)
{
this.btnConvert.Enabled = false;
// only re-process prelim stats if input filename was changed
//also pick up new decrypt key, etc//if (this.txtInputFile.Text != converter?.inputFileName)
converter = await AaxToM4bConverter.CreateAsync(this.txtInputFile.Text, this.decryptKeyTb.Text, getActivationBytes);
converter.AppName = APP_NAME;
converter.SetOutputFilename(this.txtOutputFile.Text);
converter.DecryptProgressUpdate += (s, progress) => this.progressBar1.UpdateValue(progress);
// REAL WORK DONE HERE
await Task.Run(() => converter.Run());
Console.WriteLine("Output directory: " + converter.outDir);
// open output dir
Process.Start("file://" + converter.outDir);
this.btnConvert.Enabled = true;
_conversionCompleteAction?.Invoke(converter.outputFileName);
}
}
}

View File

@ -1,20 +0,0 @@
using System;
using System.Windows.Forms;
namespace inAudibleLite
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

View File

@ -1,15 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Dinah.Core\Dinah.Core.WindowsDesktop\Dinah.Core.WindowsDesktop.csproj" />
<ProjectReference Include="..\..\AaxDecrypter\AaxDecrypter.csproj" />
<ProjectReference Include="..\ffmpeg decrypt\ffmpeg decrypt.csproj" />
</ItemGroup>
</Project>