|
| 1 | +#+AUTHOR: GTrunSec |
| 2 | + |
| 3 | +#+DATE: 10 August 2019 |
| 4 | +#+DESCRIPTION: |
| 5 | +#+KEYWORDS: |
| 6 | +#+LANGUAGE: en cn |
| 7 | +#+SETUPFILE: ~/org-notes/setup/darkcss.local |
| 8 | +#+hugo_publishdate: (0 5) |
| 9 | +#+hugo_auto_set_lastmod: t |
| 10 | +#+HUGO_categories: |
| 11 | +#+HUGO_tags: |
| 12 | +#+OPTIONS: H:3 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t |
| 13 | +#+SELECT_TAGS: export |
| 14 | +#+EXCLUDE_TAGS: noexport |
| 15 | +* Buding Zeek with Nix package manager |
| 16 | +** Building Zeek's binary by nix package manager |
| 17 | +#+begin_src sh :async t :exports both :results output |
| 18 | +git clone https://github.com/hardenedlinux/nixpkgs-hardenedlinux |
| 19 | +nix-build nixpkgs-hardenedlinux/test/zeek.nix |
| 20 | +#+end_src |
| 21 | + |
| 22 | +** Using Zeek's binary via hardenedlinux binary cache machines(Speed up) |
| 23 | +#+begin_src sh :async t :exports both :results output |
| 24 | +git clone https://github.com/hardenedlinux/nixpkgs-hardenedlinux |
| 25 | +nix-build nixpkgs-hardenedlinux/test/zeek.nix --option substituters "https://cache.nixos.org http://221.4.35.244:8301" --option trusted-public-keys "221.4.35.2 |
| 26 | +44:3ehdeUIC5gWzY+I7iF3lrpmxOMyEZQbZlcjOmlOVpeo=" |
| 27 | +these derivations will be built: /nix/store/z0wbd0vgrv5dddxswrw1v3qdx7g1yrbi-nsm-zeek.drv |
| 28 | +these paths will be fetched (0.00 MiB download, 37.78 MiB unpacked): |
| 29 | + /nix/store/3i9f2f5rklrw4x0rafs8l440h7qs8r8i-zeek-3.0.6 |
| 30 | +copying path '/nix/store/3i9f2f5rklrw4x0rafs8l440h7qs8r8i-zeek-3.0.6' from 'http://221.4.35.244:8301'... |
| 31 | +building '/nix/store/z0wbd0vgrv5dddxswrw1v3qdx7g1yrbi-nsm-zeek.drv'... |
| 32 | +created 7 symlinks in user environment |
| 33 | +/nix/store/pr41149ralbb71abdny78dnlzaaj789n-nsm-zeek |
| 34 | +#+end_src |
| 35 | + |
| 36 | +* Deploy Zeek kafka topics with Nix home-manager on Debian(OS) |
| 37 | +- get more information: https://github.com/hardenedlinux/debian-nix-manager |
| 38 | + |
| 39 | + |
| 40 | +#+begin_src sh :async t :exports both :results output |
| 41 | +home-manager switch |
| 42 | +deploy-home-manager -s ## to start each service of NSM status |
| 43 | +deploy-home-manager -c ## to check each service of NSM status |
| 44 | +#+end_src |
| 45 | + |
| 46 | +- Then Zeekctl deploy Zeek's cluster |
| 47 | + |
| 48 | + |
| 49 | +or Do a kafka topics test. |
| 50 | + |
| 51 | +#+BEGIN_EXAMPLE |
| 52 | +sudo zeek -i <enth> <hardnedlinux-zeek-script>/scirpts/local.zeek |
| 53 | +#+END_EXAMPLE |
| 54 | + |
| 55 | +#+NAME: topics |
| 56 | +#+CAPTION: test |
| 57 | +#+ATTR_ORG: :width 500 |
| 58 | +#+ATTR_LATEX: :width 5in |
| 59 | +[[file:img/index-topics.png]] |
| 60 | + |
| 61 | +#+NAME: Topics |
| 62 | +#+CAPTION: |
| 63 | +#+ATTR_ORG: :width 500 |
| 64 | +#+ATTR_LATEX: :width 5in |
| 65 | +[[file:img/topics.png]] |
| 66 | + |
| 67 | +* CHANGES |
| 68 | + taking test with zeek -i ens |
| 69 | + |
| 70 | + #+begin_src sh :async t :exports both :results output |
| 71 | +sudo zeek -i enp1s0 -C ~/project/hardenedlinux-zeek-script/scripts/local.zeek |
| 72 | + #+end_src |
| 73 | + |
| 74 | +- using nix env do zeek quickly. more information: https://github.com/hardenedlinux/NSM-data-analysis |
| 75 | + |
| 76 | + |
| 77 | +#+begin_src sh :async t :exports both :results output |
| 78 | + cd NSM-data-analysis/ |
| 79 | + mkdir -p zeek-log |
| 80 | + cd zeek-log |
| 81 | + sudo ../result/bin/zeek -i eno1 ../../scripts/local.zeek |
| 82 | +#+end_src |
| 83 | + |
| 84 | +- Quickly start with zkg |
| 85 | + |
| 86 | + |
| 87 | +#+begin_src sh :tangle yes |
| 88 | + sudo pip install bro-pkg |
| 89 | + ##zeek installation is owned by "root" user that was stored in /root/.bro-pkg |
| 90 | + sudo zkg autoconfig |
| 91 | + sudo zkg config script_dir |
| 92 | + sudo zkg config plugin_dir |
| 93 | + sudo zkg install https://github.com/hardenedlinux/hardenedlinux-zeek-script |
| 94 | + |
| 95 | +echo '@load packages' | sudo tee --append /usr/local/zeek/share/zeek/site/local.zeek |
| 96 | + |
| 97 | +#or @load packages/hardenedlinux-zeek-script |
| 98 | +sudo zeekctl deploy |
| 99 | + |
| 100 | + |
| 101 | +#+end_src |
| 102 | + |
| 103 | +- TEST Environment |
| 104 | + |
| 105 | + |
| 106 | +#+begin_src shell :tangle yes |
| 107 | +zeek -v |
| 108 | +zeek version 3.0.0-rc1 |
| 109 | + |
| 110 | +zeekctl status |
| 111 | +Name Type Host Status Pid Started |
| 112 | +manager manager 10.220.170.123 running 9214 12 Aug 02:49:28 |
| 113 | +proxy-1 proxy 10.220.170.123 running 9264 12 Aug 02:49:29 |
| 114 | +worker-1 worker 10.220.170.121 running 1784 12 Aug 02:49:31 |
| 115 | +#+end_src |
| 116 | + |
| 117 | +** VirusTotal-Check |
| 118 | +- [X] [public] [[file:scripts/files/known_hash.zeek]] |
| 119 | + |
| 120 | + - [X] [VT_API] [[file:scripts/files/vt_check.zeek]] |
| 121 | + |
| 122 | + |
| 123 | + |
| 124 | + - [X] [POSTGRESQL] [[file:scripts/files/virustotal.zeek]] |
| 125 | + |
| 126 | + |
| 127 | +#+BEGIN_EXAMPLE |
| 128 | +psql -h localhost -p 5432 -U myuser -d testdb -c 'SELECT * FROM known_hash;' |
| 129 | + |
| 130 | + id | ts | host | hash | known_file_types |
| 131 | +----+------------------+-------------+------------------------------------------+----------------------- |
| 132 | + 1 | 1570941985.53655 | 10.1.10.162 | 2dde1a34ac02478052b691bd18c89c7a13edc5f4 | application/x-dosexec |
| 133 | + 2 | 1570941985.53655 | 10.1.10.162 | 60ff5bfec4df9f809817423b23536601 | application/x-dosexec |
| 134 | + 3 | 1570941988.84281 | 10.1.10.162 | d25af249e01191f08f359b302db42414e0a4587e | application/x-dosexec |
| 135 | + 4 | 1570941988.84281 | 10.1.10.162 | 9cf60bd41e6f235e12e3c761f5d2ef11 | application/x-dosexec |
| 136 | +(4 rows) |
| 137 | + |
| 138 | + psql -h localhost -p 5432 -U myuser -d testdb -c 'SELECT permalink FROM virtustotal;' |
| 139 | + |
| 140 | + permalink |
| 141 | +---------------------------------------------------------------------------------------------------------------- |
| 142 | + https://www.virustotal.com/file/fc7eafb97431c3f45a0ced2c38e869f768234897874317ffb0755eb920316294/analysis/1565393170/ |
| 143 | + https://www.virustotal.com/file/8021b619c48d9017a2c3b0beddb1b48d067be75551a44a9d8b79c1daff78ede0/analysis/1560568105/ |
| 144 | +(2 rows) |
| 145 | +#+END_EXAMPLE |
| 146 | + |
| 147 | +- [X] [TEST_LOG] [[file:scripts/files/log]] |
| 148 | + |
| 149 | + |
| 150 | + Please see Install POSTGRESQL-analyzers: |
| 151 | + |
| 152 | +[[https://github.com/hardenedlinux/Debian-GNU-Linux-Profiles/blob/master/NSM/INSTALL/analyzer.sh][Debian-GNU-Linux-Profiles/analyzer.sh at master · hardenedlinux/Debian-GNU-Linux-Profiles]] |
| 153 | + |
| 154 | +** Known/hosts/domains |
| 155 | +- [X] [[file:scripts/protocols/dns/known-domains.zeek]] :Cluster::worker <2019-08-10 Sat 02:36> |
| 156 | + |
| 157 | + - Test_log: [[file:scripts/protocols/dns/log/known_domain.log]] |
| 158 | + |
| 159 | + |
| 160 | + |
| 161 | +- [X] [[file:scripts/protocols/dns/manager-domains.zeek]] :Cluster::manager |
| 162 | + |
| 163 | + - [[file:scripts/protocols/dns/log/manager_known_domain.log]] |
| 164 | + |
| 165 | + |
| 166 | + |
| 167 | + - add TEST ignore_dns list |
| 168 | + |
| 169 | + |
| 170 | +- [X] [[file:scripts/protocols/conn/known-hosts-with-dns.zeek]] |
| 171 | + |
| 172 | + - [[https://github.com/dopheide-esnet/zeek-known-hosts-with-dns/tree/master/scripts][zeek-known-hosts-with-dns/scripts at master · dopheide-esnet/zeek-known-hosts-with-dns]] |
| 173 | + |
| 174 | + |
| 175 | + |
| 176 | + - ~@unload protocols/conn/known-hosts~ |
| 177 | + |
| 178 | + |
| 179 | + - setting/local_net_field.zeek [Host_tracking = LOCAL_HOSTS/ALL_HOSTS] |
| 180 | + |
| 181 | + |
| 182 | +** VXLAN |
| 183 | +- [ ] [TODO] [[file:scripts/vlan-info/vlan-data.zeek][VLAN_INFO]] |
| 184 | + |
| 185 | + - Add area and adapted to known-hosts[LOCAL_HOSTS] |
| 186 | + |
| 187 | + |
| 188 | + |
| 189 | +** Notice |
| 190 | +*** Setting |
| 191 | +IGNORE - Ignores the notice and won't even log it. |
| 192 | + |
| 193 | +#+begin_src sh :async t |
| 194 | +SSL::Invalid_Server_Cert |
| 195 | +#+end_src |
| 196 | + |
| 197 | +** Count & TOPK |
| 198 | +- [X] [15mins] TOP dns |
| 199 | + |
| 200 | + |
| 201 | +- [ ] [] TOP Unknow HTTP request |
| 202 | + |
| 203 | + |
| 204 | +- [ ] [] TOP metrics |
| 205 | + :top_size count 20 |
| 206 | + :talker_bin_size = 10000; |
| 207 | + |
| 208 | + - [ ] [10sec] TOP urls |
| 209 | + |
| 210 | + |
| 211 | + |
| 212 | + - [ ] [10sec] [] TOP talks |
0 commit comments