netcat | NetCat for Windows | Security Testing library
kandi X-RAY | netcat Summary
kandi X-RAY | netcat Summary
NetCat for Windows
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of netcat
netcat Key Features
netcat Examples and Code Snippets
Community Discussions
Trending Discussions on netcat
QUESTION
I was trying to understand the iphdr struct and I don't understand what src and dest represent. For instance I have a packet sniffer that takes the packet and passes it into an iphdr struct. Running netcat with nc 127.0.0.1 7999
and nc -l 127.0.0.1 7999
I get the result 16777343 for the src and dest. Am I forgetting a conversion or something?
ANSWER
Answered 2021-Jun-10 at 16:291 * 256 * 256 * 256 + 127
is 16777343.
I think that demonstrates the needed conversion nicely.
It is close to the hexadecimal representation, just that each bytes value is then shown in decimal.
QUESTION
I tried to simplify my problem with the following setup.
- A simple netcat UDP listener on Port 1337 on my local interface (192.168.183.130)
- A simple netcat UDP client connecting to the listener on port 1337 (from 192.168.183.128)
- A very basic scapy sniffer running on 192.168.183.130
Scapy sniffer running with root privileges:
...ANSWER
Answered 2021-May-24 at 14:57I finally figured this out myself, so I am gonna leave an answer:
The problem lies in the filter of the sniffer:
QUESTION
The code below is my attempt at a minimal cross-platform echo server in C++. It does what I expect, except for a platform-dependent asymmetry in the way IP backward-compatibility is handled: on Windows, unlike the other two platforms I've tried, an IPv6 server fails to handle requests from IPv4 clients.*
To me the fact that the other platforms can do this (result #3 below) was an unexpected but very welcome win. It opens up some possibilities for me, provided I can get it to work on Windows too. So my questions are: is it expected that the same thing fails on Windows (compare results #3 and #5)? And is there something I can do with the server code to get #5 to succeed?
It breaks down as follows:
Server uses IPv4 (minimal_echo_server 8081 4
):
- client uses IPv4 address: server responds as expected
- client uses IPv6 address: connection fails** as expected
Server uses IPv6 on Ubuntu 20.04 or macOS 10.13 (./minimal_echo_server 8081 6
):
- client uses IPv4 address: server responds just fine (renders the client's IP as
::ffff:
followed by an IPv4 address) - client uses IPv6 address: server responds as expected
Server uses IPv6 on Windows 10 (.\minimal_echo_server.exe 8081 6
):
- client uses IPv4 address: connection fails**
- client uses IPv6 address: server responds as expected
* An example of what I mean by "IPv4 client" might be the following netcat
call:
ANSWER
Answered 2021-May-17 at 20:05I believe the problem you are running into is that under Windows, the IPV6_V6ONLY socket option is set enabled by default. In order to get dual-stack sockets (that can work over both IPv6 and IPv4) under Windows, you need to manually disable that option for each IPv6 socket you create:
QUESTION
I am using Docker Desktop for Mac.
Since version 3.3.0 and with 3.3.1 I cannot connect to altssh.gitlab.com on port 443 any more whereas 3.2.2 and earlier work.
So, these commands both work in 3.2.2 (I downgraded and verified):
...ANSWER
Answered 2021-May-14 at 14:17As of Docker 3.3.2 and newer, the bug has been fixed.
• Disable the HTTP and HTTPS transparent proxies when there is no upstream proxy set. Fixes docker/for-mac#5572.• Revert to the HTTP and HTTPS proxy implementation used in 3.2.2.
Previously...
Looks like the bug is known, though not exactly in this context.
The reason being that supposed "HTTPS" / TLS connections are dropped when they do not use SNI (server name indication), which SSH as a non-SSL/TLS protocol probably does not do.
There's already an open Docker Desktop for Mac issue:
https://github.com/docker/for-mac/issues/5568
And the linked StackOverflow question:
Cannot reach SSL IP when in docker container over bridge. Getting SSL_ERROR_SYSCALL
QUESTION
Here's my code, I'd like to focus on the call to WSARecv
and WSAGetOverlappedResult
:
ANSWER
Answered 2021-May-14 at 07:01You can't pass WSA_FLAG_OVERLAPPED
to WSARecv
. The socket itself is already either overlapped or not. If you pass 0
instead, the program notices the bytes from netcat
.
Furthermore, you cannot assume that WSARecv
will always generate the error ERROR_IO_PENDING
. The data may be available right away, in which case it will just return 0
. So you need to handle both these cases as success.
If you make the request with e.g. curl
, the data may be available right away, and the program will complain that it didn't get ERROR_IO_PENDING
, which you get when you manually type stuff into the socket with netcat
.
QUESTION
I have a script that I want to run using a dockerfile that looks like this:
...ANSWER
Answered 2021-May-05 at 13:50The /tmp
directory is generally intended for temporary file storage. It's common to mount a RAM disk (tmpfs
) there, and it's possible the Kubernetes setup does this without you noticing it.
You can address this by storing your script in a location that's on the default PATH
, like /usr/local/bin
:
QUESTION
So i have a script that sends data over a TCP connection with netcat which is working well.
What I would like to do is receive the data sent back by the server, and on a specific response, do an action.
The problem I have is that I don't know how to extract the full data package sent to me.
For example, the server sends me the following data (caught on wireshark):
...ANSWER
Answered 2021-May-05 at 13:26I would like to be able to print the full data packet 02 01 ... 00 03. Is that possible ?
For this I used the netcat -o file
option. This dumps all traffic into the specified output file.
QUESTION
I am creating an instance from a sourceImage, using this terraform template:
...ANSWER
Answered 2021-Apr-16 at 11:42I could solve it actually, and all this somewhere sounds very sick of GCE. Problem was while creating the base image, the instance I had chosen has had the following :
QUESTION
Context
I have spiked a TCP Echo server and am trying to write integration tests for it. I'm familiar with testing but not asynchronously.
Desired Behaviour
I would like my tests to spy on logs to verify that the code is being executed. Any asynchronous code should be handled properly, but this is where my understanding falls through.
Problem
I am getting asynchronous errors:
Cannot log after tests are done. Did you forget to wait for something async in your test?
Attempted to log "Server Ready".
Attempted to log "Client Connected".
And finally a warning:
A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --detectOpenHandles to find leaks.
Code
...ANSWER
Answered 2021-Apr-14 at 16:20You are not properly waiting for your child processes to finish. Calls to exec return a ChildProcess object as documented here. They execute asynchronously so you need to wait for them to finish using the event emitter api.
Ex from docs
QUESTION
I have a pcap file that I modified with tcprewrite to set source and destination IP = 127.0.0.1, while the port numbers are different. I also set both mac addresses to 00:00:00:00:00:00 as I understand that comms over localhost ignore MAC. I made sure checksum was fixed.
When I run tcpreplay -i lo test-lo.pcap
in one shell, and tcpdump -i lo -p udp port 50001
in another, I see the traffic. Yet, when I try to view the traffic with netcat -l -u 50001
, it sees nothing. Wireshark is capturing the traffic correctly.
Side note: I'm seeing the following warning when running tcpreplay on localhost:
Warning: Unsupported physical layer type 0x0304 on lo. Maybe it works, maybe it won't. See tickets #123/318
That seems worrisome.
I'm asking because my own UDP listener code is also having the same problem as netcat and thought that maybe I'm missing something. Why would traffic be seen by tcpdump and wireshark, and not by netcat?
...ANSWER
Answered 2021-Apr-08 at 20:35I'm asking because my own UDP listener code is also having the same problem as netcat and thought that maybe I'm missing something. Why would traffic be seen by tcpdump and wireshark, and not by netcat?
Look at this image of the kernel packet flow from wikipedia:
As you can see, there are different places along the path where packets can be accessed. Wireshark uses libpcap
, which uses an AF_PACKET
socket to see packets. Your UDP listener, like netcat, uses regular user-space sockets. Let's highlight both on this image. Wireshark obtains packets via the red path, netcat via the purple one:
As you can see, there is a whole sequence of steps packets have to go through in the kernel to get to a local process socket. These steps include bridging, routing, filtering etc. Which step drops your packets? I don't know. You can try tweaking the packets and maybe you'll get lucky.
If you want a more systematic approach, use a tool like dropwatch. It hooks into the kernel and shows you counters of where the kernel drops packets.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install netcat
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page