# == Synopsis # semtex00.rb -- solution in ruby to level 00 of the Semtex Wargame # located at http://www.pulltheplug.org # # Connect to port 24000 and receive data until the port is closed. # Every second byte you receive is trash, ignore it. # The other bytes are an elf executable that shows you the password. # # Then login to semtex1@semtex.labs.pulltheplug.org # # == Usage # ruby semtex00.rb [ -h | --help ] [ -v | --version ] # # == Author # Beau Grantham # beau@thedarkmere.net # # == Version # 0x2 2006/05/03 require 'socket' require 'rdoc/usage' require 'optparse' # RDoc opts = OptionParser.new opts.on("-h", "--help") { RDoc::usage } opts.on("-v", "--version") { RDoc::usage('version') } opts.parse(ARGV) rescue RDoc::usage('usage') server = "69.55.233.83" port = "24000" outFile = "semtex00" i = 0 # Open file writeTo = File.open(outFile, "w") # Connect socket print "Connecting to #{server}:#{port}... " sock = TCPSocket.new(server, port) puts "Success!" # Read and write every other byte print "Reading data... " while (byte = sock.read(1)) writeTo.print byte if ((i += 1)%2 != 0) end # Close file writeTo.close puts (i).to_s + " bytes read." puts "Write to file successful." puts "Run 'chmod +x #{outFile} && ./#{outFile}'"