Code in "Blackhat" is hilariously wrong but recognizable Python

The movie Blackhat was terrible. Its 33% score on Rotten Tomatoes sort of speaks for itself.

A recent article about it said that "Hollywood finally gets the internet right." I wouldn't say that, but if we're being fair it probably got more details right than most other movies in the genre. That isn't saying much.


Still the gold standard

Spoiler alert: the bad guy in Blackhat is an elite hacker who starts off the movie by melting down a nuclear power plant in Hong Kong... apparently just to raise a very modest amount of money to fund the next scam. Then there are two hours of explosions and yelling interspersed with dialog that reads like a child imagining how important grownup FBI agents probably talk to each other. At the end we learn that this was all just an overly elaborate scheme to manipulate the commodities markets.

The actual best part of the movie was this momentary shot of the main guy stealing all teh codes that the bad guy wrote to sabotage copper mines:

Screenshot of code

Wait... zoom in...

Zoomed screenshot of code

And enhance!

def checktarget (tgt):
    
    if tgt =   'Phera LTD':
              if date.time >= 03-21-2015.1900
              pumpfreeze(caloptin)
              else:
              return

    elif tgt = 'Farah Ming Mine':
              if date.time >= 03-27-2015.2000
              pumpfreeze(farahming)
              else:
              return

    elif tgt = 'Mira Rain Mining':
              if date.time >= 03-28-2015.2030
              pumpfreeze(mirarain)
              else:
              return

    elif tgt = 'Cagnoletti Mine Corporation':
              if date.time >= 04-06-2015.2030
              pumpfreeze(cags)
              else:
              return

    else tgt = 'Kantor Tine Mines':
              if date.time >= 04-08-2015.2100
              pumpfreeze(kantor)
              else:
              return
    return

As satisfying as it would be to make an exhaustive list of issues, that's left as a fun exercise for the reader.

Blackhat Python book They should have stopped at Barnes and Noble

But questions remain. Why write it in a real language at all? And after taking the trouble to almost write it in Python, why bone the landing?

We'll probably never know. My theory is that one of the advisors arranged for legitimate code to be written, but one of the uh... prop... computer wranglers (?) decided it would look so much cooler with a couple tweaks. Someday I would love to get the real story, which in addition to satisfying my curiosity would also be well in the running for least scandalous Hollywood behind-the-scenes of all time.

Shout out to John Graham-Cumming who has been documenting this kind of thing for a while. There's also a funny tumblr for fake UI's.