News for hackers. Stuff that matters.
Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by cognivore on Monday March 03, 2014 @02:46AM (#7332531)
Apologies in advance to the PHPers out there, but... PHP?!
Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by TazeTSchnitzel on Monday March 03, 2014 @02:50AM (#7332544)
MagicalTux is a known lunatic who wants to write everything in PHP. Which isn't too bad of an idea, but he, for example, hacked together an SSHd in PHP and immediately put it into production use:

http://blog.magicaltux.net/2010/06/27/php-can-do-anything-wh...

Essentially he is a bad programmer and he has Not Invented Here (fixed, thanks jey) syndrome, both of which are terrible attributes for someone coding a Bitcoin exchange.

Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by jey on Monday March 03, 2014 @03:09AM (#7332592)
I think you meant NIH ("Not Invented Here"), not NIMBY ("Not In My Backyard").
Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by TazeTSchnitzel on Monday March 03, 2014 @03:12AM (#7332601)
Oops, yes I did indeed mean Not Invented Here syndrome. Thanks.
Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by stormbrew on Monday March 03, 2014 @04:28AM (#7332807)
.. Well.. at least he didn't write the crypto primitives himself in PHP.
Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by brianpgordon on Monday March 03, 2014 @06:15AM (#7333131)
He wrote the DH key exchange himself. I didn't look at the implementation but someone commented before that it's vulnerable.
Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by mukyu on Monday March 03, 2014 @12:58PM (#7335178)
I actually wrote that comment back in the day. I was rather snarky and unhelpful it seems.

The code for the sshd does not seem to be there anymore, but from memory: it did not check if the number sent by Bob was 0, 1, or any any other groups that would make it easy solve the discrete logarithm problem. I don't think it bothered to check the primes either. [1] I think there was also something wrong with the signature checking (padding not checked maybe?).

Altogether it seemed like you could easily MITM connections made to the server, but I don't think I ever tried. It was a perfect example--to me at least--of why you should not spend a trivial amount of time reading about crypto on Wikipedia and then writing crypto code.

Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by olssonm on Monday March 03, 2014 @02:55AM (#7332559)
Just for the sake of argument – any reason why not PHP?
Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by shalmanese on Monday March 03, 2014 @03:01AM (#7332576)
For a bank?

I can think of lots of reasons.

* You're exposed to any upstream bugs in the language and interpreter

* Dynamic typing and silent errors mean you're far more likely to make a mistake and not realize it

* It's missing a lot of battle tested libraries and frameworks

* It's PHP

Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by RossM on Monday March 03, 2014 @04:48AM (#7332871)
An argument, since it's Monday and I'm grumpy:

1. As in any language,

2. As in any interpreted language. Yes PHP has the gag operator (@) but it's use is discouraged (and not used in this example),

3. Not in my opinion. The Symfony framework alone has a ton of well used packages[0]. It does look like someone's decided to build their own framework from this example though,

4. Opinion.

[0]: https://packagist.org/search/?q=bundle

Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by bunderbunder on Monday March 03, 2014 @01:04PM (#7335226)
> 2. As in any interpreted language.

Scheme, Standard ML, very early versions of Java, and BASIC come to mind.

Static typing really does seem particularly important in this domain, to the point that if an engineer is unable to find a suitable interpreted static language then the prudent choice would be to start looking at compiled langauges before relaxing the static typing requirement. Even implicit type conversion seems like a pretty questionable idea in this sphere. You really would want to be keenly aware of when you're doing something that might add or remove numerical precision.

Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by Gigablah on Monday March 03, 2014 @03:16AM (#7332609)
Maybe someone would like to post a link to the veekun article for the umpteenth time.
Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by ColdHawaiian on Monday March 03, 2014 @03:46AM (#7332699)
I'm assuming that you're referring to "PHP: a fractal of bad design"[1]?

[1]: http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de...

Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by mappu on Monday March 03, 2014 @03:24AM (#7332634)
> You're exposed to any upstream bugs in the language and interpreter

How would you mitigate that, and how is the mitigation process any different for PHP?

Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by someone13 on Monday March 03, 2014 @03:33AM (#7332666)
Not to say whether PHP is in fact a good idea or not, but at least in a statically-compiled language, once you've got a "working binary", however you accomplish that, it will presumably continue to function that same way indefinitely. Obviously barring OS-level problems, of course :)
Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by nodesocket on Monday March 03, 2014 @03:27AM (#7332644)
Would you consider Python and Ruby strongly typed? Because I happen to know two very large payments company using them. However if that is indeed their code, it makes me cry and cringe, even though PHP is my strongest language and I'm proud to admit it.
Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by eurleif on Monday March 03, 2014 @03:53AM (#7332717)
>Would you consider Python and Ruby strongly typed?

Did you mean statically typed? There are two dichotomies: static vs. dynamic, and weak vs. strong. Ruby and Python have strong dynamic typing. PHP has weak(-ish) dynamic typing.

Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by brianpgordon on Monday March 03, 2014 @06:31AM (#7333183)
Python and Ruby are great for building an MVP, and they'll take you a long way, but they're probably unsuitable for a high-stakes codebase like a financial system. When bugs are absolutely unacceptable, you need all the help you can get from static analysis.

And (don't crucify me HN) I think dynamic typing rapidly loses its allure as your codebase grows large and "enterprise." The advantages in rapid prototyping and easy changes start to be overshadowed by the increasing burden added by unexpected side effects any time you change something. In Java, if I change an interface then I can find every client of that interface with one click and make sure each one is not broken by the change. The same is not true of JavaScript code; changing the valid inputs of a function can break things scattered around the code, and you won't notice unless you use a particular feature 3 times in a row on a waning gibbous moon.

Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by _pmf_ on Monday March 03, 2014 @04:25AM (#7332800)
> Because I happen to know two very large payments company using them.

For the purpose of short selling: who are they?

Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by nodesocket on Monday March 03, 2014 @04:32AM (#7332821)
I bet you can guess, both bay area YC companies.
Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by xytop on Tuesday March 04, 2014 @05:53PM (#7343817)
Stripe?
Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by coldtea on Monday March 03, 2014 @01:16PM (#7335313)
>Because I happen to know two very large payments company using them.

Using them for what though? I doubt they use them for their transcation money handling code.

Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by nodesocket on Monday March 03, 2014 @03:19PM (#7336170)
You'd be wrong.
Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by coldtea on Tuesday March 04, 2014 @12:10AM (#7338599)
Pics or it didn't happen.
Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by dan15 on Monday March 03, 2014 @03:45AM (#7332696)
Anything in particular about this code that makes you cry and cringe?
Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by nodesocket on Monday March 03, 2014 @04:30AM (#7332815)
Lot's, but perhaps most obvious, not using a routing engine or framework, simply spaghetti code case statement:

      public static function _Route_getStats($path) {
                switch($path) {
                        case 'version':
                          ...
Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by cognivore on Monday March 03, 2014 @09:48AM (#7333953)
There are a lot of great responses (and counter responses) here already as to why PHP is a surprising choice, but primarily my objection is one of misapplication. PHP is a scripting language for fast creation of web sites. It grew organically and consequently has a lot of weird gotchas that make it easy to write in bugs. Its floating point is poor, which you would think would be a detriment in financial use.

Want to get a web site up like right now, get some PHP. Want to run the largest Bitcoin exchange in the world, maybe not so much.

Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by antocv on Monday March 03, 2014 @06:17AM (#7333139)
It looks $ugly, $code is read more $often than its $written. This $ everywhere hurts the eyes.

Its syntax is bad and inconsistent, before 5.4 you couldnt have a function return an array and call it and access array contents like this funcName()['blah']. What the.

PHP only has one data type for structures, array, which in various ways pretends to be every data type, stack, queue, tree, hashmap, list, fuck it all, lets just call it array everywhere!

Anyway, everything else is implicitly converted as well, strings, integers, fuck it all, lets ouput 0 or 1 who cares.

PHP is basically not a language, its a clusterfuck of copy-pasted code everywhere, I bet its runtime, Zend, is as a copypaste of various C-libraries cobbled together.

I feel sorry for all the PHP lovers, must be stubborn ones, just like VisualBasic people 10 years ago when it was dying. PHP-lovers have the same argument now as VisualBasic did 10-15 years ago.

EDIT: Where and when I would use PHP. Never. There is always a better alternative. This talk about how easy it is to host, blah blah, then you never had to compile php and set its config flags and include dumb oci8 modules, pear or pecl files or whatever, or see it fail and no logs anywhere but you have to have system-level access to some ini files. Ugh... I think people have just learned to live with that crap, and the more sane languages and web frameworks like Flask or Grails are much easier.

Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by jasey on Monday March 03, 2014 @08:21AM (#7333532)
One advantage it does have is apps can auto update and extend themselves. Eg, wordpress makes extending it with 3rd party plugins extremely painless from a user perspective.

As for not being able to access a array directly from a function which returns the array. It's just syntactical sugar. Yes long over due syntactical sugar however.

Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by antocv on Wednesday March 05, 2014 @03:05AM (#7345921)
Whats that got to do with the language?

Autoupdateing can be implemented in VisualBasic as well.

Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by coldtea on Monday March 03, 2014 @01:17PM (#7335321)
>It looks $ugly, $code is read more $often than its $written. This $ everywhere hurts the eyes.

As much as Lisps parenthesis everywhere do.

Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by brianpgordon on Monday March 03, 2014 @07:45AM (#7333381)
Zend is, indeed, infamously a mess. HipHop is supposed to be better.

https://github.com/facebook/hhvm

Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by dan15 on Tuesday March 04, 2014 @02:11AM (#7338930)
Yeah, Hack for HHVM adds a bunch of stuff to PHP to make it better, including:

- Collection classes like Vector (which is like an array in every other programming language ever) and Map (associative array or hashtable)

- Generics

- Lambda functions

- Asynchronous functions

- Type hinting for intrinsic types (int, string, bool)

Not much public documentation yet, but most bits are in the open source HHVM release, and there are a few blog posts on it (eg. http://www.sitepoint.com/hhvm-hack-part-1/)

Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by krapp on Monday March 03, 2014 @01:44PM (#7335510)
Do you believe that Mt.Gox would still have everybody's bitcoins if it had been written in Ruby or Python or Node.js?
Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by jl2035 on Monday March 03, 2014 @09:37PM (#7338091)
If there was the same people (person) behind it.. No.
Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by ing33k on Monday March 03, 2014 @03:27AM (#7332642)
no apologies needed , but will be better if you can add more details on why you think using PHP is bad (for Mt.Gox ).
Re:Alleged Mt.Gox code leaked on IRC node by Russian Hacker by dschiptsov on Monday March 03, 2014 @08:13AM (#7333496)
Isn't it self-evident?)

Having such a bad code in the worst language imaginable that eventually the site has been cracked by Russian punks.

This will be a great case study.