Skip to content

Instantly share code, notes, and snippets.

@HJulio
Created January 29, 2016 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HJulio/ddbf4bd4b42db39cf5ba to your computer and use it in GitHub Desktop.
Save HJulio/ddbf4bd4b42db39cf5ba to your computer and use it in GitHub Desktop.
knock knock
import os
import sys
import io
import socket
import time
import struct
TIMEOUT = 10
PORT = "5900"
filename = time.strftime("%d-%m-%Y-%H:%M:%S")
def test(ip, f):
try:
s = socket.create_connection((ip, PORT), TIMEOUT)
version = s.recv(1024)
s.send(version)
auth = s.recv(1024)
for i in range(0, len(auth)):
if struct.unpack('B', auth[i])[0] == 1:
print "NO AUTH"
f.write(ip+'\n')
except:
pass
def main():
f = open(filename + ".txt", "a")
with open(sys.argv[1]) as rf:
for line in rf:
test(line.strip(), f)
f.close()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment