I have a threaded c/c++ application that gives a pty reverse shell installed on multiple linux clients they all connect back to same server/port
now I need to find a reliable method to interact with a specific host so I can for example bash script/alias it later.

by using socat I think it should be like keep listening and wait for a specific host to select and fork and interact with it's shell and close/exit if it's not that specific host, I thought something like that would work

socat TCP-LISTEN:8080,fork SYSTEM:'[ $(hostname) != "host.d.com" ] && { exit;}',pty,stderr

but it doesn't give me any output, I tried with a simple command like

socat TCP-LISTEN:8080,fork SYSTEM:'/usr/bin/id',pty,stderr

and I get this error every time a client connects

socat[1567] E write(5, 0x7faa9c802c00, 341): Input/output error

keep in mind that I get the usual shell waiting for input with this command thats working fine for the first client that connects in

socat - TCP-LISTEN:8080

I tried also with nmap's ncat --allow option ncat -lvvp 8080 --keep-open --max-conns 1 --allow some ip/host but unfortunately I can't use it cause hosts are nated under same IP

So is there any solution to this problem that would allow me to manage/select/interact with multiple reverse client shells without having to use diffrent port for each client also I'm keeping it plain for testing but I need it to work over SSL thats why I'm trying with socat and ncat

I've seen some python projects on github but they are all buggy and weak

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.