Questions tagged [socat]
socat is a relay for bidirectional data transfer between two independent data channels.
252
questions
0
votes
0
answers
71
views
SOCAT - Forwarding TCP packets to UDP
I have an application that sends simple data over TCP (simple, no auth) and another application that must receive it. The only allowed connection between the two is UDP.
On the receiving side, I have ...
0
votes
1
answer
42
views
Sending to a serial device via socat only shows up if I'm actively reading -- I need the data to be cached
I have socat creating two serial ports: ttyclient and ttyserver, ttyclient will be called by an application and I have a script listening to ttyserver. The sequence of events I need is
My socat ...
0
votes
1
answer
41
views
PROXY protocol - test client /tool
Proxy Protocol is implemented by various software including of course HAProxy itself.
When testing from a host via a proxy, it would be useful to have a simple command-line tool to establish ...
0
votes
0
answers
20
views
Socat helping debug
I have been trying to figure out how to debug certain services running in an EC2 inside a docker container instance.
I have tried using ssh tunneling, but this won't work due to security issues on ...
1
vote
0
answers
55
views
Can't use socat to process HTTP request via serial port
I'm trying to use socat in order to process incoming HTTP requests and send them via serial port to a board which will process it and send the response back. The problem is that concurrent requests ...
-1
votes
2
answers
26
views
How to connect to an integrated VM without using SSH tunelling
I want to connect to a locked (cannot be modified and I do not have permissions to log into) windows vm which is hosted in a linux machine. Until now these two machines were communicating via port ...
0
votes
1
answer
43
views
How can I see the same as the client in a socat reverse shell?
I am serving an interactive program to a remote terminal using socat. To start simple I used script.sh below, but it also works fine for the client with bash (for reverse shell), python, vim, irssi, ...
0
votes
1
answer
45
views
How to redirect input and output between two instances of cat with socat
I'm learning socat and as an excercise try to send text between two different shell windows. The following works well:
socat - UNIX-LISTEN:uah
socat - UNIX-CONNECT:uah
I assumed that I could replace ...
0
votes
1
answer
73
views
socat throw error while trying to connect external mysql
I try to connect 2 docker containers to each other via socat.
Inside of the web container, I'll use socat to bind the external mysql-container to Port 3306.
I do use this command line:
socat TCP:$...
0
votes
0
answers
46
views
Script execution of host commands from docker for Mac using Socat
I have a SOCAT setup that allows me to break out of the docker container and execute commands on the host. I realize this defeats the purpose of the container, but I'm leveraging a CNAB tool that ...
0
votes
1
answer
123
views
How return output in local machine from socat command linux
I have an up and running service ( is an emulated machine or something similar ) on my local Ubuntu machine and i'm able to access it through a serial port and following socat command:
> sudo socat ...
2
votes
0
answers
141
views
Expose stdin and stdout of binary as TCP socket in Docker
With socat I can expose a binaries stdin/out as a socket for example like this:
$ socat TCP-LISTEN:8080,fork EXEC:./mybinary,pty
I would like to do the same with for example the go docker image.
But ...
0
votes
1
answer
216
views
Passing parameter with special characters to Socat exec script
I have a RNDIS USB modem that allows AT commands through a telnet port (5510). I want to use it to read and send SMS messages from a script.
I've used a variant of a similar question posted here but ...
0
votes
0
answers
75
views
Creating named pseudo terminal pair in Python
Is it possible to emulate the functionality of this socat command, which creates two named virtual ttys, in pure Python?
$ socat -d pty,rawer pty,rawer
2022/03/10 18:27:15 socat[37529] N PTY is /dev/...
0
votes
1
answer
41
views
Socat - certificate rotation for mTLS connection - reload credential files interval
Use case:
I use socat to stream traffic between some app and external world via Squid (app->socat->Squid). To authenticate in SQUID I use mTLS.
My socat usage:
socat -d -d tcp-listen:3128,...
-1
votes
1
answer
285
views
How can I send a UDP packet from bash and receive the response
I want to send a UDP packet from bash (perhaps using netcat or socat) and then receive the one-packet reply, or time-out after three seconds.
(Strictly, the listening needs to start before the initial ...
0
votes
0
answers
53
views
SOCAT new file for IO
I'm using Socat to mock a serial port, and it works fine, but I'd like my stdout back for regular printf().
I tried using fdout=3 but it doesn't create the file descriptor when it EXECS the process (...
0
votes
3
answers
431
views
Why does socat UDP-RECVFROM terminate after exactly 1861 datagrams?
Why does this terminate after exactly 1861 datagrams?
Host 2:
$ socat udp-recvfrom:12345,reuseaddr -
Host 1:
$ seq 1000000 | socat udp-sendto:host2:12345,reuseaddr -
On host 2, this prints out the ...
0
votes
1
answer
15
views
How to convert between 1200 and 1200/75 baud devices? socat?
Is it possible to get a program that uses symmetrical 1200 baud to communicate over serial to a device running at 1200/75? I've tried putting socet in between to create a virtual serial device running ...
0
votes
2
answers
538
views
Socat hangs when piping stdin to tcp server
I have an embedded linux system running a tcp server.
Telnet can connect to and use the tcp server interactively just fine.
I am trying to use socat to make the same connection, by linking stdin to ...
1
vote
1
answer
204
views
Does socat support SOCK_SEQPACKET for Unix domain socket?
Consider the following setup where one instance of socat pipes data from stdin to a unix domain socket, and the other instance reads that data from the unix domain socket and writes it to stdout:
...
0
votes
0
answers
64
views
use python2 script as EXEC parameter of socat
I'm trying to deploy a CTF challenge. so i have the following entrypoint.sh file:
#!/bin/bash
socat -dd -T60 TCP-LISTEN:9002,reuseaddr,fork,su=game EXEC:/home/game/game.py,stderr
however when i ...
0
votes
1
answer
30
views
GSPD information stream timing out after 30 seconds
I am using a GPSD to feed GPS information to a virtual serial port. I'm generating the virtual serial port with socat, and I am listening to the virtual port using: sudo cat /dev/pts/2, where /dev/pts/...
0
votes
1
answer
1k
views
Bidirectional UDP tunnel with socat on Linux
Is it possible to create a bidirectional UDP tunnel with socat? The starting point is a client (C) that communicates with a server (S) and receives a reply, so C⟷S. Of course, C and S are on different ...
1
vote
0
answers
368
views
Bash script to write to unix socket and then read a response but ONLY AFTER the welcome message
I am connecting to a server that initiates an SSH tunnel for me so I can connect to a remote device.
I can do an interactive socat connexion and manually issue commands like this:
Connected to ...
0
votes
0
answers
217
views
socat errormessage "E read(6, 0x555ff6463bd0, 8192): Permission denied" when trying to Portmap IPv6 to IPv4
I want to Portmap to my Router via a Server running socat.
With the command socat -d -d UDP4-LISTEN:500,fork,su=nobody UDP6:[Destination IPv6]:500 I am getting the output:
2021/11/16 15:42:38 socat[...
2
votes
2
answers
369
views
How to relay outbound request from docker container to modify headers?
I have an application that is running in Docker configured with an NGINX reverse proxy. The application is a binary, I don't have source code and there's no way to modify the header of an HTTP request ...
0
votes
0
answers
516
views
Virtual Serial Port with Socat (Linux) and allow buffer overflow
When writing from a laptop to an external serial device that I am using, it is possible for the laptop to be writing faster than the program running on the device can actually clear its serial read ...
1
vote
0
answers
120
views
Is it possible use socat to open an existing tun device instead of creating a new one?
It is known that socat can create a tun device and open it to relay. But I wonder how can I use it to relay an existing tun interface? The tun0 device has been opened by another script.
1
vote
0
answers
281
views
Can't read from serial port with socat and rawer option
I'm trying to use socat to read data from a serial port; however, it doesn't appear to read from the port correctly when passed the rawer option.
If I read from the port with either socat /dev/ttyTHS1,...
0
votes
0
answers
50
views
How can I connect two netns together by PPP rather than veth?
Now the two netns in one Linux OS ared connected by veth pair.
But the interface type of ethernet is not satisfied by some special requirements. Is there a way to connect them by PPP dialing over a ...
0
votes
0
answers
35
views
How can I use socat to update the server in a restricted zone?
How can I use socat or other software to download e.g. an update server in a restricted zone with my PC in the office which has access to the server via ssh and internet - full access?
I made a sketch ...
0
votes
1
answer
92
views
I am using Socat to open a serial connection to a cisco switch in an Expect script. I am able to log into the switch but expect commands wont work
My script is not executing after Socat opens a serial connection to a cisco switch. How to fix this?
#!/usr/bin/expect -f
socat.exe `tty`,raw,echo=0 /dev/ttyS4,raw,echo=0,setsid,sane
...
3
votes
1
answer
2k
views
Kubectl port-forwarding not working for IPv6 binding with socat
I'm trying to understand why this particular socat command isn't working in my case where I run it in a IPv6 only Kubernetes cluster.
Cluster is build on top of AWS with Calico CNI & containerd. ...
1
vote
1
answer
286
views
Bidirectional communication on stdin/stdout from container to host?
I'm building a development Docker image I intend to run on my local machine. On this image I want to put two programs; I'll call them progA and progB. I am not the author of these programs, so I ...
2
votes
2
answers
666
views
Redirect stdout and stderr separately over a socket connection
I am trying to run a script on the other side of a unix-socket connection. For this I am trying to use socat. The script is
#!/bin/bash
read MESSAGE1
echo "PID: $$"
echo "$MESSAGE1"...
1
vote
1
answer
835
views
HTTP Multiple Port Forwarding with SOCAT/Bash
I am attempting to set up a shell script to listen on a port, forward to n different IP addresses, and return the result of one of those API calls.
If I have one IP address, the solution is ...
0
votes
1
answer
385
views
Connect to host socket from within docker container
I want to connect to a unix domain socket on the host from within a docker container. Specifically, I run this on the host:
socat - ABSTRACT-LISTEN:/tmp/.X11-unix/X1
And run this in the container:
...
0
votes
0
answers
656
views
Forwarding multicast DNS requests on localhost
My ultimate goal is to forward mDNS queries from Android emulator to my local network.
I have the communication between emulator and my localhost on PC figured out. What I need to do now is to forward ...
1
vote
0
answers
65
views
Socat to UDP Server Truncating Last Character
So I am working on a Serial to UDP gateway to link a point of sale printer to a NVR that can overlay the transactions on the Camera video (When the POS unit prints on the serial printer, this unit ...
1
vote
1
answer
230
views
Pipe input to dockerized socat run on socket present on docker host
My goal is to query Haproxy Runtime API using dockerized socat.
Below command returns empty result (/var/run/haproxy.stat is haproxy socket located on the docker host)
echo "-h" | docker ...
0
votes
2
answers
660
views
Socat - Poor man's http server
I have been bashing my brains for the past few hours trying to build a poor man's http server using socat. Don't ask why or suggest alternatives. I need to do this in pure bash. So I run socat like ...
3
votes
1
answer
117
views
How to use socat with heredoc?
I can run socat in this way, if I input text from the terminal.
$ socat -d -d - TCP4:httpbin.org:80
2021/04/02 15:12:43 socat[22364] N reading from and writing to stdio
2021/04/02 15:12:43 socat[22364]...
0
votes
1
answer
241
views
scrape docker metrics from inside container
I am trying to scrape docker metrics from inside a container. I have seen the creator of Prometheus doing it this way see video here. I am not able to reproduce it.
Configuration
I have exposed docker ...
0
votes
1
answer
557
views
socat fork makes netcat to hang
I observe a behavior with socat that I had not seen before.
I run socat in a terminal with the command (under Debian 10)
# socat tcp-listen:8888,reuseaddr,fork exec:"whoami"
and connect to ...
0
votes
1
answer
998
views
Port-forwarding to a local domain using socat
I'm trying to setup port forwarding from localhost to a local server using socat. The server is available via http://my-local-domain.
Here is what I tried:
socat -d -d tcp-listen:8081,reuseaddr,fork ...
0
votes
0
answers
359
views
How to configure a proxy with socat that listens for MQTT connections
I'm trying to capture MQTT traffic between a client and a subscriber, and I want intercept this traffic using socat. I know that my broker is running on port 1883 of my localhost, so what I do after ...
0
votes
0
answers
222
views
How to forward traffic between clients using socat?
Suppose socat listens on TCP:8888. Client A and Client B both connects to it. What command should I use to forward traffic sent by Client A to Client B, and Client B to Client A? I know socat TCP4-...
1
vote
1
answer
203
views
Get the remote bash shell to use a .bash_history file that is on my local machine
My environment contains clusters with multiple hosts in each cluster and as such I tend to run similar or equivalent commands on the hosts in such a cluster.
Sometimes, I am ssh-ed into a cluster host ...
2
votes
2
answers
493
views
Baud rate simulation
I need to create a null modem simulation to test various pieces of software. I've been using socat to do this:
socat -d -d pty,raw,echo=0 pty,raw,echo=0 &
But I also need to simulate the basic ...