huuck / ADBHoney

Low interaction honeypot designed for Android Debug Bridge over TCP/IP
GNU General Public License v3.0
160 stars 33 forks source link

Non-Linux support? #15

Closed bontchev closed 5 years ago

bontchev commented 5 years ago

Currently the honeypot runs only on Linux. This is because the socket attributes TCP_KEEPIDLE, TCP_KEEPINTVL, and TCP_KEEPCNT are defined only there. They are not defined on Windows and, AFAIK, aren't defined in OS X, either. I am not familiar with socket programming, but how important are they?

If they are necessary, we should document that the honeypot runs only on Linux and maybe add some code that checks the OS and exits with an appropriate error message if it is not Linux. Otherwise we should modify the code so that they are used only if they are available; something like this:

    if hasattr(socket, 'TCP_KEEPIDLE'):
        s.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 1)
    elif hasattr(socket, 'TCP_KEEPALIVE'):
        s.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPALIVE, 1)
    if hasattr(socket, 'TCP_KEEPINTVL'):
        s.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, 1)
    if hasattr(socket, 'TCP_KEEPCNT'):
        s.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, 100)
bontchev commented 5 years ago

I have verified that, with the above change, the honeypot now works on Windows, so I have submitted a pull request (#18). It should also work on OS X now, but I can't test that.

bontchev commented 5 years ago

Pull request was merged, so I'm closing the issue. Still, would be nice if somebody could try the honeypot on OS X and report the result.