Skip to content

Instantly share code, notes, and snippets.

@card100
Forked from ed-cooper/thumbhack.rb
Created November 16, 2016 01:47
Show Gist options
  • Select an option

  • Save card100/89feff5ffe52a031c0a359a7fffcdf26 to your computer and use it in GitHub Desktop.

Select an option

Save card100/89feff5ffe52a031c0a359a7fffcdf26 to your computer and use it in GitHub Desktop.
Scratch Animated Thumbnail Hacker
#Scratch Animated Thumbnail Hacker, by @novice27b ( https://scratch.mit.edu/users/novice27b/ )
require "socket"
require "openssl"
file = File.binread('FILE PATH TO ANIMATED GIF GOES HERE - MUST BE UNDER 1MB')
id = 'PROJECT ID GOES HERE (THE END PART OF YOUR PROJECT URL)'
sessid = 'SCRATCH SESSION ID GOES HERE - CHECK YOUR BROWSER COOKIES TO GET THIS VALUE'
socket = TCPSocket.open("scratch.mit.edu", 443)
ssl = OpenSSL::SSL::SSLSocket.new(socket)
ssl.connect()
message = "\
POST /internalapi/project/thumbnail/#{id}/set/ HTTP/1.1\r\n\
Host: scratch.mit.edu\r\n\
Cookie: scratchcsrftoken=; scratchsessionsid=#{sessid}\r\n\
Content-Length: #{file.bytesize}\r\n\r\n"
ssl.write(message)
ssl.write(file)
while ( (c = ssl.getc) != "}" )
print c
end
puts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment