반응형
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | import socket import os import sys def retBanner(ip, port): try: socket.setdefaulttimeout(2) s = socket.socket() s.connect((ip, port)) banner = s.recv(1024) return banner except: return def checkVulns(banner, filename): f = open(filename, 'r') for line in f.readlines(): if line.strip('\n') in banner: print '[+] Server is vulnerable: ' +\ banner.strip('\n') def main(): if len(sys.argv) == 2: filename = sys.argv[1] if not os.path.isfile(filename): print '[-] ' + filename +\ ' does not exist.' exit(0) if not os.access(filename, os.R_OK): print '[-] ' + filename +\ ' access denied.' exit(0) else: print '[-] Usage: ' + str(sys.argv[0]) +\ ' <vuln filename>' exit(0) portList = [21,22,25,80,110,443] for x in range(147, 150): ip = '192.168.95.' + str(x) for port in portList: banner = retBanner(ip, port) if banner: print '[+] ' + ip + ' : ' + banner checkVulns(banner, filename) if __name__ == '__main__': main() | cs |
출처 - 해커의 언어, 치명적 파이썬
반응형
'Develope > Python' 카테고리의 다른 글
Python code to create Numeric list (0) | 2019.12.26 |
---|---|
[Python] frida 설치 및 에러 해결 (0) | 2019.01.03 |
[Python] Port Scanner (0) | 2017.01.22 |
[Python] Edit with IDLE가 안될 때 (2) | 2017.01.21 |
[Python] 내장함수 (0) | 2014.10.28 |