A small educational remote CLI project demonstrating TCP sockets, TLS encryption, token authentication, allowlisted Windows commands, logging, and PyInstaller packaging.
Educational Purpose Only: This project is created strictly for educational purposes and authorized cybersecurity testing on systems you own or have explicit permission to use.
| Component | Details |
|---|---|
| Server | Kali Linux |
| Client | Windows |
| Protocol | TCP + TLS |
| Port | 8443 |
| Authentication | Shared token |
| Commands | Allowlisted only |
| Windows deployment | client.exe |
The Windows client is intentionally restricted to predefined commands and does not provide an arbitrary command shell, persistence, credential theft, or security-tool evasion.
- Architecture
- Repository
- Output
- 1. Project Structure
- 3. Kali Linux Setup
- 4. Generate TLS Certificate
- 5. Generate Authentication Token
- 6. Server Configuration
- 7. Client Configuration
- 8. Start the Kali Server
- 9. Test Windows Connectivity
- 10. Test the Python Client
- 11. Available Commands
- 12. Build the Windows EXE
- 13. Windows Final Lab Machine
- 14. Logging
- 15. Troubleshooting
- 16. Security Design
- 17. Security Notes
- License
TLS / TCP :8443
┌──────────────┐ ┌──────────────────┐
│ Kali Linux │ │ Windows │
│ server.py │ ──────────────────────> │ client.exe │
│ secure-cli> │ <────────────────────── │ allowlisted │
└──────────────┘ output │ commands │
└──────────────────┘
- Repository: https://github.com/arthghori/Remote-CLI
- Server: https://github.com/arthghori/Remote-CLI/blob/main/server.py
- Client: https://github.com/arthghori/Remote-CLI/blob/main/client.py
Example session showing the Kali server and Windows client in action authentication, dir, and whoami executed through the command flow:
secure-remote-cli/
├── server/
│ ├── server.py
│ ├── server.crt
│ └── server.key
└── logs/
└── server.log
client/
└── client.py
client/
└── dist/
└── client.exe
mkdir -p ~/secure-remote-cli/server
mkdir -p ~/secure-remote-cli/logs
cd ~/secure-remote-cli/serveropenssl genrsa -out server.key 2048openssl req -new -x509 -key server.key -out server.crt -days 365 -subj "/CN=SecureRemoteCLI"Verify:
ls -lYou should have:
server.crt
server.key
Important: Never copy server.key to the Windows client.
python3 -c "import secrets; print(secrets.token_urlsafe(32))"Use the same generated token in both server.py and client.py.
AUTH_TOKEN = "YOUR_RANDOM_TOKEN"Do not publish the real token in GitHub.
Keep the server listening configuration as:
HOST = "0.0.0.0"
PORT = 8443Find the Kali IP with:
ip addrSet the current Kali IP in client.py:
SERVER_HOST = "YOUR_KALI_IP"
SERVER_PORT = 8443
AUTH_TOKEN = "YOUR_RANDOM_TOKEN"Example:
SERVER_HOST = "192.168.31.251"
SERVER_PORT = 8443Replace the example with your current Kali IP.
cd ~/secure-remote-cli/server
python3 server.pyExpected:
============================================================
SECURE REMOTE CLI SERVER
============================================================
[*] Server IP : 0.0.0.0
[*] Port : 8443
[*] Protocol : TCP + TLS
[*] Commands : Allowlisted
============================================================
[*] Listening on 0.0.0.0:8443
[*] Waiting for authorized client...
Check port 8443:
sudo ss -lntp | grep 8443PowerShell:
ping YOUR_KALI_IPThen:
Test-NetConnection YOUR_KALI_IP -Port 8443Expected:
TcpTestSucceeded : True
Before creating the EXE:
python client.pyAfter successful authentication, Kali should show:
[+] TCP/TLS connection from (...)
[+] Client authenticated
secure-cli>
The implementation uses an allowlist:
whoami
hostname
ipconfig
systeminfo
dir
date
Use:
secure-cli> help
Examples:
secure-cli> hostname
secure-cli> whoami
secure-cli> ipconfig
secure-cli> systeminfo
secure-cli> dir
secure-cli> date
Exit:
secure-cli> exit
The command flow is:
Kali secure-cli
|
v
server.py
|
| TLS
v
client.py / client.exe
|
v
Allowlisted Windows command
|
v
Command output
|
| TLS
v
Kali server
Install PyInstaller:
pip install pyinstallerBuild:
pyinstaller --onefile --noconsole --clean client.pyFinal executable:
dist\client.exe
For the authorized lab demonstration, the final Windows machine only needs:
client.exe
It does not need:
client.py
server.py
server.key
server.crt
Python
PyInstaller
Kali server log:
cat ~/secure-remote-cli/logs/server.logWindows client log:
client.log
Check Kali IP:
ip addrCheck server port:
sudo ss -lntp | grep 8443Check Windows IP:
ipconfigTest connectivity:
Test-NetConnection YOUR_KALI_IP -Port 8443If Kali's IP changes:
- Update
SERVER_HOSTinclient.py. - Rebuild the EXE.
- Copy the new
dist\client.exeto the authorized Windows test machine.
If UFW is enabled in your isolated lab:
sudo ufw statusIf required:
sudo ufw allow 8443/tcpThis project demonstrates:
- TCP socket communication
- TLS-encrypted communication
- Token-based authentication
- JSON message framing
- Command allowlisting
- Command output handling
- Connection and command logging
- Windows executable packaging
- Kali Linux server deployment
The implementation intentionally checks requested commands against a predefined allowlist instead of accepting arbitrary shell input.
The educational client uses a self-signed certificate and disables normal certificate verification. This is suitable only for an isolated lab demonstration.
For production use, implement proper certificate validation or mutual TLS (mTLS).
Use a strong random token and never publish it in the GitHub repository.
Do not commit:
server.key
AUTH_TOKEN
client.log
server.log
Add the license that matches your project requirements before publishing or distributing the repository.
