Skip to content

Instantly share code, notes, and snippets.

@postmodern
Created April 20, 2013 00:11
Show Gist options
  • Save postmodern/5424094 to your computer and use it in GitHub Desktop.
Save postmodern/5424094 to your computer and use it in GitHub Desktop.
Starter code to help you solve PlaidCTF compression 250.
#!/usr/bin/env ruby
#
# $ gem install ronin-support
# $ python compression.py &
# $ ruby compression.rb
#
require 'rubygems'
require 'ronin/formatting/binary'
require 'ronin/network/tcp'
require 'hexdump'
include Ronin::Network::TCP
messages = ["hello"]
tcp_session('localhost',4433) do |socket|
nonce = socket.recv(8)
puts "Nonce: #{nonce.hex_escape}"
messages.each do |message|
socket.send(message.length.pack(:uint),0)
socket.send(message,0)
length = socket.recv(4).unpack(:uint).first
data = socket.recv(length)
puts "Ciphertext:"
data.hexdump
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment