Package: ouija
Python relay/proxy server and library to build reliable encrypted TCP/UDP tunnels with entropy control for TCP trafficFeaturesEasy to install, configure and useTCP/UDP tunnelingPluggable traffic ciphersPluggable traffic entropy controlHides TCP traffic in encrypted TCP/UDP tunnel between relay and proxy serversRequirementsPython 3.11pbjson 1.18.0cryptography 41.0.2numpy 1.25.2Installpython3.11-mvenv.envsource.env/bin/activatepipinstallouijaUsageGenerate cipher_key/token secrets:ouija_secretRun relay/proxy server:ouija<config.json>tcp-relay.json - TCP relay server - HTTP/HTTPS proxy server interface with TCP connectors:{"protocol":"TCP","mode":"RELAY","debug":true,"monitor":true,"relay_host":"127.0.0.1","relay_port":9000,"proxy_host":"127.0.0.1","proxy_port":50000,"cipher_key":"bdDmN4VexpDvTrs6gw8xTzaFvIBobFg1Cx2McFB1RmI=","entropy_rate":5,"token":"395f249c-343a-4f92-9129-68c6d83b5f55","serving_timeout":20.0,"tcp_buffer":1024,"tcp_timeout":1.0,"message_timeout":5.0}tcp-proxy.json - TCP-relayed proxy server:{"protocol":"TCP","mode":"PROXY","debug":true,"monitor":true,"proxy_host":"0.0.0.0","proxy_port":50000,"cipher_key":"bdDmN4VexpDvTrs6gw8xTzaFvIBobFg1Cx2McFB1RmI=","entropy_rate":5,"token":"395f249c-343a-4f92-9129-68c6d83b5f55","serving_timeout":20.0,"tcp_buffer":1024,"tcp_timeout":1.0,"message_timeout":5.0}udp-relay.json - UDP relay server - HTTP/HTTPS proxy server interface with UDP connectors:{"protocol":"UDP","mode":"RELAY","debug":true,"monitor":true,"relay_host":"127.0.0.1","relay_port":9000,"proxy_host":"127.0.0.1","proxy_port":50000,"cipher_key":"bdDmN4VexpDvTrs6gw8xTzaFvIBobFg1Cx2McFB1RmI=","entropy_rate":5,"token":"395f249c-343a-4f92-9129-68c6d83b5f55","serving_timeout":20.0,"tcp_buffer":1024,"tcp_timeout":1.0,"udp_min_payload":512,"udp_max_payload":1024,"udp_timeout":2.0,"udp_retries":5,"udp_capacity":10000,"udp_resend_sleep":0.25}udp-proxy.json - UDP-relayed proxy server:{"protocol":"UDP","mode":"PROXY","debug":true,"monitor":true,"proxy_host":"0.0.0.0","proxy_port":50000,"cipher_key":"bdDmN4VexpDvTrs6gw8xTzaFvIBobFg1Cx2McFB1RmI=","entropy_rate":5,"token":"395f249c-343a-4f92-9129-68c6d83b5f55","serving_timeout":20.0,"tcp_buffer":1024,"tcp_timeout":1.0,"udp_min_payload":512,"udp_max_payload":1024,"udp_timeout":2.0,"udp_retries":5,"udp_capacity":10000,"udp_resend_sleep":0.25}Relay and proxy setup configuration with supervisord -ouija-configCipher and entropycipher_key - FernetCipher key - use ouija_secret to generate keyentropy_rate - SimpleEntropy rate, when rate=N every Nth byte will be generated and payload size will increase, rate=5 means 20% traffic overheadProtocolsStream - TCPDatagram - UDPEntitiesCipher - cipher implementation - FernetCipher out of the boxEntropy - entropy control implementation - SimpleEntropy out of the boxTuning - relay/proxy and connector/link interaction settingsRelay - HTTPS proxy server interfaceConnector - relay connector, which communicates with proxy linkProxy - proxy server, which gets requests from relay and sends back responses from remote serversLink - proxy link with relay connectorTuning - TCPcipher - cipher instance, if None then no encryption will be appliedentropy - entropy instance, if None then no entropy control will be appliedtoken - your secret token - UUID4 or anything else - use ouija_secret to generate tokenserving_timeout - timeout for serve/resend workers, 2X for handlers, secondstcp_buffer - TCP buffer size, bytestcp_timeout - TCP awaiting timeout, secondsmessage_timeout - TCP service message timeout, secondsTuning - UDPcipher - cipher instance, if None then no encryption will be appliedentropy - entropy instance, if None then no entropy control will be appliedtoken - your secret token - UUID4 or anything else - use ouija_secret to generate tokenserving_timeout - timeout for serve/resend workers, 2X for handlers, secondstcp_buffer - TCP buffer size, bytestcp_timeout - TCP awaiting timeout, secondsudp_min_payload - UDP min payload size, bytesudp_max_payload - UDP max payload size, bytesudp_timeout - UDP awaiting timeout, secondsudp_retries - UDP max retry count per interactionudp_capacity - UDP send/receive buffer capacity - max packet countudp_resend_sleep - UDP resend sleep between retries, secondsLibrary usagestream-relay.py - TCP relay server - HTTP/HTTPS proxy server interface with TCP connectors:importasyncioimportloggingfromouijaimportStreamRelayasRelay,StreamTuningasTuning,Telemetry,SimpleEntropy,FernetCipherasyncdefmain()->None:tuning=Tuning(cipher=FernetCipher(key='bdDmN4VexpDvTrs6gw8xTzaFvIBobFg1Cx2McFB1RmI='),entropy=SimpleEntropy(rate=5),token='395f249c-343a-4f92-9129-68c6d83b5f55',serving_timeout=20.0,tcp_buffer=1024,tcp_timeout=1.0,message_timeout=5.0,)relay=Relay(telemetry=Telemetry(),tuning=tuning,relay_host='127.0.0.1',relay_port=9000,proxy_host='127.0.0.1',proxy_port=50000,)asyncio.create_task(relay.debug())awaitrelay.serve()if__name__=='__main__':loop=asyncio.get_event_loop()loop.run_until_complete(main())loop.run_forever()stream-proxy.py - TCP-relayed proxy server:importasyncioimportloggingfromouijaimportStreamProxyasProxy,Telemetry,StreamTuningasTuning,SimpleEntropy,FernetCipherasyncdefmain()->None:tuning=Tuning(cipher=FernetCipher(key='bdDmN4VexpDvTrs6gw8xTzaFvIBobFg1Cx2McFB1RmI='),entropy=SimpleEntropy(rate=5),token='395f249c-343a-4f92-9129-68c6d83b5f55',serving_timeout=20.0,tcp_buffer=1024,tcp_timeout=1.0,message_timeout=5.0,)proxy=Proxy(telemetry=Telemetry(),tuning=tuning,proxy_host='0.0.0.0',proxy_port=50000,)asyncio.create_task(proxy.debug())awaitproxy.serve()if__name__=='__main__':loop=asyncio.get_event_loop()loop.run_until_complete(main())loop.run_forever()datagram-relay.py - UDP relay server - HTTPS proxy server interface with UDP connectors:importasyncioimportloggingfromouijaimportDatagramRelayasRelay,DatagramTuningasTuning,Telemetry,SimpleEntropy,FernetCipherasyncdefmain()->None:tuning=Tuning(cipher=FernetCipher(key='bdDmN4VexpDvTrs6gw8xTzaFvIBobFg1Cx2McFB1RmI='),entropy=SimpleEntropy(rate=5),token='395f249c-343a-4f92-9129-68c6d83b5f55',serving_timeout=20.0,tcp_buffer=1024,tcp_timeout=1.0,udp_min_payload=512,udp_max_payload=1024,udp_timeout=2.0,udp_retries=5,udp_capacity=10000,udp_resend_sleep=0.25,)relay=Relay(telemetry=Telemetry(),tuning=tuning,relay_host='127.0.0.1',relay_port=9000,proxy_host='127.0.0.1',proxy_port=50000,)asyncio.create_task(relay.debug())awaitrelay.serve()if__name__=='__main__':loop=asyncio.get_event_loop()loop.run_until_complete(main())loop.run_forever()datagram-proxy.py - UDP-relayed proxy server:importasyncioimportloggingfromouijaimportDatagramProxyasProxy,Telemetry,DatagramTuningasTuning,SimpleEntropy,FernetCipherasyncdefmain()->None:tuning=Tuning(cipher=FernetCipher(key='bdDmN4VexpDvTrs6gw8xTzaFvIBobFg1Cx2McFB1RmI='),entropy=SimpleEntropy(rate=5),token='395f249c-343a-4f92-9129-68c6d83b5f55',serving_timeout=20.0,tcp_buffer=1024,tcp_timeout=1.0,udp_min_payload=512,udp_max_payload=1024,udp_timeout=2.0,udp_retries=5,udp_capacity=10000,udp_resend_sleep=0.25,)proxy=Proxy(telemetry=Telemetry(),tuning=tuning,proxy_host='0.0.0.0',proxy_port=50000,)asyncio.create_task(proxy.debug())awaitproxy.serve()if__name__=='__main__':loop=asyncio.get_event_loop()loop.run_until_complete(main())loop.run_forever()Testspytest--cov-reporthtml:htmlcov--cov=ouijatests/