예제 #1
0
 public int crack(String[] plaintexts, String[] ciphertexts) {
   long[] in = parse(plaintexts);
   long[] out = parse(ciphertexts);
   int ans = 0;
   for (long cur : in) {
     long key = cur ^ out[0];
     boolean ok = true;
     for (long na : out) {
       if (Arrays.binarySearch(in, (key ^ na)) < 0) ok = false;
     }
     if (ok) ans++;
   }
   return ans;
 }
예제 #2
0
  /**
   * /* return the address of the function that address is in
   *
   * @param vma
   * @return
   */
  public Symbol getSymbol(final long vma) {
    if (this.symbols == null) {
      return null;
    }

    // @@@ If this works, move it to a single instance in this class.
    final SymbolComparator symbol_comparator = new SymbolComparator();

    int ndx = Arrays.binarySearch(this.symbols, vma, symbol_comparator);
    if (ndx > 0) {
      return this.symbols[ndx];
    }
    if (ndx == -1) {
      return null;
    }
    ndx = -ndx - 1;
    return this.symbols[ndx - 1];
  }