Advertisement
Guest User

Gui

a guest
Feb 4th, 2012
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 11.30 KB | None | 0 0
  1. Imports System.Text
  2. Imports System.Net.Sockets
  3. Imports System.IO
  4. Imports System.Windows.Forms
  5. Imports System.Windows.Controls
  6. Imports System.Object
  7. Imports System.Windows.Navigation
  8. Imports System.Windows.Shapes
  9. Imports System.Windows.Media.Imaging
  10. Public Class Form1
  11.  
  12.     Public Useraffected As String 'selected Users
  13.     Public username As String
  14.     Dim STR As StreamReader
  15.     Dim STW As StreamWriter
  16.     Dim Tcp_CLient As TcpClient
  17.     Dim isverbunden As Boolean = False
  18.     ' Dim enc As New clsCrypto '
  19.     ' Dim ver As New verschl
  20.     Public Auth As Integer
  21.  
  22.     Dim i As Integer
  23.     Public Html As String = "<Html><Head><title>Chat Window</title></head><body>"
  24.     Public Event NotConnected(ByVal sError As String)
  25.     Public Event Update_Users(ByRef Users() As Array)
  26.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  27.         Login.Close()
  28.         Me.Show()
  29.         write_to_browser("<h3>Chatroom 'Crackme' 2012</h3>")
  30.         CheckForIllegalCrossThreadCalls = False
  31.         Verbinden("127.0.0.1", 137)
  32.         Dim HWID As String = System.Security.Principal.WindowsIdentity.GetCurrent.Owner.ToString
  33.         Dim t As New System.Threading.Thread(AddressOf listener)
  34.         t.IsBackground = True
  35.         t.Start()
  36.     End Sub
  37.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  38.         Try
  39.             write_it("alle,", username, RichTextBox1.Text)
  40.             write_to_browser(RichTextBox1.Text)
  41.             RichTextBox1.Clear()
  42.         Catch ex As Exception
  43.             RaiseEvent NotConnected("Error :" & ex.Message)
  44.         End Try
  45.     End Sub
  46.     Private Sub TextBox2_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyDown
  47.         Try
  48.             If e.KeyCode = Keys.Enter Then
  49.                 e.SuppressKeyPress = True
  50.                 write_it("alle,", username, RichTextBox1.Text)
  51.                 RichTextBox1.Clear()
  52.             End If
  53.         Catch ex As Exception
  54.             RaiseEvent NotConnected("Error : " & ex.Message)
  55.         End Try
  56.     End Sub
  57.     Sub Verbinden(ByVal IP As String, ByVal Port As Integer)
  58.  
  59.         Try
  60.             Tcp_CLient = New TcpClient
  61.             Tcp_CLient.Connect(IP, Port)
  62.             If Tcp_CLient.Connected = True Then
  63.                 Me.STR = New System.IO.StreamReader(Tcp_CLient.GetStream)
  64.                 Me.STW = New System.IO.StreamWriter(Tcp_CLient.GetStream)
  65.                 System.Threading.Thread.Sleep(1000)
  66.                 STW.WriteLine("reconnect," & My.Settings.Username & "," & My.Settings.Password)
  67.                 STW.Flush()
  68.                 Dim aw As String = STR.ReadLine
  69.                 If aw.ToLower.StartsWith("true,") Then
  70.                     isverbunden = Tcp_CLient.Connected
  71.                     Dim t As New System.Threading.Thread(AddressOf Leser)
  72.                     t.IsBackground = True
  73.                     t.Start()
  74.                 End If
  75.             End If
  76.  
  77.         Catch ex As Exception
  78.             isverbunden = False
  79.             MsgBox("ok                  " & ex.Message)
  80.             RaiseEvent NotConnected("<b>Could not Connect</b>")
  81.         End Try
  82.     End Sub
  83.     Sub listener()
  84.         Dim tcp_list As TcpListener = New TcpListener(138)
  85.         tcp_list.Start(137)
  86.         Do Until isverbunden = False
  87.             Dim tcpc As TcpClient = tcp_list.AcceptTcpClient
  88.             Dim StreamWrit As StreamWriter = New StreamWriter(tcpc.GetStream)
  89.             Dim streamRead As StreamReader = New StreamReader(tcpc.GetStream)
  90.             Dim aw As String = streamRead.Read
  91.             If aw = "reconn,Server" Then
  92.                 STW.Close()
  93.                 STR.Close()
  94.                 Tcp_CLient.Client.Close()
  95.                 PictureBox1.Image = My.Resources.Skype_Red
  96.                 STW.WriteLine("roger")
  97.             Else
  98.                 MsgBox("AW " & aw)
  99.             End If
  100.             tcpc.Close()
  101.             streamRead.Close()
  102.             StreamWrit.Close()
  103.         Loop
  104.     End Sub
  105.     Sub Leser(ByVal sMessage As String)
  106.         Try
  107.             'sMessage = enc.DecryptString128Bit(STR.ReadLine, "Zt/5e4yT?9!8KwpM6nSb0Ek*Ma}=X%Rc1Sb0Ek*Ma}")
  108.             Dim ii As Integer = 1
  109.             While isverbunden = True
  110.                 sMessage = STR.ReadLine()
  111.                 If sMessage.StartsWith("kicked") = True Then
  112.                     MsgBox("You Were kicked from the Server", MsgBoxStyle.Information, "Disconnected")
  113.                 ElseIf sMessage.StartsWith("userlistupdate,") = True Then
  114.                     Username_extract(sMessage)
  115.                 Else
  116.                     write_to_browser(sMessage)
  117.                 End If
  118.             End While
  119.         Catch ex As Exception
  120.             isverbunden = False
  121.             RaiseEvent NotConnected("Leser Error:" & ex.Message)
  122.         End Try
  123.     End Sub
  124.     Public Sub write_to_browser(ByVal sText As String)
  125.         Html = Html.Replace("</body></html>", "")
  126.         Html = Html & "<br>" & sText
  127.         Html = Html & "</body></html>"
  128.         WebBrowser1.DocumentText = Html
  129.         WebBrowser1.Document.Body.ScrollIntoView(False)
  130.     End Sub
  131.  
  132.     Sub Username_extract(ByVal message As String)
  133.         Try
  134.             Users.Items.Clear()
  135.             Dim new_as As String = message.Replace("userlistupdate,", "")
  136.             Dim auth As Integer = new_as.Substring(new_as.IndexOf(1), 1)
  137.             new_as = new_as.Remove(new_as.IndexOf(1), 1)
  138.             message = ""
  139.             If new_as = My.Settings.Username Then
  140.                 Exit Sub
  141.             Else
  142.                 new_as = new_as.Replace(username, "")
  143.             End If
  144.             If new_as.Contains(",,") = True Then
  145.                 new_as = new_as.Replace(",,", ",")
  146.             ElseIf new_as.StartsWith(",") = True Then
  147.                 new_as = new_as.Remove(0, 1)
  148.             ElseIf new_as.EndsWith(",") = True Then
  149.                 Dim new_length As Integer = new_as.Length
  150.                 Dim index As Integer = new_as.LastIndexOf(",")
  151.                 new_as = new_as.Remove(index, 1)
  152.             End If
  153.             Dim iii As Integer = 1
  154.             While iii = 1
  155.                 If new_as.Length = 0 Then
  156.  
  157.                     Exit While
  158.                 Else
  159.  
  160.                     If new_as.Contains(",,") = True Then
  161.                         new_as = new_as.Replace(",,", ",")
  162.                     ElseIf new_as.StartsWith(",") = True Then
  163.                         new_as = new_as.Remove(0, 1)
  164.                     End If
  165.  
  166.                     If new_as.Contains(",") = True Then
  167.  
  168.                         Dim index As Integer = new_as.IndexOf(",")
  169.                         Dim user As String = new_as.Substring(0, index)
  170.                         new_as = new_as.Remove(0, index)
  171.                         Users.Items.Add(user).Group.Items.Add(auth)
  172.  
  173.                     Else
  174.                         Users.Items.Add(new_as).Group.Items.Add(auth)
  175.                         new_as = ""
  176.                         Exit While
  177.                     End If
  178.  
  179.                 End If
  180.             End While
  181.         Catch ex As Exception
  182.             MsgBox("error-userUpdate :" & ex.Message)
  183.         End Try
  184.     End Sub
  185.     Public Sub Set_auth_menu()
  186.         If Auth = 2 Then
  187.             ContextMenuStrip1.Items.Add("kick user")
  188.             ContextMenuStrip1.Items.Add("Send to all")
  189.         ElseIf Auth = 3 Then
  190.             ContextMenuStrip1.Items.Add("kick user")
  191.             ContextMenuStrip1.Items.Add("announce")
  192.             ContextMenuStrip1.Items.Add("bann user")
  193.             ContextMenuStrip1.Items.Add("give Mod/Admin")
  194.  
  195.         End If
  196.  
  197.  
  198.     End Sub
  199.     Private Sub Form1_NotConnected(ByVal SErrors As String) Handles Me.NotConnected
  200.         Try
  201.             isverbunden = False
  202.             PictureBox1.Image = My.Resources.Skype_Red
  203.             Tcp_CLient.Client.Close()
  204.         Catch ex As Exception
  205.             write_to_browser("<b>Not Connected</b>")
  206.         End Try
  207.  
  208.     End Sub
  209.     Public Sub write_it(ByVal target As String, ByVal Username As String, ByVal sText As String)
  210.         Try
  211.             '  Dim sehnwa As String = enc.EncryptString128Bit(target & "<b>" & Username & ":</b> " & sText, "Zt/5e4yT?9!8KwpM6nSb0Ek*Ma}=X%Rc1Sb0Ek*Ma}")
  212.             write_to_browser("<b>Me: </b>" & sText)
  213.             MsgBox(sText)
  214.             STW.WriteLine(target & "<b>" & My.Settings.Username & ":</b> " & sText)
  215.             STW.Flush()
  216.         Catch ex As Exception
  217.             isverbunden = False
  218.             write_to_browser("<b>Message could not be delivered</b>")
  219.             RaiseEvent NotConnected("<b> Not Connection </b>")
  220.         End Try
  221.  
  222.     End Sub
  223.     Public Sub Write_Instruction(ByVal insturction As String, ByVal User_Names As String, ByVal users_affected As Integer, ByVal further_instructions As String)
  224.         Try
  225.             ' Dim instruc As String = enc.EncryptString128Bit(insturction & "," & User_Names & "," & users_affected & "," & further_instructions, "Zt/5e4yT?9!8KwpM6nSb0Ek*Ma}=X%Rc1Sb0Ek*Ma}")
  226.             STW.WriteLine(insturction & "," & User_Names & "," & users_affected & "," & further_instructions)
  227.             STW.Flush()
  228.         Catch ex As Exception
  229.             write_to_browser("<b>Instruction could not be delivered</b>")
  230.             isverbunden = False
  231.             RaiseEvent NotConnected("<b> Not Connection </b>")
  232.         End Try
  233.  
  234.     End Sub
  235.     Private Sub KickToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  236.  
  237.         If Users.SelectedItems.Count > 1 Then
  238.             MsgBox("You only can kick 1 User at a Time" & vbCr & "Multiselection only works with the wisper function.", MsgBoxStyle.Information, "Kick User")
  239.             Exit Sub
  240.         ElseIf Users.SelectedItems.Count = 0 Then
  241.             MsgBox("Please Select User", MsgBoxStyle.Information, "Kick User")
  242.             Exit Sub
  243.         Else
  244.             Kick.Show()
  245.         End If
  246.  
  247.     End Sub
  248.  
  249.     Private Sub BannToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  250.         If Users.SelectedItems.Count > 1 Then
  251.             MsgBox("You only can bann 1 User at a Time" & vbCr & "Multiselection only works with the wisper function.", MsgBoxStyle.Information, "Bann User")
  252.             Exit Sub
  253.         ElseIf Users.SelectedItems.Count = 0 Then
  254.             MsgBox("Please Select User", MsgBoxStyle.Information, "Bann User")
  255.             Exit Sub
  256.         Else
  257.             Useraffected = Users.SelectedItems.Item(0).Text
  258.             BannForm.Show()
  259.         End If
  260.     End Sub
  261.  
  262.     Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
  263.         If isverbunden = False Then
  264.             PictureBox1.Image = My.Resources.skype_green
  265.             Verbinden("127.0.0.1", 137)
  266.             If isverbunden = True Then
  267.                 PictureBox1.Image = My.Resources.skype_green
  268.                 Console.WriteLine(My.Settings.Key)
  269.                 System.Threading.Thread.Sleep(200)
  270.                 Console.WriteLine(username)
  271.             End If
  272.         Else
  273.             STW.Close()
  274.             STR.Close()
  275.             Tcp_CLient.Client.Close()
  276.             If isverbunden = False Then
  277.                 PictureBox1.Image = My.Resources.Skype_Red
  278.             End If
  279.         End If
  280.     End Sub
  281. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement