Skip to content

Instantly share code, notes, and snippets.

@song940
Created September 14, 2022 15:08
Show Gist options
  • Save song940/8c88b8de03ac928d970ebf91475b1ec3 to your computer and use it in GitHub Desktop.
Save song940/8c88b8de03ac928d970ebf91475b1ec3 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from socket import *
import threading
lock = threading.Lock()
openNum = 0
threads = []
def portScanner(host,port):
global openNum
try:
s = socket(AF_INET,SOCK_STREAM)
s.connect((host,port))
lock.acquire()
openNum+=1
print('[+] %d open' % port)
lock.release()
s.close()
except:
pass
def main():
setdefaulttimeout(1)
for p in range(1,65535):
t = threading.Thread(target=portScanner,args=('lsong.me',p))
threads.append(t)
t.start()
for t in threads:
t.join()
print('[*] The scan is complete!')
print('[*] A total of %d open port ' % (openNum))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment