Advertisement
Guest User

Untitled

a guest
Jun 15th, 2017
545
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.48 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. #requires scrot and xclip
  4. #improvements to my email addy below
  5.  
  6. import socket, os
  7. from hashlib import md5
  8.  
  9. #Some config
  10. username = 'barney.gale@gmail.com'
  11. password = ''
  12. cmd = 'scrot /tmp/tinyshot.png && cat /tmp/tinyshot.png'
  13.  
  14. #Requests
  15. req1="""POST /go/upload HTTP/1.1
  16. Content-Type: multipart/form-data; boundary=0xKhTmLbOuNdArY
  17. Host: tinygrab.com
  18. Content-Length: {0}
  19. Expect: 100-continue
  20.  
  21. """
  22. req2="""--0xKhTmLbOuNdArY
  23. Content-Disposition: form-data; name="user"
  24.  
  25. {0}
  26. --0xKhTmLbOuNdArY
  27. Content-Disposition: form-data; name="contentshash"
  28.  
  29. {1}
  30. --0xKhTmLbOuNdArY
  31. Content-Disposition: form-data; name="img"; filename="windows_screenshot.png"
  32. Content-Type: image/png
  33.  
  34. {2}
  35. --0xKhTmLbOuNdArY
  36.  
  37. """
  38.  
  39. #Take a screenshot, make a hash, format requests
  40. data=os.popen(cmd).read()
  41. md5 = md5(md5(password).hexdigest()+data).hexdigest()
  42. req2 = req2.format(username, md5, data)
  43. req1 = req1.format(str(len(req2)))
  44.  
  45. #Set up socket
  46. c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  47. c.connect(('tinygrab.com', 80))
  48. p = c.makefile('r', 0)
  49.  
  50. #Write first request
  51. p.write(req1)
  52. if p.readline() != "HTTP/1.1 100 Continue\r\n":
  53.     raise Exception, "TinyGrab server won't let us continue"
  54.  
  55. #Write second request
  56. p.write(req2)
  57.  
  58. #Get past cruft
  59. p.readline()
  60. while p.readline() != "\r\n":
  61.     continue
  62. p.readline()
  63.  
  64. #Save to clipboard
  65. l = p.readline().rstrip()
  66. if not l.startswith('http'):
  67.     raise Exception, l
  68. os.popen('xclip -sel clip', 'wb').write(l)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement