# Server

## Public to the World

{% tabs %}
{% tab title="ngrok" %}
{% code overflow="wrap" %}
```bash
ngrok http <PORT>
```
{% endcode %}

{% code overflow="wrap" %}
```bash
ngrok tcp <PORT>
```
{% endcode %}

With tcp I can use the IP (`nslookup`).
{% endtab %}

{% tab title="serveo" %}
{% code overflow="wrap" %}
```bash
ssh -R 80:localhost:<PORT> serveo.net
```
{% endcode %}
{% endtab %}
{% endtabs %}

## Python

{% tabs %}
{% tab title="Python2" %}
{% code overflow="wrap" %}
```bash
python -m SimpleHTTPServer <PORT>
```
{% endcode %}
{% endtab %}

{% tab title="Python3" %}
{% code overflow="wrap" %}
```bash
python3 -m http.server <PORT>
```
{% endcode %}
{% endtab %}

{% tab title="Python3 with Upload Options" %}
Download _uploadserver_:

<pre class="language-bash" data-overflow="wrap"><code class="lang-bash"><strong>pip3 install uploadserver
</strong></code></pre>

Run:

{% code overflow="wrap" %}
```bash
python3 -m uploadserver
```
{% endcode %}

Create self-signed certificate:

{% code overflow="wrap" %}
```bash
mkdir https && cd https
openssl req -x509 -out server.pem -keyout server.pem -newkey rsa:2048 -nodes -sha256 -subj '/CN=server'
python3 -m uploadserver 443 --server-certificate ./server.pem
```
{% endcode %}
{% endtab %}
{% endtabs %}

## SMB

{% tabs %}
{% tab title="impacket-smbserver" %}
[Download impacket-smbserver](https://github.com/fortra/impacket/blob/master/examples/smbserver.py).

{% code overflow="wrap" %}
```bash
impacket-smbserver -smb2support <NAME_SHARE> <PATH>
```
{% endcode %}

You can add authentication with:

{% code overflow="wrap" %}
```bash
-user <USER> -password <PASS>
```
{% endcode %}
{% endtab %}

{% tab title="Note" %}
You can access it in Windows with:

{% code overflow="wrap" %}
```powershell
\\<OUR_IP>\<NAME_SHARE>\<FILE>
```
{% endcode %}

{% code overflow="wrap" %}
```powershell
move <FILE_IN_WINDOWS> \\<OUR_IP>\<NAME_SHARE>
```
{% endcode %}
{% endtab %}
{% endtabs %}

## FTP

Allows anonymous authentication by default.

{% tabs %}
{% tab title="twisted" %}
Download _twisted_:

<pre class="language-bash" data-overflow="wrap"><code class="lang-bash"><strong>sudo pip3 install twisted
</strong></code></pre>

Run:

{% code overflow="wrap" %}
```bash
sudo python3 -m twisted ftp -p 21 -r .
```
{% endcode %}
{% endtab %}

{% tab title="pyftpdlib" %}
Download _pyftpdlib_:

<pre class="language-bash" data-overflow="wrap"><code class="lang-bash"><strong>sudo pip3 install pyftpdlib
</strong></code></pre>

Run:

{% code overflow="wrap" %}
```bash
sudo python3 -m pyftpdlib --port 21 [--write]
```
{% endcode %}
{% endtab %}

{% tab title="Note" %}
{% code overflow="wrap" %}
```
ftp://<IP>/
```
{% endcode %}

{% code overflow="wrap" %}
```
ftp://<USER>:<PASS>@<IP>/
```
{% endcode %}
{% endtab %}
{% endtabs %}

## PHP

{% code overflow="wrap" %}
```bash
sudo php -S 0.0.0.0:<PORT>
```
{% endcode %}

File `index.php` is the default.

## Ruby

{% code overflow="wrap" %}
```bash
ruby -run -ehttpd . -p<PORT>
```
{% endcode %}

## npm

Via Node Package Manager, the package manager for JavaScript Node.js

{% code overflow="wrap" %}
```bash
npm install http-server -g
```
{% endcode %}

Run:

{% code overflow="wrap" %}
```bash
http-server -p <PORT>
```
{% endcode %}

## WebDAV

Download:

{% code overflow="wrap" %}
```bash
sudo pip3 install wsgidav cheroot
```
{% endcode %}

Run:

{% code overflow="wrap" %}
```bash
sudo wsgidav --host=0.0.0.0 --port=80 --root=<PATH> --auth=anonymous
```
{% endcode %}

Supporting collaborative content creation.
