Questions tagged [socat]

The program socat is a relay for bidirectional data transfer between two independent data channels.

Filter by
Sorted by
Tagged with
0 votes
0 answers
12 views

socat listen on fd for systemd socket activation

When using systemd socket activation, systemd listens on the socket and passes the fd to the service. Is it possible to have socat listen on the fd and connect to some where else? I am trying to move ...
user avatar
  • 4,039
0 votes
0 answers
27 views

How to check if forwarded connection is still active in socat?

I used socat to forward request from one socket to another like sudo socat UNIX-LISTEN:/var/run/docker-userns.sock,user=000000,group=000000,mode=0600,fork UNIX-CLIENT:/var/run/docker.sock which seems ...
user avatar
  • 131
0 votes
0 answers
55 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 ...
user avatar
  • 115
1 vote
0 answers
132 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 ...
user avatar
0 votes
1 answer
58 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,...
user avatar
  • 111
1 vote
1 answer
61 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 ...
user avatar
0 votes
0 answers
53 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 ...
user avatar
0 votes
1 answer
245 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 ...
user avatar
  • 157
0 votes
0 answers
77 views

When using socat as a port forwarder is there a way detect when a connection on the forwarded end, dies?

Using socat as a simple port forwarder socat tcp-listen:8888,fork tcp:$remote_ip:8888 Is there a way for socat to kill the listener (or communicate back) whenever the connection to $remote_ip fails?
user avatar
0 votes
2 answers
234 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 ...
user avatar
  • 105
0 votes
0 answers
22 views

socat looks for a dll file extension even though it has not been specified

I have a small .net based CLI executable that I want to bind to some port, and then be able to netcat to, and then run the file. After googling for a while, I found that socat might be the preferred ...
user avatar
  • 127
1 vote
1 answer
145 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 ...
user avatar
0 votes
0 answers
41 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 --...
user avatar
  • 930
0 votes
0 answers
19 views

how to share file with socat in RW

I want to share usb dongle in my local network with socat.I managed to do this with following commands but on the client side i am not able to mount it rw it works as read-only: socat FILE:/dev/sdd1 ...
user avatar
  • 11
0 votes
1 answer
82 views

make socat constantly listen for the magic packet

I have a RPi 1b+ v1.2 with Raspbery 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....
user avatar
  • 13
0 votes
0 answers
205 views

How to use socat to implement a proxy?

The goal: bidirectional communication while decoding the incoming rot13 data and encoding it back Theory: suppose to have a proxy/ server that listens on port 8080 which needs to handle multiple ...
user avatar
  • 21
0 votes
1 answer
55 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 ...
user avatar
1 vote
1 answer
201 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 ...
user avatar
  • 21
0 votes
1 answer
429 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' ...
user avatar
  • 105
2 votes
1 answer
852 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:...
user avatar
1 vote
0 answers
311 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 ...
user avatar
  • 11
0 votes
0 answers
267 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 ...
user avatar
  • 113
0 votes
1 answer
81 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 ...
user avatar
1 vote
1 answer
102 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 ...
user avatar
  • 11
1 vote
0 answers
276 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 ...
user avatar
1 vote
0 answers
141 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-...
user avatar
0 votes
0 answers
44 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 ...
user avatar
1 vote
1 answer
193 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 ...
user avatar
  • 175
0 votes
1 answer
195 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 ...
user avatar
1 vote
0 answers
223 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:...
user avatar
0 votes
1 answer
85 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 ...
user avatar
  • 109
1 vote
0 answers
106 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:`...
user avatar
  • 941
1 vote
2 answers
1k 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 --...
user avatar
  • 121
0 votes
1 answer
418 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 ...
user avatar
  • 105
3 votes
1 answer
3k 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 "...
user avatar
  • 467
2 votes
1 answer
1k 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 ...
user avatar
  • 29.6k
0 votes
1 answer
72 views

How to execute bash commands form one bash to another bash process?

I have two bash processes running. Let's name them bash_1 and bash_2. I wish to execute command in bash_1 from bash_2. I am following this method to achieve this. Get the dev file for IO in bash_1 ...
user avatar
0 votes
1 answer
2k views

how to test multicast with socat on one machine

I'm a linux beginner and trying to test multicast with socat on Ubuntu which works. A bit "too well" actually (or I'm misunderstanding something fundamental) my network looks that (ifconfig, ...
user avatar
  • 175
1 vote
1 answer
90 views

udevadm doesn't die if parent process experiences an error

I need to redirect output from udevadm monitor to a named pipe. For that end I use the following command: sudo socat -u SYSTEM:"udevadm monitor" PIPE:/tmp/test & It works until a process reading ...
user avatar
2 votes
1 answer
337 views

Cannot access haproxy stats socket with systemd

I am trying to disable a haproxy frontend from a systemd service in Debian 9 (haproxy 1.7.5-2). The default config sets up admin access via a unix socket at /run/haproxy/admin.sock so I use socat (1....
user avatar
2 votes
0 answers
79 views

Keyboard input to a serial console redirected to telnet

I'm trying to install a Cisco Nexus 9000v VM on VMWare Workstation on a Linux machine. That's how far I got: After importing the .ova file I set up a serial console in the VM settings whereby I chose ...
user avatar
1 vote
0 answers
181 views

Make sslh or nginx listen to serial port, to get VPN or HTTP(S) or SSH over serial port (real, emulated and/or virtual)

I would like to make more services than serial-console-login available via serial-port. In essence, I want to make a traditionally network-listening service (with strong encryption/authentication) of ...
user avatar
0 votes
0 answers
53 views

Order and spaces in shell command using std input/output redirections

Sorry I didn't use shell scripts for a while. In tutorial "How to run Openthread border router" steps provided: Set up a bidirectional data stream with socat socat -d -d pty,raw,echo=0 pty,raw,...
user avatar
0 votes
0 answers
861 views

Link character device to pty with socat

I have a "regular character device" - not sure of the proper naming - that doesn't support ioctl on an embedded device (/dev/appvcom). I need to connect to it with an application that uses some ioctl ...
user avatar
  • 101
2 votes
0 answers
447 views

How can I run socat so it terminate after child exits

I want to run the minecraft server.jar with an attached tcp socket, so I use: socat EXEC:"java -jar server.jar nogui" TCP-LISTEN:25567,fork I can connect (and disconnect) to the server without any ...
user avatar
  • 173
0 votes
1 answer
1k views

socat - multiple connection attempts fail to pass through serial

I'm using socat to route serial input over a network to allow me to control an Arduino device over a virtual COM port setup. My command to start socat is: socat /dev/serial0,b500000,raw,echo=0 TCP-...
user avatar
0 votes
1 answer
561 views

Sed with port forwarding in socat?

Not sure if this belongs on here, StackOverflow, or SuperUser. I have a device running a reverse telnet server that I need to be able to send/receive data to. I'm able to play with it if I run socat ...
user avatar
  • 103
2 votes
1 answer
608 views

How to resume a file transfer using netcat or socat or curl?

I have to transfer a 400Gb database consisting of a single file over the Internet from a server where I have full control to an other computer at the opposite border of the ocean (but which uses a ...
user avatar
0 votes
1 answer
236 views

How to only run a command in .bash_profile if its not already running?

Goal: Run socat only once. I'm trying to expose docker web services via TCP. On macOS/linux these services are bound to a unix socket. The following command accomplishes the task: socat -d TCP-...
user avatar
  • 103
0 votes
0 answers
263 views

How to get a Serial Connection through a Reverse SSH Tunnel

I have a project where I have a Serial port on one computer and not on the other. I need to provide a virtual serial port that is connected to TCP on the computer without a physical serial port. I ...
user avatar