Skip to content

Instantly share code, notes, and snippets.

@shutingrz
Last active July 11, 2016 23:16
Show Gist options
  • Save shutingrz/8177409 to your computer and use it in GitHub Desktop.
Save shutingrz/8177409 to your computer and use it in GitHub Desktop.
bypass codevs3.0
require 'webrick'
class LoginServlet < WEBrick::HTTPServlet::AbstractServlet
def do_POST(req,res)
res.body = '<?xml version="1.0" encoding="UTF-8"?><response><ok><code /><body /></ok></response>'
end
end
class LogoutServlet < WEBrick::HTTPServlet::AbstractServlet
def do_POST(req,res)
res.body = '<?xml version="1.0" encoding="UTF-8"?><response><ok><code /><body /></ok></response>'
end
end
class NotModifiedServlet < WEBrick::HTTPServlet::AbstractServlet
def do_GET(req,res)
res.status = 304
res['ETag'] = '"42118-283-4eb7dd7743840"'
res['Server'] = "Apache"
res['Connection'] = 'close'
res.chunked = true
end
end
class PgamesServlet < WEBrick::HTTPServlet::AbstractServlet
def do_GET(req,res)
res.body = <<"EOS"
<?xml version="1.0" encoding="UTF-8"?>
<response>
<ok>
<code>past_games</code>
<body>
<item>
<id>1</id>
<clear_count_total>123</clear_count_total>
<bomb_count_total>45</bomb_count_total>
<answered_at>2000-01-01 00:00:00</answered_at>
</item>
<item>
<id>2</id>
<clear_count_total>1234</clear_count_total>
<bomb_count_total>456</bomb_count_total>
<answered_at>2011-11-11 11:11:11</answered_at>
</item>
</body>
</ok>
</response>
EOS
end
end
srv = WEBrick::HTTPServer.new({ :DocumentRoot => './',
:BindAddress => '127.0.0.1',
:Port => 80})
srv.mount('/api/index.php/user/login', LoginServlet)
srv.mount('/api/index.php/user/logout', LogoutServlet)
srv.mount('/api/index.php/game/pgames', PgamesServlet)
srv.mount('/asset/files/codevs3.jnlp', NotModifiedServlet)
srv.mount('/asset/files/codevs3.jar', NotModifiedServlet)
trap("INT"){srv.shutdown}
srv.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment