Skip to content

Commit

Permalink
Initial fuzzing.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Apr 18, 2020
1 parent b2e642f commit a776c78
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fuzz/request/bake.rb
@@ -0,0 +1,5 @@

# Run the fuzz test.
def run
system("AFL_SKIP_BIN_CHECK=1 afl-fuzz -i input/ -o output/ -t 1000 -m 1000 -- ruby script.rb")
end
6 changes: 6 additions & 0 deletions fuzz/request/input/body.txt
@@ -0,0 +1,6 @@
POST /upload HTTP/1.1
Host: example.com
Accept: */*
Content-Length: 10

0123456789
2 changes: 2 additions & 0 deletions fuzz/request/input/simple.txt
@@ -0,0 +1,2 @@
GET / HTTP/1.1

32 changes: 32 additions & 0 deletions fuzz/request/script.rb
@@ -0,0 +1,32 @@
#!/usr/bin/env ruby

require 'socket'
require_relative '../../lib/protocol/http1'

def test
# input, output = Socket.pair(Socket::PF_UNIX, Socket::SOCK_STREAM)

server = Protocol::HTTP1::Connection.new($stdin)

# input.write($stdin.read)
# input.close

begin
host, method, path, version, headers, body = server.read_request

body = server.read_request_body(method, headers)
rescue Protocol::HTTP1::InvalidRequest
# Ignore.
end
end

if ENV["_"] =~ /afl/
require 'kisaten'
Kisaten.crash_at [], [], Signal.list['USR1']

while Kisaten.loop 10000
test
end
else
test
end

0 comments on commit a776c78

Please sign in to comment.