-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdrupal.py
36 lines (30 loc) · 1007 Bytes
/
drupal.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
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
class Drupal:
def __init__(self):
self.required = 'Log out'
def parse(self, text, user, passw):
try:
a = BeautifulSoup(text, features="html.parser")
b = a.find('input', {'name': 'form_build_id'})['value']
c = a.find('input', {'name': 'form_id'})['value']
d = a.find('input', {'name': 'op'})['value']
params = {
'name': user,
'pass': passw,
'form_build_id': b,
'form_id': c,
'op': d
}
return params
except:
return
def valid(self, status, text):
if 'IP address has been blocked' in text or status == 403:
return False
elif 'form_build_id' not in text:
return False
elif '"captcha' in text:
return False
else:
return True