Skip to content

Instantly share code, notes, and snippets.

View nikolaifedorov's full-sized avatar

Nikolai Fedorov nikolaifedorov

View GitHub Profile
@nikolaifedorov
nikolaifedorov / method_logger.rb
Created October 5, 2012 12:36 — forked from nhance/method_logger.rb
Rails compatible method logging. Use this to log all calls to instance methods of a class to the log.
Model.new.foo
@nikolaifedorov
nikolaifedorov / capybara cheat sheet
Created October 9, 2012 17:13 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@nikolaifedorov
nikolaifedorov / sample_ruby_webserver.rb
Created November 22, 2012 10:50 — forked from dcparker/sample_ruby_webserver.rb
Mini Ruby web server example!
require 'socket'
socket = TCPServer.new('0.0.0.0', '8080')
socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, 1)
loop do
client = socket.accept
data = ''
loop do
event = select([client],nil,nil,0.5)
if client.eof? # Socket's been closed by the client
@nikolaifedorov
nikolaifedorov / request.rb
Created November 22, 2012 10:53 — forked from steved/request.rb
Eventmachine Deferrable example
require 'httparty'
require 'eventmachine'
class Request
include EM::Deferrable
@@requests = []
attr_reader :method, :params
#!/usr/bin/env ruby
#
# Proof-of-Concept exploit for Rails DoS (CVE-2013-0156)
#
# ## Advisory
#
# https://groups.google.com/forum/#!topic/rubyonrails-security/61bkgvnSGTQ/discussion
#
# ## Synopsis
#
#!/usr/bin/env ruby
#
# Proof-of-Concept exploit for Rails Remote Code Execution (CVE-2013-0156)
#
# ## Advisory
#
# https://groups.google.com/forum/#!topic/rubyonrails-security/61bkgvnSGTQ/discussion
#
# ## Caveats
#
package net.hausherr.sample;
import org.apache.http.client.CookieStore;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.routing.HttpRoutePlanner;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
var http = require('http');
var server = http.createServer(function(req, res) {
// console.log(req); // debug dump the request
// If they pass in a basic auth credential it'll be in a header called "Authorization" (note NodeJS lowercases the names of headers in its request object)
var auth = req.headers['authorization']; // auth is in base64(username:password) so we need to decode the base64
console.log("Authorization Header is: ", auth);
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<title>Drag And Drop</title>
</head>
<body>
<div id="viz"></div>
Copyright (c) 2012 James Conroy-Finn
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE US