2013年11月22日 星期五

[Hacking] Undead Slayer iOS 版 破解 非JB, 洗錢

Hi

最近迷上一款手機遊戲,叫做Undead Slayer 大陸叫做亡靈殺手.

再簡單的操作裡,也可以有許多華麗的動作表現(使用Unity 3D引擎)。





每次玩遊戲都覺的,好不暢快,裝備,寶物,錢,特殊金幣也太難掉了!!

廢話不多說 ~正文開始
==============================

準備材料如下:
1. PC 一台 or Mac
2. 安裝 iFunBox or iExplorer
3. 裝有Undead Slayer的iphone

==============================
事先聲明,這招不是破解這遊戲,是洗錢!會讓你的錢和勾玉不會減少。

麻煩度
==============================

  • 把遊戲關掉(點兩下home鍵,找出程式關掉)。
  • 打開iFunBox or iExplorer, 找到 Undead Slayer的App,並且找到這個檔案<Library\Preferences\com.nhncorp.skundeadgr.plist>。在接下來的步驟我們會編輯它非常多次。
  • 接下來把它Copy到一個特定的資料夾,然後先在原地複製貼上,產生一個備份檔。


  • 用一個文字編輯器打開它,選擇文字編輯,在這裡用的是XCode。打開之後你會看到像圖下方式組合的 鍵 與 值 的對應 <key> </key> <string> </string>。



  • 這裡我們要找的是勾玉以及金錢的key值。分別是n24以及n17。意思就是<key>n24</key><string>aaaaxxxxxxxxx</string>, 以及<key>n17</key><string>bbbbxxxxxxxxxxxxx</string>.
  • 這時候我會把現在的錢 例如說1000元,記錄在記事本或是Word上,像是: 
n17 1000元
RSKv0E7wmnM3vf5nsi8wYis/pTGjdOJXMwMBXLFBBrw=
n24 7 勾玉
DXvsdNcHchz9b2UaizTkIw/obKW5LdwLjs99Vt4HgxY=

  • 所以假設你現在去遊戲裡面,花了500元之後,離開遊戲到主畫面,然後按Home鍵關閉遊戲。

  • 一樣,使用iFunBox, 找到 Library\Preferences\com.nhncorp.skundeadgr.plist.先存到某個資料夾,打開它,然後再n17的String值貼上RSKv0E7wmnM3vf5nsi8wYis/pTGjdOJXMwMBXLFBBrw=

  • 儲存檔案,再覆蓋過你手機的同樣檔案。
  • 打開遊戲!你會發現你這時金幣變成1000圓了。

小訣竅:
勾玉等於錢,錢不等於勾玉,但非常多的錢,有機會產生勾玉(靠搜尋寶物)。

刷勾玉方法,當你存到可以兌換勾玉的時候,把這個已經有10個勾玉的備份黨(就叫他A好了)存起來。
存起來之後,進到遊戲裡面,兌換勾玉變成13。然後回到主畫面,按Home鍵關掉遊戲,然後複製存在當前App中 com.nhncorp.skundeadgr.plist 裡面n24的值,也就是勾玉13的值,然後修改備份A的n24欄位,這樣就讓備份A變成,還沒兌換勾玉,但勾玉是13的備份擋了。
一直洗....
一直洗....
一直洗.... 像是這樣。

後面洗很快的原因是一直去搜尋寶物,使得寶物兌換那邊一次可以兌換10幾個勾玉。

That`s it!!.

2013年11月19日 星期二

[Coding] [Algorithm] Number-of-disc-intersections

For Interview purpose, right now I doing some online coding test: using codility

Here is the quesiton:

Given an array A of N integers, we draw N discs in a 2D plane such that the I-th disc is centered on (0,I) and has a radius of A[I]. We say that the J-th disc and K-th disc intersect if J ≠ K and J-th and K-th discs have at least one common point.
Write a function:
int solution(NSMutableArray *A);
that, given an array A describing N discs as explained above, returns the number of pairs of intersecting discs. For example, given N=6 and:
A[0] = 1  A[1] = 5  A[2] = 2 
A[3] = 1  A[4] = 4  A[5] = 0  
intersecting discs appear in eleven pairs of elements:
  • 0 and 1,
  • 0 and 2,
  • 0 and 4,
  • 1 and 2,
  • 1 and 3,
  • 1 and 4,
  • 1 and 5,
  • 2 and 3,
  • 2 and 4,
  • 3 and 4,
  • 4 and 5.
so the function should return 11.
The function should return −1 if the number of intersecting pairs exceeds 10,000,000.
Assume that:
  • N is an integer within the range [0..100,000];
  • each element of array A is an integer within the range [0..2147483647].
Complexity:
  • expected worst-case time complexity is O(N*log(N));
  • expected worst-case space complexity is O(N), beyond input storage (not counting the storage required for input arguments).
Elements of input arrays can be modified.
Copyright 2009–2013 by Codility Limited. All Rights Reserved. Unauthorized copying, publication or disclosure prohibited.

Here is my solution write in Objective-C which only got 62 points in Codility(due to timeout error in some question.)
The time complexity is O(n^2)
Space complexity is O(1)

#import <Foundation/Foundation.h>
int solution(NSMutableArray *A) {
    // write your code in Objective-C 2.0
      if(!A || [A count] <1) return 0;
          long resultCount = 0;
          for(int i = 0; i < [A count] ; i++){
              for(int j = i+1 ; j < [A count] ; j++){
                    
                  if(([(NSNumber *)A[j] longLongValue]+[(NSNumber *)A[i] longLongValue]) >= j-i){
                      resultCount ++;
                        //NSLog(@"print i = %d, j = %d",i,j);
                  }
                  if(resultCount > 10000000)
                  {
                        return -1;
                  }
              }
          }
          return resultCount;
       
}
//Improvement, I think I can make some performance improve using sorting.
First, produce a sorting array I-A[I]( the left bound of each disk) and add I +A[I] also in the structure.
struct element{
      int leftBound; (leftBound as sorting index)
      int rightBound;
}
So, start traverse the left bound from X,
Pseudo code may be

for X = 1~ X
      for(Y = X+1 && element[Y].rightBound<=Y)
        counter ++


The series of discussion can be found in here :   Number of Disc intersection Discuss in Statck overflow

Here is another smart guy claims that he has  O(N+M) time complexity with O(N) space complexity.



###Updated:
When I`m trying  to implement the algo that I mention above, by using a self-defined  @interface in Codility (WT.....! they didn`t support....).
So I use struct instead, how ever, objective-C`s NSArray only support NSObject, Here is the solution: Wrap a struct in Objective-C

Another challenge is coming, When I sorting by NSArry using this function sortedArrayUsingComparator:NSComparisonResult............ Actually, it`s too slow....
So I drop the method, by using the default struct, and using native ..... qsort

Perfect!!! I got 93 score in Codility

#import <Foundation/Foundation.h>
struct _DiskBound{
    long long leftBound;
    long long rightBound;
};
typedef struct _DiskBound DiskBound;
    
int compare (const void * first, const void * second){
    long long f = ((DiskBound *)first)->leftBound;
    long long s = ((DiskBound *)second)->leftBound;
    //NSLog(@"Current Sorting %lld, %lld",f,s);
    if(f > s )return 1;
    if(f < s) return -1;
    return 0;
    
}

int solution(NSMutableArray *A) {
    // write your code in Objective-C 2.0
if(!A && [A count] < 1) return 0;

    int resultCount = 0;
    
    DiskBound diskBound[[A count]];
    for(int i = 0; i < [A count] ; i++)
    {
        diskBound[i].leftBound =i-((NSNumber *)A[i]).integerValue;
        diskBound[i].rightBound =i+((NSNumber *)A[i]).integerValue;
    }
    qsort(diskBound, sizeof(diskBound)/sizeof(diskBound[0]), sizeof(DiskBound), compare);
    
    for (int i = 0; i < [A count]; i++){
        long long currentBound = diskBound[i].rightBound;
        for (int jj = i+1; jj < [A count] && diskBound[jj].leftBound <= currentBound; jj ++)
        {
            resultCount ++;
        }
        
        if(resultCount > 10000000)
            return -1;
    }
    return resultCount;
}

Summary:

The performance with Objective-C in Codility is relatively slower than other language. Their measurement of time complexity is the running time not from the code, I guess. So facing these kinds of mathematical problem. Using native C language can help you to do more faster and get higher grades.