Created
August 28, 2016 00:02
-
-
Save Suchiman/3ee7810a8516d881c918a705f941f66e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.ComponentModel; | |
| using System.Drawing; | |
| using System.IO; | |
| using System.Net.Sockets; | |
| using System.Text; | |
| using System.Windows.Forms; | |
| namespace competition2 | |
| { | |
| public class Form1 : Form | |
| { | |
| private IContainer components; | |
| private Button decryptButton; | |
| private Label label1; | |
| private TextBox textBox2; | |
| private Label label2; | |
| public Form1() | |
| { | |
| this.InitializeComponent(); | |
| } | |
| private void button1_Click(object sender, EventArgs e) | |
| { | |
| string str = this.textBox2.Text.Trim(); | |
| if (str.Length < 3) | |
| { | |
| MessageBox.Show("Erst Code eingeben!"); | |
| return; | |
| } | |
| if (!this.callCthulhu(str)) | |
| { | |
| MessageBox.Show("Ohne gültigen Code geht hier nix weiter."); | |
| return; | |
| } | |
| OpenFileDialog openFileDialog = new OpenFileDialog() | |
| { | |
| Filter = "Crypted files (*.crypt)|*.crypt" | |
| }; | |
| if (openFileDialog.ShowDialog() == DialogResult.OK) | |
| { | |
| try | |
| { | |
| byte[] numArray = File.ReadAllBytes(openFileDialog.FileName); | |
| byte[] numArray1 = this.invertGravity(numArray); | |
| File.WriteAllBytes(openFileDialog.FileName.Substring(0, openFileDialog.FileName.Length - 6), numArray1); | |
| MessageBox.Show("Okay, ist entschlüsselt."); | |
| } | |
| catch (Exception exception1) | |
| { | |
| Exception exception = exception1; | |
| MessageBox.Show(string.Concat("Fehler! Und Du bist schuld: ", exception.Message)); | |
| } | |
| } | |
| } | |
| private bool callCthulhu(string serial) | |
| { | |
| bool flag; | |
| try | |
| { | |
| TcpClient tcpClient = new TcpClient("127.0.0.1", 1337); | |
| byte[] bytes = Encoding.ASCII.GetBytes(serial); | |
| NetworkStream stream = tcpClient.GetStream(); | |
| stream.Write(bytes, 0, (int)bytes.Length); | |
| byte[] numArray = new byte[1024]; | |
| string empty = string.Empty; | |
| int num = stream.Read(numArray, 0, (int)numArray.Length); | |
| empty = Encoding.ASCII.GetString(numArray, 0, num); | |
| stream.Close(); | |
| tcpClient.Close(); | |
| flag = empty.Trim().Equals(this.installLinux()); | |
| } | |
| catch (Exception exception1) | |
| { | |
| Exception exception = exception1; | |
| MessageBox.Show(string.Concat("Kann mich nicht zu meinem Server verbinden.\nFehlermeldung: ", exception.Message)); | |
| flag = false; | |
| } | |
| return flag; | |
| } | |
| protected override void Dispose(bool disposing) | |
| { | |
| if (disposing && this.components != null) | |
| { | |
| this.components.Dispose(); | |
| } | |
| base.Dispose(disposing); | |
| } | |
| private void InitializeComponent() | |
| { | |
| this.decryptButton = new Button(); | |
| this.label1 = new Label(); | |
| this.textBox2 = new TextBox(); | |
| this.label2 = new Label(); | |
| base.SuspendLayout(); | |
| this.decryptButton.Location = new Point(16, 153); | |
| this.decryptButton.Name = "decryptButton"; | |
| this.decryptButton.Size = new Size(126, 23); | |
| this.decryptButton.TabIndex = 3; | |
| this.decryptButton.Text = "&Datei entschlüsseln"; | |
| this.decryptButton.UseVisualStyleBackColor = true; | |
| this.decryptButton.Click += new EventHandler(this.button1_Click); | |
| this.label1.AutoSize = true; | |
| this.label1.Font = new Font("Tahoma", 14f); | |
| this.label1.Location = new Point(12, 9); | |
| this.label1.Name = "label1"; | |
| this.label1.Size = new Size(392, 69); | |
| this.label1.TabIndex = 1; | |
| this.label1.Text = "Wir haben Deine Dateien verschlüsselt! \r\nGib hier einen Code zum Entsperren ein. \r\n(Gibts für nur 1 BTC auf unserer Homepage!)"; | |
| this.textBox2.Location = new Point(54, 109); | |
| this.textBox2.Name = "textBox2"; | |
| this.textBox2.Size = new Size(171, 20); | |
| this.textBox2.TabIndex = 2; | |
| this.label2.AutoSize = true; | |
| this.label2.Location = new Point(12, 112); | |
| this.label2.Name = "label2"; | |
| this.label2.Size = new Size(36, 13); | |
| this.label2.TabIndex = 1; | |
| this.label2.Text = "&Code:"; | |
| base.AutoScaleDimensions = new SizeF(6f, 13f); | |
| base.AutoScaleMode = AutoScaleMode.Font; | |
| base.ClientSize = new Size(485, 195); | |
| base.Controls.Add(this.label2); | |
| base.Controls.Add(this.textBox2); | |
| base.Controls.Add(this.label1); | |
| base.Controls.Add(this.decryptButton); | |
| base.Name = "Form1"; | |
| this.Text = "Wegelagerer 1.0"; | |
| base.ResumeLayout(false); | |
| base.PerformLayout(); | |
| } | |
| private string installLinux() | |
| { | |
| string str = "The iron bank will have its due"; | |
| string[] strArrays = new string[] { str.Substring(0, 1).Replace('q', 'm').Replace('T', 'A').Replace('e', 'd').Replace('v', 's').Replace('r', 'L').Replace('i', 'a'), str.Substring(3, 1), str.Substring(13, 1).Replace('i', 'k').Replace('A', 'k').Replace('n', 'q').Replace(' ', 'L').Replace('y', 'd').Replace('v', 'f').Replace('m', 'a').Replace('m', 'e'), str.Substring(10, 1), str.Substring(7, 1), str.Substring(7, 1), str.Substring(4, 1), str.Substring(26, 1), str.Substring(25, 1), str.Substring(2, 1), str.Substring(5, 1), str.Substring(3, 1), str.Substring(10, 1), str.Substring(16, 1), str.Substring(14, 1), str.Substring(10, 1), str.Substring(5, 1).Replace('c', 'l').Replace('m', 'v').Replace('d', 'o').Replace('k', 'd').Replace('r', 'y').Replace('u', 'A').Replace('g', 'm'), str.Substring(26, 1), str.Substring(3, 1), str.Substring(13, 1).Replace('u', 's').Replace('q', 'A').Replace('k', 'a').Replace('f', 'g').Replace(' ', 'p').Replace('A', 'o').Replace('A', 'r').Replace('m', 'b'), str.Substring(10, 1), str.Substring(4, 1).Replace('g', 'k').Replace('h', 'p').Replace('i', 'y').Replace('f', 'x').Replace('t', 'g').Replace('j', ' ').Replace(' ', 'b'), str.Substring(26, 1), str.Substring(3, 1), str.Substring(1, 1), str.Substring(4, 1), str.Substring(26, 1), str.Substring(3, 1), str.Substring(28, 1), str.Substring(2, 1), str.Substring(9, 1), str.Substring(25, 1), str.Substring(26, 1) }; | |
| return string.Concat(strArrays); | |
| } | |
| private byte[] invertGravity(byte[] chi) | |
| { | |
| if ((int)chi.Length % 2 != 0) | |
| { | |
| throw new Exception("Verschlüsselte Datei hat falsche Länge oder so."); | |
| } | |
| byte[] numArray = new byte[(int)chi.Length / 2]; | |
| for (int i = 0; i < (int)numArray.Length; i++) | |
| { | |
| numArray[i] = Math.Min(chi[i * 2], chi[i * 2 + 1]); | |
| } | |
| return numArray; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment