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)
评论列表
文章目录