Raspberry Pi でAbemaTV垂れ流し専用機にする

Abema TVのよくないところっていうか、不便だなと思うのはやっぱりURL開くかアプリ起動しないと見れない点。

当たり前といえば当たり前だけどテレビはリモコンから電源入れればつく。

AbemaTVアプリの起動すら面倒に感じた俺は、余ったRaspiで永遠に流せばいいんじゃね?て思った

用意したもの

  • Raspi 2
  • Rasbian 一番新しいやつ Chromeのクローン版が入ってた

結果

重すぎ、カクカクして使い物にならない

以下試行錯誤のメモ

  • オーバークロックさせたり、GPUのメモリ割り当て増やしたりしたけどあんまり変わらない
  • 解像度下げた(1024x768)にしたのが一番変化あった
  • Chromiumが重いんじゃね?wと思ってFirefox入れたら表示すらされなかった、、midoriも同じ

gem install eventmachine時に「'openssl/ssl.h' file not found」とエラー

環境

  • Mac El Capitan

Gemfileに

症状

gem install eventmachine ができない

gem "eventmachine"

でbundle instrallすると

Using ref 1.0.5
Using sass 3.2.14
Using simple_oauth 0.3.0
Using elasticsearch-api 1.0.1
Using thread_safe 0.2.0
Using airbrake 4.0.0
Using rack-test 0.6.2
Using treetop 1.4.15
Using rspec-core 3.1.7
Using rspec-mocks 3.1.3
Using rspec-expectations 3.1.2
Using better_errors 2.0.0
Using net-scp 1.2.1
Using whenever 0.9.4
Using coffee-script 2.2.0
Using unf 0.1.4
Using faraday 0.9.0
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/thr3a/.rbenv/versions/2.2.4/bin/ruby -r ./siteconf20170322-53700-z08h1b.rb extconf.rb 
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... no
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for inotify_init() in sys/inotify.h... no
checking for __NR_inotify_init in sys/syscall.h... no
checking for writev() in sys/uio.h... yes
checking for rb_thread_fd_select()... yes
checking for rb_fdset_t in ruby/intern.h... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_enable_interrupt()... no
checking for rb_time_new()... yes
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for clock_gettime()... no
checking for gethrtime()... no
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling binder.cpp
In file included from binder.cpp:20:
./project.h:116:10: fatal error: 'openssl/ssl.h' file not found
#include <openssl/ssl.h>
         ^
1 error generated.
make: *** [binder.o] Error 1

make failed, exit code 2

と怒られる

対処法

 gem install eventmachine -- --with-cppflags=-I/usr/local/opt/openssl/include  

Gemfile.lockのバージョンに合わせてインストールするには

gem install eventmachine -v "1.0.7" -- --with-cppflags=-I/usr/local/opt/openssl/include

でいける

wpscanでWordPressの脆弱性診断を行う

環境

  • Ruby(2.4指定されたけど2017年3月6日現在

インストール

Githubが最新版 普通にgit clone

github.com

rubyなのでbundle install

コマンド

# 念のためアプデ
bundle exec ruby wpscan.rb --update

# 診断開始
bundle exec ruby wpscan.rb --url www.example.com

# ユーザー名の特定
bundle exec ruby wpscan.rb --url www.example.com --enumerate u

# プロキシを挟む場合
bundle exec ruby wpscan.rb --url www.example.com --proxy http://8.8.8.8:8080 --proxy-auth user:password

実行例

thr3a:wpscan thr3a$ bundle exec wpscan.rb --url http://www.************************.net/
_______________________________________________________________
        __          _______   _____                  
        \ \        / /  __ \ / ____|                 
         \ \  /\  / /| |__) | (___   ___  __ _ _ __ ®
          \ \/  \/ / |  ___/ \___ \ / __|/ _` | '_ \ 
           \  /\  /  | |     ____) | (__| (_| | | | |
            \/  \/   |_|    |_____/ \___|\__,_|_| |_|

        WordPress Security Scanner by the WPScan Team 
                       Version 2.9.2
          Sponsored by Sucuri - https://sucuri.net
   @_WPScan_, @ethicalhack3r, @erwan_lr, pvdl, @_FireFart_
_______________________________________________________________

[i] It seems like you have not updated the database for some time.
[?] Do you want to update now? [Y]es [N]o [A]bort, default: [N]Y
[i] Updating the Database ...
[i] Update completed.
[+] URL: http://www.************************.net/
[+] Started: Sat Mar 11 09:28:41 2017

[+] robots.txt available under: 'http://www.************************.net/robots.txt'
[!] The WordPress 'http://www.************************.net/readme.html' file exists exposing a version number
[+] Interesting header: SERVER: Apache
[+] XML-RPC Interface available under: http://www.************************.net/xmlrpc.php

[+] WordPress version 4.1.16 (Released on 2017-03-06) identified from meta generator, rss generator, rdf generator, atom generator, readme, links opml

[+] WordPress theme in use: xeory_base_20150528 - v0.1.3

[+] Name: xeory_base_20150528 - v0.1.3
 |  Location: http://www.************************.net/wp-content/themes/xeory_base_20150528/
 |  Style URL: http://www.************************.net/wp-content/themes/xeory_base_20150528/style.css
 |  Theme Name: XeoryBase_TREND
 |  Theme URI: http://xeory.jp/
 |  Description: Xeoryベーステーマ
 |  Author: バズ部
 |  Author URI: http://bazubu.com/

[+] Enumerating plugins from passive detection ...
 | 1 plugin found:

[+] Name: contact-form-7 - v4.1.2
 |  Last updated: 2017-03-03T19:29:00.000Z
 |  Location: http://www.************************.net/wp-content/plugins/contact-form-7/
 |  Readme: http://www.************************.net/wp-content/plugins/contact-form-7/readme.txt
[!] The version is out of date, the latest version is 4.7

[+] Finished: Sat Mar 11 09:28:54 2017
[+] Requests Done: 89
[+] Memory used: 55.051 MB
[+] Elapsed time: 00:00:12

物理的にLANケーブルが刺さっているか確認するLinuxコマンド

ethtoolコマンドの Link detected: の欄を見るとそもそもネットに繋がる環境かどうかがわかる

つながるとき Link detected: yesになっている

# ethtool eth0
Settings for eth0:
    Supported ports: [ TP ]
    Supported link modes:   10baseT/Half 10baseT/Full 
                            100baseT/Half 100baseT/Full 
                            1000baseT/Half 1000baseT/Full 
    Supported pause frame use: No
    Supports auto-negotiation: Yes
    Advertised link modes:  10baseT/Half 10baseT/Full 
                            100baseT/Half 100baseT/Full 
                            1000baseT/Half 1000baseT/Full 
    Advertised pause frame use: Symmetric
    Advertised auto-negotiation: Yes
    Link partner advertised link modes:  10baseT/Half 10baseT/Full 
                                         100baseT/Half 100baseT/Full 
                                         1000baseT/Full 
    Link partner advertised pause frame use: No
    Link partner advertised auto-negotiation: Yes
    Speed: 1000Mb/s
    Duplex: Full
    Port: Twisted Pair
    PHYAD: 1
    Transceiver: internal
    Auto-negotiation: on
    MDI-X: off
    Supports Wake-on: g
    Wake-on: g
    Current message level: 0x000000ff (255)
                   drv probe link timer ifdown ifup rx_err tx_err
    Link detected: yes

つながらないとき Link detected: noになってる

# ethtool eth1
Settings for eth1:
    Supported ports: [ TP ]
    Supported link modes:   10baseT/Half 10baseT/Full 
                            100baseT/Half 100baseT/Full 
                            1000baseT/Half 1000baseT/Full 
    Supported pause frame use: No
    Supports auto-negotiation: Yes
    Advertised link modes:  10baseT/Half 10baseT/Full 
                            100baseT/Half 100baseT/Full 
                            1000baseT/Half 1000baseT/Full 
    Advertised pause frame use: Symmetric
    Advertised auto-negotiation: Yes
    Speed: Unknown!
    Duplex: Unknown! (255)
    Port: Twisted Pair
    PHYAD: 2
    Transceiver: internal
    Auto-negotiation: on
    MDI-X: Unknown
    Supports Wake-on: g
    Wake-on: g
    Current message level: 0x000000ff (255)
                   drv probe link timer ifdown ifup rx_err tx_err
    Link detected: no

参考リンク

@IT:ネットワークインターフェイスの状況を調べるには

Rubyのmerge()は順番によって挙動が変わる

当然といえば当然だが

# Here your code !
a = {
  hoge: {
    piyo: 111
  }
}

b = {
  hoge: {
    piyo: 222,
    fuga: {
      foo: 333
    }
  }
}

p a.merge(b)
p b.merge(a)

結果

{:hoge=>{:piyo=>222, :fuga=>{:foo=>333}}}
{:hoge=>{:piyo=>111}}