def _login(self): username = conf.get('censys', 'username') password = conf.get('censys', 'password') def fetch_csrf_token(login_url): _res = self.sreq.get(login_url) match = re.search( r'name="csrf_token" value="(?P<csrf_token>[^">].*)"', _res.content) _csrf_token = match.group('csrf_token') if match else '' match = re.search( r'name="came_from" value= "(?P<came_from>[^">].*)"', _res.content) _came_from = match.group('came_from') if match else '' return _csrf_token, _came_from i_url = 'https://www.censys.io/login' csrf_token, came_from = fetch_csrf_token(i_url) if csrf_token and came_from: post = { 'csrf_token': csrf_token, 'came_from': came_from, 'login': username, 'password': password } self.sreq.post(i_url, data=post)
def _login(self): username = conf.get('shodan', 'username') password = conf.get('shodan', 'password') i_url = 'https://account.shodan.io/login' post = { 'username': username, 'password': password, 'grant_type': 'password', 'continue': 'https://account.shodan.io/', 'login_submit': 'Log in' } self.sreq.post(i_url, data=post)
def _login(self): username = conf.get('censys', 'username') password = conf.get('censys', 'password') def fetch_csrf_token(login_url): _res = self.sreq.get(login_url) match = re.search(r'name="csrf_token" value="(?P<csrf_token>[^">].*)"', _res.content) _csrf_token = match.group('csrf_token') if match else '' match = re.search(r'name="came_from" value= "(?P<came_from>[^">].*)"', _res.content) _came_from = match.group('came_from') if match else '' return _csrf_token, _came_from i_url = 'https://www.censys.io/login' csrf_token, came_from = fetch_csrf_token(i_url) if csrf_token and came_from: post = { 'csrf_token': csrf_token, 'came_from': came_from, 'login': username, 'password': password } self.sreq.post(i_url, data=post)