diff --git a/KRY-0x02.csproj b/KRY-0x02.csproj
index bc5425e..192f11a 100644
--- a/KRY-0x02.csproj
+++ b/KRY-0x02.csproj
@@ -12,6 +12,21 @@
512
true
true
+ publish\
+ true
+ Disk
+ false
+ Foreground
+ 7
+ Days
+ false
+ false
+ true
+ 0
+ 1.0.0.%2a
+ false
+ false
+ true
AnyCPU
@@ -22,6 +37,8 @@
DEBUG;TRACE
prompt
4
+ true
+ true
AnyCPU
@@ -32,6 +49,9 @@
prompt
4
+
+
+
@@ -79,5 +99,17 @@
+
+
+ False
+ Microsoft .NET Framework 4.7.2 %28x86 and x64%29
+ true
+
+
+ False
+ .NET Framework 3.5 SP1
+ false
+
+
\ No newline at end of file
diff --git a/main_form.Designer.cs b/main_form.Designer.cs
index aa383da..5d0a34a 100644
--- a/main_form.Designer.cs
+++ b/main_form.Designer.cs
@@ -51,6 +51,8 @@
this.label7 = new System.Windows.Forms.Label();
this.textBox6capacity = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
+ this.textBoxsizemode = new System.Windows.Forms.TextBox();
+ this.label9 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
@@ -73,7 +75,7 @@
this.textBox1putm.Multiline = true;
this.textBox1putm.Name = "textBox1putm";
this.textBox1putm.Size = new System.Drawing.Size(342, 66);
- this.textBox1putm.TabIndex = 1;
+ this.textBox1putm.TabIndex = 3;
//
// label2
//
@@ -89,15 +91,17 @@
this.textBox2getm.Location = new System.Drawing.Point(22, 226);
this.textBox2getm.Multiline = true;
this.textBox2getm.Name = "textBox2getm";
+ this.textBox2getm.ReadOnly = true;
this.textBox2getm.Size = new System.Drawing.Size(342, 59);
this.textBox2getm.TabIndex = 3;
+ this.textBox2getm.TabStop = false;
//
// button1
//
this.button1.Location = new System.Drawing.Point(22, 166);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
- this.button1.TabIndex = 5;
+ this.button1.TabIndex = 4;
this.button1.Text = "put";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
@@ -107,7 +111,7 @@
this.button2.Location = new System.Drawing.Point(22, 291);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
- this.button2.TabIndex = 6;
+ this.button2.TabIndex = 5;
this.button2.Text = "get";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
@@ -152,7 +156,7 @@
this.button3.Location = new System.Drawing.Point(196, 472);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
- this.button3.TabIndex = 12;
+ this.button3.TabIndex = 6;
this.button3.Text = "export";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
@@ -162,7 +166,7 @@
this.button4.Location = new System.Drawing.Point(196, 443);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(75, 23);
- this.button4.TabIndex = 13;
+ this.button4.TabIndex = 1;
this.button4.Text = "import";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
@@ -172,7 +176,7 @@
this.button5.Location = new System.Drawing.Point(289, 443);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(75, 23);
- this.button5.TabIndex = 14;
+ this.button5.TabIndex = 2;
this.button5.Text = "use default";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
@@ -256,11 +260,30 @@
this.label8.TabIndex = 23;
this.label8.Text = "bytes";
//
+ // textBoxsizemode
+ //
+ this.textBoxsizemode.Location = new System.Drawing.Point(594, 535);
+ this.textBoxsizemode.Name = "textBoxsizemode";
+ this.textBoxsizemode.ReadOnly = true;
+ this.textBoxsizemode.Size = new System.Drawing.Size(76, 20);
+ this.textBoxsizemode.TabIndex = 25;
+ //
+ // label9
+ //
+ this.label9.AutoSize = true;
+ this.label9.Location = new System.Drawing.Point(534, 538);
+ this.label9.Name = "label9";
+ this.label9.Size = new System.Drawing.Size(54, 13);
+ this.label9.TabIndex = 26;
+ this.label9.Text = "size mode";
+ //
// main_form
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1041, 584);
+ this.Controls.Add(this.label9);
+ this.Controls.Add(this.textBoxsizemode);
this.Controls.Add(this.label8);
this.Controls.Add(this.textBox6capacity);
this.Controls.Add(this.label7);
@@ -283,6 +306,7 @@
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox1putm);
this.Controls.Add(this.label1);
+ this.Cursor = System.Windows.Forms.Cursors.Default;
this.DoubleBuffered = true;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "main_form";
@@ -320,6 +344,8 @@
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox textBox6capacity;
private System.Windows.Forms.Label label8;
+ private System.Windows.Forms.TextBox textBoxsizemode;
+ private System.Windows.Forms.Label label9;
}
}
diff --git a/main_form.cs b/main_form.cs
index 53d9a3f..a9554b5 100644
--- a/main_form.cs
+++ b/main_form.cs
@@ -25,18 +25,12 @@ namespace KRY_0x02
public static int cap = 0;
public string path = "";
- public string getpath(TextBox t)
- {
- string path = t.Text;
- return path;
- }
-
public int get_capacity(int a, int b)
{
int c = 0;
a = im_h;
b = im_w;
- c = ((a * b) / 8) - 8;
+ c = ((a * b) / 8) - 1;
cap = c;
return c;
}
@@ -44,64 +38,143 @@ namespace KRY_0x02
class do_a_stego
{
- Bitmap my_bitmap;// = new Bitmap(getpath(textBox1));
+ protected Bitmap my_bitmap;
Color pixel;
+ private readonly BackgroundWorker _bw = new BackgroundWorker();
byte bit_array_to_byte(BitArray bit_array)
{
byte[] byte_array = new byte[1];
- //if (bit_array.Count == cap)
- if (bit_array.Count == 8)
+ bit_array.CopyTo(byte_array, 0);
+ return byte_array[0];
+ }
+ public byte[] str_to_rev_binarray(string input)
+ {
+ byte[] bA = Encoding.ASCII.GetBytes(input);
+ byte[] bAA = new byte[bA.Length * 8];
+ BitArray b_a = new BitArray(bA);
+ for (int i = 0; i < b_a.Length; i++)
+ {
+ if (b_a[i] == false)
{
- bit_array.CopyTo(byte_array, 0);
+ bAA[i] = 0;
+ }
+ else
+ {
+ bAA[i] = 1;
+ }
+ }
+ return bAA;
+ }
+
+ public Bitmap encode(Bitmap b, string m)
+ {
+ if ((b.Height * b.Width) < 8)
+ {
+ MessageBox.Show("cannot use a pic of this size bro, sorry");
+ return new Bitmap(1, 1);
}
else
{
- byte_array[0] = 0;
- MessageBox.Show($"you should have {bit_array.Count} bits for a byte bro", "error happened");
- }
- return byte_array[0];
- }
+ my_bitmap = b;
+ string message = m;
+ int counter = 0;
+ int counterzero = 0;
+ byte[] letters_to_code = str_to_rev_binarray(m);
+ string zero = "00001100";
- public string encode(Bitmap b, string m)
- {
- /* WIP */
- my_bitmap = b;
- string message = m;
- for (int i = 0; i < my_bitmap.Width - 1; i++)
- {
+ for (int i = 0; i < my_bitmap.Height - 1; i++)
+ {
+ if (counterzero > 7)
+ {
+ break;
+ }
+
+ for (int j = 0; j < my_bitmap.Width - 1; j++)
+ {
+ string blue_str = "";
+ string blue_str_modded = "";
+ int blue_int_modded = 0;
+ if ((counter < (my_bitmap.Height * my_bitmap.Width) - 8) && counter < letters_to_code.Length)
+ {
+ pixel = my_bitmap.GetPixel(j, i);
+ blue_str = Convert.ToString(pixel.B, 2).PadLeft(8, '0');
+ blue_str_modded = blue_str.Substring(0, 7) + Convert.ToString(letters_to_code[counter]);
+ blue_int_modded = Convert.ToInt32(blue_str_modded, 2);
+ Console.WriteLine($"blueSTRmodded {blue_str_modded}");
+ Console.WriteLine($"blueINTmodded {blue_int_modded}");
+ my_bitmap.SetPixel(j, i, Color.FromArgb(pixel.R, pixel.G, blue_int_modded));
+ Console.WriteLine(my_bitmap.GetPixel(i,j));
+ counter++;
+ }
+ else
+ {
+ pixel = my_bitmap.GetPixel(j, i);
+ blue_str = Convert.ToString(pixel.B, 2).PadLeft(8, '0');
+ blue_str_modded = blue_str.Substring(0, 7) + zero[counterzero];
+ blue_int_modded = Convert.ToInt32(blue_str_modded, 2);
+ Console.WriteLine($"0X00 bytes blueSTRmodded {blue_str_modded}");
+ Console.WriteLine($"0X00 bytes blueINTmodded {blue_int_modded}");
+ my_bitmap.SetPixel(j, i, Color.FromArgb(pixel.R, pixel.G, blue_int_modded));
+ counterzero++;
+
+ if (counterzero > 7)
+ {
+ break;
+ }
+ }
+ }
+ }
+ return my_bitmap;
}
- return "";
}
public string gimme(Bitmap b)
{
- /* WIP */
my_bitmap = b;
- bool[] my_bool_array = new bool[8];
+ string output = "";
+ bool[] my_bool_array = new bool[(cap * 8) + 8];
+
int int_value;
+ int counter = 0;
- int ii = my_bool_array.Length - 1;
-
- for (int i = 0; i < my_bitmap.Width - 1; i++)
+ for (int i = 0; i <= b.Height - 1; i++)
{
- pixel = my_bitmap.GetPixel(i, 0);
- int_value = pixel.B;
+ for (int j = 0; j <= b.Width - 1; j++)
+ {
+ pixel = b.GetPixel(j, i);
+ int_value = pixel.B;
- if ((int_value & 1) == 0)
- {
- my_bool_array[i] = false;
- }
- else if ((int_value & 1) == 1)
- {
- my_bool_array[i] = true;
+ if ((int_value & 1) == 0)
+ {
+ my_bool_array[counter] = false;
+ }
+ else if ((int_value & 1) == 1)
+ {
+ my_bool_array[counter] = true;
+ }
+ counter++;
}
}
- BitArray my_bit_array = new BitArray(my_bool_array);
- char my_char = Convert.ToChar(Convert.ToInt32(bit_array_to_byte(my_bit_array)));
- return Convert.ToString(my_char);
+ for (int i = 0; i < my_bool_array.Length / 8; i++)
+ {
+ BitArray my_bit_array = new BitArray(my_bool_array.Skip(i * 8).Take(8).ToArray());
+ Console.WriteLine(bit_array_to_byte(my_bit_array));
+ char my_char = Convert.ToChar(Convert.ToInt32(bit_array_to_byte(my_bit_array)));
+ Console.WriteLine(my_char);
+ output += Convert.ToString(my_char);
+ }
+ // _bw.DoWork += do_magic;
+ //mm.progressBar1.Maximum = my_bitmap.Height * my_bitmap.Width;
+ //mm.progressBar1.Show();
+ //_bw.RunWorkerAsync();
+ //if (main_output != "")
+ //{
+ // output = main_output;
+ //}
+ return output;
}
}
@@ -117,7 +190,8 @@ namespace KRY_0x02
do_a_stego do_A_Stego = new do_a_stego();
Bitmap b = new Bitmap(pictureBox1.Image);
string m = textBox1putm.Text;
- do_A_Stego.encode(b, m);
+ pictureBox1.Image = do_A_Stego.encode(b, m);
+ MessageBox.Show("success!");
}
private void button2_Click(object sender, EventArgs e)
{
@@ -143,17 +217,23 @@ namespace KRY_0x02
using (OpenFileDialog dlg = new OpenFileDialog())
{
dlg.Title = "pick a pic";
- dlg.Filter = "png (*.png)|*.png|bmp (*.bmp)|*.bmp|tiff (*.tiff)|*.tiff|custom (*.*)|*.*";
+ dlg.Filter = "custom (*.*)|*.*|png (*.png)|*.png|bmp (*.bmp)|*.bmp|tiff (*.tiff)|*.tiff";
if (dlg.ShowDialog() == DialogResult.OK)
{
label5pathtopic.Text = @"path/to/pic";
pictureBox1.Image = new Bitmap(dlg.FileName);
pictureBox1.SizeMode = PictureBoxSizeMode.Normal;
+ textBoxsizemode.Text = "norm";
textBox3.Text = dlg.FileName;
path = textBox3.Text;
im_h = pictureBox1.Image.Height;
im_w = pictureBox1.Image.Width;
+ if (im_h < 100 || im_w < 100)
+ {
+ pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
+ textBoxsizemode.Text = "zoom";
+ }
textBox4height.Text = im_h.ToString();
textBox5width.Text = im_w.ToString();
textBox6capacity.Text = get_capacity(im_h,im_w).ToString();
@@ -166,7 +246,8 @@ namespace KRY_0x02
/*/* use-default-pic button */
string filename = @"C:\Users\citizen\source\repos\KRY-0x02\security.png";
pictureBox1.Image = new Bitmap(filename);
- pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
+ pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
+ textBoxsizemode.Text = "auto";
label5pathtopic.Text = $"Security: Actual actual reality: nobody cares about his secrets."
+ " (Also, I would be hard-pressed to find that wrench for $5.)";
textBox3.Text = filename + "\t\t by randall ... https://xkcd.com/538";
@@ -175,12 +256,12 @@ namespace KRY_0x02
im_w = pictureBox1.Image.Width;
textBox4height.Text = im_h.ToString();
textBox5width.Text = im_w.ToString();
- textBox6capacity.Text = Convert.ToString(get_capacity(im_h, im_w));
+ textBox6capacity.Text = get_capacity(im_h, im_w).ToString();
}
private void button6_Click(object sender, EventArgs e)
{
- /* clear pic selection */
+ /*/**//**///* clear pic selection */
label5pathtopic.Text = @"path/to/pic";
pictureBox1.Image = null;
textBox3.Text = "";
@@ -188,12 +269,15 @@ namespace KRY_0x02
textBox4height.Text = "";
textBox5width.Text = "";
textBox6capacity.Text = "";
+ textBoxsizemode.Text = "";
im_h = 0;
im_w = 0;
+ cap = 0;
}
private void button3_Click(object sender, EventArgs e)
{
+ /* save file */
if (pictureBox1.Image == null)
{
MessageBox.Show("you've nothing to export, boi");
@@ -201,7 +285,7 @@ namespace KRY_0x02
}
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
- saveFileDialog1.Title = "export your neatly stego-ed pic";
+ saveFileDialog1.Title = "export your neatly stego-ed pic";
saveFileDialog1.CheckFileExists = false;
saveFileDialog1.CheckPathExists = false;
saveFileDialog1.DefaultExt = "";
@@ -210,7 +294,6 @@ namespace KRY_0x02
saveFileDialog1.RestoreDirectory = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
- // Get file name.
string name = saveFileDialog1.FileName;
pictureBox1.Image.Save($"{name}",ImageFormat.MemoryBmp);
MessageBox.Show($"saved to {name}","gj, file saved!");