###### tags: `netology` `security` # Домашнее задание к занятию «Системное программирование (язык C) - типовые конструкции» ## Задача "Ломаем ping" 1. Какое предупреждение (Warning) было выведено при компиляции? По желанию: проведите доп.исследование на предмет сути предупреждения (с чем оно связано, какие риски от использования одной из функций в программе и что это за функция). 2. Ввод, приводящий к падению приложения 3. Ввод, приводящий к выполнению другой команды (не ping) --- 1. ```bash= ping.c: In function ‘main’: ping.c:13:5: warning: implicit declaration of function ‘gets’; did you mean ‘fgets’? [-Wimplicit-function-declaration] 13 | gets(host); | ^~~~ | fgets /usr/bin/ld: /tmp/ccci8Gpt.o: in function `main': ping.c:(.text+0x15e): warning: the `gets' function is dangerous and should not be used. ``` 2. **Input**: (Строка в которой больше 256 символов) `this_is_ver_long_string_with_more_than_two_hundred_and_fifty_six_signs_and_once_again_this_is_ver_long_string_with_more_than_two_hundred_and_fifty_six_signs_and_once_again_this_is_ver_long_string_with_more_than_two_hundred_and_fifty_six_signs_and_once_again_` ```bash= please enter host for ping <input> command: part_of_<input> host: part_of_<input> zsh: segmentation fault ./ping ``` 3. **Input**: (заглушка из 16 пробелов + хацкерская команда) ` cat /etc/passwd` ```bash= please enter host for ping cat /etc/passwd command: cat /etc/passwd host: cat /etc/passwd full command: cat /etc/passwd cat /etc/passwd ... daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin sys:x:3:3:sys:/dev:/usr/sbin/nologin sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/usr/sbin/nologin ... ```