Advertisement
TermSpar

phOS Dev Console

Jan 18th, 2016
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 13.59 KB | None | 0 0
  1. Imports System.Net
  2. Imports System.Text
  3. Imports System.Net.Sockets
  4. Imports System.Diagnostics
  5. Imports System.IO
  6. Public Class frmConsole
  7.     Dim inter As String
  8.     Dim port As Integer
  9.     Dim packets As Integer
  10.     Public SAPI As Object
  11.     Public compspeak
  12.     Public Function speak()
  13.         Dim SAPI
  14.         SAPI = CreateObject("SAPI.spvoice")
  15.         SAPI.Volume = 100
  16.         SAPI.speak(compspeak)
  17.     End Function
  18.     Private Sub txtCommands_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles txtCommands.KeyDown
  19.         Dim fileClear As String
  20.         If e.KeyCode = Keys.Enter Then
  21.             If txtCommands.Text.Contains("phOScd.clear-") Or txtCommands.Text.Contains("phoscd.clear") Then
  22.                 fileClear = txtCommands.Text.Split("-")(1)
  23.                 If My.Computer.FileSystem.FileExists(fileClear) Then
  24.                     My.Computer.FileSystem.WriteAllText(fileClear, "", False)
  25.                     txtItems.AppendText("P:\Console.ph>" & txtCommands.Text & vbNewLine & vbNewLine)
  26.                     txtItems.AppendText("File: " & fileClear & " cleared" & vbNewLine & vbNewLine)
  27.                     txtCommands.Clear()
  28.                     SendKeys.Send("{BACKSPACE}")
  29.                 Else
  30.                     txtItems.AppendText("File: " & fileClear & " not found" & vbNewLine & vbNewLine)
  31.                     txtCommands.Clear()
  32.                     SendKeys.Send("{BACKSPACE}")
  33.                 End If
  34.             ElseIf txtCommands.Text.Contains("phOS.end") Or txtCommands.Text.Contains("phos.end") Then
  35.                 txtItems.AppendText("P:\Console.ph>" & txtCommands.Text)
  36.                 Application.Exit()
  37.             ElseIf txtCommands.Text.Contains("help") Then
  38.                 txtItems.AppendText("P:\Console.ph>" & txtCommands.Text & vbNewLine & vbNewLine)
  39.                 txtItems.AppendText("Command: 'phOScd.clear' Purpose: Clear specified text file" & vbNewLine)
  40.                 txtItems.AppendText("Syntax: phOScd.clear-C:\example.txt" & vbNewLine & vbNewLine)
  41.                 txtItems.AppendText("Command: 'phOS.end' Purpose: Exit phOS" & vbNewLine & vbNewLine)
  42.                 txtItems.AppendText("Command: 'stress' Purpose: Send packets to stress an IP address" & vbNewLine)
  43.                 txtItems.AppendText("Syntax: stress 127.0.0.1 80 : 100 ('stress' IP Port : Packets)" & vbNewLine & vbNewLine)
  44.                 txtItems.AppendText("Command: 'IP.get' Purpose: Get a websites IP address" & vbNewLine)
  45.                 txtItems.AppendText("Syntax: IP.get www.google.com" & vbNewLine & vbNewLine)
  46.                 txtItems.AppendText("Command: 'myInfo.get' Purpose: Display information about your machine" & vbNewLine & vbNewLine)
  47.                 txtItems.AppendText("Command: 'files.list' Purpose: View Files on Drive" & vbNewLine & "Syntax: files.list(desktop)" & vbNewLine & vbNewLine)
  48.                 txtItems.AppendText("Command: 'launch' Purpose: Launch an app from the console" & vbNewLine & "Syntax: launch@calculator" & vbNewLine & vbNewLine)
  49.                 txtItems.AppendText("Command: 'say' Purpose: Have The Computer Talk" & vbNewLine & "Syntax: say hello world" & vbNewLine & vbNewLine)
  50.                 txtItems.AppendText("Command: 'goTo' Purpose: opens a website in default browser" & vbNewLine & "Syntax: goTo http://www.google.com (URL must include http://)" & vbNewLine & vbNewLine)
  51.                 txtCommands.Clear()
  52.                 SendKeys.Send("{BACKSPACE}")
  53.             ElseIf txtCommands.Text.Contains("stress ") Then
  54.                 txtItems.AppendText("P:\Console.ph>" & txtCommands.Text & vbNewLine & vbNewLine)
  55.                 If txtCommands.Text.Contains(" : ") And txtCommands.Text.IndexOf(" ") >= 4 Then
  56.                     inter = txtCommands.Text.Split(" ")(1)
  57.                     port = txtCommands.Text.Split(" ")(2)
  58.                     packets = txtCommands.Text.Split(":")(1)
  59.                     If inter <> Nothing And port <> Nothing And packets <> Nothing Then
  60.                         Timer1.Start()
  61.                     Else
  62.                         txtItems.AppendText("Syntax: stress 127.0.0.1 80 : 100 ('stress':IP:Port:Packets)" & vbNewLine & vbNewLine)
  63.                     End If
  64.                 Else
  65.                     txtItems.AppendText("Syntax: stress 127.0.0.1 80 : 100 ('stress':IP:Port:Packets)" & vbNewLine & vbNewLine)
  66.                 End If
  67.                 txtCommands.Clear()
  68.                 SendKeys.Send("{BACKSPACE}")
  69.             ElseIf txtCommands.Text.Contains("stop") Then
  70.                 txtItems.AppendText("P:\Console.ph>" & txtCommands.Text & vbNewLine & vbNewLine)
  71.                 If Timer1.Enabled = True Then
  72.                     Timer1.Enabled = False
  73.                 End If
  74.                 txtCommands.Clear()
  75.                 SendKeys.Send("{BACKSPACE}")
  76.             ElseIf txtCommands.Text.Contains("IP.get") Or txtCommands.Text.Contains("ip.get") Then
  77.                 txtItems.AppendText("P:\Console.ph>" & txtCommands.Text & vbNewLine & vbNewLine)
  78.                 Dim websiteURL As String
  79.                 websiteURL = txtCommands.Text.Split(" ")(1)
  80.                 Dim hostname As IPHostEntry = Dns.GetHostEntry(websiteURL)
  81.                 Dim ip As IPAddress() = hostname.AddressList
  82.                 txtItems.AppendText("IP of " & websiteURL & " is " & ip(0).ToString & vbNewLine & vbNewLine)
  83.                 txtCommands.Clear()
  84.                 SendKeys.Send("{BACKSPACE}")
  85.             ElseIf txtCommands.Text.Contains("clear") Then
  86.                 txtItems.Clear()
  87.                 txtCommands.Clear()
  88.                 SendKeys.Send("{BACKSPACE}")
  89.                 btnStart.PerformClick()
  90.             ElseIf txtCommands.Text.Contains("myInfo.get") Or txtCommands.Text.Contains("myinfo.get") Then
  91.                 txtItems.AppendText("P:\Console.ph>" & txtCommands.Text & vbNewLine & vbNewLine)
  92.                 Dim myIPaddress As String
  93.                 Dim tmpHostName As String = System.Net.Dns.GetHostName()
  94.                 myIPaddress = System.Net.Dns.GetHostByName(tmpHostName).AddressList(0).ToString()
  95.                 Dim myIPaddress2 As String
  96.                 Dim tmpHostName2 As String = System.Net.Dns.GetHostName()
  97.                 myIPaddress2 = System.Net.Dns.GetHostEntry(tmpHostName2).AddressList(0).ToString()
  98.                 txtItems.AppendText("Your Local IP is: " & myIPaddress & vbNewLine & "Your Public IP is: " & myIPaddress2 & vbNewLine & "Computer Name: " & My.Computer.Name & vbNewLine & vbNewLine)
  99.                 txtCommands.Clear()
  100.                 SendKeys.Send("{BACKSPACE}")
  101.             ElseIf txtCommands.Text.Contains("files.list(programs)") Then
  102.                 txtItems.AppendText("P:\Console.ph>" & txtCommands.Text & vbNewLine & vbNewLine)
  103.                 For Each foundFile As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.SpecialDirectories.ProgramFiles)
  104.                     txtItems.AppendText(foundFile)
  105.                 Next
  106.                 txtCommands.Clear()
  107.                 SendKeys.Send("{BACKSPACE}")
  108.             ElseIf txtCommands.Text.Contains("files.list(desktop)") Then
  109.                 txtItems.AppendText("P:\Console.ph>" & txtCommands.Text & vbNewLine & vbNewLine)
  110.                 For Each foundFile As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.SpecialDirectories.Desktop)
  111.                     txtItems.AppendText(foundFile)
  112.                 Next
  113.                 txtCommands.Clear()
  114.                 SendKeys.Send("{BACKSPACE}")
  115.             ElseIf txtCommands.Text.Contains("say") Then
  116.                 txtItems.AppendText("P:\Console.ph>" & txtCommands.Text & vbNewLine & vbNewLine)
  117.                 Dim sayCom As String
  118.                 sayCom = txtCommands.Text.Replace("say", " ")
  119.                 compspeak = sayCom
  120.                 speak()
  121.                 txtItems.AppendText("Computer:" & sayCom & vbNewLine & vbNewLine)
  122.                 txtCommands.Clear()
  123.                 SendKeys.Send("{BACKSPACE}")
  124.             ElseIf txtCommands.Text.Contains("goTo") Or txtCommands.Text.Contains("goto") Then
  125.                 txtItems.AppendText("P:\Console.ph>" & txtCommands.Text & vbNewLine & vbNewLine)
  126.                 Dim webURL As String
  127.                 webURL = txtCommands.Text.Split(" ")(1)
  128.                 If txtCommands.Text.Contains("http") And webURL <> Nothing Then
  129.                     Process.Start(webURL)
  130.                 Else
  131.                     txtItems.AppendText("Make sure the website is valid and contains 'http://' before the URL" & vbNewLine & vbNewLine)
  132.                 End If
  133.                 txtCommands.Clear()
  134.                 SendKeys.Send("{BACKSPACE}")
  135.             ElseIf txtCommands.Text.Contains("@") Then
  136.                 txtItems.AppendText("P:\Console.ph>" & txtCommands.Text & vbNewLine & vbNewLine)
  137.                 Dim app As String
  138.                 app = txtCommands.Text.Split("@")(1)
  139.                 If app <> Nothing And txtCommands.Text.Contains("@") Then
  140.                     If app.Contains("binary") Then
  141.                         frmBinary.Show()
  142.                         txtItems.AppendText("Launching app BinaryTranslator" & vbNewLine & vbNewLine)
  143.                     ElseIf app.Contains("calculator") Then
  144.                         frmCalculator.Show()
  145.                         txtItems.AppendText("Launching app calculator" & vbNewLine & vbNewLine)
  146.                     ElseIf app.Contains("notes") Then
  147.                         frmWord.Show()
  148.                         txtItems.AppendText("Launching app notes" & vbNewLine & vbNewLine)
  149.                     ElseIf app.Contains("messenger") Then
  150.                         frmMessenger.Show()
  151.                         txtItems.AppendText("Launching app messenger" & vbNewLine & vbNewLine)
  152.                     ElseIf app.Contains("mail") Then
  153.                         frmMail.Show()
  154.                         txtItems.AppendText("Launching app mail" & vbNewLine & vbNewLine)
  155.                     ElseIf app.Contains("gpa") Then
  156.                         frmGPACalculator.Show()
  157.                         txtItems.AppendText("Launching app gpa" & vbNewLine & vbNewLine)
  158.                     ElseIf app.Contains("chat") Then
  159.                         frmChatBot.Show()
  160.                         txtItems.AppendText("Launching app chat bot" & vbNewLine & vbNewLine)
  161.                     ElseIf app.Contains("browser") Then
  162.                         frmBrowser.Show()
  163.                         txtItems.AppendText("Launching app browser" & vbNewLine & vbNewLine)
  164.                     ElseIf app.Contains("finals") Then
  165.                         frmFinals.Show()
  166.                         txtItems.AppendText("Launching app finals calculator" & vbNewLine & vbNewLine)
  167.                     ElseIf app.Contains("watch") Then
  168.                         frmStopWatch.Show()
  169.                         txtItems.AppendText("Launching app stop watch" & vbNewLine & vbNewLine)
  170.                     ElseIf app.Contains("finals") Then
  171.                         frmFinals.Show()
  172.                         txtItems.AppendText("Launching app finals calculator" & vbNewLine & vbNewLine)
  173.                     Else
  174.                         txtItems.AppendText("Syntax: launch@calculator" & vbNewLine & vbNewLine)
  175.                     End If
  176.                     txtCommands.Clear()
  177.                     SendKeys.Send("{BACKSPACE}")
  178.                 End If
  179.             Else
  180.                 txtItems.AppendText("P:\Console.ph>" & txtCommands.Text & vbNewLine & vbNewLine)
  181.                 txtItems.AppendText("'" & txtCommands.Text & "' is not recognized as an internal or external command. Type 'help' to recieve information on commands and their syntax's." & vbNewLine & vbNewLine)
  182.                 txtCommands.Clear()
  183.                 SendKeys.Send("{BACKSPACE}")
  184.             End If
  185.             txtItems.SelectionStart = txtItems.TextLength
  186.             txtItems.ScrollToCaret()
  187.         End If
  188.     End Sub
  189.  
  190.     Private Sub frmConsole_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  191.         btnStart.PerformClick()
  192.         txtCommands.Select()
  193.     End Sub
  194.  
  195.     Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
  196.         Timer1.Interval = packets
  197.         Try
  198.             txtItems.AppendText("Stressing " + inter + " with packet number: ")
  199.             txtItems.AppendText(My.Computer.Info.AvailableVirtualMemory & " (type 'stop' to end process)" & vbNewLine & vbNewLine)
  200.             txtItems.AppendText("")
  201.             Dim udpClient As New UdpClient
  202.             Dim GLOIP As IPAddress
  203.             Dim bytCommand As Byte() = New Byte() {}
  204.             GLOIP = IPAddress.Parse(inter)
  205.             udpClient.Connect(GLOIP, port)
  206.             udpClient.Send(bytCommand, bytCommand.Length)
  207.             txtItems.SelectionStart = txtItems.TextLength
  208.             txtItems.ScrollToCaret()
  209.         Finally
  210.         End Try
  211.     End Sub
  212.  
  213.     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles btnStart.Click
  214.         txtItems.AppendText("Welcome to phOS Developer Console (v2.1)" & vbNewLine)
  215.         txtItems.AppendText("Type 'help' to get started" & vbNewLine)
  216.         txtItems.AppendText("-------------------------------------------------------------" & vbNewLine)
  217.     End Sub
  218.  
  219.     Private Sub txtItems_Click(sender As Object, e As System.EventArgs) Handles txtItems.Click
  220.         txtCommands.Select()
  221.     End Sub
  222.  
  223.     Private Sub frmConsole_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
  224.         If Me.Size.Height >= 602 And Me.Size.Width >= 1026 Then
  225.             txtItems.Font = New Font("Microsoft Sans Serif", 12.5)
  226.         Else
  227.             txtItems.Font = New Font("Microsoft Sans Serif", 9)
  228.         End If
  229.     End Sub
  230. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement