Advertisement
Guest User

Untitled

a guest
Jun 25th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.88 KB | None | 0 0
  1. Imports System.IO
  2. Public Class Form1
  3. Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs)
  4.  
  5. TextBox1.Text = ("")
  6.  
  7.  
  8. End Sub
  9.  
  10. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  11. TextBox2.Text = "'This script is generated in Duckyscript2VBScript © converter"
  12. TextBox2.Text = TextBox2.Text & Environment.NewLine & "set wshshell = wscript.createobject(""wscript.shell"")"
  13. TextBox2.Text = TextBox2.Text & Environment.NewLine & "set objshell = createobject(""shell.application"")"
  14. If File.Exists("data.txt") = True Then
  15. File.Delete("data.txt")
  16. End If
  17.  
  18. ' Get the current lines.
  19. Dim lines() As String = TextBox2.Lines
  20. ' At line 0 Insert the "Hello World" string at position 2
  21.  
  22. ' Reassign the lines property.
  23. TextBox2.Lines = lines
  24. 'loop code in vbs needs to be impleneted in vb.net
  25. 'For i = 1 To 100
  26. 'WshShell.SendKeys("hello world")
  27. 'WshShell.SendKeys("{ENTER}")
  28. 'Next
  29.  
  30.  
  31.  
  32.  
  33. TextBox2.Text = TextBox2.Text & Environment.NewLine & TextBox1.Text
  34.  
  35. TextBox2.Text = TextBox2.Text.Replace("^", "{^}")
  36. TextBox2.Text = TextBox2.Text.Replace("(", "{(}")
  37. TextBox2.Text = TextBox2.Text.Replace(")", "{)}")
  38. TextBox2.Text = TextBox2.Text.Replace("'", "{'}")
  39. TextBox2.Text = TextBox2.Text.Replace("|", "{|}")
  40. TextBox2.Text = TextBox2.Text.Replace("%", "{%}")
  41. TextBox2.Text = TextBox2.Text.Replace("""", """""")
  42. TextBox2.Text = TextBox2.Text.Replace("set wshshell = wscript.createobject{(}""""wscript.shell""""{)}", "set wshshell = wscript.createobject(""wscript.shell"")")
  43. TextBox2.Text = TextBox2.Text.Replace("set objshell = createobject{(}""""shell.application""""{)}", "set objshell = createobject(""shell.application"")")
  44.  
  45. TextBox2.Text = TextBox2.Text.Replace("{'}This script is generated in Duckyscript2VBScript © converter", "'This script is generated in Duckyscript2VBScript © converter")
  46. TextBox2.Text = TextBox2.Text.Replace("STRING ", "WshShell.SendKeys(""") 'The space "string[space]" is needed.
  47. TextBox2.Text = TextBox2.Text.Replace("ENTER", "WshShell.SendKeys(""{ENTER}"")")
  48. TextBox2.Text = TextBox2.Text.Replace("ALT F4", "WshShell.SendKeys(""%{f4}"")")
  49. TextBox2.Text = TextBox2.Text.Replace("WINDOWS m", "objShell.MinimizeAll")
  50. TextBox2.Text = TextBox2.Text.Replace("WINDOWS d", "objShell.MinimizeAll")
  51. 'TextBox2.Text = TextBox2.Text.Replace("REPEAT ", "for i = 1 to ")
  52. TextBox2.Text = TextBox2.Text.Replace("GUI d", "objShell.MinimizeAll")
  53. TextBox2.Text = TextBox2.Text.Replace("GUI m", "objShell.MinimizeAll")
  54. TextBox2.Text = TextBox2.Text.Replace("ALT", "WshShell.SendKeys(""%"")")
  55. TextBox2.Text = TextBox2.Text.Replace("WINDOWS r", "objShell.FileRun")
  56. TextBox2.Text = TextBox2.Text.Replace("GUI r", "objShell.FileRun")
  57. TextBox2.Text = TextBox2.Text.Replace("GUI", "WshShell.SendKeys(""^{Esc}"")")
  58. TextBox2.Text = TextBox2.Text.Replace("WINDOWS", "WshShell.SendKeys(""^{Esc}"")")
  59. TextBox2.Text = TextBox2.Text.Replace("MENU", "WshShell.SendKeys(""{HOME}"")")
  60. TextBox2.Text = TextBox2.Text.Replace("DELAY", "WScript.Sleep")
  61. TextBox2.Text = TextBox2.Text.Replace("UPARROW", "WshShell.SendKeys(""{UP}"")")
  62. TextBox2.Text = TextBox2.Text.Replace("UP", "WshShell.SendKeys(""{UP}"")")
  63. TextBox2.Text = TextBox2.Text.Replace("DOWNARROW", "WshShell.SendKeys(""{DOWN}"")")
  64. TextBox2.Text = TextBox2.Text.Replace("DOWN", "WshShell.SendKeys(""{DOWN}"")")
  65. TextBox2.Text = TextBox2.Text.Replace("LEFTARROW", "WshShell.SendKeys(""LEFT}"")")
  66. TextBox2.Text = TextBox2.Text.Replace("LEFT", "WshShell.SendKeys(""LEFT}"")")
  67. TextBox2.Text = TextBox2.Text.Replace("RIGHTARROW", "WshShell.SendKeys(""{RIGHT}"")")
  68. TextBox2.Text = TextBox2.Text.Replace("RIGHT", "WshShell.SendKeys(""{RIGHT}"")")
  69. TextBox2.Text = TextBox2.Text.Replace("F1", "WshShell.SendKeys(""{F1}}"")")
  70. TextBox2.Text = TextBox2.Text.Replace("F2", "WshShell.SendKeys(""{F2}"")")
  71. TextBox2.Text = TextBox2.Text.Replace("F3", "WshShell.SendKeys(""{F3}"")")
  72. TextBox2.Text = TextBox2.Text.Replace("F4", "WshShell.SendKeys(""{F4}"")")
  73. TextBox2.Text = TextBox2.Text.Replace("F5", "WshShell.SendKeys(""{F5}"")")
  74. TextBox2.Text = TextBox2.Text.Replace("F6", "WshShell.SendKeys(""{F6}"")")
  75. TextBox2.Text = TextBox2.Text.Replace("F7", "WshShell.SendKeys(""{F7}"")")
  76. TextBox2.Text = TextBox2.Text.Replace("F8", "WshShell.SendKeys(""{F8}"")")
  77. TextBox2.Text = TextBox2.Text.Replace("F9", "WshShell.SendKeys(""{F9}"")")
  78. TextBox2.Text = TextBox2.Text.Replace("F10", "WshShell.SendKeys(""{F10}"")")
  79. TextBox2.Text = TextBox2.Text.Replace("F11", "WshShell.SendKeys(""{F11}"")")
  80. TextBox2.Text = TextBox2.Text.Replace("F12", "WshShell.SendKeys(""{F12}"")")
  81. TextBox2.Text = TextBox2.Text.Replace("F13", "WshShell.SendKeys(""{F13}"")")
  82. TextBox2.Text = TextBox2.Text.Replace("F14", "WshShell.SendKeys(""{F14}"")")
  83. TextBox2.Text = TextBox2.Text.Replace("F15", "WshShell.SendKeys(""{F15}"")")
  84. TextBox2.Text = TextBox2.Text.Replace("F16", "WshShell.SendKeys(""{F16}"")")
  85. TextBox2.Text = TextBox2.Text.Replace("ESCAPE", "WshShell.SendKeys(""{ESC}"")")
  86. TextBox2.Text = TextBox2.Text.Replace("ESC", "WshShell.SendKeys(""{ESC}"")")
  87. TextBox2.Text = TextBox2.Text.Replace("REM", "'")
  88. TextBox2.Text = TextBox2.Text.Replace("TAB", "WshShell.SendKeys(""{TAB}"")")
  89. TextBox2.Text = TextBox2.Text.Replace("WshShell.SendKeys(""%{f4}"")", "WshShell.SendKeys(""%{F4}"")")
  90. My.Computer.FileSystem.WriteAllText("data.txt", TextBox2.Text, False)
  91. For Each Line As String In File.ReadLines("data.txt")
  92.  
  93.  
  94. If Line.StartsWith("STRING", StringComparison.InvariantCultureIgnoreCase) Then
  95. Line = "WshShell.SendKeys(""" & Line.Substring(6)
  96. End If
  97.  
  98. Next
  99.  
  100. Dim gines = System.IO.File.ReadAllLines("data.txt")
  101. For i = 0 To gines.Length - 1
  102. If gines(i).StartsWith("REPEAT") Then
  103. MsgBox((i - 1))
  104. TextBox2.Lines(i - 1) = (i + 1)
  105.  
  106.  
  107. End If
  108. Next
  109. System.IO.File.WriteAllLines("data.txt", gines)
  110.  
  111.  
  112.  
  113. 'Dim index As Integer
  114. 'Dim customerName As String = "KEYS.SENDKEYS("" "
  115.  
  116. 'For i As Integer = 1 To TextBox2.Lines.Length - 1
  117. 'If TextBox2.Lines(i - 1).Contains("Customer") Then
  118. 'customerName = TextBox2.Lines(i)
  119. 'Exit For
  120. 'End If
  121. 'Next
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143. TextBox2.Text = ""
  144.  
  145. For Each Line As String In File.ReadLines("data.txt")
  146.  
  147.  
  148. If Line.Contains("(""") Then
  149.  
  150. TextBox2.AppendText(Line & """)" & Environment.NewLine)
  151. Else
  152.  
  153. TextBox2.AppendText(Line & Environment.NewLine)
  154. End If
  155.  
  156. Next
  157.  
  158.  
  159.  
  160.  
  161.  
  162. TextBox2.Text = TextBox2.Text.Replace(""")"")", """)")
  163. TextBox2.Text = TextBox2.Text.Replace(""") "")", """)")
  164. My.Computer.FileSystem.WriteAllText("data.txt", TextBox2.Text, False)
  165.  
  166.  
  167.  
  168. End Sub
  169.  
  170. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  171. TextBox1.Text = "Put your DuckyScript code here."
  172. TextBox2.Text = "set wshshell = wscript.createobject(""wscript.shell"")"
  173. TextBox2.Text = TextBox2.Text & Environment.NewLine & "set objshell = createobject(""shell.application"")"
  174. Timer1.Start()
  175. If File.Exists("data.txt") = True Then
  176. File.Delete("data.txt")
  177. End If
  178.  
  179.  
  180. End Sub
  181.  
  182. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  183. TextBox1.Text = ""
  184. TextBox1.Paste()
  185.  
  186. End Sub
  187.  
  188. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  189. TextBox1.Text = "Put your DuckyScript code here."
  190. TextBox2.Text = "set wshshell = wscript.createobject(""wscript.shell"")"
  191. TextBox2.Text = TextBox2.Text & Environment.NewLine & "set objshell = createobject(""shell.application"")"
  192. Timer1.Start()
  193. If File.Exists("data.txt") = True Then
  194. File.Delete("data.txt")
  195. End If
  196. End Sub
  197.  
  198. Private Sub TextBox1_TextChanged_1(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
  199.  
  200. End Sub
  201.  
  202. Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
  203.  
  204. End Sub
  205.  
  206. Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  207. If TextBox1.Text = ("") = True Then
  208. Button1.Enabled = False
  209. Else
  210. Button1.Enabled = True
  211. End If
  212. If TextBox1.Text = ("Put your DuckyScript code here.") = True Then
  213. Button1.Enabled = False
  214. Else
  215. Button1.Enabled = True
  216. End If
  217. End Sub
  218.  
  219. Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
  220. SaveFileDialog1.InitialDirectory = "C:\"
  221. SaveFileDialog1.Title = "Save vbs Files"
  222. SaveFileDialog1.CheckFileExists = False
  223. SaveFileDialog1.CheckPathExists = True
  224. SaveFileDialog1.DefaultExt = "VBS"
  225. SaveFileDialog1.Filter = "VBS files (*.vbs)|*.vbs"
  226. SaveFileDialog1.FilterIndex = 2
  227. SaveFileDialog1.RestoreDirectory = True
  228. SaveFileDialog1.ShowDialog()
  229.  
  230.  
  231. End Sub
  232.  
  233. Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
  234. MsgBox("People who worked hard on this program: Tim Wanders and Andrio")
  235. End Sub
  236.  
  237. Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
  238.  
  239. End Sub
  240.  
  241. Private Sub SaveFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk
  242. Dim ANSIString() As Byte, MyEncoder As New System.Text.ASCIIEncoding()
  243. Dim fFile As IO.File, fStream As IO.FileStream
  244. Dim sSourceString As String = TextBox2.Text
  245. Dim sFilename As String = SaveFileDialog1.FileName
  246. ANSIString = MyEncoder.Convert(System.Text.Encoding.UTF8, System.Text.Encoding.ASCII, MyEncoder.GetBytes(sSourceString))
  247.  
  248. Try
  249.  
  250.  
  251. If fFile.Exists(sFilename) Then
  252. fFile.SetAttributes(sFilename, IO.FileAttributes.Normal)
  253. fFile.Delete(sFilename)
  254. End If
  255.  
  256. fStream = fFile.OpenWrite(sFilename)
  257. fStream.Write(ANSIString, 0, ANSIString.Length)
  258. fStream.Close()
  259.  
  260. Catch myException As Exception
  261.  
  262. MessageBox.Show(myException.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  263. End Try
  264. End Sub
  265. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement