Skip to content

Instantly share code, notes, and snippets.

@mala
mala / gist:1599411
Created January 12, 2012 08:26
jquery core refactoring
// Handle HTML strings
if ( typeof selector === "string" ) {
var mode, id, tag;
if (/^#[\w\-]*$/.test(selector)) { // single #id
mode = "id";
id = selector.substring(1);
} else if (/^\s*<[\w\W]+>.*/.test(selector)) { // at least one html tag
mode = "html";
} else { // selector expr
mode = "expr";
@mala
mala / gist:1392927
Created November 25, 2011 06:26
setterとかArrayコンストラクタ書き換えとかの挙動知りたい人向けのサンプル
<html>
<head>
<title>JSON Hijacking Test</title>
</head>
<body>
<script>
Object.prototype.__defineSetter__('test', function(val){ alert(val); return val });
a = [ {"test": "hoge"} ];
b = {"hoge": "hoge"};
@mala
mala / gist:1073612
Created July 9, 2011 14:20
jQuery MobileのloadPageで異なるホストを弾く
// jQuery MobileのloadPageで異なるホストを弾く
// Note: 同一ドメインにオープンリダイレクタがないか確認すること
(function($){
var old = $.mobile.loadPage;
var gethost = function(url){
var a = document.createElement("a");
a.href = url;
return a.host
};
@mala
mala / gist:1073591
Created July 9, 2011 13:50
jQueryでクロスドメイン読み込みを全般的に禁止する
// jQueryでクロスドメイン読み込みを全般的に禁止する
// Note: 同一ドメインにオープンリダイレクタがないか確認すること
(function($){
var gethost = function(url){
var a = document.createElement("a");
a.href = url;
return a.host
};
var old_beforesend = $.ajaxSettings.beforeSend;
@mala
mala / gist:1071708
Created July 8, 2011 12:19
Furlでローカルアドレスへのアクセス禁止したい
# FurlX::ParanoidAgent 的なやつ
my $furl = Furl->new(
inet_aton => \&_inet_aton,
);
sub _inet_aton {
my $addr = Net::DNS::Lite::inet_aton(@_);
if (is_local_addr($addr)) { return }
$addr;
@mala
mala / jq_quickpatch.html
Created June 26, 2011 03:13 — forked from anonymous/jq_quickpatch.html
quick patch for jQuery selector XSS
<script type="text/javascript">
// http://ma.la/jquery_xss/
(function($){
var _init = $.fn.init;
$.fn.init = function(selector, context, rootjQuery){
// note: only block "#<img>", "a[href=<img onerror=...>]" still work.
if( typeof arguments[ 0 ] == "string" && /^#.*</.test( arguments[ 0 ] ) ){
throw new Error( "selector error" );
}
// console.log(arguments[0]);
@mala
mala / jquery_patch.pl
Created June 21, 2011 14:57
quick patch script for jQuery http://bugs.jquery.com/ticket/9521
#!perl
# perl jquery_patch.pl jquery-n.nn.min.js > jquery-n.nn.min.patched.js
$old = join "|", map quotemeta, (
q{/^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/},
q{/^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/},
q{/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/}
);
$new = q{/^(?:\s*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/};
<!DOCTYPE html>
<html version="HTML+RDFa 1.0" lang="ja">
<head>
<meta charset="UTF-8">
<title>test</title>
</head>
<body>
<font color="red" size="7">IE 6/7 must DIE!!</font>
<script type="text/javascript">alert("this is html")</script>
</body>

Facebookに3/27に送ったメールより転載

「クリックジャッキングが行われていると疑われるページ」を検知する改良を行っていると書かれていますが、URLに対するlikeで宣伝リンクをワーム的にばらまくspam行為や、ブラウザやプラグインの脆弱性を利用したマルウェアの配布に使われるのであれば、そういった対策はある程度効果があるでしょう。iframeで埋め込まれたコンテンツから、自分がどこに、どのように埋めこまれているのかを把握することはSame origin policyによって不可能ですし、リファラを隠蔽した上で埋め込む方法もいくらでも有ります。つまりそういった方法(クリックジャッキングの検出)ではlike数の不自然な増加を検出した事後の対策になりますし、私が指摘したような問題においては攻撃者が既に訪問者のFacebookアカウントを特定した後になります。必要な対策はもっと別のことです。

>>
Hi,
We apologize, but the only way we will be able to verify ownership of this account is if you reply to this email with an attached color image of your government-issued photo identification confirming your full name and date of birth. Rest assured that we will permanently delete your ID from our servers once we have used it to verify the authenticity of your account.
Please note that we will not be able to process your request unless you send in proper identification. We apologize for any inconvenience this may cause.
Thanks,
<<