Verfasser: Innokenty Sennovsky (rumata888)
Wie kann man einen Studenten fĂŒr ein langweiliges Fach interessieren? Geben Sie dem Lernen eine Form des Spielens. Vor langer Zeit hat sich jemand ein solches Sicherheitsspiel ausgedacht - Capture the Flag oder CTF. Daher waren faule SchĂŒler mehr daran interessiert zu lernen, wie man Programme umkehrt, wo es besser ist, AnfĂŒhrungszeichen einzufĂŒgen und warum proprietĂ€re VerschlĂŒsselung wie ein Sprung auf einen Rechen mit einem laufenden Start ist.
Die SchĂŒler sind erwachsen geworden, und jetzt nehmen erfahrene Fachleute mit Kindern und Hypotheken an diesen "Spielen" teil. Sie haben viel gesehen, daher ist es keine leichte Aufgabe, eine Aufgabe fĂŒr die CTF zu erledigen, damit die âalten Leuteâ nicht jammern.
Und wenn Sie es mit Hardcore ĂŒbertreiben, werden die Teams, die diesen nicht zum Kern gehörenden Themenbereich oder die erste ernsthafte CTF haben, gesprengt.
In diesem Artikel werde ich Ihnen erzĂ€hlen, wie unser Team ein Gleichgewicht zwischen "hmm, etwas Neues" und "das ist eine Art Dose" gefunden hat, wĂ€hrend es die Krypta-Aufgabe fĂŒr das CTFZone-Finale in diesem Jahr entwickelte.
Endanzeige CTFZone 2020

Inhalt
- Optionale EinfĂŒhrung: CTF in 2 Minuten erklĂ€ren
- Wie haben wir verstanden, dass wir eine Krypta brauchen?
- Wie wir den Stapel gewÀhlt haben
-
4.1. .
4.2. . -
5.1. :
5.2. :
5.3.
: CTF 2
, CTF, â . , CTF- .
: jeopardy attack-defense.
jeopardy . «Jeopardy!», « ». , . , «» . , .
attack-defense (AD) . , â . : attack-defense -10 -20 jeopardy.
AD vulnboxes â , . vulnboxes . â , (checker). , .
, â , . , 5 . . vulnbox , .
, :
- vulnbox;
- , ;
- , .
- CTF, , :
- web,
- pwn,
- misc,
- PPC,
- forensic,
- reverse,
- crypto ( , ).
, , jeopardy. , AD . «» , - , CTFZone.
,
CTFZone, , AD.
, AD, , . , . , .
, . . , nonce ECDSA, , .
, . - AD- , . , : . , , .
, ( ), . , .
, , CTF . â .
, , . , ? :)
, , Python. , .
, DEF CON , Python + C ( , ). C, Python , .
, , , .
, , CTF, â Zero Knowledge Proofs of Knowledge (ZKPoK), . , , - , . ZKPoK : - , . .
.
. . . â , .
, , . , , .
â . , . , .
.
. , , , , , . , 4 : A, B, C, D. A B, C D.
:

, , .
, , : , ABCD â BADC. (): BâAâDâCâB.
. . . , â . :

, . .
, . , , .
â :

, (x, y) (y, x), B D.
.
:
- - , . ;
- , , .
, , (Prover), (Verifier).
0. . , : AâBâCâDâA. , , (. . ) . ( ) .

, . â .
1. . , (commitment). , , : , â , . , , .
:
- . ;
- . , . : .
2. . , (challenge) . , ( ) ( ) .
, , â .
3. . , , , , . , , , .
, , . , , .
. , . , : , , , . , . , - ( , ).
, , , 50- , , . , . . , . 25%, â 12,5% . . , .
.
P.S. Zero Knowledge, - Zero Knowledge Proofs: An illustrated primer. .
. « » = «», « » = «», « » = « ».
:
, , . , , , . :
- ;
- ;
- 16- RANDOMR, ;
- RSA- .
RANDOMR , .
, : , DoS- . PKCS#1 v1.5. , , 3 (Bleichenbacher's e=3 signature attack). , 3 (, SAFE_VERSION macro ):
uint8_t* badPKCSUnpadHash(uint8_t* pDecryptedSignature, uint32_t dsSize){
uint32_t i;
if (dsSize<MIN_PKCS_SIG_SIZE) return NULL;
if ((pDecryptedSignature[0]!=0)||(pDecryptedSignature[1]!=1))return NULL;
i=2;
while ((i<dsSize) && (pDecryptedSignature[i]==0xff)) i=i+1;
if (i==2 || i>=dsSize) return NULL;
if (pDecryptedSignature[i]!=0) return NULL;
i=i+1;
if ((i>=dsSize)||((dsSize-i)<SHA256_SIZE)) return NULL;
#ifdef SAFE_VERSION
//Check that there are no bytes left, apart from hash itself
//(We presume that the caller did not truncate the signature afte exponentiation
// and the dsSize is the equal to modulus size in bytes
if ((dsSize-i)!=SHA256_SIZE) return NULL;
#endif
return pDecryptedSignature+i;
}
30 :
- ;
- , ;
- , .
, .
. , , . , , .
:
, , .
â Python + C. C, 95% . Python . . (, void_p ctypes. 64- 32 ).
Python :
verifier=Verifier(4,4,7)
:
- .
- .
- .
.
. , , , : .
, 256. :
- -, , 2 ( , ). , 5 , .
- -, , .
. , , - . . .
, , 64, . â .
, â .
. , 3 , :
- , "" CRC32;
- , SHA-256;
- , AES-128 CBC.
, . : CRC32, SHA-256, AES. , CRC32 AES, CRC32.
, :
- ( ).
- .
- , 1. proof_count.
- ( proof_count).
- , .
- , , .
- 3.
. (, ). . (simulation mode), . . . , , , . , . , ,
. .
CRC32 SHA-256 , . , (uint16_t), , 8 . , , -. :
. , , . , , . , , .
AES, : . , , . :
. .
, , AES, ( , , ). , SHA-256, ( ), - , .
CRC32, , , . CRC32 . Meet-in-the-Middle (« »), .
: , . . MitM , .. .
Meet-in-the-Middle , CRC32. ,
,
, 6 ( ). CRC32 :
- .
- , ( â , â ).
- .
, 6 :
:
:
CRC32 . , , :
:
- -, .
- . , -. , . .
- : , , , .
: « , , , â , , ». â , . , :
, HASHES â , , , . , 6 :
,
.
4 . . , , â (PRNG ).
C rand, - . Legendre PRF, .
, , , - . , . , ( 0) .
- , , , , . , ( â ) . . , . 50%, , .
. Python :
def LegendrePRNG(a,p):
if a==0:
a+=1
while True:
next_bit=pow(a,(p-1)//2,p)
if next_bit==1:
yield 1
else:
yield 0
a=(a+1)%p
if a==0:
a+=1
32- , Meet-in-the-Middle. , , . , 32- , 32 . , â big-endian little-endian, â .
, . Legendre PRNG. 32 . , (, ).
, . , . , , . , â . , , .
, , . , . , .
, :
- Bleichenbacherâs e=3.
- .
- .
- CRC32.
- .
, .
, , , . - Linux Usermode Kernel CryptoAPI .
, : . SIMD, . , , : . .
, . , : . â . , . . , .
, . , , , :
- .
- , , .
- - .
- .
:

(, ) .

, . .

. .

, .

.

, , , - . , memcpy , SIMD, memcpy . .
- . Zero Knowledge , Python, PEM. , , , .
, .
24 , , . CryptoAPI: AF_ALG, .
, - . .
, , .
, , . , pwn :)
, :
- -, C , . ASAN (Address Sanitizer), .
- -, , , . , . Libfuzzer , .
: . /dev/urandom randrand, ( Legendre PRF, ) srand(0). , . - AES- .
, . , .
, , . , , â : , , .
Legendre PRNG . , . , .
Proof of Knowledge, . , , . , :
- . , . - , SLA ( ).
- , , . . . - , SLA.
- . . , , , . , , . SLA.
(Bushwhackers) SLA 65%, . , scoreboard, .
, , . .
, , . , , . , .
, https://github.com/bi-zone/CTFZone-2020-Finals-LittleKnowledge. , . , ( ) . . , , . , - CTF.
, , !