Like the title saying.
I have a C program and I compile it to an ELF by using gcc.
Now I want to run this ELF up and using netcat to proxy it.
Let client can netcat to service then send message and get response
I run the command below
nc -lp 8763 -e ./test
then shell tell me that natcat
do not have -e option
❯ nc -e
nc: invalid option -- 'e'
usage: nc [-46CDdFhklNnrStUuvZz] [-I length] [-i interval] [-M ttl]
[-m minttl] [-O length] [-P proxy_username] [-p source_port]
[-q seconds] [-s sourceaddr] [-T keyword] [-V rtable] [-W recvlimit]
[-w timeout] [-X proxy_protocol] [-x proxy_address[:port]]
[destination] [port]
So I trying socat
.
socat tcp4-l:8763 exec:./test
The service run, but when I connect the service from client.
Server cannot get the message sent by client.
The only way I've tried to succeed is running the command below.
socat - tcp4-l:8763 | ./test
But it can only recieve message from client, cannot response and message to client.
Does someone know why, or how can I make a netcat server like CTF.
Here is my C program
// test.c
#include <stdio.h>
int main(void){
int n;
while (scanf("%d", &n) != EOF){
if (n == 1) {
printf("Only one\n");
} else {
printf("%d\n", n);
}
}
return 0;
}
then compile it with
gcc -o test test.c