Skip to main content

IpServer

CI - Test CI - Test CI - Test PyPI - Status License - MIT Newest PyPI version Number of PyPI downloads GitHub code size in bytes Supported Versions

"IpServer" is a simple server that supports TCP, UDP, SSL, HTTP, and HTTPS protocols for various uses such as testing, debugging, or network investigation. It features also an interactive mode and forwarding capabilities. Additionally, you can customize its behavior using Python.

Installation

PyPI

$ pip install ipserver
or
$ pip3 install ipserver
$ ipserver --help

Conda

$ conda install conda-forge::ipserver

Requirements

  • python and pip command
  • Python 3.6 or later version.

Documentation site

https://deerhnt.github.io/ipserver/

Features

  • Simple TCP / UDP server.
  • Support SSL connection. SSL server.
  • HTTP / HTTPS server.
  • IP restriction - Allow / Deny.
  • Interactive sending.
  • TCP Forwarding. Bypassing the data transmission is available.
  • Display received data or sent data in various format(TEXT, BINARY, BASE64, HEX...).
  • HTTP -> FILE: Viewing file and directory and uploading file.
  • HTTP -> FORWARDING: Forwarding HTTP transmission. e.g. HTTP <-> HTTPS
  • HTTP -> APP: Running python application. And running CGI via python.
  • HTTP -> INFO: Show request headers from client.
  • Support HTTP digest authentication.
  • Logging / Debug log.
  • Dump transmission data to file.
  • Configure by JSON file.
  • Customize by Python code. e.g. You can convert transmission data or develop original protocol server.

Running example

$ ipserver --mode=HTTP
Mode:             HTTP
Bind:             0.0.0.0
Port:             8000
HTTP opt:         FILE
Input:            TEXT
Output:           NONE
Output target:    RECEIVE
Timeout:          30.0
Max connections:   20
Dumpfile:         -

[Command help]
send:             Begin input to send. Send by a Line-break. The shortcut is `s`.
bulk:             Begin bulk input to send. Send by Ctrl-key. The shortcut is `b`.
"1,2,3,..":       Switch the connection.
current:          Show current connection.
latest:           Switch latest connection.
list:             List the connections.
close:            Close current connection.
refresh:          Refresh connections.
exit:             Exit.
help:             Show help.

:
[1] Accepted from 192.168.10.1:52322

[1] Closed from 192.168.10.1:52322

[2] Accepted from 192.168.10.1:52329

[2] Receive 600 bytes from 192.168.10.1:52329

[2] Send 421 bytes to 192.168.10.1:52329

[3] Accepted from 192.168.10.1:52330

Description of Mode

TCP Server

Simple server

$ ipserver --port=8002
$ ipserver --mode=TCP --bind=127.0.0.1
$ ipserver --timeout=120

$ ipserver --info
$ ipserver --debug
$ ipserver --port=8002 --log=app.log

$ ipserver --quiet
# TEST
# telnet localhost 8000
# telnet localhost 8002

SSL server

$ ipserver --port=8443 --mode=SSL
$ ipserver --port=8443 --mode=SSL --ssl_context=TLS1.1
$ ipserver --port=8443 --mode=SSL --ssl_keypath=/home/foo/sslkeys/
# TEST
$ openssl s_client -connect 192.168.1.100:8443

IP restriction

$ ipserver --restrict_allow=192.168.2.10
$ ipserver --restrict_allow="192.168.2.10;192.168.10.0/24"

$ ipserver --restrict_deny=192.168.10.101
$ ipserver --restrict_deny="192.168.10.101;192.168.50.0/24"

Dump file

$ ipserver --port=8002 --dumpfile=1
$ ipserver --port=8002 --dumpfile=logs

TCP Forwarding

  • 80 Port Forwarding : HTTP
$ ipserver --forwarding=wikipedia.org --port=8001 # port: 80
$ ipserver --mode=SSL --forwarding=tcp://wikipedia.org:80 --port=8443
$ ipserver --forwarding=tcp://wikipedia.org:80 --timeout=-1
  • 443 Port Forwarding : HTTPS
$ ipserver --forwarding=ssl://wikipedia.org:443 # Listen: 8000 port
$ ipserver --forwarding=wikipedia.org:443 --port=8443 --dumpfile=1
  • 22 Port Forwarding : SSH
$ ipserver --forwarding=tcp://your-host:22 --timeout=-1 --port=8022
  • 3306 Port Forwarding : MySQL
$ ipserver --forwarding=tcp://your-db-host:3306 --timeout=-1 --port=13306

Test

# TEST
$ openssl s_client -connect 192.168.1.100:8443

$ curl https://localhost/path -v

Please see the following about "HTTP Forwarding".

HTTP/HTTPS

View File and directory

$ ipserver --mode=HTTP
$ ipserver --mode=HTTP --http_opt=FILE
$ ipserver --mode=HTTP --http_opt=FILE --http_path="../"

$ ipserver --port=8443 --mode=HTTPS
$ ipserver --port=8443 --mode=HTTPS --http_path="../"

# Shortcut
$ ipserver --http_file=1
$ ipserver --http_file="../"

Enable file upload

$ ipserver --mode=HTTP --http_opt=FILE --enable_file_upload=1
$ ipserver --mode=HTTPS --http_path="../" --enable_file_upload=2

# Shortcut
$ ipserver --http_file_upload=1
$ ipserver --http_file_upload="../"

Application

$ ipserver --mode=HTTP --http_opt=APP
$ ipserver --mode=HTTPS --http_opt=APP --http_path="../"

# Shortcut
$ ipserver --http_app=1
$ ipserver --http_app="./app/"

Display info

$ ipserver --mode=HTTP --http_opt=INFO

HTTP Forwarding

$ ipserver --mode=HTTP --http_opt=FORWARDING --forwarding="https://www.reddit.com/"

# Shortcut
$ ipserver --http_forwarding="https://www.reddit.com/"
$ ipserver --mode=HTTPS --http_forwarding="https://www.wikipedia.org/"

HTTP/HTTPS test

You can test by web-browser or command.

# Commands
$ curl http://localhost/test.py

$ curl https://localhost:8443 -k -v

HTTP Digest authentication

$ ipserver --mode=HTTP --http_digest_auth="admin:123456"
$ ipserver --mode=HTTP --http_digest_auth="admin:d71fa85bc0ded05215b28dfd8ca14112" --http_file_upload=1

$ ipserver --port=8001 --http_app="./app/" --http_digest_auth=".htdigest"
$ ipserver --port=8443 --mode=HTTPS --http_app="./app/" --http_digest_auth=".htdigest"

Mixed options

You can investigate the detailed behavior of HTTP/HTTPS by mixed options.

HTTP file-upload + IP restriction

$ ipserver --http_file_upload="../" --restrict_allow="192.168.2.10;192.168.10.0/24"

HTTP application + Digest auth

$ ipserver --http_app="./app/" --http_digest_auth="admin:123456"

HTTPS + Output Send/Receive data

$ ipserver --mode=HTTPS --output_target=ALL --output=BINARY

HTTPS + Dumpfile

$ ipserver --mode=HTTPS --http_opt=INFO --dumpfile=1

Description of Interactive command

:help
[Command help]
send:         Begin input to send. Send by a Line-break. The shortcut is `s`.
bulk:         Begin bulk input to send. Send by Ctrl-key. The shortcut is `b`.
"1,2,3,..":   Switch the connection.
current:      Show current connection.
latest:       Switch latest connection.
list:         List the connections.
close:        Close current connection.
refresh:      Refresh connections.
exit:         Exit.
help:         Show help.

Examples

:s
[1] Switched automatically.
Please input data to send...

Hello world!

[1] Sent to 127.0.0.1:45528

--
:2
[2] Switched.

--
:list
[1] 192.168.10.1:54721
[2] 192.168.10.1:54722

--
:latest
[2] Switched automatically.

--
:current

[2] Switched automatically.
ID: 2
Client IP: 192.168.10.1
Client port: 54722

--
:close
[2] Switched automatically.
[2] The connection is closed.

Command options

ipserver have many options. Please read Command arguments(.md) reference.

usage: ipserver [-h] [--verbose {0,1,2,3}] [--debug] [--info]
                   [--log {string}] [--quiet] [--conf]
                   [--mode {TCP,UDP,SSL,HTTP,HTTPS}]
                   [--input {TEXT,BINARY,HEX,BASE64}]
                   [--output {NONE,TEXT,BINARY,HEX,BASE64}]
                   [--output_target {ALL,SEND,RECEIVE}] [--output_max]
                   [--dumpfile {string}] [--bind {string}] [--port {int}]
                   [--timeout {float}] [--max_connections {int}]
                   [--restrict_allow {string}] [--restrict_deny {string}]
                   [--ssl_context {SSLV3,TLS1.0,TLS1.1,TLS1.2,TLS1.3}]
                   [--ssl_keypath {string}] [--ssl_certfile {string}]
                   [--ssl_keyfile {string}] [--forwarding {string}]
                   [--http_opt {INTERACTIVE,FILE,PASS,APP,INFO,FORWARDING}]
                   [--http_path {string}] [--http_forwarding_convert_host]
                   [--http_digest_auth {string}] [--enable_file_upload {int}]
                   [--http_app {string}] [--http_file {string}]
                   [--http_file_upload {string}] [--http_forwarding {string}]
                   [--version]

Customize examples

IpServer is extensible program. There are some examples in here.

# HTTP customize response.
$ python3 http_response_customize.py --info 

# HTTP forwarding, Change request header. Set random Accept-Language.
$ python3 http_forwarding_change_header.py --port=8000

# The forwarding protocol is SSL, however the listening protocol is not SSL.
$ python3 tcp_forwarding_ssl_protocol.py --port=8000

--
http://develop-server:8000/

Path summary

Directory Description
.github GitHub Actions files
docs Documentation files
examples Customizing program examples
examples/public-sample Sample public files
ipserver Main package/Sources
tests Test files

Documents

The following documents exist in ipserver. You can read documents in Documentation site.

Title Path
Command arguments command_arguments.md
Customizing and Examples customize_examples.md
Development and Architecture development_architecture.md
IpServer's Major Modules and Classes github.io / Modules and Classes reference

Debugging

In verbose mode, outputting internal data and behaviors in detail.

$ ipserver ***** --verbose=2    #INFO
$ ipserver ***** --verbose=3    #DEBUG

$ ipserver ***** --info     #INFO  This option is equivalent to "--verbose=2"

$ ipserver ***** --debug     #DEBUG  This option is equivalent to "--verbose=3"

Dependencies

Metadata

Release files for ipserver 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ipserver 1.0.2
File Size Uploaded Provenance Actions
ipserver-1.0.2.tar.gz 40.5 kB Without provenance Details for ipserver-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ipserver 1.0.2
File Interpreter ABI Platform Actions
ipserver-1.0.2-py3-none-any.whl Python 3 none any Details for ipserver-1.0.2-py3-none-any.whl

Total release size: 83.6 kB

Release files / ipserver-1.0.2.tar.gz

Download URL ipserver-1.0.2.tar.gz
Size 40.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7c13532fd49c5a6980c6584f2ef84a32382144a33fa383d328c077d66bb6fd7f
BLAKE2b-256 checksum
How to use checksums
99ac3df8732e48b7bd2c1d80f39f883916e1a8bf3dd8d5e4d0b3cd33437fee4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / ipserver-1.0.2-py3-none-any.whl

Download URL ipserver-1.0.2-py3-none-any.whl
Size 43.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b9d36eea27f24ecdc94532df6605a56364b72f78524ed5475b8e1381347f742
BLAKE2b-256 checksum
How to use checksums
27ba4df058bc17c42242d4c51c9a6adee644fe352b67d40166a58af92f6e858c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for ipserver 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page