Advertisement
Thunder-Menu

Themida_(un)Protect.ps1

Apr 7th, 2023
1,067
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 4.80 KB | Source Code | 0 0
  1. # Récupération du chemin vers le dossier contenant le script
  2. $scriptPath = Split-Path $MyInvocation.MyCommand.Path
  3.  
  4. # Vérification des droits administrateur
  5. $isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
  6. if (-not $isAdmin) {
  7.     # Redémarrage du script en mode administrateur
  8.     Start-Process powershell.exe -Verb RunAs -ArgumentList "-File `"$($MyInvocation.MyCommand.Path)`""
  9.  
  10.     # Sortie du script actuel
  11.     exit
  12. }
  13.  
  14. # Récupération du chemin vers Themida en fonction de l'architecture
  15. $themidaPath = if ([IntPtr]::Size -eq 8) {
  16.     Join-Path $scriptPath "themida64.exe"
  17. } else {
  18.     Join-Path $scriptPath "themida.exe"
  19. }
  20.  
  21. # Fonction de protection
  22. function Protect-File {
  23.     param (
  24.         [Parameter(Mandatory=$true, Position=0)]
  25.         [string]$filePath
  26.     )
  27.  
  28.     # Protection du fichier avec Themida
  29.     & $themidaPath /protect $filePath
  30.  
  31.     # Renommage du fichier avec l'extension .thunder
  32.     $newFilePath = Join-Path (Split-Path $filePath) "$([IO.Path]::GetFileNameWithoutExtension($filePath)).thunder"
  33.     Rename-Item -Path $filePath -NewName $newFilePath -Force
  34.  
  35.     Write-Host "Fichier protégé avec succès : $newFilePath"
  36. }
  37.  
  38. # Fonction de déprotection
  39. function Unprotect-File {
  40.     param (
  41.         [Parameter(Mandatory=$true, Position=0)]
  42.         [string]$filePath
  43.     )
  44.  
  45.     # Déprotection du fichier avec Themida
  46.     & $themidaPath /unprotect $filePath
  47.  
  48.     # Renommage du fichier sans l'extension .thunder
  49.     $newFilePath = Join-Path (Split-Path $filePath) "$([IO.Path]::GetFileNameWithoutExtension($filePath) -replace '\.thunder$')"
  50.     Rename-Item -Path $filePath -NewName $newFilePath -Force
  51.  
  52.     Write-Host "Fichier déprotégé avec succès : $newFilePath"
  53. }
  54.  
  55. # Création de la fenêtre principale
  56. Add-Type -AssemblyName System.Windows.Forms
  57. $form = New-Object System.Windows.Forms.Form
  58. $form.Text = "Protection de fichiers avec Themida"
  59. $form.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedSingle
  60. $form.MaximizeBox = $false
  61. $form.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterScreen
  62.  
  63. # Création du ComboBox pour le choix de l'action
  64. $actionComboBox = New-Object System.Windows.Forms.ComboBox
  65. $actionComboBox.Items.Add("Protéger")
  66. $actionComboBox.Items.Add("Déprotéger")
  67. $actionComboBox.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
  68. $actionComboBox.Location = New-Object System.Drawing.Point(10, 10)
  69. $actionComboBox.Size = New-Object System.Drawing.Size(150, 20)
  70. $form.Controls.Add($actionComboBox)
  71.  
  72. # Création du ComboBox pour le choix de la configuration
  73. $configComboBox = New-Object System.Windows.Forms.ComboBox
  74. $configComboBox.Items.Add("Forte")
  75. $configComboBox.Items.Add("Moyenne")
  76. $configComboBox.Items.Add("Faible")
  77. $configComboBox.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
  78. $configComboBox.Location = New-Object System.Drawing.Point(170, 10)
  79. $configComboBox.Size = New-Object System.Drawing.Size(100, 20)
  80. $form.Controls.Add($configComboBox)
  81.  
  82. # Création du bouton pour sélectionner le fichier
  83. $fileButton = New-Object System.Windows.Forms.Button
  84. $fileButton.Text = "Sélectionner un fichier"
  85. $fileButton.Location = New-Object System.Drawing.Point(10, 40)
  86. $fileButton.Size = New-Object System.Drawing.Size(260, 23)
  87. $fileButton.Add_Click({
  88.     $openFileDialog = New-Object System.Windows.Forms.OpenFileDialog
  89.     $openFileDialog.Filter = "All files (*.*)|*.*"
  90.     $openFileDialog.Multiselect = $false
  91.     $openFileDialog.InitialDirectory = [Environment]::GetFolderPath("Desktop")
  92.  
  93.     if ($openFileDialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {
  94.         $filePathTextBox.Text = $openFileDialog.FileName
  95.     }
  96. })
  97. $form.Controls.Add($fileButton)
  98.  
  99.  
  100. #Création de la zone de texte pour afficher le chemin du fichier
  101. $filePathTextBox = New-Object System.Windows.Forms.TextBox
  102. $filePathTextBox.Location = New-Object System.Drawing.Point(10, 70)
  103. $filePathTextBox.Size = New-Object System.Drawing.Size(260, 20)
  104. $filePathTextBox.ReadOnly = $true
  105. $form.Controls.Add($filePathTextBox)
  106.  
  107. #Création du bouton pour lancer l'action
  108. $actionButton = New-Object System.Windows.Forms.Button
  109. $actionButton.Text = "Lancer l'action"
  110. $actionButton.Location = New-Object System.Drawing.Point(10, 100)
  111. $actionButton.Size = New-Object System.Drawing.Size(260, 23)
  112. $actionButton.Add_Click({
  113. if ($actionComboBox.SelectedItem -eq "Protéger") {
  114. Protect-File -filePath $filePathTextBox.Text
  115. } elseif ($actionComboBox.SelectedItem -eq "Déprotéger") {
  116. Unprotect-File -filePath $filePathTextBox.Text
  117. } else {
  118. Write-Host "Action inconnue : $($actionComboBox.SelectedItem)"
  119. }
  120. })
  121. $form.Controls.Add($actionButton)
  122.  
  123. # Affichage de la fenêtre
  124. $form.ShowDialog()
  125.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement