Skip to content

Instantly share code, notes, and snippets.

View shinh's full-sized avatar

Shinichiro Hamaji shinh

  • Preferred Networks
  • Tokyo, Japan
View GitHub Profile
@shinh
shinh / README.md
Last active February 26, 2024 09:56
MN-Core2 vsm ゴルフ

https://projects.preferred.jp/mn-core/ で MN-Core2 のエミュレータとアセンブラが公開されたということで、喜び勇んでゴルフ場に足そうと準備してたのですが、ゴルフ場 32bit やんけ!と気付いて悲しくなりました

まぁせっかく標準入出力をつなぐスクリプトを書いたので、 caddy というの経由でゴルフ場の問題を楽しめる手順を説明する gist です。環境は x86-64 の Linux を使ってください

caddy を取ってきます

$ git clone https://github.com/shinh/caddy.git
$ cd caddy
[0.912186, 2.09844, 2.97607, 4.14946, 5.37743, 6.29846, 6.73902, 7.49435, 8.36626, 8.65255, 8.93503, 9.17226, 9.60044, 10.0415, 10.4127, 10.9737]
[0.913203, 2.14546, 2.93329, 4.15793, 5.37541, 6.29056, 6.72585, 7.49473, 8.36669, 8.65173, 8.92966, 9.18283, 9.59602, 10.0444, 10.4158, 10.9762]
[0.915957, 2.11986, 3.03985, 4.09351, 5.2462, 6.54203, 6.71142, 7.92987, 8.40744, 8.92736, 9.17984, 9.39551, 9.5926, 10.0081, 10.4185, 11]
[0.924493, 2.1302, 2.94256, 4.15317, 5.25912, 6.46091, 6.67396, 7.71306, 8.37245, 8.80263, 9.03436, 9.20792, 9.59715, 9.89134, 10.208, 10.8579]
[0.924812, 2.14028, 2.96557, 4.15362, 5.3745, 6.29662, 6.73848, 7.49589, 8.3685, 8.64838, 8.93194, 9.17155, 9.59795, 10.0437, 10.4161, 10.9813]
[0.927185, 2.1439, 2.93144, 4.14637, 5.37417, 6.3002, 6.72389, 7.49844, 8.37279, 8.6494, 8.93341, 9.17312, 9.59938, 10.0432, 10.4113, 10.9802]
[0.927547, 2.14155, 2.94826, 4.16001, 5.25621, 6.4628, 6.67752, 7.72232, 8.37654, 8.81443, 9.05387, 9.1988, 9.59758, 9.89667, 10.1768, 10.8536]
[0.92812, 2.12867,
@shinh
shinh / export
Created December 13, 2021 07:55
export command
pp=$(gdb -q -p $PPID -batch -ex "p (int)getppid()" -ex "quit" | awk '/^\$1 = / {print $3}')
gdb -q -p $pp -batch -ex "p (int)putenv(\"$1\")" -ex "quit"
@shinh
shinh / forge_dwarf.rb
Last active May 5, 2021 04:27
DEF CON CTF 2021 Qual exploit-for-dummies
#!/usr/bin/env ruby
# Need gold or lld, probably
def File.read(filename)
File.open(filename, 'r:binary') do |f|
f.read
end
end
@shinh
shinh / qoo.rb
Last active May 5, 2021 04:45
DEF CON CTF 2021 Qual back-to-qoo
#!/usr/bin/env ruby
# qoo_run.rb の結果を ruby qoo.rb log として食べさせると secret を出すやつ
c1s = []
c2s = []
p1s = []
wins = []
msgs = []
no_changes = []
show_time() {
local e=$1
local o="$(printf "%02d" $(($e % 60)))s"
e=$(($e / 60))
if (( $e >= 0 )); then
o="$(printf "%02d" $(($e % 60)))m${o}"
e=$(($e / 60))
if (( $e > 0 )); then
o="$(($e % 24))h${o}"
e=$(($e / 24))
@shinh
shinh / gen_el_lua_py2_jvm.rb
Last active December 26, 2020 18:15
bytecode polyglot - def con qual 2020 bytecoooding
#!/usr/bin/env ruby
# elisp, lua, python2, and jvm
# https://docs.google.com/spreadsheets/d/1l1N_wtK8xA7N-ezG5iUjDeg6iKQgVaYf8ckTSp30QIo/
$flag = File.read('flag').chomp
$ml_preamble = nil
$lua_preamble = nil
$ruby_preamble = nil
@shinh
shinh / gen55.rb
Created May 6, 2020 17:57
esolang golf #6 in cyclic bf
# size base 1pad 2pad step pad code loop mod tbl total
# mod4 27 0 0 (2) 2 29 3
# mod6 27 4 1 (3) 0 32 3 1 17 53+
# mod8 27 0 2 (4) 6 35 3 3 17 58
# mod9 27 1 5 0 2 35 3 1 17 56
# mod10 27 2 3 (5) 2 34 3 3 17 57
# mod12 27 4 4 (6) 6 41
mapping = '<[>]+,-.Z'
#mapping = '[]+-.<>,'
from z3 import *
x, y, a = Ints(['x', 'y', 'a'])
solver = Solver()
def r(x, n):
solver.add(x >= n)
solver.add(x < n * 10)
solver.add(y * 10 == x * a)
solver.add(((x % 10) * (a % 10)) % 10 == 0)
# Usage:
#
# $ PYTHONPATH=. python3 testcases/elichika_tests/utils/collect_types.py
import importlib
import inspect
import os
import sys
import types