Reputation: 3
When a TCP connection is established to the server, it prompts a question and waits for an answer for 3 seconds in while loop and then terminates. I need to send contents of the file to the server as a response to a prompt - so I would want to put them on the stdin.
I absolutely must wait, server first needs to ask a question and then I need to send result from a file back.
Is there a way to accomplish this task with pipes and netcat or something similar? Or do I have to adjust some basic tcp client program for my needs?
Edit Background: For a university assignment I need to overflow the buffer to get access to the server. I have constructed a string that does that successfully for the precompiled binary now I need to send that to the server. Simple copy paste wouldn't work since my string contains unprintable characters or characters that if encoded result in different hex values.
Edit Logfile for cat file | nc host port
Upvotes: 0
Views: 109
Reputation: 20718
You cannot do that with a simple shell pipe, as the flow through pipes is unidirectional. You can build loops with pipes, but not in a single command, and at that point, I’d just go for a simple TCP client application written in a programming language of your liking.
Upvotes: 0
Reputation: 1082
If I understand you want transfer one file from client to server throw netcast.
So in the server side you can do: nc -l 3333 > myfile.txt
and in the client side cat myfile.txt | nc localhost 3333
But I don't understand when you say "When a TCP connection is established to the server" actually it means nothing.
Upvotes: 1