-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServer.cs
29 lines (27 loc) · 925 Bytes
/
Server.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Net;
using System.Net.WebSockets;
using System.Threading.Tasks;
namespace MaliceRAT
{
class Server
{
public async Task Start(string url)
{
HttpListener httpListener = new HttpListener();
httpListener.Prefixes.Add(url);
httpListener.Start();
Console.WriteLine("WebSocket Server started at " + url);
while (true)
{
HttpListenerContext httpListenerContext = await httpListener.GetContextAsync();
if (httpListenerContext.Request.IsWebSocketRequest)
{
HttpListenerWebSocketContext webSocketContext = await httpListenerContext.AcceptWebSocketAsync(null);
WebSocket webSocket = webSocketContext.WebSocket;
// Handle the WebSocket connection here
}
}
}
}
}