Skip to content

Instantly share code, notes, and snippets.

require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
Rank = ExcellentRanking
@@trav_string = '%5c%2e%2e%2f'
include Msf::Exploit::Remote::HttpClient
def initialize(info = {})
super(update_info(info,
@forced-request
forced-request / server.js
Created February 22, 2019 21:06
Handle all uncaught exceptions to prevent node service from crashing. This is useful for preventing denial-of-service attacks in Node.JS
/* Tell Node not to crash */
process.on('uncaughtException', function (err) {
console.log('Caught exception: ', err);
});
@forced-request
forced-request / request_forgery_protection.rb
Last active April 18, 2017 23:46
protect_from_forgery
def protect_from_forgery(options = {})
self.request_forgery_protection_token ||= :authenticity_token
prepend_before_filter :verify_authenticity_token, options
end
def verify_authenticity_token
unless verified_request?
logger.warn "WARNING: Can't verify CSRF token authenticity" if logger
handle_unverified_request
end
@forced-request
forced-request / request_forgery_protection.rb
Last active March 27, 2017 17:55
handle_unverified_request
def handle_unverified_request
reset_session
end
def verified_request?
!protect_against_forgery? || request.get? ||
form_authenticity_token == params[request_forgery_protection_token] ||
form_authenticity_token == request.headers['X-CSRF-Token']
end
@forced-request
forced-request / migration.rb
Last active December 20, 2015 04:39
== ConvertFriendshipTable: migrating ========================================= -- rename_column(:friendships, :sender, :user) rake aborted! An error has occurred, this and all later migrations canceled: undefined method `to_sym' for nil:NilClass/Users/web/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/ab…
class ConvertFriendshipTable < ActiveRecord::Migration
def change
rename_column :friendships, :sender, :user
end
end
class FunctionParser
def test
# How do I access @vals from sim.rb?
# puts @vals.inspect
end
end
@forced-request
forced-request / json_encode-xss-prevention.php
Created July 27, 2015 23:37
Using json_encode to prevent JS context XSS
<html>
<body>
<script>
var a = “prefix” + <?= json_encode($_GET['p']); ?> + “suffix”;
</script>
</body>
</html>
@forced-request
forced-request / htmlentities_javascript.php
Last active August 29, 2015 14:26
htmlentities in JavaScript context
<html>
<body>
<script>
var a = '<?= htmlentities($_GET['p']); ?>';
</script>
</body>
</html>
def show
template = params[:id]
d = Dir[“myfolder/*.erb]
if d.include?(“myfolder/#{template}.erb”)
render "myfolder/#{template}"
else
# throw exception or 404
end
end
def show
template = params[:id]
valid_templates = {
"dashboard" => "dashboard",
"profile" => "profile",
"deals" => "deals"
}
if valid_templates.include?(template)