Advertisement
Guest User

Server List Ping code

a guest
Jan 24th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. from struct import pack, unpack
  2. import socket
  3. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  4. s.connect(('69.175.115.230', 25585))
  5. handshakeBytes = bytearray()
  6. handshakeBytes.append(pack('<i', 0x00))
  7. handshakeBytes.append(pack('<i', 47))
  8. handshakeBytes.append(pack('<i', len(pack('>s', '69.175.115.230'))))
  9. handshakeBytes.append(pack('>s', '69.175.115.230'))
  10. handshakeBytes.append(pack('>H', 25585))
  11. handshakeBytes.append(pack('<i', 1))
  12. bytesLength = bytearray(pack('<i', len(handshakeBytes)))
  13. handshakeBytes = bytesLength + handshakeBytes
  14. s.send(handshakeBytes)
  15. requestBytes = bytearray()
  16. requestBytes.append(pack('<i', 0x00))
  17. requestBytesLength = bytearray(pack('<i', len(requestBytes)))
  18. requestBytes = requestBytesLength + requestBytes
  19. s.send(requestBytes)
  20. recvdJson = s.recv(4096)
  21. s.close()
  22. print(unpack('>s', recvdJson))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement