-
Notifications
You must be signed in to change notification settings - Fork 7
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
smirnovmaks
committed
Nov 20, 2022
0 parents
commit 80392a0
Showing
338 changed files
with
96,831 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,49 @@ | ||
# Отборочный этап VI Кубка CTF России | ||
|
||
Исходные коды, разборы, эксплоиты и файлы для деплоя заданий с отборочного тура VI Кубка CTF России, который проходил 19-20 ноября 2022 года в онлайн-формате. | ||
|
||
[Сайт соревнований](https://ctfcup.ru/) | ||
|
||
Генеральный партнер соревнований - **Газпромбанк**\ | ||
Официальный партнер - **СБЕР**\ | ||
Стратегический партнер - **RDP**\ | ||
Технологические партнеры - **EdgeCenter** и **UserGate**\ | ||
Партнеры - **PositiveTechnologies**, **НТЦ Вулкан**, **Координационный центр доменов .RU/.РФ** | ||
|
||
Таск | Категория | Баллы | Кол-во решений | Автор | | ||
| ---------------------------------------------------------------------------------------- | --------- | ----- | -------------- | ----- | | ||
| [Good pad / bad pad](tasks/crypto/good_pad_bad_pad/README.md) | crypto | 1000 | 0 | @bork_dog | | ||
| [Important task](tasks/crypto/important_task/README.md) | crypto | 213 | 38 | @bork_dog | | ||
| [Dinosaurs](tasks/crypto/dinosaurs/README.md) | crypto | 1000 | 1 | @bork_dog | | ||
| [The time has come](tasks/crypto/the_time_has_come/README.md) | crypto | 909 | 2 | @bork_dog | | ||
| [Stolen blueprints](tasks/crypto/stolen_blueprints/README.md) | crypto | 333 | 21 | @bork_dog | | ||
| [onlytweets](tasks/web/onlytweets/README.md) | web | 833 | 3 | @jnovikov | | ||
| [warmup](tasks/web/warmup/README.md) | web | 357 | 19 | @jnovikov | | ||
| [legacy](tasks/web/legacy/README.md) | web | 455 | 13 | @jnovikov | | ||
| [simple](tasks/web/simple/README.md) | web | 833 | 3 | @shipko | | ||
| [malware_autopsy](tasks/forensics/malware_autopsy/README.md) | forensic | 213 | 38 | @swissarmy | | ||
| [fallen_angel](tasks/forensics/fallen_angel/README.md) | forensic | 78 | 120 | @swissarmy | | ||
| [french_connection](tasks/forensics/french_connection/README.md) | forensic | 1000 | 1 | @slyshay6 | | ||
| [Red firmware I](tasks/forensics/Red_firmware_I/README.md) | forensic | 244 | 32 | @greg0r0 | | ||
| [Simple Encoder](tasks/reverse/simple_encoder/README.md) | reverse | 526 | 10 | @greg0r0 | | ||
| [unicorn_plc](tasks/reverse/unicorn_plc/README.md) | reverse | 769 | 4 | @greg0r0 | | ||
| [crackme2077](tasks/reverse/crackme2077/README.md) | reverse | 1000 | 1 | @revker | | ||
| [bebrus](tasks/reverse/bebrus/README.md) | reverse | 667 | 6 | @revker | | ||
| [watcher](tasks/pwn/watcher/README.md) | pwn | 1000 | 1 | @revker | | ||
| [SHELLyha](tasks/pwn/shellyha/README.md) | pwn | 833 | 3 | @revker | | ||
| [ozne](tasks/pwn/ozne/README.md) | pwn | 909 | 2 | @revker | | ||
| [babystack](tasks/pwn/babystack/README.md) | pwn | 667 | 6 | @revker | | ||
| [classic_matreshka](tasks/warmup/classic_matreshka/README.md) | warmup | 50 | 193 | @RegularITCat | | ||
| [gpb_math_pong](tasks/warmup/math_pong/README.md) | warmup | 92 | 100 | @RegularITCat | | ||
## Результаты | ||
|
||
 | ||
|
||
[Полный список](scoreboard/full.png) | ||
|
||
## Инфраструктура | ||
|
||
Инфраструктура была предоставлена компанией [EdgeCenter](https://edgecenter.ru) | ||
|
||
- DevOps: [@Rubikoid](https://github.com/@Rubikoid) | ||
- Checksystem: [yatb](https://github.com/kksctf/yatb) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
# Crypto | Hard | dinosaurs | ||
|
||
## Информация | ||
Как-то раз один иностранец Bin Zhang пошутил: "Какова вероятность, что ты сегодня на улице встретишь динозавра? Правильно, 50% - либо ты его встретишь, либо нет!" Криптографы нашего завода очень оценили шутку, поэтому решили внедрить описываемый в его докладе шифр в аппаратуру на нашем заводе. | ||
Теперь вам нужно решить, ставить ли в угол ответственных за такие решения, или нет? | ||
|
||
## Деплой | ||
- | ||
|
||
## Выдать участникам | ||
Файлы из папки public | ||
|
||
## Описание | ||
- | ||
|
||
## Решение | ||
Нам дан фильтрующий генератор с нелинейной функцией. У нелинейной функции есть переменные, для которых корреляционная (утекающая) вероятность велика - попробуем применить корреляционную атаку. Но мне удобнее работать с комбинирующими генераторами. Мы можем перейти от фильтрующего генератора к комбинирующему - как это сделать, я описал в pdf-файлике ["Переход от фильтрующего генератора к комбинирующему"](solve/Переход_от_фильтрующего_генератора_к_комбинирующему.pdf). Также для понятности я написал [скрипт](solve/filt_to_comb.py), который показывает эквивалентность двух схем. | ||
|
||
Теперь нам надо как-то восстановить начальное заполнение регистра. В описании задания делается акцент на веротяности - самые растпространенные атаки на комбинирующие генераторы (аналогично и на фильтрующие) - это корреляционные атаки. Тепрь нужно подобрать подходящий метод. Для обычной корреляционной атаки регистр слишком длинный - атака Зигентайлера не сработает быстро, в многочлене обратной связи слишком много точек съема - быстрая атака Майера-Штафельбаха тоже не сработает. Но если обратить внимание на описание задания, там упомянут некий Bin Zhang - если поискать статьи по корреляционным атакам от данного автора, то первыми ссылками будут его статьи по порционным корреляционным атакам. На основе одной из таких статей и основывается таск - для вас я специально описал данную атаку в pdf-файлике ["корреляционная атака"](solve/Корреляционная_атака.pdf), а также реализовал её в [скрипте](solve/brek.py). | ||
|
||
После получения начального заполнения (должно получиться одно, но если их несколько - не сильно страшно, применяем действия к каждому по очереди), просто применяем к нему действия, которые были описаны в данном по условию нам python-файлике. | ||
## Флаг | ||
|
||
`CUP{iZdXTOHf}` | ||
|
Empty file.
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,2 @@ | ||
Как-то раз один иностранец Bin Zhang пошутил: "Какова вероятность, что ты сегодня на улице встретишь динозавра? Правильно, 50% - либо ты его встретишь, либо нет!" Криптографы нашего завода очень оценили шутку, поэтому решили внедрить описываемый в его докладе шифр в аппаратуру на нашем заводе. | ||
Теперь вам нужно решить, ставить ли в угол ответственных за такие решения, или нет? |
Empty file.
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,55 @@ | ||
#! /usr/bin/env python3 | ||
|
||
from pylfsr import LFSR | ||
from Crypto.Util.number import long_to_bytes | ||
from base64 import b64encode | ||
import json | ||
|
||
f = [0,0,0,1,0,0,0,1,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,1,0,0,0,1,1,0,1,1,0,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,0,0,0,1,1,1,1,0,1,1,1] | ||
pickup_points = [7, 10, 17, 23, 36, 42] | ||
poly = [48, 47, 44, 42, 41, 37, 36, 35, 31, 30, 27, 24, 23, 21, 20, 17, 16, 15, 13, 10, 9, 8, 7, 4, 3, 1] | ||
start_pos = 1000 | ||
N = 20000 | ||
|
||
|
||
def Gen_gamma_filt_gen(state, N): | ||
L = LFSR(fpoly=poly,initstate = state) | ||
|
||
gamma = [] | ||
L.runKCycle(start_pos) | ||
for _ in range(N): | ||
st = list(L.state) | ||
st.reverse() | ||
bin_idx = [st[i] for i in pickup_points] | ||
idx = int("".join([str(i) for i in bin_idx]),2) | ||
gamma.append(f[idx]) | ||
L.runKCycle(1) | ||
|
||
return gamma | ||
|
||
|
||
def Dump_gamma(gamma, filename): | ||
dict = {"g": gamma} | ||
filename = f"{filename}.json" | ||
with open(filename, 'w') as file_object: | ||
json.dump(dict, file_object) | ||
|
||
|
||
def main(): | ||
init_state = [1,0,0,0,1,0,0,1,1,0,0,1,0,1,1,1,0,1,0,1,0,1,1,1,0,1,0,0,1,1,0,0,1,1,1,0,0,0,0,1,1,1,0,1,1,1,1,1] | ||
#init_state = [random.randint(0,1) for _ in range(48)] | ||
#init_state = 48*[0] | ||
print("0b"+"".join([str(i) for i in init_state])) | ||
|
||
bt = long_to_bytes(int("".join([str(i) for i in init_state]),2)) | ||
flag = b64encode(bt).decode() | ||
print("CUP{"+flag+"}") | ||
|
||
g = Gen_gamma_filt_gen(init_state, N) | ||
filename = "output" | ||
|
||
Dump_gamma(g, filename) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,21 @@ | ||
#! /usr/bin/env sage | ||
|
||
def main(): | ||
F.<x> = GF(2)[] | ||
f = F.random_element(degree=48) | ||
while not f.is_primitive(): | ||
f = F.random_element(degree=48) | ||
print(f) | ||
print(f.list()) | ||
|
||
f_index = [] | ||
for i,val in enumerate(f.list()[1:]): | ||
if val: | ||
f_index.append(i+1) | ||
f_index.reverse() | ||
print(f_index) | ||
print(f.is_irreducible()) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
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,53 @@ | ||
#! /usr/bin/env python3 | ||
|
||
from pylfsr import LFSR | ||
from Crypto.Util.number import long_to_bytes | ||
from base64 import b64encode | ||
import json | ||
|
||
f = [0,0,0,1,0,0,0,1,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,1,0,0,0,1,1,0,1,1,0,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,0,0,0,1,1,1,1,0,1,1,1] | ||
pickup_points = [7, 10, 17, 23, 36, 42] | ||
poly = [48, 47, 44, 42, 41, 37, 36, 35, 31, 30, 27, 24, 23, 21, 20, 17, 16, 15, 13, 10, 9, 8, 7, 4, 3, 1] | ||
start_pos = 1000 | ||
N = 20000 | ||
|
||
|
||
def Gen_gamma_filt_gen(state, N): | ||
L = LFSR(fpoly=poly,initstate = state) | ||
|
||
gamma = [] | ||
L.runKCycle(start_pos) | ||
for _ in range(N): | ||
st = list(L.state) | ||
st.reverse() | ||
bin_idx = [st[i] for i in pickup_points] | ||
idx = int("".join([str(i) for i in bin_idx]),2) | ||
gamma.append(f[idx]) | ||
L.runKCycle(1) | ||
|
||
return gamma | ||
|
||
|
||
def Dump_gamma(gamma, filename): | ||
dict = {"g": gamma} | ||
filename = f"{filename}.json" | ||
with open(filename, 'w') as file_object: | ||
json.dump(dict, file_object) | ||
|
||
|
||
def main(): | ||
init_state = 48*[0] | ||
print("0b"+"".join([str(i) for i in init_state])) | ||
|
||
bt = long_to_bytes(int("".join([str(i) for i in init_state]),2)) | ||
flag = b64encode(bt).decode() | ||
print("CUP{"+flag+"}") | ||
|
||
g = Gen_gamma_filt_gen(init_state, N) | ||
filename = "output" | ||
|
||
Dump_gamma(g, filename) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
Oops, something went wrong.