(Get-Item malware.pdf.js).Attributes += 'Hidden' - ukryj plik lub katalog w Windowsie
Z wykorzystaniem cmdletu Get-Item możemy pobrać plik, by następnie uzyskać dostęp do jego atrybutów - właściwość Attributes. Atrybuty możemy dodać z wykorzystaniem operatora += co oznacza, że do aktualnych atrybutów dodajemy nowy. Odwrotnością tego będzie operator -+. Atrybut Hidden spowoduje, że plik będzie ukryty. Jeśli plik jest ukryty, do takich cmdletów jak Get-ChildItem czy Get-Item należy dodać parametr -Force.
Ciekawym atrybutem jest również System, co może czasem zmylić antywirusy i inne takie (lub wprost przeciwnie). Warto poeksperymentować.
W ten sposób możemy nie tylko schować malware, ale i ukryć na współdzielonym komputerem przed żoną/mężem faktury zakupowe związane z naszym hobby. 🤪
Niegłupim pomysłem jest zobaczenie w akcji mniej więcej tak wyglądających poleceń. Naturalnie, aliasem na Get-Item jest gi.
(Get-Item malware.pdf.js).Attributes += "Hidden"
(Get-Item -Force malware.pdf.js).Attributes -= "Hidden"
(Get-Item -Force malware.pdf.js).Attributes += "Hidden,System"
(gi -fo malware.pdf.js).Attributes = ""
(gi -fo malware.pdf.js).Attributes
A jakie jeszcze są dostępne właściwośći plików i katalogów? Get-Member #FTW:
PS C:\Users\drg> (Get-Item .\Desktop\malware.pdf.js,.\Desktop) | gm -MemberType Property
TypeName: System.IO.FileInfo
Name MemberType Definition
---- ---------- ----------
Attributes Property System.IO.FileAttributes Attributes {get;set;}
CreationTime Property datetime CreationTime {get;set;}
CreationTimeUtc Property datetime CreationTimeUtc {get;set;}
Directory Property System.IO.DirectoryInfo Directory {get;}
DirectoryName Property string DirectoryName {get;}
Exists Property bool Exists {get;}
Extension Property string Extension {get;}
FullName Property string FullName {get;}
IsReadOnly Property bool IsReadOnly {get;set;}
LastAccessTime Property datetime LastAccessTime {get;set;}
LastAccessTimeUtc Property datetime LastAccessTimeUtc {get;set;}
LastWriteTime Property datetime LastWriteTime {get;set;}
LastWriteTimeUtc Property datetime LastWriteTimeUtc {get;set;}
Length Property long Length {get;}
LinkTarget Property string LinkTarget {get;}
Name Property string Name {get;}
UnixFileMode Property System.IO.UnixFileMode UnixFileMode {get;set;}
TypeName: System.IO.DirectoryInfo
Name MemberType Definition
---- ---------- ----------
Attributes Property System.IO.FileAttributes Attributes {get;set;}
CreationTime Property datetime CreationTime {get;set;}
CreationTimeUtc Property datetime CreationTimeUtc {get;set;}
Exists Property bool Exists {get;}
Extension Property string Extension {get;}
FullName Property string FullName {get;}
LastAccessTime Property datetime LastAccessTime {get;set;}
LastAccessTimeUtc Property datetime LastAccessTimeUtc {get;set;}
LastWriteTime Property datetime LastWriteTime {get;set;}
LastWriteTimeUtc Property datetime LastWriteTimeUtc {get;set;}
LinkTarget Property string LinkTarget {get;}
Name Property string Name {get;}
Parent Property System.IO.DirectoryInfo Parent {get;}
Root Property System.IO.DirectoryInfo Root {get;}
UnixFileMode Property System.IO.UnixFileMode UnixFileMode {get;set;}
PS C:\Users\drg>
.