0

I am trying to figure out how to manage my debian and make it to reload script in /etc/init.d if the remote, reverese connection is not responding

what I have at the moment is:

root@pwnpi:~# netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State

tcp        0    512 10.28.4.115:34233       xx.xxx.xxx.xxx:31337    ESTABLISHED

and I would like to reload script /etc/init.d/reverseshell if this connection is not ESTABLISHED or LISTEN

Can anyone help with that?

3
  • The term "reboot" is usually taken to mean the entire system. Do you mean restarting a process (through its init script) based on some criteria? Please edit as appropriate to clarify.
    – user
    Jan 16, 2015 at 12:54
  • Maybe this item on UNIX & Linux SE answers your question? Also: what's the point in rebooting your computer when a networking connection is lost? If the datacenter has a networking outage (which shouldn't occur often), your server will continually reboot. It might be better just to restart the networking services... Finally: what have you already tried? Where are you stuck? SE is not a scripting service.
    – agtoever
    Jan 16, 2015 at 13:28
  • I need to scan our internal network /12 this weekend and the solution I have (reverse shell) is failing on me every few hours.
    – Adam
    Jan 16, 2015 at 14:32

1 Answer 1

0

Make a cron for that command

lsof -i4TCP@xx.xxx.xxx.xxx:31337 -sTCP:ESTABLISHED,LISTEN >/dev/null 2>&1 || /etc/init.d/reverseshell restart

PS: don't be evil :-)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.