Questions tagged [socat]
The program socat is a relay for bidirectional data transfer between two independent data channels.
149
questions
0
votes
2
answers
43
views
socat et al.: run a command when incoming connection is received
Let's say one is listening on a tcp port for an incoming connection using socat like this:
$ socat file:`tty`,echo=1 "TCP-L:8080"
Is is possible to run a command (just once) when connection ...
0
votes
1
answer
99
views
How to send UDP broadcast datagrams to port below 1025?
Scenario
I'm trying to send a UDP datagram message with socat to a broadcast address.
On the receiving end this is how I'm running socat (with root privileges):
socat UDP-LISTEN:1011 -
I'm trying to ...
0
votes
2
answers
412
views
socat: How to do simple duplex communication with shell?
I would like to create a TCP connection to a remote server with socat, where a client sends
an action for an image file ("convert", "open", etc.)
the image (binary content) ...
1
vote
2
answers
267
views
How to run multiple `socat` and forwarding both TCP and UDP traffic?
I want to forward Microsoft Remote Desktop on a Linux Server, assume that the remote Windows host is 192.168.1.100, I want to run:
socat TCP4-LISTEN:3389,fork TCP4:192.168.1.100:3389
socat UDP4-LISTEN:...
0
votes
2
answers
189
views
Tunnel multiple HTTP connections over a bidirectional stream
I'm looking to forward an http server (on Linux) over a single non-network bidirectional stream (specifically, a QEMU virtio-serial stream, but that doesn't really matter). Basically what I want is:
[...
0
votes
0
answers
20
views
reading serial output from a linux service script without logging it
I have a python script which reads incoming data from a physical serial port, does some processing and MQTT publishes it. It's deployed as a systemd service. Debugging information is just printed(). I ...
0
votes
1
answer
62
views
TCP port visible from inside nor outside
I've used autossh (reverse) connecting to my server. The ssh side works like used to. But in an ARM64 system, my Ubuntu has less possibilities but this is another story (...).
So what I see whit nmap ...
1
vote
1
answer
309
views
how to remove the buffer when simulating a serial device with socat
I am creating a fake serial device like this:
socat -d -d pty,raw,echo=0 pty,raw,echo=0
This creates devices with new numbers each time. Let's call them /dev/pty/6 and /dev/pty/7
To simulate a ...
1
vote
0
answers
175
views
Trying to make a fake GPS device with socat
Background:
I am trying to make a fake GPS device so that I can put the wrong time in the output, and then make sure that when I set up chrony and gpsd, I am getting the time from serial feed that I ...
1
vote
1
answer
113
views
socat tunnel traffic drops after some time
I have two Linux machines, I want to create a tunnel between them using socat, this is my workaround:
Machine1:
socat -d -d UDP-LISTEN:4711,reuseaddr TUN:10.50.50.1/24,iff-up,iff-broadcast,iff-...
0
votes
0
answers
202
views
How to use a http proxy as socks5?
I have a macOS machine with socat installed. And I also have a http proxy server provided by my company.
What I want to do is to use the http proxy as a socks5 proxy, to use telegram on my company ...
0
votes
1
answer
103
views
Start only a socat process when integrating with systemd
I want to run a "socat" command to replicate the information coming on port 162 to another machine and on the same port.
I added a systemd to do this process:
[Unit]
Description=Socat SNMP ...
0
votes
1
answer
730
views
Socat specify source port
How do I specify source port in socat?
In netcat I can simply:
nc -u -s 192.168.0.1 -p 8888 192.168.0.2 9999
I tried
socat udp4:192.168.0.2:9999 STDIN:192.168.0.1:8888
It's failed
STDIN: wrong ...
1
vote
1
answer
2k
views
Connect to host machine from WSL2
Problem
Can't connect to Windows X Server (VcXsrv) from WSL2 due firewall rules (sometimes it works, but sometimes it doesnt; it's very strange). Changing the firewall rules is not possible.
But any ...
0
votes
0
answers
382
views
Socat serial to tcp for authorized users
Hello everyone I hope you doing well
I have a raspberry pi and I kind need a serial port server which can access from internet
Now I use socat command like bellow on my raspberry and from putty on ...
0
votes
1
answer
192
views
How do I inject a header line into a pipe via a shell script?
I am working on a process to send data via a pipe from one server to another for processing.
Although this is not the exact command, it might look something like this:
tail -f logfile | grep "abc&...
0
votes
2
answers
1k
views
Proxying localhost to HTTPS using socat returns Connection refused first time
I'm trying to fetch a page from https://termbin.com/9hc2k using bash redirections and socat, especially using special file /dev/tcp/localhost/8080 to open a network connection.
# fetch.sh
# fetch ...
2
votes
1
answer
3k
views
Intercept communications on physical serial port using socat
I'm no Linux expert so please go easy ;).
Ok, the situation is that I have a single board computer running Debian Wheezy. I know its old/risky etc etc but its not actually "my" equipment and ...
0
votes
0
answers
309
views
socat streaming UDP is slower than TCP
I'm currently using subprocess.run(["socat", f"udp-listen:{_to},fork,reuseaddr,bind=127.0.0.1", f"""exec:'sudo ip netns exec {netns} socat STDIO "UDP-connect:...
0
votes
1
answer
243
views
socat does not honor sourceport option
I am trying to send a udp packet from a specific port:
$ echo hello | socat - UDP-DATAGRAM:192.168.1.255:11111,broadcast,sourceport=22222
But a random port is used instead:
# tcpdump -vvvv -ttttt -...
0
votes
0
answers
204
views
redirected stdin : how to get ALL lines of the incoming request instead of doing multiple "read"
THIS QUESTION IS BASH SCRIPT RELATED... the rest is to explain the context.
context : experimentation : create a simple mini webserver with socat instead of apache.
** the test I'm doing is able to ...
1
vote
0
answers
2k
views
Local port forwarding on Ubuntu 20.04?
I have a service listening on port :3000. However, I would like to change that to port :8080. Unfortunately, the program that I'm running does not allow me to change the listen port.
Is there any way ...
1
vote
1
answer
1k
views
How do I write multiple socat statements in a systemd file for restart on failure?
CODE:
/etc/systemd/system/socat.service
[Unit]
Description="socat systemd"
[Service]
Type=simple
Restart=on-failure
RestartSec=10
User=ubuntu
ExecStart = /usr/bin/socat tcp-listen:1111,...
1
vote
1
answer
557
views
tell socat to stop on connection refuse with fork enabled
I'm using this instruction to forward a port to another, both on a local machine:
socat -d -d TCP4-LISTEN:80,reuseaddr,fork TCP4:127.0.0.1:8000
I need to keep the port open unless the destination ...
0
votes
0
answers
96
views
Redirect specific traffic between two port on same device
I have two running SIP applications on a Debian buster server, one app use port 1000 (a softphone) and another one using port 2000 (VoIP server like FreePBX).
both of them are on the same machine and ...
0
votes
1
answer
2k
views
SOCAT (only) reverse tunnel
I have a situation where we are trying to get data from one network to another - specifically access to a private maven repo on a different network.
Network 1 contains a maven repo. And network is ...
1
vote
2
answers
2k
views
How to receive a file and save it with socat
**** This is for learning purpose. I just like to deep dive into sockets, tcp, packets, etc.
For doing tests and learning, I began to "play" with socat
CONTEXT (tests) :
1- Bind a port to a ...
1
vote
1
answer
903
views
socat: EXEC does not relay correctly
I have a small program that first outputs a string to the user and then takes an input. I instead want the program to work by sending and receiving from a port. To try to realize this I ran the ...
0
votes
0
answers
170
views
Contents of variable somehow lost with socat and wall
I'm not sure what is going on or which command causes the unexpected behavior, so I'll post everything I've done:
I have created a script onreceive.sh containing:
#!/bin/bash
read INCOMING
wall --...
0
votes
1
answer
411
views
Make "socat" constantly listen for the magic packet
I have a RPi 1b+ v1.2 with Raspberry Pi OS June 2021.
I'm using socat to trigger a bash script that wakes another PC in the network up. I use this command:
sudo socat UDP-LISTEN:10 EXEC:scripts/pi-wol....
0
votes
1
answer
331
views
listener message on port 23
I want to have a message to anyone that tries to telnet (port 23) to my server that they are connecting to the wrong port, then disconnects them.
Basically something like socat would be ideal, but I ...
1
vote
1
answer
448
views
How to use socat to implement a base64 decoding proxy?
The goal: bidirectional communication while decode in a unidirectional way the incoming data
Theory: suppose to have a proxy/ server that listens on port 8080 which needs to handle multiple clients at ...
0
votes
1
answer
3k
views
send udp broadcast via bash
I try to send a udp broadcast with 2 (FF 01) bytes over bash, but in my network sniffer I notice it's 3 bytes. FF 01 0A where does the line break come from and how can i prevent it?
echo -e '\xFF\x01' ...
2
votes
1
answer
6k
views
How to run socat as a systemd service to bridge two remote unix sockets?
In order to use Exim's dovecot authentication, I need to bridge two unix sockets in two different machines: the exim server and the dovecot one.
To do so I'm using socat:
eximserver# socat UNIX-LISTEN:...
1
vote
0
answers
738
views
What are the side effects of using socat to monitor the traffic of a serial port regarding the monitored serial port?
Disclaimer: Long and detailed problem description + I actually have no idea about socat, but ran into a very strange problem. Something similar to a tl;dr at the end.
I am currently trying to connect ...
0
votes
0
answers
867
views
SSH local port forwarding or SSH + Socat
I would like to connect to a service running on port X on a host. The service cannot be reached on the host IP address and port. There are 2 options I know which can achieve this:
Local port ...
0
votes
1
answer
111
views
How to get bash to reevaluate $(date) when part of a background job - if possible
OS FreeBSD-12.2
I have a virtual printer setup using socat. The socat command runs in the background. It spawns a system shell that processes the input stream and sends it to gpcl6 to create pdf ...
1
vote
1
answer
255
views
PPP fails LCP negotiation with serial to wifi connection using Socat
I'm trying to setup a connection over a serial to wifi adapter. I'm using Socat to create a socket to bridge the connection to a PTY for pppd. Data appears to be be flowing both directions, but pppd ...
1
vote
0
answers
583
views
Passing arguments to socat child process
I am solving a challenge and I need to perform privilege escalation. Currently I have privileges of a local user.
So there is a binary which runs as root and launches shell if we pass any argument ...
1
vote
0
answers
503
views
socat bidrectionally with a shell script. echo, read, then hand off to socat
There is a VMM which doesn't conform to the the standard VSOCK implementation: Firecracker
For each guest it creates a v.sock unix socket file
The ordinary VSOCK-CONNECT:cid:1234 then becomes:
UNIX-...
0
votes
0
answers
69
views
What's the best/easiest way to create a usb connection from Windows to Linux
I'm wondering what's the best way for me to setup a usb connection from Windows to a remote linux servers (Redhat)? I did some Googling and found socat but that was for Linux to Linux, any ideas?
My ...
1
vote
1
answer
358
views
use socat as a service 24/7
We have a server which main focus is to stream data from one point to another.
e.g.
transfer data form 192.168.0.10:5000 to 192.168.0.20:6000
transfer data form 232.0.0.1:5000 to 192.168.0.20:6000
...
0
votes
1
answer
370
views
Forward data from unix socket to cups printer
I'd like to print out of a VM (KVM/QEMU via virt-manager).
For the VM to host connection there is an emulated parallel port in the VM that should be connected to a Unix Socket.
I tried to create a ...
1
vote
0
answers
379
views
How to create a collecting socket relay with socat?
I'm using socat to forward to another port on localhost:
socat tcp-l:5050,fork,reuseaddr tcp:localhost:2020
Problem: if the program running on 2020 is down, socat will answer incoming connections like:...
0
votes
1
answer
161
views
Port forwarding without having account on host machine
Network structure
I want to setup a simple method acessing a machine A from a machine B with VNC. Both machines are behind a NAT. I have a raspberry with ddns setup.
A -> NAT1 -> rasp <- NAT2 ...
1
vote
0
answers
395
views
Send the contents of a file before send-receive over a TTY with socat
I'm using socat like this to connect to a TCP server interactively:
socat file:`tty`,raw,echo=0 tcp:127.0.0.1:1337
I can also send a file instead of interactive input:
socat file:/tmp/myfile'!!'file:`...
1
vote
2
answers
3k
views
Pipe multiple commands to socat reverse shell (network-namespaced)
I have a bash script that:
does some thing
connects/opens a reverse shell.
does another thing
my-script contents:
#!/usr/bin/env bash
# does 'some thing'
sudo /usr/bin/nsenter --setuid 1000 --...
0
votes
1
answer
970
views
socat bidirectional communication with user-defined bash function
So i want socat to persistently listen for connections, get the first x lines and reply back with a message. Ideally i want to use a user defined function to handle that logic but i couldn't find a ...
3
votes
1
answer
7k
views
Socat: send a UDP broadcast from stdin, but handling responses with SYSTEM
I'm trying to implement a simple proprietary discovery protocol using socat. The discovery is done by sending a UDP broadcast to a well-defined port with a small payload, then listening to "...
2
votes
1
answer
3k
views
Use socat as https to http proxy
Based on https://superuser.com/questions/1583159/secure-connection-failed-to-old-printer-with-https I was thinking:
Can socat (or similar) be used to connect to the printer with an old https version ...