-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
2,074 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
all: pat pat2 pat3 howtouse sh nagoya qr2txt pow | ||
|
||
pow: pow.cc | ||
$(CXX) -o $@ $< -g -O -lssl -lcrypto | ||
|
||
pat: pat.cc | ||
$(CXX) -o $@ $< -g -O | ||
|
||
qr2txt: qr2txt.cc | ||
$(CXX) -o $@ $< -g -O -lSDL `sdl-config --cflags` | ||
|
||
pat2: pat2.cc | ||
$(CXX) -o $@ $< -g -O -std=c++11 | ||
|
||
pat3: pat3.cc | ||
$(CXX) -o $@ $< -g -O -std=c++11 | ||
|
||
nagoya: nagoya.cc | ||
$(CXX) -o $@ $< -g -O -std=c++11 -lSDL `sdl-config --cflags` | ||
|
||
sh: sh.c | ||
$(CC) -o $@ $< -g -O -m32 -ldl -Wl,-Ttext-segment=0x2000000 | ||
|
||
howtouse: howtouse.cc | ||
$(CXX) -o $@ $< -g -O -m32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
public | ||
def i n | ||
def each | ||
yield succ end | ||
for r in n | ||
end | ||
r end | ||
def each | ||
clear | ||
concat i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i size | ||
concat i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i size | ||
concat i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i size | ||
concat i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i size | ||
def each | ||
read end | ||
for i in open self | ||
end | ||
i | ||
end | ||
for i in inspect | ||
end | ||
|
||
|
||
__END__ | ||
|
||
class String | ||
def coerce | ||
32 | ||
end | ||
end | ||
|
||
class Integer | ||
def each | ||
p quo "hoge" | ||
end | ||
end | ||
|
||
for i in 40 | ||
end | ||
|
||
|
||
class String | ||
alias each bytes end | ||
class A | ||
for A in name | ||
end end | ||
|
||
class String | ||
def each | ||
for c in bytes | ||
case c | ||
when 65 | ||
concat 59 | ||
when 66 | ||
concat 46 | ||
when 67 | ||
concat 39 | ||
when 68 | ||
concat 32 | ||
else | ||
concat c | ||
end | ||
end | ||
print self | ||
eval self | ||
end | ||
end | ||
|
||
class AputsDFileBreadCflagC | ||
for i in name | ||
end | ||
end | ||
|
||
public | ||
def i n | ||
def each | ||
yield succ end | ||
for r in n | ||
end | ||
r end | ||
|
||
class File | ||
def each | ||
p read | ||
end end | ||
|
||
class String | ||
def each | ||
clear | ||
concat i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i size | ||
concat i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i size | ||
concat i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i size | ||
concat i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i size | ||
for f in open self | ||
end end end | ||
for i in String nil | ||
end | ||
|
||
|
||
exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
c = '36 36 2a 64 4b 4b 4a 21 1e 4b 1f 20 1f 21 4d 4b 1b 1d 19 4f 21 4c 1d 4a 4e 1c 4c 1b 22 4f 22 22 1b 21 4c 20 1d 4f 1f 4c 4a 19 22 1a 66' | ||
|
||
c.split.each do |v| | ||
v = v.hex | ||
if v >= 0x0 && v <= 0x99 | ||
putc (v - 0x2a + 'A'.ord).chr | ||
else | ||
putc '?' | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env ruby | ||
|
||
c = 'e3 e3 83 21 33 96 23 43 ef 9a 9a 05 18 c7 23 07 07 07 c7 9a 04 33 23 07 23 ef 12 c7 04 96 43 23 23 18 04 04 05 c7 fb 18 96 43 ef 43 ff' | ||
|
||
tbl = '04 c7 23 c3 18 96 05 9a 07 12 83 2c 1a 1b 6e 5a a0 52 3b d6 b3 29 e3 2f 84 53 d1 00 ed 20 fc b1 5b 6a cb be ef aa fb 43 4d 33 85 45 f9 02 7f 50 3c 9f a8 51 a3 40 8f 92 9d 38 f5 bc b6 da'.split | ||
|
||
a = [*'0'..'9'] + [*'A'..'Z'] + [*'a'..'z'] | ||
|
||
c.split.each do |v| | ||
i = tbl.index(v) | ||
if i | ||
putc a[i] | ||
else | ||
putc '?' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require './ctfutils' | ||
|
||
c = '60 00 0c 3a 1e 52 02 53 02 51 0c 5d 56 51 5a 5f 5f 5a 51 00 05 53 56 0a 5e 00 52 05 03 51 50 55 03 04 52 04 0f 0f 54 52 57 03 52 04 4e'.split | ||
|
||
a = [*'0'..'9'] + [*'a'..'f'] | ||
|
||
d = 'MMA{e000000000000000000000000000000000000000}' | ||
n = 5 | ||
while d[n] != '}' | ||
a.each do |ch| | ||
d[n] = ch | ||
resp = `curl -d 's=#{d}' http://bow.chal.mmactf.link/~scs/crypt5.cgi 2> /dev/null` | ||
r = resp[/\/h1>(.*?) </, 1].split | ||
STDERR.puts "try: #{d} got: #{r}" | ||
if r[n] == c[n] | ||
puts d | ||
break | ||
end | ||
end | ||
|
||
n += 1 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require './ctfutils' | ||
|
||
c = File.read('cannotberun.exe') | ||
c[0x3c] = 0xe8.chr | ||
|
||
print c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#!/usr/bin/env ruby | ||
|
||
# for Digital Circuit | ||
|
||
require './ctfutils' | ||
|
||
def get_c1(v) | ||
res = `vvp ./digital_circuit/program +input=#{$input + v * 2 ** (128+64)}` | ||
res = res.force_encoding('ASCII-8BIT') | ||
if res !~ /\(c1\)=\s*(\d+)/ | ||
raise res | ||
end | ||
$1.to_i | ||
end | ||
|
||
|
||
mul = 0b00000000000000000000000000000000000000000000000000100010010010000100010101001100010011000100111100100001001000010010001000100001 | ||
xorv = 0b00001110111000011011000000000101000110001011000101111110100100000111110001100000110010110000100011000101110010000001011110110010 | ||
c40 = invmod(mul, 2**128) * xorv % (2**128) | ||
|
||
c20 = 6442758005744298871 * 2**128 | ||
|
||
$input = c40 + c20 | ||
|
||
base = get_c1(0) | ||
|
||
a = [] | ||
64.times{ | ||
a << [] | ||
} | ||
|
||
diffs = [] | ||
|
||
STDERR.puts '%b' % base | ||
64.times{|i| | ||
diff = base ^ get_c1(2 ** i) | ||
diffs << diff | ||
|
||
d = diff | ||
j = 0 | ||
while d != 0 | ||
if d % 2 == 1 | ||
a[j] << i | ||
end | ||
d >>= 1 | ||
j += 1 | ||
end | ||
} | ||
|
||
STDERR.puts a.inspect | ||
STDERR.puts diffs.inspect | ||
|
||
c10 = 0 | ||
|
||
c = base | ||
64.times{|b| | ||
if a[b].size != 1 | ||
raise | ||
end | ||
|
||
if a[b][0] != b | ||
raise | ||
end | ||
|
||
if (c >> b) % 2 == 1 | ||
STDERR.puts "#{b} #{1<<b} #{diffs[b]}" | ||
c10 += 1 << b | ||
c ^= diffs[b] | ||
end | ||
|
||
a = a.map{|cands| | ||
cands - [b] | ||
} | ||
} | ||
|
||
STDERR.puts c | ||
STDERR.puts c10 | ||
|
||
c10 = 0 | ||
[1,2,4,5,6,12,13,14,16,17,18,22,25,27,28,30,33,34,36,37,38,40,43,44, | ||
45,49,52,53,57,60,62].each do |b| | ||
c10 |= 1 << b | ||
end | ||
|
||
STDERR.puts '%064b' % base | ||
|
||
STDERR.puts '%064b'%get_c1(c10) | ||
STDERR.puts '%064b'%get_c1(c10 | (1 << 62)) | ||
|
||
c10 *= 2**(128+64) | ||
|
||
# l = ('%b'%diff).size | ||
# puts "#{i} #{diff} %b vs %b" % [diff, ('%b'%base)[-l+1..-1]] | ||
#} | ||
|
||
#c10 = 2 * 2**(128+64) | ||
puts c10 + c20 + c40 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/usr/bin/env ruby | ||
|
||
code_size = 41 | ||
|
||
cc = '' | ||
|
||
cc += "##{code_size}" | ||
t = "#35.:\\,#1-:!!#" | ||
cc += t + "#{t.size+5}*~@_" | ||
|
||
#cc += "##{code_size}" | ||
#t = "#35.#1-:,#92.#35.#35,#46.#44.:!!#" | ||
#cc += t + "#{t.size+5}*~@_" | ||
|
||
cc += "##{code_size}" | ||
t = "#1-^.:!!#" | ||
cc += t + "#{t.size+5}*~@;" | ||
|
||
code = cc | ||
if code.size > code_size | ||
raise | ||
end | ||
while code.size < code_size | ||
code += ' ' | ||
end | ||
|
||
c = '' | ||
d = '' | ||
|
||
code.reverse.each_byte{|b| | ||
raise if b == 0 | ||
d += "##{b}" | ||
} | ||
c += d | ||
|
||
#code_size.times{|i| | ||
# c += "##{code_size-i-1}" | ||
# c += "\\" | ||
# c += "#35.," | ||
#} | ||
|
||
#c += cc | ||
|
||
print c + code | ||
|
||
__END__ | ||
|
||
code = 'dc' | ||
|
||
c = '#0' | ||
d = '' | ||
code.each_byte{|b| | ||
d += "##{b}^:#999*@^#35.," | ||
} | ||
|
||
puts c + d + code | ||
|
||
__END__ | ||
|
||
code = '__:!#99*@#35.,dc' | ||
|
||
c = '#1' | ||
d = '' | ||
|
||
code.reverse.each_byte{|b| | ||
d += "##{b}^" | ||
} | ||
|
||
c += d | ||
c += "#^#^##{d.size+10}*~" | ||
c += "@" | ||
|
||
puts c + code |
Oops, something went wrong.