Showing posts with label Mac. Show all posts
Showing posts with label Mac. Show all posts

Monday, October 21, 2013

Mac OS X: Path to 802.11 utility command

/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport

"/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport" will display the usage.
Usage: airport <interface> <verb> <options>
<interface>
If an interface is not specified, airport will use the first AirPort interface on the system.
<verb is one of the following:
prefs If specified with no key value pairs, displays a subset of AirPort preferences for
the specified interface.
Preferences may be configured using key=value syntax. Keys and possible values are specified below.
Boolean settings may be configured using 'YES' and 'NO'.
DisconnectOnLogout (Boolean)
JoinMode (String)
Automatic
Preferred
Ranked
Recent
Strongest
JoinModeFallback (String)
Prompt
JoinOpen
KeepLooking
DoNothing
RememberRecentNetworks (Boolean)
RequireAdmin (Boolean)
RequireAdminIBSS (Boolean)
RequireAdminNetworkChange (Boolean)
RequireAdminPowerToggle (Boolean)
WoWEnabled (Boolean)
logger Monitor the driver's logging facility.
sniff If a channel number is specified, airportd will attempt to configure the interface
to use that channel before it begins sniffing 802.11 frames. Captures files are saved to /tmp.
Requires super user privileges.
debug Enable debug logging. A debug log setting may be enabled by prefixing it with a '+', and disabled
by prefixing it with a '-'.
AirPort Userland Debug Flags
DriverDiscovery
DriverEvent
Info
SystemConfiguration
UserEvent
PreferredNetworks
AutoJoin
IPC
Scan
802.1x
Assoc
Keychain
RSNAuth
WoW
P2P
Roam
BTCoex
AllUserland - Enable/Disable all userland debug flags
AirPort Driver Common Flags
DriverInfo
DriverError
DriverWPA
DriverScan
AllDriver - Enable/Disable all driver debug flags
AirPort Driver Vendor Flags
VendorAssoc
VendorConnection
AllVendor - Enable/Disable all vendor debug flags
AirPort Global Flags
LogFile - Save all AirPort logs to /var/log/wifi.log
<options> is one of the following:
No options currently defined.
Examples:
Configuring preferences (requires admin privileges)
sudo airport en1 prefs JoinMode=Preferred RememberRecentNetworks=NO RequireAdmin=YES
Sniffing on channel 1:
airport en1 sniff 1

LEGACY COMMANDS:
Supported arguments:
 -c[<arg>] --channel=[<arg>]    Set arbitrary channel on the card
 -z        --disassociate       Disassociate from any network
 -I        --getinfo            Print current wireless status, e.g. signal info, BSSID, port type etc.
 -s[<arg>] --scan=[<arg>]       Perform a wireless broadcast scan.
  Will perform a directed scan if the optional <arg> is provided
 -x        --xml                Print info as XML
 -P        --psk                Create PSK from specified pass phrase and SSID.
  The following additional arguments must be specified with this command:
                                  --password=<arg>  Specify a WPA password
                                  --ssid=<arg>      Specify SSID when creating a PSK
 -h        --help               Show this help

Sunday, June 2, 2013

Updated: Installing wireshark & GNS3 & QEMU on Ubuntu 12.04 x86 64 on VMware Fusion 5

The following procedure installs the latest GNS3 and QEMU as of June 2, 2013.
# The procedure for a physical Ubuntu box should be the same as the following.

Environment
HW: rMBP Mid 2012
OS: OS X 10.8.2
VMware Fusion: 5.0.2
VM OS: Ubuntu 12.04 x86 64

1. Wireshark installation
Installing the wireshark package
$ sudo apt-get update
$ sudo apt-get upgrade -y
$ sudo apt-get install wireshark
Setting a permission to dumpcap to use wireshark from a non-root user
$ sudo groupadd wireshark
$ sudo usermod -a -G wireshark USERNAME
$ sudo chgrp wireshark /usr/bin/dumpcap
$ sudo chmod 750 /usr/bin/dumpcap
$ sudo setcap cap_net_raw,cap_net_admin=eip /usr/bin/dumpcap

2. QEMU installation
Updated: The following procedure instals Qemu 1.5. If you want to run ASA on GNS3, you need UDP tunnel patched qemu 0.11 or 0.14 instad of the latest Qemu.

# Download UDP tunnel patched qemu 0.11 or 0.14, unpack the tar, and run the installation script after reading README.
# http://sourceforge.net/projects/gns-3/files/Qemu/Linux/

2.1. Enabling vmx on VMware Fusion 5 (only for Fusion 4 and later with a capable physical CPU)

Edit the file when the VM is shut down.
$ cd /Users/USERNAME/Documents/Virtual\ Machines.localized
$ vim MACHINE_NAME.vmwarevm/MACHINE_NAME.vmx

Adding the folloing line to the MACHINE_NAME.vmx file
vhv.enable = "TRUE"

Check the cpuinfo
$ cat /proc/cpuinfo | grep vmx

2.2. Installing dependencies for GNS3 and QEMU
texinfo is for QEMU's man. QEMU requires autoconf and libtool to make
$ sudo apt-get install zlib1g-dev libsdl1.2-dev libpcap-dev texinfo autoconf libtool
$ sudo apt-get install qt4-dev-tools

# If gcc is not installed
# $ sudo apt-get install build-essential

2.3. Installing QEMU 1.5
$ wget http://wiki.qemu-project.org/download/qemu-1.5.0.tar.bz2
$ tar jxvf qemu-1.5.0.tar.bz2
$ cd qemu-1.5.0
$ ./configure --prefix=/usr/local
$ make
$ sudo make install

3. GNS3 0.8.3.1 Installation
$ wget http://downloads.sourceforge.net/project/gns-3/GNS3/0.8.3.1/GNS3-0.8.3.1-src.tar.bz2
$ tar jxvf GNS3-0.8.3.1-src.tar.bz2
$ sudo mv GNS3-0.8.3.1-src /opt/GNS3
$ wget http://downloads.sourceforge.net/project/gns-3/Dynamips/0.2.8-RC3-community/dynamips-0.2.8-RC3-community-x86_64.bin
$ chmod 750 dynamips-0.2.8-RC3-community-x86_64.bin
$ sudo mv dynamips-0.2.8-RC3-community-x86_64.bin /opt/GNS3
$ sudo chown -R root:root /opt/GNS3

4. Setting GNS3
General -> General Settings tab
Untick "Launch the project dialog at startup"
General -> Terminal Settings tab
Use Gnome Terminal
General -> GUI Settings
Tick "Always use manual mode when adding links"
Dynamips -> Dynamips
Set "Executable path to Dynamips:" to "/opt/GNS3/dynamips-0.2.8-RC3-community-x86_64.bin"
Tick "Enable sparse memory support"
Qemu -> Qemu Guest
Use "-no-acpi" option for LinuxMicroCore that is provided by GNS3 official site

5. Notes
- GNS3 from apt-get is too old to run some of the IOS images that should be able to run on it.
- QEMU 1.5 (QEMU1.1 and later) includes patches for UDP tunnel and multicast provided by GNS3 official site
- There is no notable differences between qemu and qemu-kvm from 1.3 (See the release note for QEMU 1.3)
- autoconf and libtool are necessary to compile qemu 1.5
- QEMU's KVM support works only "when running a target architecture that is the same as the host architecture".

6. Reference
Enabling Intel VT on VMware
http://communities.vmware.com/docs/DOC-8970
About QEMU patches
http://brezular.wordpress.com/2012/02/12/installation-solaris-sparc-2-6-sunos-5-6-on-qemu-part-1-qemu-installation/


Friday, May 31, 2013

Solarized, Uniform Color Scheme

I've switched my vim's color scheme from oceandeep to solarized. Oceandeep is an eye-friendy dark color scheme great for people who prefer not to be distracted by highlighted text. However, it makes you feel a bit awkward when you launch vim from a console because it supports only gvim. I got hungry for "uniformity", and solarized came in.

Solarized - Precision colors for machines and people
http://ethanschoonover.com/solarized

Solarized is a color scheme maintained by Ethan Schoonover provides uniformity to your environment; it supports not only editors (not limited to vim!) but also other system development tools like terminal emulators and IDEs.

I've changed color schemes for vim and iTerm2, and they look coordinated. Awesome.

Saturday, May 18, 2013

How to use UC-SGT on Mac OS X Mountain Lion 10.8.2 (15' rMBP 2012)

It's been ages since a serial port disappeared from a laptop PC. Nevertheless, network devices requires a serial connection as a our-of-band connection. I grabbed a USB serial adapter UC-SGT, but my laptop (15' rMBP 2012, Mountain Lion) needed a trick to recognize it.
  1. Download a driver from a prolific's website
    http://prolificusa.com/pl-2303hx-drivers/
  2. Install the driver following README
  3. Add an entry for UC-SGT to the driver
    cd /System/Library/Extensions/ProlificUsbSerial.kext/Contents
    sudo cp -p Info.plist Info.plist.ori
    sudo vim Info.plist Info.plist.ori

    * Insert the following entry before the entry for <key>067B_2303</key>
             <key>056E_5004</key>
             <dict>
                 <key>CFBundleIdentifier</key>
                 <string>com.prolific.driver.PL2303</string>
                 <key>IOClass</key>
                 <string>com_prolific_driver_PL2303</string>
                 <key>IOProviderClass</key>
                 <string>IOUSBInterface</string>
                 <key>bConfigurationValue</key>
                 <integer>1</integer>
                 <key>bInterfaceNumber</key>
                 <integer>0</integer>
                 <key>idProduct</key>
                 <integer>20484</integer>
                 <key>idVendor</key>
                 <integer>1390</integer>
             </dict>

  4. Rebuild kext cache
    sudo touch /System/Library/Extentions/
    sudo reboot
Caution: kext cache needs to be rebuilt; otherwise, you need to issue kextload /System/Library//Extensions/ProlificUsbSerial.kext  command every time you boot the box.

Note: TU-S9 from TRENDnet works on prolific's driver without changing plist.

Thursday, May 16, 2013

How to enable native tftpd on Mac OS X Mountain Lion 10.8.2

I needed to tftp server to update IOS images for switches in my home lab. Mac OS X has its native tftp daemon and will do for the purpose.

To launch tftpd,
$ sudo launchctl load -F /System/Library/LaunchDaemons/tftp.plist
# Default tftp root directory, in which data files are stored, is /private/tftpboot/

To check tftp is up and running,
$ lsof -i:69

To stop tftpd
$ sudo launchctl unload /System/Library/LaunchDaemons/tftp.plist
or reboot the system.

Note:
1. tftpd will not start next time the system is booted. To make tftpd persistant, issue
$ sudo launchctl load -w /System/Library/LaunchDaemons/tftp.plist
1.1. -w option erases <key>Disabled</key> entry in tftp.plist and launch tftpd.
1.2. If you want to make tftpd persistant, think about security concerns since there is no authentication in tftp protocol. (i.e. at least adding -l option to tftpd.plist for logging, caring about permissions for files/directories.


To disable it,
$ sudo launchctl unload -w /System/Library/LaunchDaemons/tftp.plist

2. -F option is needed since /System/Library/LaunchDaemons/tftp.plist has <key>Disabled</key> entry.

3. The owner of /private/tftpboot/ is root and its permission is 755.

Reference:
man tftpd
man launchctl
man launchd.plist


Wednesday, May 15, 2013

How to enable sshd on Mac OS X Mountain Lion 10.8.2

It's an easy step with GUI.

1. Go to System Preferences => Sharing => Remote Login
2. Turn on Remote Login
3. Check sshd is running
$ sudo lsof -i:22

Note: The firewall on the system is automatically adjusted to pass an incoming ssh connection.

Tuesday, May 14, 2013

How to rebuild kext cache on Mountain Lion 10.8

kext cache rebuild is just a two-step task.
  1. sudo touch /System/Library/Extensions/
  2. sudo reboot

It's NOT recommended to execute kextcache manually.
KEXTCACHE(8)              BSD System Manager's Manual             KEXTCACHE(8)
Caution: Incorrect use of kextcache can render a volume incapable of startup.  Installers and administrators should not use this program to
     update system kext caches.  Instead they should run touch(1) on the /System/Library/Extensions/ directory of the installation target volume
     after they have finished, which invalidates the existing caches and causes the system to update all necessary kext caches.

Monday, December 10, 2012

Wireshark on Mac: Changing menu fonts

You can change a font for captured data from preferences, but it doesn't change the font for the application menu. To make the ugly unpleasant font acceptable, change "pre_gtkrc" file in "/Applications/Wireshark.app/Contents/Resources/themes/Clearlooks-Quicksilver-OSX/gtk-2.0/"

1. Change the font
#gtk-font-name="Lucida Grande 12"
gtk-font-name="Sans 10"

2. Change the menu sizes (buttons, etc.)
#gtk-icon-sizes = "gtk-menu=16,16:gtk-dialog=48,48:gtk-dnd=32,32:gtk-button=20,20:gtk-large-toolbar=24,24:gtk-small-toolbar=16,16:inkscape-decoration=12,12"
gtk-icon-sizes = "gtk-menu=14,14:gtk-dialog=24,24:gtk-dnd=32,32:gtk-button=14,14:gtk-large-toolbar=14,14:gtk-small-toolbar=10,10:inkscape-decoration=6,6"

3. Results


4. Notes
- Lucida Grande is the default system font for Mac, but it looks completely difference under X11.
- The environment is rMBP Mid 2012 running Mountain lion 10.8.2.
- The output is somewhat blurred since X11 cannot handle the retina display.

Tuesday, August 21, 2012

Updated: After Installed Mountain Lion

  1. Changed trackpad settings to "NORMAL"
    1. Enabled tap and click
    2. Fixed scrolling direction
    3. Enabled click and drag
      1. System Preference -> Accessibility -> Mouse & Trackpad -> Trackpad Options
  2. Enabled key repeat 
    1. Issue "defaults write -g ApplePressAndHoldEnabled -bool false"
  3. Made user's library directory visible from finder
    1. Issue "chflags nohidden /Users/USERNAME/Library"
  4. Installed
    1. MacVim
      1. Installed "ocean deep" color scheme
      2. Syntax highlight for arduino
      3. Made .vimrc 
    2. TextWrangler
    3. Xcode
      1. Added "command line tools" component
        1. Preferences -> Downloads -> Components
    4. VMware Fusion
      1. Installed Ubuntu 12.04 Desktop 64bit
        1. Updated installed packages
          1. $ sudo apt-get update
          2. $ sudo apt-get upgrade
        2. Installed C compiler
          1. $ sudo apt-get install build-essential
        3. Installed Oracle JAVA 7
          1. $ sudp add-apt-repository ppa:webupd8team/java
          2. $ sudo apt-get update
          3. $ sudo apt-get install oracle-java7-installer
          4. $ java -version
            Ref: http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html
        4. Installed Netbeans
          1. Download package, and the run install script
            http://netbeans.org
        5. Installed Arduino programming environment
          1. $ sudo apt-get install arduino-core arduino 
      2. Installed Windows 7
        1. Windows Update - Required packages
        2. Windows Update - Recommended packages
          *CAUTION* VMware Fusion got freeze while patching
    5. Adobe Acrobat Pro 9.0
      1. Patched manually! There was no automatic update option on 9.0...
        After all the patches were done (Ver. 9.5.2) the Acrobat got "Check for update" option in "Help" menu.
    6. The unarchiver
    7. MplayerX
    8. Caffeine
    9. Reeder
    10. Microsoft Office
    11. iWorks
    12. ScanSnap Manager


Tuesday, March 20, 2012

Change of .vimrc

Change log:
1) Added tab settings for html
2) Enabled filetype plugins
3) Enabled matchit

  1 "
  2 " This file (.vimrc) is modified on 2012/3/19
  3 "
  4
  5 " General
  6 set number " to display lines
  7 set title " display filename on the title bar
  8 set ignorecase " search not casesensitively
  9 set showmatch " hilight a pair of parenthesis and braces
 10 set matchtime=2 " limit the showmatch's hilight time, ms
 11 set wildmenu " compliment vim's commandline instructions
 12 set tabstop=4
 13 set shiftwidth=4
 14 set softtabstop=4
 15 set autoindent " Enable autoindent
 16 set ruler  " Ruler on
 17 set incsearch
 18 set hlsearch
 19 set backup
 20 set backupdir=~/.tmp_vim
 21 set dir=~/.tmp_vim
 22
 23 " Plugins
 24 filetype on           " Enable filetype detection
 25 filetype indent on    " Enable filetype-specific indenting
 26 filetype plugin on    " Enable filetype-specific plugins
 27 runtime macros/matchit.vim
 28
 29 " Ruby
 30 autocmd FileType ruby,eruby compiler ruby
 31 autocmd FileType ruby,eruby set tabstop=2
 32 autocmd FileType ruby,eruby set shiftwidth=2
 33 autocmd FileType ruby,eruby set softtabstop=2
 34 autocmd FileType ruby,eruby set expandtab
 35
 36 " HTML
 37 autocmd FileType html set tabstop=2
 38 autocmd FileType html set shiftwidth=2
 39 autocmd FileType html set softtabstop=2
 40
 41
 42 " For GUI
 43 if has("gui_running")
 44   colorscheme oceandeep
 45   set clipboard+=unnamed  " Yanks to clipboard
 46 endif
 47

Wednesday, January 18, 2012

.vimrc の見直し

今回の変更で set clipboard+=unnamed のオプションを追加

"
" This file (.vimrc) is modified on 2012/1/18
"
set number " to display lines
set title " display filename on the title bar
set ignorecase " search not casesensitively
set showmatch " hilight a pair of parenthesis and braces
set matchtime=2 " limit the showmatch's hilight time, ms
set wildmenu " compliment vim's commandline instructions
set softtabstop=4
set expandtab
set autoindent " Enable autoindent
set ruler  " Ruler on
if has("gui_running")
  colorscheme oceandeep
  set clipboard+=unnamed  " Yanks to clipboard
  autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
  autocmd FileType ruby,eruby set tabstop=2
  autocmd FileType ruby,eruby set shiftwidth=2
  autocmd FileType ruby,eruby set softtabstop=2
endif

Monday, August 8, 2011

USB RS232-C 変換ケーブルについて

変換ケーブルで使われているチップを確認し、チップのメーカーサイトからドライバを入手する。

USB シリアル 変換ケーブル 秋月電子
http://akizukidenshi.com/catalog/g/gM-00720/

Prolific
http://www.prolific.com.tw/eng/downloads.asp?id=31

USB-CVRS9 SANWA SUPPLY
http://www.sanwa.co.jp/product/syohin.asp?code=USB-CVRS9

FDTI
http://www.ftdichip.com/Drivers/VCP.htm

Thursday, July 28, 2011

Mac: Open with に重複したエントリーが表示される

Snow Leopard の Open With メニューに重複したエントリーができてしまったため、対策方法を調べました。下記コマンドをコンソールから実行することで、重複エントリや既に存在しないアプリケーションが表示されなくなりました。
$ /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user
備考:
1. 上記コマンドで Open With が参照しているデータベースをリビルドしている
2. コマンド実行時、sudoは不要 
参考:
Duplicate programs in "Open With" menu
https://discussions.apple.com/message/11193505?messageID=11193505#11193505?messageID=11193505

Sunday, June 5, 2011

Snow Leopard の irb で日本語が使えない

irb で 日本語の入力ができない。原因は Mac 付属の readline にある、ということで、GNU Readline を /usr/local/bin にインストールし、irb から GNU Readline を呼び出すようにする。

readline のソースを /usr/local/src/ に展開した上で、
$ cd /usr/local/src/readline-6.2
$ ./configure --prefix=/usr/local
$ make
$ sudo make install

Ruby1.9 のリコンパイル。 --with-readline-dir オプションを追加
$ cd /usr/local/src/ruby-1.9.2-p180
$ ./configure --enable-shared --enable-pthread CFLAGS=-D_XOPEN_SOURCE=1 --with-readline-dir=/usr/local
$ make
$ sudo make install

参考:
GNU Readline
http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
2011/6/5 現在の最新は readline 6.2

備考:
1. readline 6.2 は Snow Leopard に対応済で、ソースの修正無しにコンパイルができる。
readline-6.2/support/shobj-conf の該当部分
    159 # Darwin/MacOS X
    160 darwin[89]*|darwin10*)

2. Ruby のインストール時、 ./configure の出力で下記警告が出るが、問題なく有効になっているってのをどこかで読んだ。
実際に問題なく動いてくれているのでOK。
configure: WARNING: unrecognized options: --with-readline-dir
  
Ruby のインストールについては、下記参照
http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard/

Tuesday, May 31, 2011

Mac で環境変数を変更する

path の編集は
/etc/paths というファイルの中身を編集すればOK。

manpath  の方は、
/private/etc/man.conf

Linuxとは違うのね。

Thursday, January 20, 2011

Mac で HDD の障害に会ったら

インストールCD で Mac を起動
 Disk Utility で Repair Disk を実施

Apple のサポート曰く、fsck は行うな、と。
# 出典は Google で調べて下さい。

Sunday, January 9, 2011

Mac にシングルユーザーモードでログオン

  1. 電源ボタンを押下
  2. "Tadah" というオープニングの音がなった直後にシフトキーを押下
    灰色のプログレスインディケータが表示されたらシフトキーを離してOK

Sunday, December 26, 2010

MBP Mid 2009 の HDD交換

MacBook Pro Mid 2009 の HDD が手狭になってしまったので、
大容量のものに交換。

今回選んだのは、日立グローバルストレージテクノロジーズの
0S03085 というモデル。750GB で7500円でした。
メーカー保証が付いているリテールパッケージ品なので若干お値段高めです。

早速 Time Capsule  のバックアップからデータのリストアをしてみたところ、
動作音が小さく、発熱も少ないことが確認できました。

標準搭載の HDD よりも動作音が小さくて嬉しくなっちゃいましたよ、と。

参考:http://www.ifixit.com/Guide/Repair/Installing-MacBook-Pro-15-Inch-Unibody-2-53-GHz-Mid-2009-Hard-Drive-Replacement/1518/1

MobileMe のアイコンをメニューバーから追い出すには

MobileMe のアイコンをメニューバーから追い出すには、
Command を押しながらドラッグしてメニュバーから追い出す、と。
http://discussions.apple.com/thread.jspa?messageID=11200954&#11200954

Friday, October 22, 2010

20101022 iPhone 4 4.1 GreenPois0n を使った Jailbreak

GreenPois0n で Jail Break した後に PownageTool が出てるのに気づいた。。。

GreenPois0n のチュートリアル
http://www.youtube.com/watch?v=ZjJQbhlfTGI
http://www.youtube.com/watch?v=F8MLac-9Dew&feature=related

GreenPois0n の DL
http://www.greenpois0n.com/
Cydia のインストールが完了しても Loader はそのまま残すを選択

パスワードの変更
http://www.redmondpie.com/how-to-secure-your-jailbroken-iphone-from-ssh-hack-9140084/

Cydia にアクセスしていたら、自動的に OpenSSH の新しいバージョンのインストールを促される -> update

Cydia から Mobile Terminal をインストール
-> Mobile Terminal をインストールした後、iPhone のリブートが必要?(Terminalが立ち上がってすぐにウィンドウが閉じてしまう。)

...Mobile Terminal が動かない。
作戦変更。
xSellize のリポジトリから、MobileTerminal Beta for iOS4 をインストール。
http://forums.macrumors.com/showthread.php?t=982601

ターミナルからパスワードを変更

これで一段落。

念のためのツール。
http://www.tipb.com/2010/09/24/manually-set-iphone-ipad-carrier-apn-iphone-configuration-utility/