How to Use Netcat for Windows to Send a Binary File to a Tcp Connection

How to use NetCat for Windows to send a binary file to a TCP connection?

I found the solution. Its

nc 127.0.0.1 1200 < binary.bin

In addition, if the response needs to be saved then

nc 127.0.0.1 1200 < binary.bin > response.bin

How to send a file using netcat and then keep the connection alive?

Perhaps you were doing:

cat MY_FILE - | ncat ...

(Note that I've intentionally mispelled netcat, because I believe ncat is a superior program.)

Free tool to send binary data to IP address and port?

I found a freeware tool named TCP/IP Builder.

But if you found a better free tool, please let me know.

Send a binary file (line by line) to a socket server with Netcat

After a lot of trying and pulling my hair I finally figured out that I could use NCat instead of Netcat as NCat can execute a command.

Start a connection with NCat to my socket server on port 5000 and execute the script ./sendlines.sh:

ncat --exec "./sendlines.sh" 192.168.1.10 5000

./sendlines.sh will send 4 lines with a delay of two seconds between each line:

#!/bin/bash
#
# sendlines.sh, v1.00, initial release
#
i="0"
while [ $i -lt 4 ]
do
echo -ne "\x00e\x00\x0000370513,6598,no,8,,2z\x00"
sleep 2
i=$[$i+1]
done

I have not figured out how to send a binary file, line by line, but this is not strictly necessary as I can manage by sending the same string many times.

If you know a way to send a binary file, line by line, it would be great as it would be the best solution for me.

Powershell TCP Send Entire File

Client

$test=[System.Convert]::ToBase64String([io.file]::ReadAllBytes("c:\test"));
$socket = New-Object net.sockets.tcpclient('172.26.4.26',8080);
$stream = $socket.GetStream();
$writer = new-object System.IO.StreamWriter($stream);
$buffer = new-object System.Byte[] 1024;
$writer.WriteLine($test);
$socket.close()

Server

#!/usr/bin/env ruby
require 'socket'
require 'base64'
begin
server = TCPServer.open(8080)
client = server.accept
out_put = client.gets()
File.open("test","w") {|f| f.write(Base64.decode64(out_put))}
end


Related Topics



Leave a reply



Submit