Imports System.Net.Sockets
Imports System.Text
Class TCPSrv
Shared Sub Main()
'----------------START LISTENING----------------------------------
Const portNumber As Integer = 8000
Dim tcpListener As New TcpListener(portNumber)
tcpListener.Start()
Console.WriteLine("<NO CONNECTION>")
'---------------ACCEPT CONNECTION-------------------------------
1:
Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient()
Console.Clear()
Console.WriteLine("<CONNECTION ESTABLISHED>")
Dim networkStream As NetworkStream = tcpClient.GetStream()
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
Dim clientdata As String = Encoding.ASCII.GetString(bytes)
Console.WriteLine("Incomming command: " & clientdata)
If clientdata.Contains("hello") Then
Console.WriteLine(clientdata & "recognized, sending LOGIN page!")
Dim responseString As String = " ___ ______ " & vbNewLine & " / _ \ | ___ \" & vbNewLine & " / /_\ \ ___ | |_/ /" & vbNewLine & " | _ |/ _ \| ___ \" & vbNewLine & " | | | | (_) | |_/ /" & vbNewLine & " *****\_| |_/\___/\____/***** " & vbNewLine & " *____________________________*" & vbNewLine & " |~~~~~~~ WELCOME TO ~~~~~~~~~|" & vbNewLine & " |~~~~~~ DARK ARRAYS ~~~~~~~~~|" & vbNewLine & " |~~~~~~ COMMAND-LINE ~~~~~~~~|" & vbNewLine & " |~~~~~~~~~ CENTER ~~~~~~~~~~~|" & vbNewLine & " |____________________________|" & vbNewLine & "_____________________________________________" & vbNewLine & vbNewLine & vbNewLine
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(responseString)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Console.ReadLine()
GoTo 1
Else
Dim responseString As String = "Who are you?"
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(responseString)
networkStream.Write(sendBytes, 0, sendBytes.Length)
GoTo 1
End If
End Sub
'----------------------AUTHENTICATION------------------------
Shared Sub pass()
Try
Dim tcpClient As New System.Net.Sockets.TcpClient()
Dim networkStream As NetworkStream = tcpClient.GetStream()
If networkStream.CanWrite And networkStream.CanRead Then
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("Please enter a password: ")
networkStream.Write(sendBytes, 0, sendBytes.Length)
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
' Output the data received from the client to the console.
Dim returndata As String = Encoding.ASCII.GetString(bytes)
Console.WriteLine(("Host returned: " + returndata))
End If
Catch ex As Exception
MsgBox("FAILED TO SEND REQUEST")
End Try
Console.ReadLine()
End Sub
End Class