PDA

Просмотр полной версии : выдергивание части строки из текста


traceme
14.07.2015, 15:38
Есть список баннеров при сканировании ssh серверов через масскан

Подскажите рецепт, чтобы средствами bash оставить только список ip столбиком при условии что оставить надо только те адреса, которые имеюt определенную версию ssh

faza02
14.07.2015, 15:54
формат списка бы привели

traceme
14.07.2015, 16:08
↑ (https://antichat.live/posts/3868220/)
формат списка бы привели


Например вывод в формате json

{ "ip": "xxx.xxx.xxx.xxx", "ports": [ {"port": 21, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 59} ] },

{ "ip": "xxx.xxx.xxx.xxx", "ports": [ {"port": 21, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 59} ] },

{ "ip": "xxx.xxx.xxx.xxx", "ports": [ {"port": 21, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 59} ] },

{ "ip": "xxx.xxx.xxx.xxx", "ports": [ {"port": 21, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 59} ] },

{ "ip": "xxx.xxx.xxx.xxx", "ports": [ {"port": 21, "proto": "tcp", "service": {"name": "ftp", "banner": "220 (vsFTPd 2.3.2)\u000a530 Please login with USER and PASS."} } ] },

{ "ip": "xxx.xxx.xxx.xxx", "ports": [ {"port": 21, "proto": "tcp", "service": {"name": "ftp", "banner": "220 (vsFTPd 2.3.2)\u000a530 Please login with USER and PASS."} } ] },

{ "ip": "xxx.xxx.xxx.xxx", "ports": [ {"port": 21, "proto": "tcp", "service": {"name": "ftp", "banner": "220 FTP Server ready.\u000a500 AUTH not understood"} } ] },

{ "ip": "xxx.xxx.xxx.xxx", "ports": [ {"port": 21, "proto": "tcp", "service": {"name": "ftp", "banner": "220 FTP Server ready.\u000a500 AUTH "} } ] },

{ "ip": "xxx.xxx.xxx.xxx", "ports": [ {"port": 21, "proto": "tcp", "service": {"name": "ftp", "banner": "220 ProFTPD 1.3.3a Server (Debian) [::ffff:xxx.xxx.xxx.xxx]\u000a500 AUTH not understood"} } ] },

Необходимо получить список адресов где баннер содержит "220 (vsFTPd 2.3.2)"

b3
14.07.2015, 17:34
cat qqq | grep '220 (vsFTPd 2.3.2)' | awk '{print $3}' | tr -d '",'


Вот так

traceme
14.07.2015, 17:46
↑ (https://antichat.live/posts/3868262/)
Вот так


Спасибо)

traceme
15.07.2015, 04:03
Не хочется создавать под каждый вопрос тему, спрошу тут

В баш скрипте необходимо получать ввод пользователя, а именно диапазона адресов

Банальный пример


#!/bin/bash
echo "Enter ip range for scan ex.10.0.0.0/8"
read range

Подскажите как применить маску для ввода и выдавать ошибку при некорректном вводе диапазона

b3
15.07.2015, 06:11
man test


А вот пару примеров: http://stackoverflow.com/questions/14425613/regex-and-input-validation-bash