-
Notifications
You must be signed in to change notification settings - Fork 4
/
VNC.cs
59 lines (57 loc) · 2.8 KB
/
VNC.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Net.Sockets;
using System.Text;
using static Reecon.OSINT_Instagram_Info;
namespace Reecon
{
class VNC
{
public static (string PortTitle, string PortInfo) GetInfo(string target, int port)
{
string returnText = "";
Byte[] buffer = new Byte[12];
using (Socket vncSocket = new(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
{
vncSocket.ReceiveTimeout = 5000;
vncSocket.SendTimeout = 5000;
try
{
vncSocket.Connect(target, port);
int byteCount = vncSocket.Receive(buffer, buffer.Length, 0);
string bannerText = Encoding.ASCII.GetString(buffer, 0, byteCount);
bannerText = bannerText.Trim();
if (bannerText.StartsWith("RFB "))
{
// https://www.dcs.ed.ac.uk/home/vnc/rfbproto.pdf
// Handshaking begins by the server sending the client a ProtocolVersion message. This
// lets the client know which is the latest RFB protocol version number supported by the
// server
returnText += "- VNC Header Confirmed." + Environment.NewLine;
// Extract the protocol version from the data string
string version = bannerText.Remove(0, 4).Trim();
Version theVersion = Version.Parse(version);
returnText += "- Protocol version: " + theVersion + Environment.NewLine;
// The client then replies with a similar message giving the version number of the protocol which should actually be used
// Console.WriteLine("Sending back....");
// vncSocket.Send(buffer, 0, byteCount, SocketFlags.None);
// byteCount = vncSocket.Receive(buffer, buffer.Length, 0);
// Once the protocol version has been decided, the server then sends a word indicating the
// authentication scheme to be used on the connection:
}
else
{
// Not VNC
returnText += "- Unknown VNC Header: " + bannerText + Environment.NewLine;
PortInfo.FindUnknownPortInfo(target, port);
return ("Done", "");
}
}
catch (Exception ex)
{
returnText += $"- Unknown Error: {ex.Message}";
}
}
return ("VNC", returnText);
}
}
}