Ana içeriğe geç

local.txt / proof.txt — Linux, PowerShell ve CMD

V2 kaynak aktarımı: Eski GitBook sayfasından birebir açıklama ve komut aktarımı. Eski kaynak ve notlar korunur. Gerçek sistem/araç sürümünde ayrıca test gereklidir.

OSCP'de shell aldıktan sonra flag dosyasını bulmak için üç ortamda kullanacağın kısa komutlar. Önce tipik kullanıcı dizinlerini ara; bulamazsan aramayı diske yay.

İlk shell'in kimlik ve IP bağlamını birlikte kaydet

# HEDEF LINUX
id; whoami; hostname; ip -br addr

Bu çıktı eriştiğin host ve user için snapshot'tır. Linux root için gerçek UID/EUID; Windows için elevated token ve SYSTEM ayrımı; domain için replication hakları ayrıca doğrulanır. Daha sonra local.txt/proof.txt dosyasını ilgili host için ara.

1. Linux shell — find

Önce /home:

find /home -type f -name 'local.txt' 2>/dev/null
find /home -type f -name 'proof.txt' 2>/dev/null

Tüm dosya sistemi (daha uzun sürebilir):

find / -type f -name 'local.txt' 2>/dev/null
find / -type f -name 'proof.txt' 2>/dev/null

İki dosyayı tek seferde ara:

find / -type f \( -name 'local.txt' -o -name 'proof.txt' \) 2>/dev/null

Bulunan dosyayı oku:

cat /home/<USER>/local.txt
cat /root/proof.txt

2>/dev/null erişim hatalarını gizler. Dosya bulunmaması dosyanın hiç olmadığı anlamına gelmeyebilir; izin engeli olabilir.

2. Windows PowerShell / Evil-WinRM

Önce Desktop klasörlerinde:

Get-ChildItem C:\Users\*\Desktop\local.txt -ErrorAction SilentlyContinue
Get-ChildItem C:\Users\*\Desktop\proof.txt -ErrorAction SilentlyContinue

Tüm kullanıcı profillerinde recursive arama:

Get-ChildItem C:\Users -Filter local.txt -File -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName
Get-ChildItem C:\Users -Filter proof.txt -File -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName

Tüm C: diski (gerekirse):

Get-ChildItem C:\ -Filter local.txt -File -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName

Bulunan dosyayı oku:

Get-Content 'C:\Users\<USER>\Desktop\local.txt'
type 'C:\Users\Administrator\Desktop\proof.txt'

-ErrorAction SilentlyContinue, erişim izni olmayan dizinlerde hata mesajlarını gizler.

3. Windows CMD — where /r

Önce C:\Users altında:

where /r C:\Users local.txt 2>nul
where /r C:\Users proof.txt 2>nul

Tüm C: diskinde:

where /r C:\ local.txt 2>nul
where /r C:\ proof.txt 2>nul

Alternatif: dir /s /b

cd /d C:\Users
dir /s /b local.txt 2>nul
dir /s /b proof.txt 2>nul

Bulunan dosyayı oku:

type "C:\Users\<USER>\Desktop\local.txt"
type "C:\Users\Administrator\Desktop\proof.txt"

2>nul, CMD'deki hata mesajlarını bastırır.

Sınavda hatırla

Ortam Arama aracı İçeriği okuma
Linux find /home -name 'local.txt' 2>/dev/null cat <DOSYA_YOLU>
PowerShell / Evil-WinRM Get-ChildItem C:\Users -Filter local.txt -Recurse -File -EA SilentlyContinue Get-Content '<DOSYA_YOLU>'
CMD where /r C:\Users local.txt 2>nul type "<DOSYA_YOLU>"

Konumlar örnektir: Linux'ta /home/<USER>/local.txt ve /root/proof.txt; Windows'ta C:\Users\<USER>\Desktop\local.txt ve C:\Users\Administrator\Desktop\proof.txt sık görülür. Flag konumu ve okuma izni makineye göre değişebilir. Gerçek dosyayı bulmadan yolu varsayma.

Kaynaklar: find(1) · PowerShell Get-ChildItem · Windows where