Better HN
topnewbestaskshowjobs
Log inSign up

DCoder

1,260 karma · joined Nov 2, 2009 (17y ago) · 479 submissions

not here anymore
Submissions

comment 15y ago · link · parent

Nice trick!

  var f = []['concat']; // Array.prototype.concat
  f()[0]; // returns the global window
The rest of the script appears to mostly be old tricks - convert stuff to strings, combine characters in strings to compose expressions, pass them to eval...

comment 15y ago · link · parent

1. Function to String conversion produces different results in different browsers.

  var f = []['concat']; (f + ''); 
  // Chrome
  "function concat() { [native code] }"
  // IE (9)
  "
  function concat() {
    [native code]
  }
  "
This script tries to extract letters from that string representation, which fails if the string is different. (This is also used as an anti-debugging measure in some JS malware, to prevent researchers from replacing document.write with alert() or similar.)

2. Iterating over the window object doesn't work the same way in IE: http://blogs.msdn.com/b/ericlippert/archive/2005/05/04/41468...

In particular, this script tries to extract strings 'sessionStorage', 'getComputedStyle', 'onchange' by iterating over the window object, all of whom fail in IE.

comment 15y ago · link · parent

- If you want to reverse-engineer existing code (security checking, malware analysis, unofficial bug fixing [1]), then of course yes.

[1] http://www.hexblog.com/?p=21 - The author of IDA Pro disassembler wrote a hotfix for the WMF vulnerability in Windows about a week before MS released a fix. From what I've heard, his site completely tanked due to all the downloads.

comment 15y ago · link · parent

Am I the only one who still uses Total Commander instead of Windows Explorer whenever possible? I'd love to see this multiple-jobs-in-movecopy-queue functionality in it, but in all other situations it suits me so much better.

comment 15y ago · link · parent

VC++ 2010 supports a lot of them: http://blogs.msdn.com/b/vcblog/archive/2010/04/06/c-0x-core-...

I've gotten into the habit of auto'ing most variables nowadays, it's quite convenient not having to type

     LongTemplateName<ClassName> variable = LongTemplateName<ClassName>::StaticCollection.Find(something);

comment 15y ago · link · parent

In MSVC, this warning's off by default: http://msdn.microsoft.com/en-us/library/wzxffy8c(v=VS.100).a...

comment 15y ago · link · parent

Part 1 of the post: http://news.ycombinator.com/item?id=2747344

----

Small clarification: I shared some info on the internal workings of Command&Conquer in the comments of the last post. The author of this post took that to mean that I was one of the developers. That's not true - I'm just a bored coder with a disassembler and (not so much lately) free time on my hands. Some friends of mine and I reverse engineered large amounts of code in those games to add new functionality or fix bugs, which there were plenty of...

comment 15y ago · link · parent

There has grown in the minds of certain groups in this country the idea that just because a man or corporation has made a profit out of the public for a number of years, the government and the courts are charged with guaranteeing such a profit in the future, even in the face of changing circumstances and contrary to public interest. This strange doctrine is supported by neither statute or common law. Neither corporations or individuals have the right to come into court and ask that the clock of history be stopped, or turned back.

R. A. Heinlein, "Life-Line", 1939

comment 15y ago · link · parent

C&C series, at least the older pre-Generals ones, work the same way - hashing the full state in each frame and sending it over. When a desync is detected, it dumps checksums of the last 256 frames along with current frame's checksums of each object into a log file, these can be compared. The logs also contain brief printouts of most objects on the map, and we actually found an uninitialized field and a few more serious bugs thanks to these printouts.

The cheaters also found a small loophole in the hashing, because only specific fields are hashed and not entire objects, one important field was missed that gave cheaters an unfair advantage of seeing the current targets of their opponents' units. It is easy enough to fix when you know about it, fortunately.

comment 15y ago · link · parent

Sorry for double posting, but those additional resources are boot loaders for Rescue Disks. Why and how do they differ from normal loaders, I don't know.

comment 15y ago · link · parent

Yes, that's what I said... but this is the resource section of the installer, not of the extracted executable. The extracted executable is the same and doesn't, as far as I can see, make any references to those resources.

It is possible they recompiled it with the new license and the installer project was configured to carry all resources it found in specific folders, while the executable was configured to only include specific resource files... I used Extract instead of Install because my system disk is already truecrypt'ed, but if you can provide the files the installation creates, I could compare those too.

comment 15y ago · link · parent

I downloaded the setups from the links, and used the "Extract" option in the installers. It appears that only the license was changed: http://pastebin.com/G3H78tSt

Edit: However, the installer binaries' sizes differ by 113280 bytes, while the extracted files' size totals differ only by 925 bytes.

Edit 2: the majority of the size difference is in the .rsrc section, the newer version contains several additional binary resources, some of which appear to be boot loaders. And the text resources are different... is it possible the installed versions are different and the extracted ones are not?

comment 15y ago · link · parent

Lithuania here - 25 pounds/month gives me unrestricted 100 Mbps, next month they're tripling all speeds for no additional costs. The one-step-cheaper option is 90% of the cost for only 10% of the speed, so I opted for this one instead.

comment 15y ago · link · parent

If web page "has nothing except JavaScript" (e.g. GMail) is probably is web app and indexing it makes little sense anyway.

What about JS frameworks like JavascriptMVC or Sammy [1]? Google even created a spec [2] for crawling such sites.

[1] http://sammyjs.org/ [2] http://code.google.com/web/ajaxcrawling/docs/getting-started...

comment 15y ago · link · parent

Missed one:

    foobar() is the same as FOOBAR()
    $foobar is completely separate from $FOOBAR

comment 15y ago · link · parent

More pure CSS minigames can be seen at http://www.cssplay.co.uk/menu/ , under Puzzles.

comment 15y ago · link · parent

The decompilation quality really depends on how obfuscated the original code was, and how much time you care to invest. For example, I'm using Hex-Rays to decompile Command & Conquer: Red Alert 2 and extend it, and now its output looks like [1] , which is a lot better than raw assembly menemonics. Though I've been digging into this game since late 2008, which is a long time.

[1] http://img824.imageshack.us/img824/1188/hexrayscpp.png

comment 15y ago · link · parent

Thanks for the ideas. However, in this case the DLL relies on MSVC for binary compatibility with its host, and the version control server is a *nix box.

comment 15y ago · link · parent

Compilation output does not belong in source control

I've seen this before, but never found a suitable alternative. Where does it belong? Suppose multiple developers are compiling a C++ .dll which testers are grabbing through websvn and testing. To track down crashes they get, we need the associated .pdb for the right revision. Where should these files be kept? In a plain folder where each revision gets its own subfolder named as the revision number? That means updating two separate locations with each build, using two different interfaces...

comment 15y ago · link · parent

Were those recurring meetings or one-offs?

Part of a product I'm working on now is being able to schedule repeating tasks every day, every month, etc. Which means that "07:30 every Friday" has to happen at 07:30 in the author's timezone, whether or not DST is active. To my knowledge Javascript can only tell you the timezone offset from UTC for a given date/time. You can determine the DST-less offset that way, but there are multiple timezones sharing the same offset (e.g. PHP has 63 separate timezone records for Europe alone) and then simply matching them by offsets doesn't work ideally, you need the user to make a choice.

comment 15y ago · link · parent

Google Gears still works on Firefox 3.x and IE 8, and can be used to emulate WebSQL. It doesn't support async queries, but it's still a good alternative.

comment 15y ago · link · parent

That sounds like something http://tenaciousc.com/ can help with.

comment 15y ago · link · parent

SQL NULL. Javascript NaN.

Their behaviour is defined by the standards and special checks are required to identify these values properly. In SQL, it's

  X IS (NOT) NULL
, in Javascript it'd be

  isNaN(X)
.

rand() (well, most of the time[1]). This you just have to know :)

Improperly expanding C macros:

  #define isupper(c) ((c) >= 'A' && (c) <= 'Z')
  #define X isupper(getchar())
  printf("X == X = %d\n", X == X);
And like lurker14 said, anything in general that has side-effects.

[1] It is possible rand() will return the same value twice in a row, just not very likely. Also the original author might have been twisted enough to memoize it. Thank you, "Higher order Perl", for that idea.

comment 15y ago · link · parent

Well noticed! I wasn't able to look at the images earlier (at work), but at least this image http://bankofamericasuck.com/wp-content/uploads/2011/01/boa1... is interesting - the email is timed March 11, but it's in the January folder. Wordpress doesn't let you upload new versions of the same image, so it can't be that... Which makes it look like a pre-scheduled hoax?

comment 15y ago · link · parent

Draft post was written back in January, probably, and the files in /03 were only added recently. Wordpress can split uploaded files into this folder structure automatically based on upload time.

comment 15y ago · link · parent

I don't think you're doing this right. The first .then receives a function, but the second .then executes function.apply at construction time and receives only its result (null) as the callback.

Also, after understanding what's going on, existing solutions might be better than rolling your own: http://api.jquery.com/jQuery.proxy/ .

comment 15y ago · link · parent

It's not just Apache you need to configure - PHP ignores Apache's directory access configurations entirely, you need open_basedir and preferably something like suPHP.

Disabling shell functions (system, exec, etc.) is also a good idea, unless the application itself requires them (e.g. if the host is too stupid/lazy to have the imagick extension installed and tells you to call /usr/bin/imagick instead...).

comment 15y ago · link · parent

Sure you can, but why would you want to? Reinventing the wheel is not fun.

A colleague pointed me to Yii Framework [1] a couple years ago, and I stopped looking for alternatives. Don't see any reason to invent my own frameworks, since Yii has practically every feature I could want already implemented and, more importantly, well tested. In those rare cases when I need to customize or extend something, it's fairly simple to do so, since the code is well documented and organized (though the authors seem to be suffering from a severe allergy to whitespace...).

Controllers with access control rules and filters? Check.

Autoloading? Check.

Caching with support for multiple mechanisms (file cache, db cache, eAccelerator, MemCache, XCache, Zend Data Cache)? Check.

DB layer based on PDO? Check.

ActiveRecord? Check.

Mass attribute assignment to Active Record, complete with validation and allowed/forbidden attribute configuration)? Check.

Named scopes? Check.

Multiple database engine support (MySQL, MSSQL, Oracle, SQLite, PostgreSQL)? Check.

Testing environment? Check.

CLI mode? Check.

I18N support? Check.

Plain PHP views with simple HTML escaping and HTML construction? Check.

Event raising and handling? Check.

[1] http://www.yiiframework.com/

Edit: However, no framework can take away the programmer's stupidity. My former colleague used another framework that has decent support for parametrized queries and still concatenated his SQL from raw user input and printed data into javascript variables by simply wrapping it in '' with no escaping... So glad all of his code has been retired.

comment 15y ago · link · parent

Thanks for the link! You were correct, the quality is noticeably better: https://github.com/Laurelai/decompile-dump/blob/master/outpu... vs http://img715.imageshack.us/img715/1051/hexraysstx.png

comment 15y ago · link · parent

I've seen HexRays do the same thing - most of the time you need to actually tell it that a variable is a pointer before it tries to do that.

Stating the function type explicitly also helps it display the right arguments given to it. This output could be significantly improved if the assembly version were available as well.

1
1213141516