Search

hack_anon

anonymous hacks and reverse engineering voodoo

Category

Uncategorized

Code Snippet: List Selector

Today I present to you a function that takes in a list of integer values and a matching list of custom typed objects and returns the object that corresponds to the largest numerical value from the source list, or a default value when all integers are found to be equal.

    public static T selectMax<T>(int[] selectors, T[] values, T defaultValue)
    {
        int imax = 0; // first element = 1, or i+1

        for (int i = 1; i < selectors.Length; i++)
        {
            if (imax == 0)
            {
                if (selectors[i] == selectors[i - 1])
                    continue;

                imax = i;
            }

            if (selectors[i] > selectors[imax - 1])
            {
                imax = i + 1;
            }
        }

        return imax == 0 ? defaultValue : values[imax - 1];
    }

 

Usage

Say you are trying to read the suit value of a card where each suit has own color as follows:

  • Red – Hearts
  • Green – Clubs
  • Blue – Diamonds
  • Black – Spades

Simply by analyzing the RGB histogram of a source image (or region that represents said suit) you can then determine suit value via:

 
string suit = selectMax<string>(
                   new int[] { r, g, b },
                   new string[] { "Heart", "Club", "Diamond" }, "Spade");

Game Reversal…

If you are a software developer who’s also into games, you’d no doubt find the field of game reversal particularly interesting, especially mmo type games where you face off against live opponents. Take a game like H1Z1 – a zombie apocalypse survival mmo kind. How cool would it be to run around with an active radar that would allow you to see stuff your opponents can’t (as a case in point consider one of the few popular esp radars out there like h1c1.com).

And whereas it is nice to just grab a readily available radar off the shelf (if you have the $$), what I find more exciting and personally full-filling is to build one yourself.

So what does it take to break a game, how’d one go about building own radar for example?

Well first off you’d need to get the right tools for the job.. some of the key ones are

Reclass (intro)

IDA

OllyDbg

CheatEngine (careful as this could often get you banned right off the bat!)

Granted you have basic understanding how these tools work, you are ready for the prime time!

Tutorial: Building an H1Z1 Radar

Ex-Machine: the code

There’s a point in the film where Caleb is entering code on Nathan’s workstation. And unlike code you’d find in other films, this one actually serves a useful purpose as mentioned in my earlier post.

If you’d like to play with the code in Google’s own Code Playground, you can copy & paste this snippet adapted to work with google’s webapp API:

import webapp2

def sieve(n):
    x = [1] * n
    x[1] = 0
    for i in range(2,n/2):
            j = 2 * i
            while j < n:
                    x[j]=0
                    j = j+i
    return x
  
def prime(n,x):
    i = 1
    j = 1
    while j <= n:
            if x[i] == 1:
                    j = j + 1
            i = i + 1
    return i - 1

def DeusEx():
  x=sieve(10000)
  code = [1206,301,384,5]
  key =[1,1,2,2,]
  
  out = "".join(chr(i) for i in [73,83,66,78,32,61,32])
  for i in range (0,4):
      out += str(prime(code[i],x)-key[i])
  return out

# WebApp 
class MainHandler(webapp2.RequestHandler):

  def get(self):  # pylint:disable-msg=invalid-name
    """Handle GET requests."""
    self.response.write(DeusEx())

APP = webapp2.WSGIApplication([
    ('/.*', MainHandler),
], debug=True)

In case you were wondering, the ISBN number is generated by concatenating the 1206th, 301th, 384th, and 5th prime number, where each pair is subtracted by an N starting with 1, 2, and so on:

The 1,206th prime is 9,781. -1
The 301st prime is 1,993. -1
The 384th prime is 2,657. -2
The 5th prime is 11. -2
= 9780 1992 2655 9

73,83,66,78,32,61,32 are the ascii characters for “ISBN = ”

Of course, the name of the function “sieve” is a reference to a method of reducing number of prime candidates as described on this wiki http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes

Deus Ex-Machina

Following up on my previous post where I had talked about the latest AI movie Ex-Machina, I thought you’d be interested in examining some of the BlueBook’s source code. (WARNING: SPOILER)

 
Continue reading “Deus Ex-Machina”

Sentient Machines

Have you seen the latest flick Ex-Machina? If you haven’t, you must. Having re-watched it a few times by now, I find myself enthralled by it’s message and apprehensive of the implication of that message. Are we, humans, capable of building truly sentient machines? And if it were possible, could we ensure these machines we build would be benign or the beginning of the end of our entire kind?

As a software programmer, a hacker, I’m particularly interested in the field of artificial intelligence. What does it really mean to be intelligent? Obviously being able to sum up a pair of digits (such as a 2) doesn’t make one smart; capable of pulling of simple arithmetic operations, but definitely not smart. But what about a machine capable of making many mathematical computations in a very short span of time, over and over again, in perpetuity and without a pause; does that make for an intelligent machine? Hardly. Just like we cannot in full conscience define computers as intelligent. They are very capable machines, perfectly fit to solve specific problems. But do they posses true intelligence? I think not.

The Mariam-Webster Dictionary defines the word “intelligence” as

the ability to learn or understand things or to deal with new or difficult situations

Thus, the mark of true intelligence is the ability to learn new things. Therefore the key to building a truly intelligent system is to program it to be able to learn: process new input, acquire and catalogue information in a meaningful way so as to be able to reference these vast stores of data to make sense of reality (through external stimuli) and chart future course of action.

And just how do we go about building such a machine? That I will touch on in my future musings.. stay tuned.

Hello…

… I have nothing to say… yet.

Stay tuned …

Blog at WordPress.com.

Up ↑