osprey's diary

日々の雑感を書き綴ります

Ubuntu16.04 でWindowsアプリを動かす

会社のPCをMacにしてもらった関係でMS free な環境になったけど、会社で扱っているWatchGuardの管理ソフトがWindowsということで、Wineを試すことになった。

 

VirtualBox 上でUbuntu16.04の環境にWineを入れる。素のWineだと文字化けするのでWineTricks でフォントをインストールする。

$ sudo apt install wine winetricks

$ winetricks allfonts 

 

これでOKなはず。

 

WatchGuard社のサイトからexeファイルをダウンロードしてwineで実行。

$ wine WSM11_12_2.exe

installerが走るのでインストールする。

 

インストールが終わったらwineで実行。ホームディレクトリに.wine/ というディレクトリが作成されて、その下にインストールされるみたい。ディレクトリ名にスペースが使われるため、そのまま叩くとエラーになるのでシングルクォートで囲って実行してみる。

$ wine '/home/user/.wine/drive_c/Program Files (x86)/WatchGuard/wsm11/wsm/bin/AppMngr.exe'

おー、結構きれいに動く。少し様子を見てみる。

 

Ubuntu17.04 で ファイルを圧縮して暗号化

7zipを使いました。

どうせなら堅牢な暗号化技術を使いたいなと。

 

7zipをパッケージからインストールします。依存するライブラリなんかも一括でインストール

$ sudo apt -y install p7zip-full

 

7zipを使って暗号化しつつzipで圧縮します。オプションいろいろあるみたいなので、詳細はmanで確認。

$ 7za a -tzip -p -mem=AES256 zip-filename.zip file1 file2 ....

...snip...

Scanning the drive:
1 folder, 19 files, xxxxxxx bytes (XXXX KiB)

Creating archive: zip-filename.zip

Items to compress: 20


Enter password (will not be echoed):
Verify password (will not be echoed) :

Files read from disk: 19
Archive size:xxxxxxx bytes (XXXX KiB)
Everything is Ok 

 

こんな感じでAES256で暗号化してzipファイルを作ることが出来るようです。

Ubuntuでsshで公開鍵認証

 

検証用サーバにかんたんにssh接続できるようにメモ。

ssh-keygenコマンドとssh-copy-idコマンドでできた。

passphraseを空にすることもできる(社内検証用なので今回は気にしない)。

このあと相手側ホストのsshd_configでパスワード認証を切っておく。

 

% ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX user@host
The key's randomart image is:
...snip...
% ssh-copy-id user2@host2
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
user2@host2's password:

Number of key(s) added: 1

Now try logging into the machine, with: "ssh 'user2@host2'"
and check to make sure that only the key(s) you wanted were added.

 

 

Ubuntuでgoを使う(新しいVerをaptで管理)

Sourceから入れるのが一番だろうけど、面倒なのでパッケージで管理したい。

今日(2017/4/19)でパッケージは1.6だったけど、stable版1.8.1が最新みたい。

 

sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt update
sudo apt install golang-go

 

 

vulsを使ってみたかったので、これで行けるか確認してみる。

SlackのIncoming Webhooksでコメント投稿

SlackのIncoming Webhooksでコメントを投稿してみる。

Incoming Webhooksはチャンネルが変えられないっぽい。(Incoming Webhooksでチャンネルを指定する記事を見かけたけど、うまく行かなかった、Web APIのほうなら行けそう。あまり掘り下げてない。)

 

こんな感じ。

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import slackweb

# --- Slack Setting ---
SLACK_WEBHOOK='https://hooks.slack.com/services/XXXXXXXXXXXXX/YYYYYYYYYYYYYYYYYYYY'
SLACK_TEXT="お知らせです"

# --- Slack Post ---
slack=slackweb.Slack(url=SLACK_WEBHOOK)
attachments=[]
attachment={"pretext": "告知内容です",
"color": "#ff0000",
"fields":[
{
"title": "AAA",
"value": "123",
},
{
"title": "BBB",
"value": "456",
}
]
}
attachments.append(attachment)
slack.notify(text=SLACK_TEXT, attachments=attachments) 

 次は頑張ってパラメータによってメッセージを変えたい。

WatchGuardでssh接続

WatchGuardでssh接続をしてみる。

 

Fireware Command Line Interface Reference

 

default port は4118/tcp になってるようです。

userはadminかstatusで、statusはreadonlyのようです。

コンソールからssh接続します。

 

$ ssh -p 4118 -l admin <WatchGuard IP or HostName>

Password:
--
-- WatchGuard Fireware OS Version 11.12.2.B526900
-- Support: https://www.watchguard.com/support/supportLogin.asp
-- Copyright (C) 1996-2017 WatchGuard Technologies Inc.
--

WG#

こんなコンソールが出たらログイン成功。

ちなみにWebUIからログインしていると弾かれるので、一度ログアウトしてから再度試してみてください。

 

日本語のドキュメントが少ないので、少しずつ試していく。

とりあえずshowコマンドでlogを見ていく。

例えば192.168.0.10というIPに絞ってlogを見たいときは以下のようになる。

WG#show log-cache key "192.168.0.10"

 

こんな感じ。

PyCharm 2017.1が出たのでaptで管理してみる

ソースはここです。

 

手順にあるとおり。

$ sudo sh -c 'echo "deb http://archive.getdeb.net/ubuntu $(lsb_release -sc)-getdeb apps" >> /etc/apt/sources.list.d/getdeb.list'

 

$ wget -q -O - http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add -

 

あとは apt update && aptupgrade 。