Add wsscp - WebSocket SCP wrapper application

New wsscp application:
- WebSocket SCP wrapper similar to wsssh but for SCP instead of SSH
- Uses -P option for port detection (SCP standard) instead of -p
- Automatically constructs ProxyCommand for WebSocket tunnels
- Supports same command line syntax as regular SCP
- Includes automatic port detection from -P option
- Full integration with wsssht WebSocket tunnel infrastructure

Implementation details:
- wsscp.h: Header file with configuration structures and function declarations
- wsscp.c: Complete implementation with argument parsing and SCP command generation
- Updated configure.sh to build wsscp alongside other tools
- Added wsscp.1 man page with comprehensive documentation
- Tested functionality with debug mode and argument parsing

Features:
- Automatic wsssht path detection (PATH or same directory)
- Smart port detection: explicit --wssshd-port takes precedence over -P option
- Support for all wsssht tunnel options (--tunnel, --tunnel-control, --debug)
- Compatible with existing wssshc/wsssht infrastructure
- Proper error handling and user-friendly help messages

Usage examples:
  wsscp localfile user@myclient:/remote/path
  wsscp -P 2222 localfile user@myclient.server.com:/remote/path
  wsscp --debug --tunnel websocket localfile user@myclient:/remote/path
parent e9748765
...@@ -58,12 +58,12 @@ LDFLAGS = $(shell pkg-config --libs openssl) ...@@ -58,12 +58,12 @@ LDFLAGS = $(shell pkg-config --libs openssl)
# Source files # Source files
LIB_SRCS = libwsssht/wssshlib.c libwsssht/websocket.c libwsssht/wssh_ssl.c libwsssht/tunnel.c libwsssht/utils.c libwsssht/modes.c libwsssht/threads.c LIB_SRCS = libwsssht/wssshlib.c libwsssht/websocket.c libwsssht/wssh_ssl.c libwsssht/tunnel.c libwsssht/utils.c libwsssht/modes.c libwsssht/threads.c
LIB_OBJS = $(LIB_SRCS:.c=.o) LIB_OBJS = $(LIB_SRCS:.c=.o)
SRCS = wssshc.c wsssht.c wsssh.c SRCS = wssshc.c wsssht.c wsssh.c wsscp.c
OBJS = $(SRCS:.c=.o) OBJS = $(SRCS:.c=.o)
TARGETS = wssshc wsssht wsssh TARGETS = wssshc wsssht wsssh wsscp
# Man pages # Man pages
MANPAGES = man/wssshc.1 man/wsssht.1 man/wsssh.1 MANPAGES = man/wssshc.1 man/wsssht.1 man/wsssh.1 man/wsscp.1
# Default target # Default target
all: $(TARGETS) all: $(TARGETS)
...@@ -78,13 +78,16 @@ wsssht: wsssht.o $(LIB_OBJS) ...@@ -78,13 +78,16 @@ wsssht: wsssht.o $(LIB_OBJS)
wsssh: wsssh.o wsssh: wsssh.o
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
wsscp: wsscp.o
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
# Object files # Object files
%.o: %.c %.o: %.c
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
# Clean # Clean
clean: clean:
rm -f $(OBJS) $(LIB_OBJS) $(TARGETS) rm -f $(OBJS) $(LIB_OBJS) $(TARGETS) wsscp.o
# Install (optional) # Install (optional)
install: all install: all
...@@ -107,15 +110,19 @@ uninstall: ...@@ -107,15 +110,19 @@ uninstall:
rm -f $(DESTDIR)/usr/local/bin/wssshc rm -f $(DESTDIR)/usr/local/bin/wssshc
rm -f $(DESTDIR)/usr/local/bin/wsssht rm -f $(DESTDIR)/usr/local/bin/wsssht
rm -f $(DESTDIR)/usr/local/bin/wsssh rm -f $(DESTDIR)/usr/local/bin/wsssh
rm -f $(DESTDIR)/usr/local/bin/wsscp
rm -f $(DESTDIR)/usr/local/share/man/man1/wssshc.1 rm -f $(DESTDIR)/usr/local/share/man/man1/wssshc.1
rm -f $(DESTDIR)/usr/local/share/man/man1/wsssht.1 rm -f $(DESTDIR)/usr/local/share/man/man1/wsssht.1
rm -f $(DESTDIR)/usr/local/share/man/man1/wsssh.1 rm -f $(DESTDIR)/usr/local/share/man/man1/wsssh.1
rm -f $(DESTDIR)/usr/local/share/man/man1/wsscp.1
rm -f $(DESTDIR)/usr/bin/wssshc rm -f $(DESTDIR)/usr/bin/wssshc
rm -f $(DESTDIR)/usr/bin/wsssht rm -f $(DESTDIR)/usr/bin/wsssht
rm -f $(DESTDIR)/usr/bin/wsssh rm -f $(DESTDIR)/usr/bin/wsssh
rm -f $(DESTDIR)/usr/bin/wsscp
rm -f $(DESTDIR)/usr/share/man/man1/wssshc.1 rm -f $(DESTDIR)/usr/share/man/man1/wssshc.1
rm -f $(DESTDIR)/usr/share/man/man1/wsssht.1 rm -f $(DESTDIR)/usr/share/man/man1/wsssht.1
rm -f $(DESTDIR)/usr/share/man/man1/wsssh.1 rm -f $(DESTDIR)/usr/share/man/man1/wsssh.1
rm -f $(DESTDIR)/usr/share/man/man1/wsscp.1
.PHONY: all clean install uninstall .PHONY: all clean install uninstall
EOF EOF
......
.TH WSSCP 1 "September 2024" "wsscp 1.0" "WebSocket SSH Tools"
.SH NAME
wsscp \- SCP wrapper with WebSocket ProxyCommand support
.SH SYNOPSIS
.B wsscp
[\fB\-\-help\fR] [\fB\-\-clientid\fR \fIclient_id\fR] [\fB\-\-wssshd\-host\fR \fIhost\fR]
[\fB\-\-wssshd\-port\fR \fIport\fR] [\fB\-\-debug\fR] [\fB\-\-tunnel\fR \fItransport\fR]
[\fB\-\-tunnel\-control\fR \fItransport\fR] \fIsource_file\fR \fIdestination\fR
.SH DESCRIPTION
.B wsscp
is an SCP wrapper that automatically configures SCP to use WebSocket tunnels through
.B wsssht
with ProxyCommand. It parses the destination specification and constructs the appropriate
SCP command with ProxyCommand to establish secure file transfers through WebSocket relays.
.SH OPTIONS
.TP
.B \-\-help
Show help message and exit.
.TP
.B \-\-clientid \fIclient_id\fR
Specify the client ID of the registered wssshc endpoint.
.TP
.B \-\-wssshd\-host \fIhost\fR
Specify the wssshd relay host.
.TP
.B \-\-wssshd\-port \fIport\fR
Specify the wssshd relay websocket port (default: 9898).
.TP
.B \-\-debug
Enable debug output. When debug is enabled, the SCP command is displayed but not executed.
.TP
.B \-\-tunnel \fItransport\fR
Select data channel transport (comma-separated or 'any').
.TP
.B \-\-tunnel\-control \fItransport\fR
Select control channel transport (comma-separated or 'any').
.SH DESTINATION FORMAT
The destination specification follows the format:
.sp
\fIuser\fR[\fB@\fR[\fIclientid\fR][\fB.\fR[\fIwssshd\-host\fR]][\fB:\fR[\fIremote_path\fR]]]
.sp
Where:
.RS
.TP
\fIuser\fR
SCP username
.TP
\fIclientid\fR
Client ID of the registered wssshc endpoint
.TP
\fIwssshd\-host\fR
wssshd relay hostname
.TP
\fIremote_path\fR
Remote file path on the target system
.RE
.SH EXAMPLES
.TP
Copy file to myclient:
.B wsscp localfile user@myclient:/remote/path
.TP
Copy file with specific relay host:
.B wsscp localfile user@myclient.server.com:/remote/path
.TP
Copy file with custom port:
.B wsscp -P 2222 localfile user@myclient.server.com:/remote/path
.TP
Enable debug output:
.B wsscp \-\-debug localfile user@myclient.server.com:/remote/path
.TP
Specify transport:
.B wsscp \-\-tunnel websocket localfile user@myclient.server.com:/remote/path
.TP
Pass additional SCP options:
.B wsscp localfile user@myclient.server.com:/remote/path -P 2222 -o StrictHostKeyChecking=no
.SH ENVIRONMENT
.B wsscp
requires
.B wsssht
to be available either in PATH or in the same directory as wsscp.
.SH SEE ALSO
.BR wsssht (1),
.BR wssshc (1),
.BR wsssh (1),
.BR scp (1)
.SH AUTHOR
Written by Stefy Lanza <stefy@nexlab.net> and SexHack.me
.SH COPYRIGHT
Copyright \(co 2024 Stefy Lanza <stefy@nexlab.net> and SexHack.me
.br
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
.SH BUGS
Report bugs to <stefy@nexlab.net>
\ No newline at end of file
This diff is collapsed.
/*
* WebSocket SCP (wsscp) - Header file
* SCP wrapper with WebSocket ProxyCommand support.
*
* Copyright (C) 2024 Stefy Lanza <stefy@nexlab.net> and SexHack.me
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef WSSCP_H
#define WSSCP_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <getopt.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <pthread.h>
#include <sys/select.h>
// Configuration structure for wsscp
typedef struct {
char *client_id;
char *wssshd_host;
int wssshd_port;
int wssshd_port_explicit; // Flag to track if --wssshd-port was explicitly set
int debug;
char *tunnel;
char *tunnel_control;
char *user;
char *target_host;
char *ssh_string;
char *source_file;
char *destination;
int remaining_argc;
char **remaining_argv;
} wsscp_config_t;
// Function declarations
int parse_wsscp_args(int argc, char *argv[], wsscp_config_t *config);
int parse_target_string(const char *target, wsscp_config_t *config);
int parse_scp_port_from_args(wsscp_config_t *config);
char *build_proxy_command(wsscp_config_t *config);
char *find_wsssht_path();
int execute_scp_command(char *command, int debug);
void print_usage(const char *program_name);
#endif /* WSSCP_H */
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment