Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Text
- Imports System.Net.Sockets
- Imports System.IO
- Imports System.Windows.Forms
- Imports System.Windows.Controls
- Imports System.Object
- Imports System.Windows.Navigation
- Imports System.Windows.Shapes
- Imports System.Windows.Media.Imaging
- Public Class Form1
- Public Useraffected As String 'selected Users
- Public username As String
- Dim STR As StreamReader
- Dim STW As StreamWriter
- Dim Tcp_CLient As TcpClient
- Dim isverbunden As Boolean = False
- ' Dim enc As New clsCrypto '
- ' Dim ver As New verschl
- Public Auth As Integer
- Dim i As Integer
- Public Html As String = "<Html><Head><title>Chat Window</title></head><body>"
- Public Event NotConnected(ByVal sError As String)
- Public Event Update_Users(ByRef Users() As Array)
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Login.Close()
- Me.Show()
- write_to_browser("<h3>Chatroom 'Crackme' 2012</h3>")
- CheckForIllegalCrossThreadCalls = False
- Verbinden("127.0.0.1", 137)
- Dim HWID As String = System.Security.Principal.WindowsIdentity.GetCurrent.Owner.ToString
- Dim t As New System.Threading.Thread(AddressOf listener)
- t.IsBackground = True
- t.Start()
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- Try
- write_it("alle,", username, RichTextBox1.Text)
- write_to_browser(RichTextBox1.Text)
- RichTextBox1.Clear()
- Catch ex As Exception
- RaiseEvent NotConnected("Error :" & ex.Message)
- End Try
- End Sub
- Private Sub TextBox2_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyDown
- Try
- If e.KeyCode = Keys.Enter Then
- e.SuppressKeyPress = True
- write_it("alle,", username, RichTextBox1.Text)
- RichTextBox1.Clear()
- End If
- Catch ex As Exception
- RaiseEvent NotConnected("Error : " & ex.Message)
- End Try
- End Sub
- Sub Verbinden(ByVal IP As String, ByVal Port As Integer)
- Try
- Tcp_CLient = New TcpClient
- Tcp_CLient.Connect(IP, Port)
- If Tcp_CLient.Connected = True Then
- Me.STR = New System.IO.StreamReader(Tcp_CLient.GetStream)
- Me.STW = New System.IO.StreamWriter(Tcp_CLient.GetStream)
- System.Threading.Thread.Sleep(1000)
- STW.WriteLine("reconnect," & My.Settings.Username & "," & My.Settings.Password)
- STW.Flush()
- Dim aw As String = STR.ReadLine
- If aw.ToLower.StartsWith("true,") Then
- isverbunden = Tcp_CLient.Connected
- Dim t As New System.Threading.Thread(AddressOf Leser)
- t.IsBackground = True
- t.Start()
- End If
- End If
- Catch ex As Exception
- isverbunden = False
- MsgBox("ok " & ex.Message)
- RaiseEvent NotConnected("<b>Could not Connect</b>")
- End Try
- End Sub
- Sub listener()
- Dim tcp_list As TcpListener = New TcpListener(138)
- tcp_list.Start(137)
- Do Until isverbunden = False
- Dim tcpc As TcpClient = tcp_list.AcceptTcpClient
- Dim StreamWrit As StreamWriter = New StreamWriter(tcpc.GetStream)
- Dim streamRead As StreamReader = New StreamReader(tcpc.GetStream)
- Dim aw As String = streamRead.Read
- If aw = "reconn,Server" Then
- STW.Close()
- STR.Close()
- Tcp_CLient.Client.Close()
- PictureBox1.Image = My.Resources.Skype_Red
- STW.WriteLine("roger")
- Else
- MsgBox("AW " & aw)
- End If
- tcpc.Close()
- streamRead.Close()
- StreamWrit.Close()
- Loop
- End Sub
- Sub Leser(ByVal sMessage As String)
- Try
- 'sMessage = enc.DecryptString128Bit(STR.ReadLine, "Zt/5e4yT?9!8KwpM6nSb0Ek*Ma}=X%Rc1Sb0Ek*Ma}")
- Dim ii As Integer = 1
- While isverbunden = True
- sMessage = STR.ReadLine()
- If sMessage.StartsWith("kicked") = True Then
- MsgBox("You Were kicked from the Server", MsgBoxStyle.Information, "Disconnected")
- ElseIf sMessage.StartsWith("userlistupdate,") = True Then
- Username_extract(sMessage)
- Else
- write_to_browser(sMessage)
- End If
- End While
- Catch ex As Exception
- isverbunden = False
- RaiseEvent NotConnected("Leser Error:" & ex.Message)
- End Try
- End Sub
- Public Sub write_to_browser(ByVal sText As String)
- Html = Html.Replace("</body></html>", "")
- Html = Html & "<br>" & sText
- Html = Html & "</body></html>"
- WebBrowser1.DocumentText = Html
- WebBrowser1.Document.Body.ScrollIntoView(False)
- End Sub
- Sub Username_extract(ByVal message As String)
- Try
- Users.Items.Clear()
- Dim new_as As String = message.Replace("userlistupdate,", "")
- Dim auth As Integer = new_as.Substring(new_as.IndexOf(1), 1)
- new_as = new_as.Remove(new_as.IndexOf(1), 1)
- message = ""
- If new_as = My.Settings.Username Then
- Exit Sub
- Else
- new_as = new_as.Replace(username, "")
- End If
- If new_as.Contains(",,") = True Then
- new_as = new_as.Replace(",,", ",")
- ElseIf new_as.StartsWith(",") = True Then
- new_as = new_as.Remove(0, 1)
- ElseIf new_as.EndsWith(",") = True Then
- Dim new_length As Integer = new_as.Length
- Dim index As Integer = new_as.LastIndexOf(",")
- new_as = new_as.Remove(index, 1)
- End If
- Dim iii As Integer = 1
- While iii = 1
- If new_as.Length = 0 Then
- Exit While
- Else
- If new_as.Contains(",,") = True Then
- new_as = new_as.Replace(",,", ",")
- ElseIf new_as.StartsWith(",") = True Then
- new_as = new_as.Remove(0, 1)
- End If
- If new_as.Contains(",") = True Then
- Dim index As Integer = new_as.IndexOf(",")
- Dim user As String = new_as.Substring(0, index)
- new_as = new_as.Remove(0, index)
- Users.Items.Add(user).Group.Items.Add(auth)
- Else
- Users.Items.Add(new_as).Group.Items.Add(auth)
- new_as = ""
- Exit While
- End If
- End If
- End While
- Catch ex As Exception
- MsgBox("error-userUpdate :" & ex.Message)
- End Try
- End Sub
- Public Sub Set_auth_menu()
- If Auth = 2 Then
- ContextMenuStrip1.Items.Add("kick user")
- ContextMenuStrip1.Items.Add("Send to all")
- ElseIf Auth = 3 Then
- ContextMenuStrip1.Items.Add("kick user")
- ContextMenuStrip1.Items.Add("announce")
- ContextMenuStrip1.Items.Add("bann user")
- ContextMenuStrip1.Items.Add("give Mod/Admin")
- End If
- End Sub
- Private Sub Form1_NotConnected(ByVal SErrors As String) Handles Me.NotConnected
- Try
- isverbunden = False
- PictureBox1.Image = My.Resources.Skype_Red
- Tcp_CLient.Client.Close()
- Catch ex As Exception
- write_to_browser("<b>Not Connected</b>")
- End Try
- End Sub
- Public Sub write_it(ByVal target As String, ByVal Username As String, ByVal sText As String)
- Try
- ' Dim sehnwa As String = enc.EncryptString128Bit(target & "<b>" & Username & ":</b> " & sText, "Zt/5e4yT?9!8KwpM6nSb0Ek*Ma}=X%Rc1Sb0Ek*Ma}")
- write_to_browser("<b>Me: </b>" & sText)
- MsgBox(sText)
- STW.WriteLine(target & "<b>" & My.Settings.Username & ":</b> " & sText)
- STW.Flush()
- Catch ex As Exception
- isverbunden = False
- write_to_browser("<b>Message could not be delivered</b>")
- RaiseEvent NotConnected("<b> Not Connection </b>")
- End Try
- End Sub
- Public Sub Write_Instruction(ByVal insturction As String, ByVal User_Names As String, ByVal users_affected As Integer, ByVal further_instructions As String)
- Try
- ' Dim instruc As String = enc.EncryptString128Bit(insturction & "," & User_Names & "," & users_affected & "," & further_instructions, "Zt/5e4yT?9!8KwpM6nSb0Ek*Ma}=X%Rc1Sb0Ek*Ma}")
- STW.WriteLine(insturction & "," & User_Names & "," & users_affected & "," & further_instructions)
- STW.Flush()
- Catch ex As Exception
- write_to_browser("<b>Instruction could not be delivered</b>")
- isverbunden = False
- RaiseEvent NotConnected("<b> Not Connection </b>")
- End Try
- End Sub
- Private Sub KickToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
- If Users.SelectedItems.Count > 1 Then
- MsgBox("You only can kick 1 User at a Time" & vbCr & "Multiselection only works with the wisper function.", MsgBoxStyle.Information, "Kick User")
- Exit Sub
- ElseIf Users.SelectedItems.Count = 0 Then
- MsgBox("Please Select User", MsgBoxStyle.Information, "Kick User")
- Exit Sub
- Else
- Kick.Show()
- End If
- End Sub
- Private Sub BannToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
- If Users.SelectedItems.Count > 1 Then
- MsgBox("You only can bann 1 User at a Time" & vbCr & "Multiselection only works with the wisper function.", MsgBoxStyle.Information, "Bann User")
- Exit Sub
- ElseIf Users.SelectedItems.Count = 0 Then
- MsgBox("Please Select User", MsgBoxStyle.Information, "Bann User")
- Exit Sub
- Else
- Useraffected = Users.SelectedItems.Item(0).Text
- BannForm.Show()
- End If
- End Sub
- Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
- If isverbunden = False Then
- PictureBox1.Image = My.Resources.skype_green
- Verbinden("127.0.0.1", 137)
- If isverbunden = True Then
- PictureBox1.Image = My.Resources.skype_green
- Console.WriteLine(My.Settings.Key)
- System.Threading.Thread.Sleep(200)
- Console.WriteLine(username)
- End If
- Else
- STW.Close()
- STR.Close()
- Tcp_CLient.Client.Close()
- If isverbunden = False Then
- PictureBox1.Image = My.Resources.Skype_Red
- End If
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement