SlideShare a Scribd company logo
FEAL
APPENDIX FOR KATAGAITAI CTF TECHTALK
CSAW CTF 2014 QUALS - CRYPT0 300
YOU0708@YOKARO-MON
CSAW CTF 2014 QUALS - CRYPT0 300: FEAL
NOTICE
▸ This material is an appendix for katagaitai CTF TechTalk
▸ https://atnd.org/events/71810
▸ An modified version was used in katagaitai CTF
▸ Encryption key (SUBKEY) is fixed hex strings
FEAL 4.3
CSAW CTF 2014 QUALS
CRYPT0 300
FEAL
CSAW CTF 2014 QUALS - CRYPT0 300: FEAL
FEAL 4.3
▸ Feal 4.3 is used for the question
You must first solve a puzzle, a sha1 sum ending
in 16 bit's set to 1, it must be of length 21
bytes, starting with PkExU2wOJRG/XBDB
Welcome to feal 4.3
Please decrypt: edcf27af7821cc71615f329e78d1f65e
CSAW CTF 2014 QUALS - CRYPT0 300: FEAL
FBOX IN FEAL 4.3
▸ Feal 4.3 uses “rot 3” in fBox
▸ Differential values are not same with Feal 4
CSAW CTF 2014 QUALS - CRYPT0 300: FEAL
DIFFERENTIAL VALUE
In [1]: import array
In [2]: %paste
def rot3(x):
return ((x<<3)|(x>>5))&0xff
def gBox(a,b,mode):
return rot3((a+b+mode)%256)
def fBox(plain):
(snip.)
In [3]: x1 = array.array("B", "80800000".decode("hex"))
In [4]: fBox(x1)
Out[4]: [10, 64, 8, 68]
In [5]: x2 = array.array("B", "00000000".decode("hex"))
In [6]: fBox(x2)
Out[6]: [10, 64, 8, 64]
In [7]: for a, b in zip(fBox(x1), fBox(x2)):
print a ^ b,
....:
0 0 0 4 ΔY = 0x00000004
BREAKING
FEAL 4.3
CSAW CTF 2014 QUALS
CRYPT0 300
FEAL
CSAW CTF 2014 QUALS - CRYPT0 300: FEAL
K3 FEALの最終ラウンドの差分解析49
0x02000000
key
f
出力差分(ΔC1)
ΔC1+ΔC2
入力差分(ΔX1) 入力差分(ΔX2)
出力差分(ΔC2)
f(C1+C2+key)+f(C1’+C2’+key)
この値は?
ΔC1 = f(C1+C2+key)+f(C1’+C2’+key)+0x02000000
0x00000004
0x00000004
CSAW CTF 2014 QUALS - CRYPT0 300: FEAL
K3
k3 = None
if k3 == None:
print "[*] start k3 attack"
p1, p2, c1, c2, dc1, dc2, dcL, dcR = get_dataset(f, n,
array.array(“B”,"8080000080800000".decode("hex")))
for k3 in xrange(65536):
k3 = array.array("B", "%04x"%k3)
for i in xrange(n):
if dcL[i] != list_xor(
list_xor(
fBox(list_xor(dc1[i], k3)),
fBox(list_xor(dc2[i], k3))),
array("B", “00000004”.decode("hex"))
):
break
else:
print "[*] found k3: %s" % "".join(map(chr, k3))
break
else:
print "[!] could not find k3"
return
SUBKEY is hex string
Multiple candidates will be find
if you use few plainest sets
CSAW CTF 2014 QUALS - CRYPT0 300: FEAL
K2
0x02000000
key
f
出力差分(ΔC1)
ΔC1+ΔC2
入力差分(ΔX1) 入力差分(ΔX2)
出力差分(ΔC2)
f(C1+C2+key)+f(C1’+C2’+key)
この値は?
ΔC1 = f(C1+C2+key)+f(C1’+C2’+key)+0x02000000
0x80800000
0x80800000
It can be calculated from
encrypted value and k3
It can be calculated from
encrypted value and k3
CSAW CTF 2014 QUALS - CRYPT0 300: FEAL
K2
for i in xrange(n):
c1L = list_xor(c1[i][:4], c1[i][4:])
c1R = list_xor(c1[i][:4],
fBox(list_xor(k3, list_xor(c1[i][4:], c1[i][:4]))))
c2L = list_xor(c2[i][:4], c2[i][4:])
c2R = list_xor(c2[i][:4],
fBox(list_xor(k3, list_xor(c2[i][4:], c2[i][:4]))))
c1[i] = c1L + c1R
c2[i] = c2L + c2R
dcL[i] = list_xor(c1L, c2L)
for k2 in xrange(65536):
k2 = array.array("B", "%04x"%k2)
for i in xrange(n):
if dcL[i] != list_xor(
list_xor(
fBox(list_xor(c1[i][4:], k2)),
fBox(list_xor(c2[i][4:], k2))),
array("B", "80800000".decode("hex"))):
break
else:
print "[*] found k2: %s" % "".join(map(chr, k2))
break
else:
print "[!] could not find k2"
return
Calculate ΔC1, ΔC2 using k3
CSAW CTF 2014 QUALS - CRYPT0 300: FEAL
K1
▸ You must re-generate plaintext sets to change result after
fBox
FEALの差分解析41
次の差分を持つ平文ペアを入力する
0x8080000080800000
同じ鍵で暗号化されているため鍵の入力差分は0
0x80800000 0x80800000
0x80800000
0
0x02000000
ここの差分は不明
0
ΔC1 is fixed value
It means: k1 can not be calculated
CSAW CTF 2014 QUALS - CRYPT0 300: FEAL
K1
▸ e.g. ΔX = 0x0000000040000000
FEALの差分解析41
次の差分を持つ平文ペアを入力する
0x8080000080800000
同じ鍵で暗号化されているため鍵の入力差分は0
0x80800000 0x80800000
0x80800000
0
0x02000000
ここの差分は不明
0
0x00000000 0x40000000
0x40000000
????
????
ΔX1 = 0x40000000
CSAW CTF 2014 QUALS - CRYPT0 300: FEAL
K1
0x02000000
key
f
出力差分(ΔC1)
ΔC1+ΔC2
入力差分(ΔX1) 入力差分(ΔX2)
出力差分(ΔC2)
f(C1+C2+key)+f(C1’+C2’+key)
この値は?
ΔC1 = f(C1+C2+key)+f(C1’+C2’+key)+0x02000000
0x40000000
0x40000000
It can be calculated from
encrypted value and k3
It can be calculated from
encrypted value, k3, and k2
CSAW CTF 2014 QUALS - CRYPT0 300: FEAL
K1
p1, p2, c1, c2, dc1, dc2, dcL, dcR = get_dataset(f, n,
array.array("B","0000000040000000".decode("hex")))
for i in xrange(n):
c1L = list_xor(c1[i][:4], c1[i][4:])
c1R = list_xor(c1[i][:4],
fBox(list_xor(k3, list_xor(c1[i][4:], c1[i][:4]))))
c2L = list_xor(c2[i][:4], c2[i][4:])
c2R = list_xor(c2[i][:4],
fBox(list_xor(k3, list_xor(c2[i][4:], c2[i][:4]))))
c1[i] = c1L + c1R
c2[i] = c2L + c2R
dcL[i] = list_xor(c1L, c2L)
c1L = c1[i][4:]
c1R = list_xor(c1[i][:4], fBox(list_xor(k2, c1[i][4:])))
c2L = c2[i][4:]
c2R = list_xor(c2[i][:4], fBox(list_xor(k2, c2[i][4:])))
c1[i] = c1L + c1R
c2[i] = c2L + c2R
dcL[i] = list_xor(c1L, c2L)
for k1 in xrange(65536):
k1 = array.array("B", "%04x"%k1)
for i in xrange(n):
if dcL[i] != list_xor(
list_xor(
fBox(list_xor(c1[i][4:], k2)),
fBox(list_xor(c2[i][4:], k2))),
array("B", "80800000".decode("hex"))):
CSAW CTF 2014 QUALS - CRYPT0 300: FEAL
K0
▸ e.g. ΔX = 0x0000000040000000
FEALの差分解析41
次の差分を持つ平文ペアを入力する
0x8080000080800000
同じ鍵で暗号化されているため鍵の入力差分は0
0x80800000 0x80800000
0x80800000
0
0x02000000
ここの差分は不明
0
0x00000000 0x40000000
0x0400000
????
????
ΔX1 = 0x00000000
CSAW CTF 2014 QUALS - CRYPT0 300: FEAL
K0
for i in xrange(n):
c1L = c1[i][4:]
c1R = list_xor(c1[i][:4], fBox(list_xor(k1, c1[i][4:])))
c2L = c2[i][4:]
c2R = list_xor(c2[i][:4], fBox(list_xor(k1, c2[i][4:])))
c1[i] = c1L + c1R
c2[i] = c2L + c2R
dcL[i] = list_xor(c1L, c2L)
for k0 in xrange(65536):
k0 = array.array("B", "%04x"%k0)
for i in xrange(n):
if dcL[i] != list_xor(fBox(list_xor(c1[i][4:], k0)),
fBox(list_xor(c2[i][4:], k0))):
break
else:
print "[*] found k0: %s" % "".join(map(chr, k0))
break
else:
print "[!] could not find k0"
return
CSAW CTF 2014 QUALS - CRYPT0 300: FEAL
K4, K5, FLAG
k4 = list_xor(list_xor(fBox(list_xor(k0, c1[0][4:])),
c1[0][:4]),
p1[0][:4])
print "[*] found k4: %s" % "".join(map(chr, k4))
k5 = list_xor(list_xor(list_xor(p1[0][:4], k4), c1[0][4:]),
p1[0][4:])
print "[*] found k5: %s" % "".join(map(chr, k5))
k = [k0, k1, k2, k3, k4, k5]
print "[*] got encryption key:", k
flag = "".join(map(chr, feal.decrypt(array("B", flag1), k)))
+ "".join(map(chr, feal.decrypt(array("B", flag2), k)))
print "[*] the flag is:", flag
THANK YOU!
CSAW CTF 2014 QUALS
CRYPT0 300
FEAL

More Related Content

PDF
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
PDF
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
PDF
Diving into byte code optimization in python
PDF
Bytes in the Machine: Inside the CPython interpreter
PDF
Exploring slides
PDF
Recognize Godzilla
PDF
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
ODP
Exploiting Memory Overflows
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Diving into byte code optimization in python
Bytes in the Machine: Inside the CPython interpreter
Exploring slides
Recognize Godzilla
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
Exploiting Memory Overflows

What's hot (20)

DOCX
PDF
Python opcodes
PPTX
TCO in Python via bytecode manipulation.
PDF
JavaScript Event Loop
PDF
[JS EXPERIENCE 2018] Javascript Event Loop além do setInterval - Derek Stavis
PPTX
JavaScript Event Loop
PDF
All I know about rsc.io/c2go
PDF
Galios: Python Programming
PDF
Performance testing of microservices in Action
PDF
Faster Python, FOSDEM
PDF
Concurrency in Python4k
PPT
computer notes - Data Structures - 9
PDF
cwit-poster_logo
DOCX
Wap to implement bitwise operators
PPT
Jan 2012 HUG: RHadoop
PDF
The Ring programming language version 1.5.2 book - Part 45 of 181
PDF
Time Series Analysis Sample Code
PDF
Powered by Python - PyCon Germany 2016
PDF
A gentle introduction to functional programming through music and clojure
PDF
Data structure programs in c++
Python opcodes
TCO in Python via bytecode manipulation.
JavaScript Event Loop
[JS EXPERIENCE 2018] Javascript Event Loop além do setInterval - Derek Stavis
JavaScript Event Loop
All I know about rsc.io/c2go
Galios: Python Programming
Performance testing of microservices in Action
Faster Python, FOSDEM
Concurrency in Python4k
computer notes - Data Structures - 9
cwit-poster_logo
Wap to implement bitwise operators
Jan 2012 HUG: RHadoop
The Ring programming language version 1.5.2 book - Part 45 of 181
Time Series Analysis Sample Code
Powered by Python - PyCon Germany 2016
A gentle introduction to functional programming through music and clojure
Data structure programs in c++
Ad

Viewers also liked (7)

PPTX
katagaitai CTF勉強会 #3 crypto
DOC
Nivin Joseph- resume
PPTX
A1. MEP 1 - Mod 1 - Tema1
PPTX
Experiencing victory God’s way
PDF
Silabo evaluacion educativa pato tobar
PPT
Відкриття періодичного закону
DOCX
NUR SYUHADA AZHAR. RESUME (1)
katagaitai CTF勉強会 #3 crypto
Nivin Joseph- resume
A1. MEP 1 - Mod 1 - Tema1
Experiencing victory God’s way
Silabo evaluacion educativa pato tobar
Відкриття періодичного закону
NUR SYUHADA AZHAR. RESUME (1)
Ad

Similar to FEAL - CSAW CTF 2014 Quals Crypto300 (20)

PPTX
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
PDF
Modular Module Systems
PDF
CS Sample Paper 1
 
PDF
Cbse question paper class_xii_paper_2000
PPTX
R programming language
PDF
HHVM on AArch64 - BUD17-400K1
PDF
5th Semester Electronic and Communication Engineering (June/July-2015) Questi...
PDF
Finish the program below that does several bit-wise manipulations of.pdf
PPTX
Seminar PSU 10.10.2014 mme
PDF
4th Semester (June; July-2014) Computer Science and Information Science Engin...
PDF
keeloq-final
PDF
Time Series Analysis and Mining with R
PPTX
Oh Composable World!
DOCX
C cheat sheet for varsity (extreme edition)
PDF
The Ring programming language version 1.3 book - Part 84 of 88
PDF
6th Semester (June; July-2014) Electronics and Communication Engineering Ques...
PDF
Computer Science Sample Paper 2
 
PDF
3rd Semester Computer Science and Engineering (ACU) Question papers
PDF
AP PGECET Computer Science 2016 question paper
PDF
An overview of Python 2.7
Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019
Modular Module Systems
CS Sample Paper 1
 
Cbse question paper class_xii_paper_2000
R programming language
HHVM on AArch64 - BUD17-400K1
5th Semester Electronic and Communication Engineering (June/July-2015) Questi...
Finish the program below that does several bit-wise manipulations of.pdf
Seminar PSU 10.10.2014 mme
4th Semester (June; July-2014) Computer Science and Information Science Engin...
keeloq-final
Time Series Analysis and Mining with R
Oh Composable World!
C cheat sheet for varsity (extreme edition)
The Ring programming language version 1.3 book - Part 84 of 88
6th Semester (June; July-2014) Electronics and Communication Engineering Ques...
Computer Science Sample Paper 2
 
3rd Semester Computer Science and Engineering (ACU) Question papers
AP PGECET Computer Science 2016 question paper
An overview of Python 2.7

Recently uploaded (20)

PDF
PPT on Performance Review to get promotions
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
737-MAX_SRG.pdf student reference guides
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
DOCX
573137875-Attendance-Management-System-original
PPTX
Sustainable Sites - Green Building Construction
PPTX
Safety Seminar civil to be ensured for safe working.
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
web development for engineering and engineering
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPT on Performance Review to get promotions
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
737-MAX_SRG.pdf student reference guides
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Internet of Things (IOT) - A guide to understanding
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
573137875-Attendance-Management-System-original
Sustainable Sites - Green Building Construction
Safety Seminar civil to be ensured for safe working.
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
web development for engineering and engineering
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
UNIT 4 Total Quality Management .pptx
Fundamentals of safety and accident prevention -final (1).pptx
bas. eng. economics group 4 presentation 1.pptx
Foundation to blockchain - A guide to Blockchain Tech
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk

FEAL - CSAW CTF 2014 Quals Crypto300

  • 1. FEAL APPENDIX FOR KATAGAITAI CTF TECHTALK CSAW CTF 2014 QUALS - CRYPT0 300 YOU0708@YOKARO-MON
  • 2. CSAW CTF 2014 QUALS - CRYPT0 300: FEAL NOTICE ▸ This material is an appendix for katagaitai CTF TechTalk ▸ https://atnd.org/events/71810 ▸ An modified version was used in katagaitai CTF ▸ Encryption key (SUBKEY) is fixed hex strings
  • 3. FEAL 4.3 CSAW CTF 2014 QUALS CRYPT0 300 FEAL
  • 4. CSAW CTF 2014 QUALS - CRYPT0 300: FEAL FEAL 4.3 ▸ Feal 4.3 is used for the question You must first solve a puzzle, a sha1 sum ending in 16 bit's set to 1, it must be of length 21 bytes, starting with PkExU2wOJRG/XBDB Welcome to feal 4.3 Please decrypt: edcf27af7821cc71615f329e78d1f65e
  • 5. CSAW CTF 2014 QUALS - CRYPT0 300: FEAL FBOX IN FEAL 4.3 ▸ Feal 4.3 uses “rot 3” in fBox ▸ Differential values are not same with Feal 4
  • 6. CSAW CTF 2014 QUALS - CRYPT0 300: FEAL DIFFERENTIAL VALUE In [1]: import array In [2]: %paste def rot3(x): return ((x<<3)|(x>>5))&0xff def gBox(a,b,mode): return rot3((a+b+mode)%256) def fBox(plain): (snip.) In [3]: x1 = array.array("B", "80800000".decode("hex")) In [4]: fBox(x1) Out[4]: [10, 64, 8, 68] In [5]: x2 = array.array("B", "00000000".decode("hex")) In [6]: fBox(x2) Out[6]: [10, 64, 8, 64] In [7]: for a, b in zip(fBox(x1), fBox(x2)): print a ^ b, ....: 0 0 0 4 ΔY = 0x00000004
  • 7. BREAKING FEAL 4.3 CSAW CTF 2014 QUALS CRYPT0 300 FEAL
  • 8. CSAW CTF 2014 QUALS - CRYPT0 300: FEAL K3 FEALの最終ラウンドの差分解析49 0x02000000 key f 出力差分(ΔC1) ΔC1+ΔC2 入力差分(ΔX1) 入力差分(ΔX2) 出力差分(ΔC2) f(C1+C2+key)+f(C1’+C2’+key) この値は? ΔC1 = f(C1+C2+key)+f(C1’+C2’+key)+0x02000000 0x00000004 0x00000004
  • 9. CSAW CTF 2014 QUALS - CRYPT0 300: FEAL K3 k3 = None if k3 == None: print "[*] start k3 attack" p1, p2, c1, c2, dc1, dc2, dcL, dcR = get_dataset(f, n, array.array(“B”,"8080000080800000".decode("hex"))) for k3 in xrange(65536): k3 = array.array("B", "%04x"%k3) for i in xrange(n): if dcL[i] != list_xor( list_xor( fBox(list_xor(dc1[i], k3)), fBox(list_xor(dc2[i], k3))), array("B", “00000004”.decode("hex")) ): break else: print "[*] found k3: %s" % "".join(map(chr, k3)) break else: print "[!] could not find k3" return SUBKEY is hex string Multiple candidates will be find if you use few plainest sets
  • 10. CSAW CTF 2014 QUALS - CRYPT0 300: FEAL K2 0x02000000 key f 出力差分(ΔC1) ΔC1+ΔC2 入力差分(ΔX1) 入力差分(ΔX2) 出力差分(ΔC2) f(C1+C2+key)+f(C1’+C2’+key) この値は? ΔC1 = f(C1+C2+key)+f(C1’+C2’+key)+0x02000000 0x80800000 0x80800000 It can be calculated from encrypted value and k3 It can be calculated from encrypted value and k3
  • 11. CSAW CTF 2014 QUALS - CRYPT0 300: FEAL K2 for i in xrange(n): c1L = list_xor(c1[i][:4], c1[i][4:]) c1R = list_xor(c1[i][:4], fBox(list_xor(k3, list_xor(c1[i][4:], c1[i][:4])))) c2L = list_xor(c2[i][:4], c2[i][4:]) c2R = list_xor(c2[i][:4], fBox(list_xor(k3, list_xor(c2[i][4:], c2[i][:4])))) c1[i] = c1L + c1R c2[i] = c2L + c2R dcL[i] = list_xor(c1L, c2L) for k2 in xrange(65536): k2 = array.array("B", "%04x"%k2) for i in xrange(n): if dcL[i] != list_xor( list_xor( fBox(list_xor(c1[i][4:], k2)), fBox(list_xor(c2[i][4:], k2))), array("B", "80800000".decode("hex"))): break else: print "[*] found k2: %s" % "".join(map(chr, k2)) break else: print "[!] could not find k2" return Calculate ΔC1, ΔC2 using k3
  • 12. CSAW CTF 2014 QUALS - CRYPT0 300: FEAL K1 ▸ You must re-generate plaintext sets to change result after fBox FEALの差分解析41 次の差分を持つ平文ペアを入力する 0x8080000080800000 同じ鍵で暗号化されているため鍵の入力差分は0 0x80800000 0x80800000 0x80800000 0 0x02000000 ここの差分は不明 0 ΔC1 is fixed value It means: k1 can not be calculated
  • 13. CSAW CTF 2014 QUALS - CRYPT0 300: FEAL K1 ▸ e.g. ΔX = 0x0000000040000000 FEALの差分解析41 次の差分を持つ平文ペアを入力する 0x8080000080800000 同じ鍵で暗号化されているため鍵の入力差分は0 0x80800000 0x80800000 0x80800000 0 0x02000000 ここの差分は不明 0 0x00000000 0x40000000 0x40000000 ???? ???? ΔX1 = 0x40000000
  • 14. CSAW CTF 2014 QUALS - CRYPT0 300: FEAL K1 0x02000000 key f 出力差分(ΔC1) ΔC1+ΔC2 入力差分(ΔX1) 入力差分(ΔX2) 出力差分(ΔC2) f(C1+C2+key)+f(C1’+C2’+key) この値は? ΔC1 = f(C1+C2+key)+f(C1’+C2’+key)+0x02000000 0x40000000 0x40000000 It can be calculated from encrypted value and k3 It can be calculated from encrypted value, k3, and k2
  • 15. CSAW CTF 2014 QUALS - CRYPT0 300: FEAL K1 p1, p2, c1, c2, dc1, dc2, dcL, dcR = get_dataset(f, n, array.array("B","0000000040000000".decode("hex"))) for i in xrange(n): c1L = list_xor(c1[i][:4], c1[i][4:]) c1R = list_xor(c1[i][:4], fBox(list_xor(k3, list_xor(c1[i][4:], c1[i][:4])))) c2L = list_xor(c2[i][:4], c2[i][4:]) c2R = list_xor(c2[i][:4], fBox(list_xor(k3, list_xor(c2[i][4:], c2[i][:4])))) c1[i] = c1L + c1R c2[i] = c2L + c2R dcL[i] = list_xor(c1L, c2L) c1L = c1[i][4:] c1R = list_xor(c1[i][:4], fBox(list_xor(k2, c1[i][4:]))) c2L = c2[i][4:] c2R = list_xor(c2[i][:4], fBox(list_xor(k2, c2[i][4:]))) c1[i] = c1L + c1R c2[i] = c2L + c2R dcL[i] = list_xor(c1L, c2L) for k1 in xrange(65536): k1 = array.array("B", "%04x"%k1) for i in xrange(n): if dcL[i] != list_xor( list_xor( fBox(list_xor(c1[i][4:], k2)), fBox(list_xor(c2[i][4:], k2))), array("B", "80800000".decode("hex"))):
  • 16. CSAW CTF 2014 QUALS - CRYPT0 300: FEAL K0 ▸ e.g. ΔX = 0x0000000040000000 FEALの差分解析41 次の差分を持つ平文ペアを入力する 0x8080000080800000 同じ鍵で暗号化されているため鍵の入力差分は0 0x80800000 0x80800000 0x80800000 0 0x02000000 ここの差分は不明 0 0x00000000 0x40000000 0x0400000 ???? ???? ΔX1 = 0x00000000
  • 17. CSAW CTF 2014 QUALS - CRYPT0 300: FEAL K0 for i in xrange(n): c1L = c1[i][4:] c1R = list_xor(c1[i][:4], fBox(list_xor(k1, c1[i][4:]))) c2L = c2[i][4:] c2R = list_xor(c2[i][:4], fBox(list_xor(k1, c2[i][4:]))) c1[i] = c1L + c1R c2[i] = c2L + c2R dcL[i] = list_xor(c1L, c2L) for k0 in xrange(65536): k0 = array.array("B", "%04x"%k0) for i in xrange(n): if dcL[i] != list_xor(fBox(list_xor(c1[i][4:], k0)), fBox(list_xor(c2[i][4:], k0))): break else: print "[*] found k0: %s" % "".join(map(chr, k0)) break else: print "[!] could not find k0" return
  • 18. CSAW CTF 2014 QUALS - CRYPT0 300: FEAL K4, K5, FLAG k4 = list_xor(list_xor(fBox(list_xor(k0, c1[0][4:])), c1[0][:4]), p1[0][:4]) print "[*] found k4: %s" % "".join(map(chr, k4)) k5 = list_xor(list_xor(list_xor(p1[0][:4], k4), c1[0][4:]), p1[0][4:]) print "[*] found k5: %s" % "".join(map(chr, k5)) k = [k0, k1, k2, k3, k4, k5] print "[*] got encryption key:", k flag = "".join(map(chr, feal.decrypt(array("B", flag1), k))) + "".join(map(chr, feal.decrypt(array("B", flag2), k))) print "[*] the flag is:", flag
  • 19. THANK YOU! CSAW CTF 2014 QUALS CRYPT0 300 FEAL