-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathis_wp.py
executable file
·55 lines (49 loc) · 1.71 KB
/
is_wp.py
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
#!/usr/bin/env python3
import requests
import argparse
import sys
def is_wp(domain):
if not domain.startswith('http'):
domain = 'http://' + domain + '/'
try:
r = requests.get(domain + '/wp-login.php')
if r.status_code == 200:
return True
else:
return False
except requests.exceptions.ConnectionError:
return False
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Check if a website is done with WordPress')
subparsers = parser.add_subparsers(help='Subcommand')
parser_a = subparsers.add_parser('domain', help='Information on a domain')
parser_a.add_argument('DOMAIN', help='Domain')
parser_a.set_defaults(subcommand='domain')
parser_b = subparsers.add_parser('file', help='List of domains')
parser_b.add_argument('FILE', help='File path')
parser_b.set_defaults(subcommand='file')
args = parser.parse_args()
if 'subcommand' in args:
if args.subcommand == 'domain':
if is_wp(args.DOMAIN):
print('Definively a Wordpress website')
else:
print('NOPE')
elif args.subcommand == 'file':
try:
with open(args.FILE) as f:
data = f.read().split('\n')
except FileNotFoundError:
print('File does not exist')
sys.exit(1)
for d in data:
if d.strip() == '':
continue
if is_wp(d.strip()):
print('%s;Yes' % d.strip())
else:
print('%s;No' % d.strip())
else:
parser.print_help()
else:
parser.print_help()