# 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*:

{% code overflow="wrap" %}

```bash
pip3 install uploadserver
```

{% endcode %}

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'
```

{% endcode %}

{% code overflow="wrap" %}

```bash
python3 -m uploadserver 443 --server-certificate <PATH>/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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ivalexev.gitbook.io/rednote/utility/server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
