Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make cross compatible server #1

Open
techgaun opened this issue Jul 17, 2015 · 1 comment
Open

Make cross compatible server #1

techgaun opened this issue Jul 17, 2015 · 1 comment

Comments

@techgaun
Copy link
Owner

The server can be made cross-compatible. Currently, only the netcat variants with -e are supported.
From netcat-openbsd package's manpage:
There is no -c or -e option in this netcat, but you still can execute a command after connection being established by redirecting file descriptors. Be cautious here because opening a port and let anyone connected execute arbitrary command on your site is DANGEROUS. If you really need to do this, here is an example:

On ‘server’ side:

       $ rm -f /tmp/f; mkfifo /tmp/f
       $ cat /tmp/f | /bin/sh -i 2>&1 | nc -l 127.0.0.1 1234 > /tmp/f

On ‘client’ side:

       $ nc host.example.com 1234
       $ (shell prompt from host.example.com)

By doing this, you create a fifo at /tmp/f and make nc listen at port 1234 of address 127.0.0.1 on ‘server’ side, when a ‘client’ establishes a connection successfully to that port, /bin/sh gets executed on ‘server’ side and the shell prompt is given to ‘client’ side.

When connection is terminated, nc quits as well. Use -k if you want it keep listening, but if the command quits this option won't restart it or keep nc running. Also don't forget to remove the file descriptor once you don't need it anymore:

       $ rm -f /tmp/f
@techgaun
Copy link
Owner Author

With some free time, I attempted to port to nc.openbsd but I believe its due to my limited knowledge that I've not been able to port it properly. Currently, support for nc.openbsd is not able to write the command output back to the client. Unfortunately, I didn't have enough time to dig more. PRs/suggestions/advices are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant