mkdir prueba cd .\prueba "hola" > hola.txt ForEach($fichero in ls .) { $ficheronuevo = "$fichero.hash" (Get-FileHash $fichero).hash > $ficheronuevo } ForEach($fichero in ls .) { #Cifrar el contenido del fichero $cifrado=gc $fichero $var=1 $textocifrado=(0..($cifrado.Length-1) | % {[char]::ConvertFromUtf32([char]::ConvertToUtf32($cifrado[$_].ToString(),0)-$var)}) -join "" #Cifrar el nombre y añadir el contenido cifrado #Quitamos los puntos y otros caracteres para no tener errores a la hora de crear el nuevo fichero cifrado $ficherosin=$fichero.Name.Replace(".","") $ficherosin $ficherocifrado=(0..($ficherosin.Length-1) | % {[char]::ConvertFromUtf32([char]::ConvertToUtf32($ficherosin[$_].ToString(),0)-$var)}) -join "" $textocifrado | Out-File $ficherocifrado } ForEach($fichero in ls . -File) { if((Get-FileHash $fichero).hash -eq (gc .\hashes\hola.txt.hash)) { "es igual" } else { "es distinto" } }
Ejercicios de seguridad: detectar mediante firmas que un fichero se ha infectado (Seguridad, PowerShell)
Except where otherwise noted, Jesusninoc by Jesús N. is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.