Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #requires scrot and xclip
- #improvements to my email addy below
- import socket, os
- from hashlib import md5
- #Some config
- username = 'barney.gale@gmail.com'
- password = ''
- cmd = 'scrot /tmp/tinyshot.png && cat /tmp/tinyshot.png'
- #Requests
- req1="""POST /go/upload HTTP/1.1
- Content-Type: multipart/form-data; boundary=0xKhTmLbOuNdArY
- Host: tinygrab.com
- Content-Length: {0}
- Expect: 100-continue
- """
- req2="""--0xKhTmLbOuNdArY
- Content-Disposition: form-data; name="user"
- {0}
- --0xKhTmLbOuNdArY
- Content-Disposition: form-data; name="contentshash"
- {1}
- --0xKhTmLbOuNdArY
- Content-Disposition: form-data; name="img"; filename="windows_screenshot.png"
- Content-Type: image/png
- {2}
- --0xKhTmLbOuNdArY
- """
- #Take a screenshot, make a hash, format requests
- data=os.popen(cmd).read()
- md5 = md5(md5(password).hexdigest()+data).hexdigest()
- req2 = req2.format(username, md5, data)
- req1 = req1.format(str(len(req2)))
- #Set up socket
- c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- c.connect(('tinygrab.com', 80))
- p = c.makefile('r', 0)
- #Write first request
- p.write(req1)
- if p.readline() != "HTTP/1.1 100 Continue\r\n":
- raise Exception, "TinyGrab server won't let us continue"
- #Write second request
- p.write(req2)
- #Get past cruft
- p.readline()
- while p.readline() != "\r\n":
- continue
- p.readline()
- #Save to clipboard
- l = p.readline().rstrip()
- if not l.startswith('http'):
- raise Exception, l
- os.popen('xclip -sel clip', 'wb').write(l)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement