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 / gen_payload.rb
Created August 19, 2018 13:58
DEF CON CTF 2018 doublethink - A polyglot of 9 architectures
#!/usr/bin/env ruby
#
# DEF CON CTF 2018 doublethink
#
# A polyglot of 9 architectures amd64, mix, pdp-8, pdp-1, pdp-10,
# nova, lgp-30, clemency, and mmix. MMIX was added after the CTF.
#
# This will generate a file named "payload" and you can try it by
#
# $ ./scripts/service.py < payload
@shinh
shinh / test.java
Created September 15, 2018 08:06
TMCTF 2018 misc-3
import java.io.*;
import java.util.*;
import javax.servlet.ServletInputStream;
import com.trendmicro.CustomOIS;
import com.trendmicro.Person;
import com.trendmicro.jail.Flag;
import org.apache.commons.collections.Factory;
import org.apache.commons.collections.Transformer;
@shinh
shinh / main.py
Created November 6, 2018 06:43
mypy with cyclic dep
import u
print(u.U().foo())
$ python3 ./scripts/elichikacheck.py mutable.py

すると out/elichika_tmp/tmp_mutable/model.onnx と out/elichika_tmp/tmp_immutable/model.onnx が出ます

$ pip3 install --user netron
$ netron out/elichika_tmp/tmp_mutable/model.onnx
import ast
import inspect
import os
import sys
def my_lambda_source(l):
s = inspect.getsource(l)
if s.count('lambda') == 2:
return None
# Usage:
#
# $ PYTHONPATH=. python3 testcases/elichika_tests/utils/collect_types.py
import importlib
import inspect
import os
import sys
import types
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)
@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 = '[]+-.<>,'
@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
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))