claymoreexporter_lib.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:claymore-exporter 作者: sdelrio 项目源码 文件源码
def netcat(hostname, port, content):
    """ Netcat equivalent to get data from Claymore. Normal http get doesn't works."""
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    try:
        s.connect((hostname, port))
        s.sendall(content)
        s.shutdown(socket.SHUT_WR)
        s.setblocking(0)
        fulltext = ''
        while 1:
            ready = select.select([s], [], [], timeout)
            if ready[0]:
                data = s.recv(4096)
            if data == "":
                break
            fulltext += data
    except socket.error, e:
        fulltext='{"error": true, "id": 0, "result": ["No client", "6", "0;0;0", "0;0", "0;0;0", "0;0", "0;0;0;0", "-;--", "0;0;0;0"]}'
        print "Socket error: ", e
    except IOError, e:
        fulltext='{"error": true, "id": 0, "result": ["No client", "6", "0;0;0", "0;0", "0;0;0", "0;0", "0;0;0;0", "-;--", "0;0;0;0"]}'
        print "IOError: error: ", e
    finally:
        s.close()
    return parse_response(fulltext)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号