æªæã®ãããã¡ã¤ã³åã®ãã©ãã¯ãªã¹ããã¾ã¨ãã¦åå¾ã»ç®¡çãããã¼ã« mdstore ãå ¬éãã¾ãã
æªæã®ãããã¡ã¤ã³åã®ãã©ãã¯ãªã¹ããåå¾ã»ç®¡çãã mdstore ã¨ãããã¼ã«ãä½ã£ã¦å ¬éãã¾ããã
ä¸ã®ä¸ã«ã¯ãã£ãã·ã³ã°è©æ¬ºããã«ã¦ã§ã¢ã«ããæ»æã«ä½¿ããããã¡ã¤ã³åã®ãã©ãã¯ãªã¹ããå ¬éãã¦ãããµã¼ãã¹ãããã¤ãããã¾ãï¼åèï¼ãè¿å¹´ã¯DGA(Domain Generation Algorithm)ãå©ç¨ãããã«ã¦ã§ã¢ããããããã©ãã¯ãªã¹ãåã ãã§ã¯è¿½ãã¤ããªãå ´åãããã¾ãããããã§ãæ¢ç¥ã®æ»æã«å©ç¨ããããã¡ã¤ã³åã®åå解決ãçºè¦ãããã¯é²æ¢ã§ããã°ãæ°´éã§æ»æã«ãã被害ãé£ãæ¢ããããå¯è½æ§ãããã¾ãã
ãã ããã®ãããªãã©ãã¯ãªã¹ãã¯æä¾ãã¦ãããµã¤ãã«ãã£ã¦ã«ãã¼ãã¦ããé åãªã©ãéãããããã©ãã¯ãªã¹ããã¨ã«éããã¡ã¤ã³ãæ±ããã¦ãã¾ããå¤ãã®ãã¡ã¤ã³ãç¶²ç¾ ãããã¨ããã¨è¤æ°ã®ãµã¤ããããã¼ã¿ãåå¾ããå¿ è¦ãããã¾ããããã©ã¼ããããç°ãªããªã©ã®çç±ããä¸æéå¿ è¦ã§ãã
ãã®ãã¼ã«ã¯è¤æ°ã®ãã©ãã¯ãªã¹ãããã¼ã«ã«ã«ãã¦ã³ãã¼ãããDBã«æãå ¥ãã¦ç®¡çã»å©ç¨ãããã¨ã§ããã®ä¸æéãç°¡ç¥åãããã¨ãããã®ã§ãã2017å¹´1æ7æ¥ç¾å¨ã以ä¸ã®3ãµã¤ããããã¼ã¿ãåå¾ãã¾ãã
- DNS-BH â Malware Domain Blocklist: BH DNS Files, Terms of Use
- MVPS: Blocking Unwanted Connections with a Hosts File
- hpHosts: Download, End User Licence Agreement
注æï¼ãã©ãã¯ãªã¹ããæä¾ãã¦ããåãµã¤ãã®å©ç¨è¦ç´ã§ã¯åºæ¬çã«internalãªå©ç¨ã¯èªãã¦ããããã§ãããç¹ã«åç¨å©ç¨ãªã©ãããå ´åã«ã¯è©³ç´°ããèªèº«ã§ãã確èªãã¦ãã ããã
使ãæ¹
ã»ããã¢ãã
æ¬ãã¼ã«ã¯nodeã§åä½ããredisã«ãã¼ã¿ãæ ¼ç´ãã¾ããåä½ã確èªãã¦ãããã¼ã¸ã§ã³ã¯ä»¥ä¸ã®ã¨ããã§ãã
- node: v7.2.1, v6.0, v6.1
- redis: v3.2.6
ã¤ã³ã¹ãã¼ã«ã¯ç°å¢ã«åããã¦ãããªã«ãã£ã¦ãã ããããã®å¾ãnpmã使ã£ã¦mdstoreãã¤ã³ã¹ãã¼ã«ãã¾ãã
$ npm install -g mdstore
ãã¹ãéãã®ãé¢åã§ãªããã°ã«ã¬ã³ããã£ã¬ã¯ããªã¸ã®ã¤ã³ã¹ãã¼ã«ï¼ä¸è¨ã³ãã³ããã-g
ãæãï¼ã§ãåé¡ããã¾ããã
ããã«ãã¼ã«å©ç¨åã«redis-serverãåä½ãã¦ãããã¨ã確èªãã¦ãã ããã
- install mdstore by npm
npm install -g mdstore
- start redis server, e.g.
redis-server &
ã¾ãããã©ã«ãã®redis serveræ¥ç¶å (localhost, port 6379, db 0) 以å¤ã使ãããå ´åã¯ãªãã·ã§ã³ã§æå®ã§ãã¾ãã
-s
or--host
: redis server host-p
or--port
: redis server port-d
or--db
: redis server db
ãã©ãã¯ãªã¹ãã®æ´æ°
update
ã³ãã³ãã使ããã¨ã§åãµã¤ãã®ãã©ãã¯ãªã¹ãããã¦ã³ãã¼ãããDBã¸ã®æ ¼ç´ã¾ã§ãå®æ½ãã¾ãããã§ã«å¯¾è±¡ã®ãã¡ã¤ã³åãåå¨ããå ´åã¯ãåå¾ããã¨ããå±¥æ´ã追è¨ããã¾ããç¾å¨ãµãã¼ããã¦ãããµã¤ãã¯3ãµã¤ãã ãã§ãããhpHostsãç¹ã«ä»¶æ°ãå¤ãããå®äºã¾ã§ã«2ã3åãããã¾ãã
$ mdstore update update: OK
ãã¡ã¤ã³ãæ¢ã
get
ã³ãã³ãã使ããã¨ã§ãããã¡ã¤ã³åãåå¨ãããã©ããã調ã¹ããã¨ãã§ãã¾ããä¸è¨ã§ã¯ä¾ã¨ã㦠151.ru
ã¨ãããã¡ã¤ã³åãåå¨ãã¦ãããã©ãããã¯ã¨ãªãã¦ãã¾ãã
% mdstore get 151.ru 2017-01-06T14:44:05.347Z { source: 'hphosts', ts: 1483713845.347 }
å·¦ã®ã«ã©ã ã対象ã¨ãªããã©ãã¯ãªã¹ãããã¦ã³ãã¼ãããæå»ã«ãªãã¾ããå³å´ã®ts
ã®ãã£ã¼ã«ããã¿ã¤ã ã¹ã¿ã³ãã§ãããDateã«å¤æãããã®ã§ãããã¡ã¤ã³åããã©ãã¯ãªã¹ãã«è¿½å ãããæå»ã§ã¯ãªãç¹ã«æ³¨æãã¦ããããã°ã¨æãã¾ããsourceã¯ãã©ãã¯ãªã¹ãã®åå¾å
ã表ãã¦ãããhphosts
ãdnsbh
ãmvps
ã®ããã«è¡¨ç¤ºããã¾ãã
ãã®ä»ããã¼ã¿ã®åå¾å ã§æ²è¼ããã¦ããé ç®ã«å¿ãã¦è¿½å ã®ã¡ã¿æ å ±ã表示ããã¾ãã
/etc/hosts ã®çæ
ãã¼ã«ã«ã®redisã«ä¿åãã¦ãããã¼ã¿ããã¨ã«ãæªæã®ãããã¡ã¤ã³åã 127.0.0.1 ã«å¼·å¶çã«å¤æãã /etc/hosts ãçæãã¾ããããã /etc/hosts ã¨ç½®ãæãããã¨ã§æªæã®ãããµã¼ãã¨éä¿¡ããå¯è½æ§ãä½æ¸ããããã¨ãã§ãã¾ãã
$ mdstore hosts > hosts.txt $ head hosts.txt 127.0.0.1 localhost ::1 localhost 127.0.0.1 www.wwsupport.net 127.0.0.1 www.memdesign.co.uk 127.0.0.1 www.titanweb.net 127.0.0.1 www.livingston.rs 127.0.0.1 iphonesupport.co.uk 127.0.0.1 up1702.info 127.0.0.1 dcstest.wtlive.com 127.0.0.1 ad.doubleclick.net.34325.9225.302br.net $ sudo cp hosts.txt /etc/hosts # Linuxã®å ´å $ sudo cp hosts.txt /private/etc/hosts # macOSã®å ´å
ãã¼ã¿ã¸ã®ã¢ã¯ã»ã¹
CLIã§ã¢ã¯ã»ã¹ãã以å¤ã«ã¯ããã¼ã«ã«ã®redisã«æ ¼ç´ãããã¼ã¿ã¯mdstoreã®ã©ã¤ãã©ãªã使ã£ã¦åç §ãããã¨ãã§ãã¾ãã以ä¸ã®ãããªnodeã®ã³ã¼ãã§ã¢ã¯ã»ã¹ã§ãã¾ããDNSã®åãåãããã°ãæã£ã¦ããå ´åãèªåã§ã³ã¼ããæ¸ããã¨ã§ä¸å¯©ãªãµã¤ãã¸ã®ã¢ã¯ã»ã¹ããªãã£ããã確èªã§ãã¾ãã
var mdstore = new (require('mdstore')).Redis(); mdstore.update((err) => { // synced mdstore.get('is.the.domain.malicious.com', (err, res) => { if (res.length > 0) { console.log('yes, the domain name is malicious'); } else { console.log('no, this is benign'); } }); });
ã¾ããå½ç¶ã§ããredis serverã«ç´æ¥ã¯ã¨ãªãããã¨ãå¯è½ã§ãããã ããå±¥æ´ãã¼ã¿ã¯MessagePackã§ã¨ã³ã³ã¼ãããã¦ããã®ã§ç´æ¥äººéãèªãã®ã¯ã¡ãã£ã¨é£ããã§ããä¸å¿ã以ä¸ã®ãããª1 linerã§è¡¨ç¤ºããããã¨ã¯ã§ãã¾ãã
$ redis-cli --raw lindex 151.ru 0 | node -e "process.stdin.pipe(require('msgpack-lite').createDecodeStream()).on('data', console.log);"