Created
September 14, 2022 15:08
-
-
Save lsongdev/8c88b8de03ac928d970ebf91475b1ec3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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