Advertisement
Guest User

Untitled

a guest
Feb 5th, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.70 KB | None | 0 0
  1. from selenium import webdriver
  2. from selenium.webdriver.common.by import By
  3. from selenium.webdriver.support.ui import WebDriverWait
  4. from selenium.webdriver.support import expected_conditions as EC
  5. from selenium.webdriver.support.ui import Select
  6. from selenium.common.exceptions import NoSuchElementException
  7. from selenium.webdriver.support.wait import WebDriverWait
  8. import requests
  9. from bs4 import BeautifulSoup
  10. import string
  11. import re
  12. import requests
  13. import sys
  14. import time
  15. import random
  16.  
  17. def func1():
  18.  
  19. # usernameStr = raw_input("Username: ")
  20. # passwordStr = raw_input("Password: ")
  21. ch1 = ['country:"GB"', 'country:"US"', 'country:"CA"', 'country:"AU"', 'country:"NZ"']
  22. ch2 = [' kerio']
  23. ch1 = random.choice(ch1)
  24. ch2 = random.choice(ch2)
  25. usernameStr = 'stupidcatface'
  26. passwordStr = 'likewhatthefuck2'
  27. browser = webdriver.Chrome('/home/catface/Desktop/chrome/chromedriver')
  28. browser.get(('https://account.shodan.io/login'))
  29.  
  30. username = browser.find_element_by_name('bofh')
  31. username.send_keys(usernameStr)
  32. password = browser.find_element_by_name('isgay')
  33. password.send_keys(passwordStr)
  34.  
  35. nextButton = browser.find_element_by_name('login_submit')
  36. nextButton.click()
  37.  
  38. #searchStr = ('vuln:cve-2014-0160' ,ch1,ch2,ch3')
  39.  
  40. searchStr = ('vuln:cve-2014-0160 ' , str(ch1), str(ch2))
  41. srch = browser.find_element_by_id('search_input')
  42. srch.send_keys(searchStr)
  43. srch.submit()
  44. source = browser.page_source
  45. soup = BeautifulSoup(source, 'html5lib')
  46. soup = re.findall(r'[0-9]+(?:\.[0-9]+){3}:\d{1,5}', str(soup), flags=re.MULTILINE)
  47. soup = re.sub(r'[\']', "", str(soup), flags=re.MULTILINE)
  48. soup = re.sub(r'[\,]',"", str(soup), flags=re.MULTILINE)
  49. soup = re.sub(r'[\ ]',"\n", str(soup), flags=re.MULTILINE)
  50. soup = re.sub(r'\[|\]',"", str(soup), flags=re.MULTILINE)
  51. #soup = re.sub(r'\:',' -p ', str(soup), flags=re.MULTILINE)
  52. print soup
  53.  
  54. ###########################################################################
  55. #nextpage = browser.find_element_by_link_text("Next")
  56. # if browser.is_element_present_by_xpath(By.LINK, contains(text(),"Next")):
  57. nextpage = browser.is_element_present(By.LINK_TEXT, "Next")
  58.  
  59. if nextpage.is_displayed():
  60. print("Element Found")
  61. nextpage.click()
  62. else:
  63. nextpage.is_not_displayed()
  64. browser.quit()
  65. # else:
  66. # browser.quit()
  67.  
  68. ################################################################################
  69.  
  70. page2 = browser.find_element_by_link_text("Next")
  71. page2.click()
  72.  
  73. soup = BeautifulSoup(source, 'html5lib')
  74. soup = re.findall(r'[0-9]+(?:\.[0-9]+){3}:\d{1,5}', str(soup), flags=re.MULTILINE)
  75. soup = re.sub(r'[\']', "", str(soup), flags=re.MULTILINE)
  76. soup = re.sub(r'[\,]',"", str(soup), flags=re.MULTILINE)
  77. soup = re.sub(r'[\ ]',"\n", str(soup), flags=re.MULTILINE)
  78. soup = re.sub(r'\[|\]',"", str(soup), flags=re.MULTILINE)
  79. #soup = re.sub(r'\:',' -p ', str(soup), flags=re.MULTILINE)
  80. print soup
  81.  
  82. page3 = browser.find_element_by_link_text("Next")
  83. page3.click()
  84.  
  85. soup = BeautifulSoup(source, 'html5lib')
  86. soup = re.findall(r'[0-9]+(?:\.[0-9]+){3}:\d{1,5}', str(soup), flags=re.MULTILINE)
  87. soup = re.sub(r'[\']', "", str(soup), flags=re.MULTILINE)
  88. soup = re.sub(r'[\,]',"", str(soup), flags=re.MULTILINE)
  89. soup = re.sub(r'[\ ]',"\n", str(soup), flags=re.MULTILINE)
  90. soup = re.sub(r'\[|\]',"", str(soup), flags=re.MULTILINE)
  91. #soup = re.sub(r'\:',' -p ', str(soup), flags=re.MULTILINE)
  92. print soup
  93.  
  94. page4 = browser.find_element_by_link_text("Next")
  95. page4.click()
  96.  
  97. soup = BeautifulSoup(source, 'html5lib')
  98. soup = re.findall(r'[0-9]+(?:\.[0-9]+){3}:\d{1,5}', str(soup), flags=re.MULTILINE)
  99. soup = re.sub(r'[\']', "", str(soup), flags=re.MULTILINE)
  100. soup = re.sub(r'[\,]',"", str(soup), flags=re.MULTILINE)
  101. soup = re.sub(r'[\ ]',"\n", str(soup), flags=re.MULTILINE)
  102. soup = re.sub(r'\[|\]',"", str(soup), flags=re.MULTILINE)
  103. #soup = re.sub(r'\:',' -p ', str(soup), flags=re.MULTILINE)
  104. print soup
  105.  
  106. page5 = browser.find_element_by_link_text("Next")
  107. page5.click()
  108.  
  109. soup = BeautifulSoup(source, 'html5lib')
  110. soup = re.findall(r'[0-9]+(?:\.[0-9]+){3}:\d{1,5}', str(soup), flags=re.MULTILINE)
  111. soup = re.sub(r'[\']', "", str(soup), flags=re.MULTILINE)
  112. soup = re.sub(r'[\,]',"", str(soup), flags=re.MULTILINE)
  113. soup = re.sub(r'[\ ]',"\n", str(soup), flags=re.MULTILINE)
  114. soup = re.sub(r'\[|\]',"", str(soup), flags=re.MULTILINE)
  115. #soup = re.sub(r'\:',' -p ', str(soup), flags=re.MULTILINE)
  116. print soup
  117.  
  118. browser.close()
  119.  
  120. var = 1
  121. while var == 1 :
  122. func1()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement