Created
August 21, 2019 20:48
-
-
Save Anirbansingha1/720a495cc58accda6fea2e7aa6df276d to your computer and use it in GitHub Desktop.
This will check http or https website.
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
| import urllib2,argparse,sys | |
| from threading import Thread | |
| def parse_args(): | |
| parser=argparse.ArgumentParser(description='This tool is use for checking live host. This support multithread.',epilog='python '+sys.argv[0]+' -u [url]') | |
| parser.add_argument('-u','--url',help='url to check [with/without] http/https',type=str,default=False) | |
| parser.add_argument('-l','--lists',help='file contain url',type=str,default=Flase) | |
| parser.add_argument('-t','--timeout',help='time out default =10',type=int,default=10) | |
| parser.add_argument('-T','--thread',help='thread to check default=1000',default=1000,type=int) | |
| parser.add_argument('-o','--output',help=' output to save result',type=str) | |
| return parser.parse_args() | |
| def check_http(url): | |
| if url.startswith('http'): | |
| url=url.replace('http://','') | |
| elif url.startswith('https://'): | |
| url=url.replace('https://','') | |
| else: | |
| pass | |
| return url | |
| def up_verify(url,timeout,c): | |
| url=check_http(url) | |
| try: | |
| url='https://'+url | |
| check_status=urllib2.urlopen(url,timeout=10).read().getcode() | |
| c.append(url+'------->'+check_status) | |
| except: | |
| url='http://'+url | |
| check_status=urllib2.urlopen(url,timeout=timeout).read().getcode() | |
| c.append(url+'------->'+check_status) | |
| except urllib2.URLError: | |
| pass | |
| def main(url,lists,timeout,th,output): | |
| c=[] | |
| if url: | |
| url=check_http(url) | |
| up_verify(url,timeout,c) | |
| if lists: | |
| with open(lists) as l: | |
| for url in l: | |
| for t in range(th): | |
| t=thread(target=up_verify, args=(url,timeout,c,)) | |
| t.start() | |
| t.join() | |
| output_file_open=open(output,'w') | |
| for line in c: | |
| output_file_open.write(c+'\n') | |
| output_file_open.close() | |
| args=parse_args(): | |
| url=args.url | |
| lists=args.lists | |
| timeout=args.timeout | |
| th=args.thread | |
| output=args.output | |
| if url is False or lists is False: | |
| print ('[-] Please check documentation!') | |
| exit() | |
| main(url,lists,timeout,th,output) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it's for personal may be it's wrong don't use it