Downloading Files
Python
Python is a popular programming language. Currently, version 3 is supported, but we may find servers where Python version 2.7 still exists. Python
can run one-liners from an operating system command line using the option -c
. Let's see some examples:
Python 2 - Download
Python 3 - Download
PHP File Transfers
Did you know PHP powers over 77% of websites with a known server-side language? π€― So when youβre doing offensive security, expect to see PHP a lot β and it has some very handy tricks for transferring files. βοΈ
Letβs dive into 3 solid ways to download files using PHP β from saving to disk to fileless piping into bash
!
PHP Download and save a file locally:
This is the quick and dirty one-liner
π This does:
Fetches the remote file using
file_get_contents()
πSaves it as
LinEnum.sh
usingfile_put_contents()
πΎ
PHP Download Using fopen()
+ Buffer Read
fopen()
+ Buffer ReadWant more control or need to download large files? Use fopen()
with a buffer:
β Benefits:
Handles large files better
Allows buffered downloads (less memory, smoother transfers) π§
Fileless PHP Execution
Just like with curl
or wget
, PHP can download and pipe code directly into bash
:
π This will:
Download the file line-by-line with
file()
Echo the contents to stdout
Pipe it straight to
bash
for execution π
No files saved = stealthier ops π΅οΈββοΈ
Ruby β Download a File
π Whatβs happening?
require "net/http"
: loads Rubyβs HTTP client π‘Net::HTTP.get(...)
: fetches the file πFile.write(...)
: saves it locally asLinEnum.sh
πΎ
Super clean and easy for Ruby fans!
Perl β Download
π Whatβs going on?
use LWP::Simple
: loads Perlβs web request module π‘getstore(...)
: grabs the file and saves it locally π½
Absolutely! Here's your JavaScript-based file download guide, rewritten in a fun, clear, and engaging format β perfect for anyone exploring Windows scripting tricks! π»π¦π―
JavaScript for File Downloads on Windows
πΎ The Plan: Download a File Using JavaScript + cscript.exe
cscript.exe
Weβll create a tiny JavaScript file that:
Opens a web request π
Fetches a remote file π¦
Saves it to disk π½
π Step 1: Create wget.js
wget.js
Create a file named wget.js
and paste this code inside:
π This script:
Uses
WinHttpRequest
to download the fileStreams the binary data using
ADODB.Stream
Saves the result to the specified local file
βοΈ Step 2: Execute with cscript.exe
cscript.exe
Run the script with:
π Breakdown:
/nologo
: hides the banner clutter π§Ήwget.js
: your scriptFirst argument: URL to download
Second argument: Local filename to save as
π Result: The PowerView.ps1
script is downloaded and saved right in your current directory!
VBScript File Downloads on Windows
VBScript (Visual Basic Scripting Edition) is an old-school but still useful scripting language baked into Windows since the days of Windows 98! πΎ
And guess what? You can use it to download files from the internet β no external tools required! Perfect for Red Teaming, CTFs, or locked-down environments. π΅οΈββοΈπ
Step 1: Create wget.vbs
wget.vbs
Open Notepad (or any text editor) and paste this code:
π What's happening:
Microsoft.XMLHTTP
β sends the GET request πAdodb.Stream
β handles the binary file stream πΎArguments = URL to download + local file to save as
Step 2: Run It with cscript.exe
cscript.exe
Open Command Prompt or PowerShell, then run:
π What it does:
Downloads the
PowerView.ps1
script from GitHubSaves it as
PowerView2.ps1
in the current folder
β
No PowerShell
, curl
, or bitsadmin
needed!
π‘ Bonus Tip
If HTTPS fails (older systems), you can host your files on a local web server using HTTP (e.g., Python http.server
), then fetch using VBScript like this:
Last updated