diff --git a/TeddyBench/AskHexForm.Designer.cs b/TeddyBench/AskHexForm.Designer.cs
new file mode 100644
index 0000000..5fd7271
--- /dev/null
+++ b/TeddyBench/AskHexForm.Designer.cs
@@ -0,0 +1,104 @@
+namespace TeddyBench
+{
+ partial class AskHexForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.label1 = new System.Windows.Forms.Label();
+ this.btnOk = new System.Windows.Forms.Button();
+ this.btnCancel = new System.Windows.Forms.Button();
+ this.txtValue = new System.Windows.Forms.TextBox();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(13, 7);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(144, 13);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "Please enter the ID you want";
+ //
+ // btnOk
+ //
+ this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK;
+ this.btnOk.Location = new System.Drawing.Point(16, 59);
+ this.btnOk.Name = "btnOk";
+ this.btnOk.Size = new System.Drawing.Size(75, 23);
+ this.btnOk.TabIndex = 2;
+ this.btnOk.Text = "Ok";
+ this.btnOk.UseVisualStyleBackColor = true;
+ //
+ // btnCancel
+ //
+ this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.btnCancel.Location = new System.Drawing.Point(112, 59);
+ this.btnCancel.Name = "btnCancel";
+ this.btnCancel.Size = new System.Drawing.Size(75, 23);
+ this.btnCancel.TabIndex = 3;
+ this.btnCancel.Text = "Cancel";
+ this.btnCancel.UseVisualStyleBackColor = true;
+ //
+ // txtPass
+ //
+ this.txtValue.Font = new System.Drawing.Font("Courier New", 10F);
+ this.txtValue.Location = new System.Drawing.Point(16, 33);
+ this.txtValue.MaxLength = 8;
+ this.txtValue.Name = "txtPass";
+ this.txtValue.Size = new System.Drawing.Size(171, 23);
+ this.txtValue.TabIndex = 1;
+ this.txtValue.Text = "50000000";
+ this.txtValue.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
+ this.txtValue.TextChanged += new System.EventHandler(this.txtPass_TextChanged);
+ //
+ // AskHexForm
+ //
+ this.AcceptButton = this.btnOk;
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.CancelButton = this.btnCancel;
+ this.ClientSize = new System.Drawing.Size(202, 89);
+ this.Controls.Add(this.txtValue);
+ this.Controls.Add(this.btnCancel);
+ this.Controls.Add(this.btnOk);
+ this.Controls.Add(this.label1);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
+ this.Name = "AskHexForm";
+ this.Text = "Enter value";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Button btnOk;
+ private System.Windows.Forms.Button btnCancel;
+ private System.Windows.Forms.TextBox txtValue;
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/TeddyBench/AskHexForm.cs b/TeddyBench/AskHexForm.cs
new file mode 100644
index 0000000..bf20102
--- /dev/null
+++ b/TeddyBench/AskHexForm.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace TeddyBench
+{
+ public partial class AskHexForm : Form
+ {
+ internal string ValueText;
+
+ public uint Value => uint.Parse(ValueText, System.Globalization.NumberStyles.HexNumber);
+
+ public AskHexForm(string value = null)
+ {
+ InitializeComponent();
+
+ if(value == null)
+ {
+ value = (DateTimeOffset.Now.ToUnixTimeSeconds() - 0x50000000).ToString("X8");
+ }
+ ValueText = value;
+ txtValue.Text = ValueText;
+ }
+ protected override void OnShown(EventArgs e)
+ {
+ txtValue.Text = ValueText;
+ txtValue.Select();
+ txtValue.Select(0, 8);
+ base.OnShown(e);
+ }
+
+ protected override void OnClosing(CancelEventArgs e)
+ {
+ ValueText = txtValue.Text;
+ base.OnClosing(e);
+ }
+
+ private void txtPass_TextChanged(object sender, EventArgs e)
+ {
+ if (txtValue.Text.Length != 8 || !txtValue.Text.All("0123456789abcdefABCDEF".Contains))
+ {
+ txtValue.BackColor = Color.PaleVioletRed;
+ btnOk.Enabled = false;
+ }
+ else
+ {
+ txtValue.BackColor = Color.LightGreen;
+ btnOk.Enabled = true;
+ }
+ }
+ }
+}
diff --git a/TeddyBench/AskHexForm.resx b/TeddyBench/AskHexForm.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/TeddyBench/AskHexForm.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/TeddyBench/TeddyBench.csproj b/TeddyBench/TeddyBench.csproj
index 0ad77f2..49d2fa4 100644
--- a/TeddyBench/TeddyBench.csproj
+++ b/TeddyBench/TeddyBench.csproj
@@ -74,6 +74,9 @@
+
+ Form
+
True
True
diff --git a/TeddyBench/TeddyMain.cs b/TeddyBench/TeddyMain.cs
index 2ec8a89..c4705b1 100644
--- a/TeddyBench/TeddyMain.cs
+++ b/TeddyBench/TeddyMain.cs
@@ -485,10 +485,26 @@ protected override void OnDragDrop(DragEventArgs drgevent)
if (drop != null)
{
- AddFiles(drop);
+ AddFiles(drop, GetAudioID());
}
}
+ private uint GetAudioID()
+ {
+ if(MessageBox.Show("Do you want to set a specific Audio-ID? If you don't know, just say 'No'.", "Set specific Audio ID", MessageBoxButtons.YesNo) == DialogResult.No)
+ {
+ return uint.MaxValue;
+ }
+
+ AskHexForm form = new AskHexForm();
+ if(form.ShowDialog() != DialogResult.OK)
+ {
+ return uint.MaxValue;
+ }
+
+ return form.Value;
+ }
+
protected override void OnFormClosing(FormClosingEventArgs e)
{
StopThreads();
@@ -1006,11 +1022,11 @@ private void btnAdd_Click(object sender, EventArgs e)
if (dlg.ShowDialog() == DialogResult.OK)
{
- AddFiles(dlg.FileNames);
+ AddFiles(dlg.FileNames, GetAudioID());
}
}
- private void AddFiles(string[] fileNames)
+ private void AddFiles(string[] fileNames, uint id = uint.MaxValue)
{
AskUIDForm ask = new AskUIDForm(Proxmark3);
@@ -1027,7 +1043,7 @@ private void AddFiles(string[] fileNames)
case DialogResult.No:
return;
case DialogResult.Yes:
- EncodeFile(ask.Uid, new[] { fileName });
+ EncodeFile(ask.Uid, new[] { fileName }, id);
return;
}
}
@@ -1057,7 +1073,7 @@ private void AddFiles(string[] fileNames)
return;
}
- EncodeFile(ask.Uid, fileNames);
+ EncodeFile(ask.Uid, fileNames, id);
}
}
}
@@ -1151,7 +1167,7 @@ public override void Warning(string message)
}
}
- private void EncodeFile(string uid, string[] v)
+ private void EncodeFile(string uid, string[] v, uint id = uint.MaxValue)
{
btnAdd.Enabled = false;
btnDelete.Enabled = false;
@@ -1169,7 +1185,10 @@ private void EncodeFile(string uid, string[] v)
try
{
- uint id = (uint)DateTimeOffset.Now.ToUnixTimeSeconds() - 0x50000000;
+ if (id == uint.MaxValue)
+ {
+ id = (uint)(DateTimeOffset.Now.ToUnixTimeSeconds() - 0x50000000);
+ }
audio = new TonieAudio(v, id, cbr: new EncodeCallback(this));
}
catch (Exception ex)