Questions tagged [netcat]
Netcat is a computer networking service for reading from and writing network connections using TCP or UDP
305 questions
0
votes
2
answers
61
views
socat/netcat how to send a file and wait for server response?
I want to send a file to a TCP server, keep the TCP connection open, wait (couple of seconds) for the response, and send the response to stdout. I don't want the connection to be (half) closed ...
0
votes
3
answers
273
views
Send input from a file into a single netcat connection via a Bash script
I have tried the following to no avail, the script just stops after the first input.
filename="..."
while IFS="" read -r line; do
echo "$line" | nc <target> <...
0
votes
1
answer
728
views
Communicate with UNIX sockets opened by dbus-daemon
I'm trying to learn how to interact with message buses under Linux, and doing so with shell commands that doesn't involve utilities packaged under dbus-*. For this instance, I want to understand how ...
0
votes
1
answer
108
views
Can I use netcat to read data from a serial port?
We routinely use netcat (nc) to read data from UDP ports. For example:
user@host ~$ nc -luv 57303
Listening on [0.0.0.0] (family 0, port 57303)
NAV 2024/12/05 12:09:56.326365 DPS112 $GPZDA,121003.35,...
2
votes
1
answer
759
views
Why am I getting no output in tcpdump even though there is data being sent and received when using network namespaces?
I'm using a fresh minimal Ubuntu server 24.04.1 LTS install.
I run these commands as root to set up networking and do some experiments:
If you have seen this post, it's the same setup but with the ip ...
3
votes
2
answers
324
views
Why doesn't netcat print anything when listening in UDP mode when it can't reach the client even when the client can reach the server?
I'm using a fresh minimal Ubuntu server 24.04.1 LTS install.
I run these commands as root to set up networking and do some experiments:
apt install netcat-traditional
ip netns add ns1
ip netns add ...
1
vote
1
answer
128
views
How does netcat-openbsd work with UDP?
On a Ubuntu system I have the netcat(-openbsd) package installed, the one that, when run with no parameters, prints:
This is nc from the netcat-openbsd package. An alternative nc is available
in the ...
0
votes
3
answers
143
views
Sending to linux serial tty from embedded system too fast
I use an embedded computer to send data to a Linux serial port for transfer to a remote server. The terminal mode is "none". After my embedded system logs in, it sends data for example,
...
0
votes
0
answers
118
views
Check if a port is blocked with socat
How to check if a port is blocked with socat?
How to check with IPv6?
I heard a saying that machines behind NAT can still be directly connected via IPv6, is that true?
Anyway, say I have a machine ...
3
votes
1
answer
668
views
Piping live sound from raspberry pi to macOS
I want to pipe and live play the sound recorded on my raspberry to my MacBook. I've tried the following:
On My raspberry:
I tried to establish a data stream on a port 3333
arecord -D plughw:3,0 -f ...
0
votes
1
answer
243
views
websocat command argument equivalent for this nginx custom configuration?
I have this nginx custom configuration:
server {
listen 8080;
server_name subdomain.domain.my.id;
location /vless-ws { # Consistent with the path of V2Ray configuration
if ($...
-1
votes
2
answers
188
views
How I could check connectivity in shell using an oneliner command without using netcat?
In a docker image I want to avoid installing netcat in order to ping for db connectivity at my entrypoint script:
/bin/sh
MOODLE_DB_HOST="xxxx"
MOODLE_DB_PORT=80
function pingdb {
OK=0
...
0
votes
0
answers
230
views
Using netcat stty not giving complete tty shell when doing CTRL+Z
I'm using netcat and stty to get terminal (tty) access, but I'm not able to do so as the CTRL+Z action on the netcat session is giving me suspended session instead of stopped and then I'm not able to ...
0
votes
0
answers
46
views
Strange incongruent output for both nc and fifo
I have this exact code:
#!/bin/bash
gtimeout(){
if type -f gtimeout &> /dev/null; then
command gtimeout "$@"
else
timeout "$@"
fi
}
export -f gtimeout;
...
0
votes
1
answer
546
views
busybox nc server cannot accept new connection once the old one dropped out
BusyBox v1.36.1 (2023-07-17 18:29:09 UTC) multi-call binary.
I run minimal nc server like:
nc -lkp 12345
I can connect to it once nc localhost 12345. After ctr-C, the next attempt will fail.
however ...
1
vote
1
answer
284
views
Can nc send message from client to server on a udp port?
Both client and server are Debian 11
On Server as root:
nc -ulp 1194
On Client as root:
nc -u serverip 1194
When I type something on client, in theory it should appear on the server right if no ...
1
vote
2
answers
450
views
How to pass a bash variable (list of numeric data) to gnuplot *without using a file*
I am using netcat to get a series of points which I would like to plot with gnuplot. However, I am having trouble passing the data to gnuplot without writing it to a file first.
In the simplest case, ...
0
votes
0
answers
122
views
netcat redirects stderr to stdout then variable losing newlines [duplicate]
I am working on a script to parse a file containing a list of IP addresses and ports then do a bunch of test on the ports with netcat. The port argument can be a single port, a list of ports, or a ...
0
votes
0
answers
174
views
MD5 Hash modified trought netcat
I used dd to create a sample empty file with 1MB, edited the sample file, created a MD5 hash of the file, started a listener on the examiner machine, piped the output off to nc and compared the hashes....
0
votes
1
answer
487
views
Can I relay the data received from Netcat to a URL as a POST?
I have a PHP-based website, and I'm trying to integrate it with another system.
This system sends XML data to a specific port (let's say port 9999). I am able to capture the incoming data and save it ...
1
vote
1
answer
1k
views
send (alsa) audio via network via UDP
This to my understanding records mono in wav format for 300 seconds to a named pipe called "mic_rec"
rec arecord -D hw:4,0 -d 300 -f cd -t wav -c 1 mic_rec
And this sends whatever it finds ...
10
votes
1
answer
5k
views
Discrepancies in netcat installation process between debian bullseye vs debian bookworm-slim
In debian:bullseye
oot@4770c7ba00ac:/# apt install -y netcat
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be ...
0
votes
0
answers
52
views
Netcat uploads hanging after a certain point
I'm working through an introductory cybersec challenge that requires me to upload a word and brute force a 4 digit code to a port. I put the combinations in a file, and tried to use netcat to upload ...
1
vote
1
answer
277
views
How to pipe terminal interaction with running process over network?
How can I run a program that expects to be executing in a terminal in such a way that it's STDIO can be arbitrarily connected-to remotely?
Specifically, I want to be able to launch gdb on one host and ...
2
votes
1
answer
2k
views
Can i trust echo result of nc command for UDP?
Context :
I want to test UDP port with nc command
What happens :
nc command return nothing on output and 0 when i put echo $?
Which command :
nc -vzu <ip> <port>
echo $?
What is the ...
2
votes
1
answer
1k
views
ipv6 multicast fails when it should loop back to self
So far I use multicast with ipv4 and it works; all involved computers run linux. I listen on two machines and send on one of those two (in a separate terminal). In the below example 'Hello 1' is ...
2
votes
1
answer
2k
views
Usage of named pipe as data source for netcat
I want to use netcat as a TCP-server that reads data from a named pipe. For that I did the following:
Step 1. Created a pipe and the server that uses it as a source
mkfifo /tmp/all.pipe
nc -k -l 8080 &...
0
votes
1
answer
617
views
netcat forwarding and listening
I am listening on a port for logs coming from a device, then I used netcat to redirect those logs to a text file whenever a log is available on the device and all this to happen in the background ...
3
votes
1
answer
209
views
Unable to get output from netconsole
nc -l -u 6666 on the receiving machine gets no messages from netconsole.
tested by doing "echo test > /dev/kmsg"
i am able to connect with netcat by doing "nc -u 10.0.0.192 6666"...
0
votes
0
answers
119
views
finger daemon / nc fowarding error
For an assignment I'm trying to properly send a buffer overflow exploit with ncat in order gain root access on a vulnerable machine set up by the professor. I feel I created my egg right but I keep ...
0
votes
0
answers
298
views
How can I write a command into a subprocess?
Currently, I am working on a project where I use telnet to netcat to send an email message within my university.
I am trying to make the process automated but my script can't seem to enter in any ...
0
votes
1
answer
2k
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 ...
0
votes
0
answers
73
views
why does Netcat show output in the wrong order?
I am using netcat to run a file over a network like so
nc -lvnp 1111 -e file
on the client machine, the connection is empty and I only get an output after I enter an input.
How to show the output of ...
1
vote
1
answer
549
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
1
answer
104
views
Bash script to open a port when traffice is being recieved
I have 2 Ubuntu boxes one of them acting as an Attack platform (we will call it AP), the other as an already compromised server (we will call it S1).
I have this rule
sudo iptables -t nat -I ...
1
vote
1
answer
629
views
Is it possible to create a ncat loop?
If you had two computers, wanting to control one from another using only ncat, without using telnet, ssh or other networking tools and only two shells, how could i go about that?
I have successfully ...
0
votes
1
answer
8k
views
"Connection refused" when I try to send a UDP packet with netcat on an embedded-linux board
I'm trying to send a binary packet to a local process, via netcat (nc), like this:
nc -w 1 -u localhost 10000 < my_binary_packet.bin
The output is:
read(net): Connection refused
Anyone know what'...
1
vote
0
answers
4k
views
netcat command not working
Any idea why nc command is not working and telnet is working.
Ideally nc will also work. I am trying to use nc in script but getting error however telnet is working. Ideally nc command is working for ...
1
vote
0
answers
484
views
How to pass IP address to netcat as variable in bash scripting?
I have this script on a Linux machine that loops through a .txt file to see if connection is successful or not. When I give the IP directly is works. However, when I pass the variable it says: nc: ...
0
votes
0
answers
286
views
Exporting Python's script errors/traceback to file with netcat
I have a Python script accessible with netcat: nc 'serverIP' port.
The Python script awaits an input from the user. If the input is expected, the script keeps running. If the input is unexpect (e.g. ...
2
votes
1
answer
2k
views
How can I connect to a specfic Ethernet interface using netcat
I am trying to use netcat to echo some data to a custom board I have. The board is connected using a 10G Ethernet connection. I can see that the link is up but when I try using netcat I am not getting ...
0
votes
1
answer
763
views
Basic webserver supporting post+get (using curl and netcat)
Sorry if the question's title isn't clear about the objective of this question.
I was able to make a respond-only webserver using Bash only; when it gets a curl post request, it returns results no ...
0
votes
2
answers
1k
views
netcat in systemd service resets
I am using netcat to connect to a server over TCP and continuously pipe the data received to file.
nc 10.0.2.2 3456 > file.data
When running this from terminal or a script it stays connected
I want ...
1
vote
0
answers
2k
views
nc -lvnp (port) Non-responsive w/ PHP Reverse Shell til closed
I am currently working on Machine's on HackTheBox. I've used nc -lvnp (port) quite a bit and i've never ran into this issue:
$nc -lvnp 4444
listening on [any] 4444 ....
connect to [my IP] from (...
0
votes
1
answer
3k
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 ...
4
votes
1
answer
1k
views
'netcat' not working as expected on Arch, but works on openSUSE Tumbleweed? What's going on?
I'm having a bit of trouble utilising netcat on Arch, specifically, the GNU version of it.
My situation: I basically made a simple server in Python that can accept multiple clients and send responses. ...
1
vote
1
answer
620
views
How to "talk" to a "parent" IP in a subnet?
I have access to just *nix systems. Either NetBSD and/or bare Linux-based OS.
So my question comes from the fact that ADB is not widely available on all platforms, if so is very hard to install or ...
4
votes
1
answer
6k
views
netcat closing connection on localhost listening end after connection attempt
Ι am nc-listening on localhost:2500
▶ nc -l 2500
_
On another terminal I am trying to connect to this listening end
▶ nc -zv localhost 2500
nc: connectx to localhost port 2500 (tcp) failed: ...
1
vote
1
answer
3k
views
netcat broadcast understanding
I'm using macOS with gnu netcat. I want to understand how can I broadcast message using netcat.
I have a netcat listening on 4555
netcat -l -p 4555 192.168.0.101
but as I attempt to send a broadcast ...
0
votes
1
answer
1k
views
Using netcat to setup a bind shell on localhost, but having issue with '-e' flag
I'm trying to do a simple exercise, where I need to set up a "server" hosting a bind shell, using netcat. On my localhost.
I'm running ubuntu 20.04
I'm following this tutorial, that has this ...