SHARE
TWEET

Untitled

a guest Sep 12th, 2019 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /usr/bin/env python3
  2.  
  3. from PIL import Image
  4. from pytesseract import image_to_string
  5. from bs4 import BeautifulSoup as soup
  6. import requests
  7. import base64
  8. import webbrowser
  9.  
  10. url = "http://challenge01.root-me.org/programmation/ch8/"
  11.  
  12. a = webbrowser.open(url)
  13.  
  14. s = requests.session()
  15.  
  16. html_content = s.get(url).content
  17. page = soup(html_content, "html.parser")
  18.  
  19. data_url = page.find("img")['src'] ##png img
  20. print(data_url)
  21. header, encoded = data_url.split(",", 1)
  22. data = base64.b64decode(encoded)
  23.  
  24. with open ("img.png", "wb") as f:
  25.     f.write(data)
  26.  
  27. password = image_to_string(Image.open("img.png")) # Grab the text content
  28. print(password)
  29.  
  30. # Need to post the content
  31. post_data = {'cametu': password}
  32. r = s.post(url, data=password)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top