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

This looks like the output of HexRays [1], which is the best C decompiler I've seen. Defining some structures and typing the variables would make it a lot more readable in some cases. I've used HexRays to make sense of C++ games several times, after investing enough time to define and use data types, the result looks [2] much better, but then again, that's unobfuscated and not optimized C++, not old-school "I know what I'm doing and I don't need the compiler second-guessing me" C.

Unfortunately there's still a lot decompilers can't do, mostly compiler tricks (e.g. storing a pointer to the middle of a structure instead of its beginning, and using negative offsets to access other struct members [3] - this is usually obvious when looking at it, but HexRays can't make sense of it so it falls back to raw pointer math).

[1] http://www.hex-rays.com/ [2] http://img824.imageshack.us/img824/1188/hexrayscpp.png [3] https://github.com/Laurelai/decompile-dump/blob/master/outpu...

comment 15y ago · link · parent

Consider this sequence:

     0041301E  33 D2     xor edx, edx
     00413020  83 E8 02  sub eax, 2
     00413023  74 01     jz loc_00413026
     00413025  4A        dec edx
     00413026  ...
Without a single-byte int 3, a break on dec edx will mess up everything if that branch is not taken.

comment 15y ago · link · parent

In x86 assembly (and a lot of other contexts), 16 bits are called a word (a left over from 16 bit days when 16 bits were in fact a machine word), and larger data types are named dword (double word, 32 bits), qword (quad word, 64 bits), and so on. This terminology is even included in certain instruction mnemonics (movsb|movsw|movsd, ...).

comment 15y ago · link · parent

Nowadays MSVC supports the /hotpatch command line option, which inserts fillers like "mov edx, edx" or "lea edi, [edi]" at the start of each function for the same purpose.

comment 16y ago · link · parent

Seems relevant:

The Korean concept of Han, as explained by The West Wing: "There is no literal English translation. It's a state of mind. Of soul, really. A sadness. A sadness so deep no tears will come. And yet still there's hope."

http://en.wikipedia.org/wiki/Han_%28cultural%29

comment 16y ago · link · parent

In Russian it's also called "mayak" (literally 'beacon').

comment 16y ago · link · parent

The presentation is nice, but I strongly disagree with the author's chosen method of drawing browser icons:

  .browser-support dd:nth-of-type(3) { background-image:url("img/opera-logo.png"); }
  .browser-support dd.no-support:nth-of-type(3) { background-image:url("img/opera-logo-white.png"); }
And looking at the calculated width example reminded me of the box-sizing property [1], which would simplify that particular use case.

[1]: http://www.w3.org/TR/css3-ui/#box-sizing

comment 16y ago · link · parent

"Let's execute command 382 to see what it does."

Oy. Not the best idea, generally speaking.

Edit: I used to read the localized paper version of http://xakep.ru/ several years ago, and practically every hacking story/tool roundup they had mentioned the annoying problem with ls --color, it was apparently present in almost every public rootkit at the time. It's kinda interesting to see that idiots still use outdated tools years later.

comment 16y ago · link · parent

For hosts that support git, I simply clone/pull updates from a central repos.

For hosts that don't (i.e. we used to have one project running on a Windows server with nothing but Remote Desktop access and no permission to install any VCS), I use this:

    alias gdate=date\ +%Y.%m.%d-%H.%M.%S
    gitzip () { zip -ruv "$(gdate).zip" $(git diff $@ --name-only); }
Invoking `gitzip $commit` produces a zip file containing all the changed files since said commit. Unzip archive to wwwroot, check for files that need to be deleted, done.

comment 16y ago · link · parent

Some background: This was written by a defected Soviet military intelligence officer Victor Suvorov: http://en.wikipedia.org/wiki/Victor_Suvorov .

Suvorov wrote a lot of books exploring WWII and demonstrating large amounts of evidence for his "Icebreaker" theory, claiming that Stalin intentionally led Hitler to power, planning to occupy Europe after Nazis and the Western countries were both weary and weakened. The theory has a lot of vocal opponents, but Suvorov never misses a chance to point out that most of them are (paid by) Soviet political/military figures, who are obviously biased and would never admit such a plan. It's a shame that these books are not all translated to English.

He also wrote two memoir books, (Tales of a) "Liberator", describing his service in the Soviet regular forces, and "Aquarium", covering the period after he got noticed by and accepted into the intelligence forces. The first one contains some rather fascinating stories of everyday Soviet life and dogma, well worth a read if you can find it. The second one is also good, even though it lacks those everyday stories.

Summa summarum, the book OP linked to is an interesting view into the old Soviet thinking. Might be an eye opener for those who believe the Soviets were anywhere near as humane as the Western countries.

comment 16y ago · link · parent

He had nothing to do with the Stalingrad breakthrough, and he wasted two whole tank armies in Berlin because he was too daft to see that narrow, barricaded and rubble-filled streets are not the best place for tanks. Such a great guy.

Excusing the Russians' war atrocities simply because they beat the Germans is quite like picking the frying pan instead of the fire - they are both very bad, just one is somewhat worse than the other. (Then again, I'm from the Baltic states, where we were actually stuck with the Russians until 1990, so I am probably biased.)

Did the Nazis have long distance bombers that could actually destroy the industrial complexes in Ural or further to the East? I am not aware of any.

comment 16y ago · link · parent

No, he was a guy who

- carried out his orders blindly and without thinking ( see http://en.wikipedia.org/wiki/Battles_of_Rzhev where he blindly sent several hundred thousand troops into fortified German position - if you send your forces up the same road for two months straight without gaining any advances, wouldn't you at least try to find an alternate route that the enemy doesn't expect you to use? ) ,

- was very hungry for fame and glory (I can't find references now, but it was his initial reports to higher command during the first few days after 1941-06-22 that led Stalin to believe the German invasion was already mostly contained and delayed Russian defense deployments. In addition, Stalin demoted Zhukov later, citing "attributes others' achievements to himself" as a significant reason.), and

- was generally vain, sadistic and incompetent. Several high ranking officials and civilians reported his attitude towards his subordinates as nothing less than disgusting.

- He was also in charge of Totsk nuclear testing ( http://www.johnstonsarchive.net/nuclear/radevents/1954USSR1.... ), where he had over 40k soldiers split into two teams and engage each other moments after a nuke had been detonated above the battlefield.

Also, he had nothing to do with the German defeat at Stalingrad - he was still too busy headbutting Rzhev: http://en.wikipedia.org/wiki/Battle_for_Velikiye_Luki_(1943)

For more details, I suggest looking up Viktor Suvorov's "Shadow of Victory". And other Suvorov's books for a different view of WWII in general.

comment 16y ago · link · parent

If you're running on Windows, Vista/W7 has `clip` as an equivalent to pbcopy. One project I was working on, the sysadmin didn't give us any access to the server, so we had to instruct him to use git each time an update went through (daily). `git rev-parse HEAD | clip` was the fastest way to get the "revision your tree should be at after pulling" then and send it to him.

comment 16y ago · link · parent

+1. I find that their psychedelics (Lynton Samuel Dawson, Voyage 34, Staircase Infinities, No Reason To Live No Reason To Die, Moonloop) mix quite well with Pink Floyd's (A Saucerful of Secrets, Atom Heart Mother, Set the controls...). Most of the later works are too vocal and distracting.

comment 16y ago · link · parent

They could have made it fully case sensitive, or fully case insensitive... but they went for the confusing middle point:

  foobar() == FOOBAR()
but

  $foobar != $fooBar
And then there was that fun issue with the Turkish locale and function names...

comment 16y ago · link · parent

Work: Tuesday, international flight to a customer to gather requirements for new product version - enough work for a year. Thursday, try to integrate WordPress and Facebook Connect and curse loudly - the architects who return either a userID or a WP_Error object and the plugin writers who just (int) $result without checking if it's an error.

Free time: reverse engineering a C++ game and extending it. http://img180.imageshack.us/img180/9215/devenv.png - IDA to rev/eng it, Eclipse C++ with a custom build tool to compile, Rose Tyler background just because.

comment 16y ago · link · parent

What are you aiming to reverse-engineer? Applications written in C/C++? Java/.NET? Aged firmware (8/16 bit asm)? ARM code?

I have some experience with the C/C++ part, so I'll try to answer that. Though this is more of a "what to learn in what order" post than a "how to learn it" one. Sorry, I'm mostly self-taught so can't really recommend exhaustive resources.

0: Intel's manuals are great, but mind that they're a reference, not beginner's books. Also, Intel used to give away dead tree versions of their manuals for free, unfortunately I don't think they do that anymore.

1: I don't think you need to learn all the ins and outs of assembly at first - knowing the basic flow control and math/logic operations will be enough. Don't worry about interrupts, descriptor tables, and other magic yet.

2: Once you learn the basics, practice: try to write simple programs in C and step through them in an IDE while looking at the disassembly view. Add inline assembly and practice writing it too.

3: After that, you'll probably need to learn how C++ constructs get translated to assembly code, which is a really large topic. Stanley Lippman's "C++ Object Model" covers quite a lot of it by showing how C++ gets transformed into C-like code, which you should already be familiar with. Mind that each compiler does some things differently than the others, so you should look at at least G++ and MSVC++.

When you get here, it's a good idea to browse around blogs like http://www.nynaeve.net/ and http://www.pagetable.com/ .

4: OS specifics and abstractions. Learn what the OS won't let you do in user mode, why, and so on.

5: Code injection. If you want to add/change code in an existing program, you'll either need to patch its binaries or use an existing code injection program to do it automatically. The second approach is nicer when your changes need to be propagated to other installations of that program, and they don't require modifications to the actual program, which can be nice when it does checksumming/updates itself. Several "gray" methods exist to do this, something like [1] might be a good start.

Tools: Aside from a C/C++ toolchain (no assembler as such - I don't think raw assembly programs are a good idea, and prefer pieces of inline assembly in a C++ program, YMMV), you'll definitely need a disassembler and a debugger. Personally, I love IDA Pro (it does both) with its graphing features and extendability. Their decompiler is a fabulous piece of work too, even though it's not perfect.

(In fact, my friends and I are currently reverse-engineering a certain game and fixing/extending it. This is a really fun and enlightening hobby - we need to work out what the functions/objects do, map out their signatures in C++ , fix any inconsistencies with inline ASM, resulting in interesting macro collections like [2], and then write code using them without breaking stuff. Fun, for certain #define of fun.)

[1]http://www.memoryhacking.com/Misc/Tut/Injection%20Manager.ht... [2]http://svn.renegadeprojects.com/filedetails.php?repname=YR%2...

comment 16y ago · link · parent

Conditional initialization? Suppose I have several objects of the same type and need to do manipulations on one of them, which one depends on something:

  Foo * pFoo = NULL;
  if(x) {
   // stuff
   pFoo = Foo::p1;
  } else {
   // stuff
   pFoo = Foo::p2;
  }
  if(pFoo) {
   pFoo->bar();
  }
I can't declare pFoo inside if(x) due to scoping, so I have to declare it before initializing it meaningfully. It has to be either a pointer to the object (references don't work without initialization) or an object copy, which would not modify the original object...

comment 16y ago · link · parent

Been there, seen that, all I got was this lousy t-shirt.

From the system I maintain:

  /*
 e - ExternalStatus
 i - InternalStatus

          e\i  |   D    F     N   X
          --------------------------
          D    |   A    B     C   D
          F    |   E    F     G   H 
          N    |   I    J     K   L
          X    |   M    N     O   P 
*/

  switch( $inst->Status ) {
   case 'A' : 	case 'D' : case 'M' :
    $stats['d']++; break;
   case 'E' : case 'F' : case 'G' : case 'H' :
   case 'B' : case 'J' : case 'N' :
    $stats['f']++; $stats['d']++; break;
   default : $stats['n']++;
  }

comment 16y ago · link · parent

He didn't get the "famous hacker" label for this incident. See http://en.wikipedia.org/wiki/Adrian_Lamo

comment 16y ago · link · parent

Late Syd Barrett of Pink Floyd was into LSD when his career went off the tracks. Such a shame, he was amazingly good.

Another British band, Porcupine Tree, explored LSD in their early works, from "Lynton Samuel Dawson" to the amazing "Voyage 34", which includes the following remark:

  *They're not drug addicts
  Wandering around, not knowing where they are
  They're your most creative, most courageous
  And like it or not, they're going to build you
  A new civilization...*

comment 16y ago · link · parent

Lambdas are also supported in MSVC++ 2010.

comment 16y ago · link · parent

PHP hosting is easier to find. Competent and secure PHP hosting is hard to find. Most PHP hosts run with all the compatibility options on to support their existing customers who were too cheap to get their sites done right. PHP is easier to start with, but more complex to grow in the right direction. PHP is ridiculously inconsistent and frustrating ([1]). If you get stuck, PHP coding help is easier to find... but it's useless 95% of the time as people give the same old wrong answers. Lower barrier to entry - more clueless "coders" on the forums sharing their (lack of) knowledge. Following from last point, "coders" like that mean you can get more consulting gigs fixing their crap.

Personally, I stick to PHP for new projects because it's what I know - trying RoR out would have to be a spare-time endeavor, and I already have tons of stuff I like to do in my spare time. If I had no prior experience, I'd probably pick RoR though.

[1] ignoring the old tired rant about function naming: object->badproperty just causes a notice and carries on, object->badfunction() crashes with a fatal error, null->property, null[property] and 1 + undefined are also just notices... basically you want an error handler that turns anything into a fatal error, but then you can't co-op with any older code as even older "frameworks" such as Joomla are full of that crap.

comment 16y ago · link · parent

> had Russia fallen to Germany

How do you define "fallen"? I'm pretty sure Germany didn't have enough forces to destroy all the Russian production centers in, and to the east of, Ural.

comment 16y ago · link · parent

Author, please check your site for hacks. ESET Security detects malware and blocks connection, and bogus JS is returned after the </html> tag.

Edit: it's loading scripts and iframes from harpear.ru, which is on a lot of known malware domain blacklists.

comment 16y ago · link · parent

In certain cases, this level of optimization makes perfect sense. In other cases, arguably more common when writing C++, it makes more sense to invest that time in understanding the object model, i.e. what actually happens when you pass a struct by value, return an object (NRV), where invisible object copying occurs (STL, I'm looking at you) or similar issues. Lippman's "C++ Object Model" is a good reference for that.

comment 16y ago · link · parent

Something I came up with when deploying updates to hosts that don't support git, for example, a windows server we have RDC into:

  alias gdate=date\ +%Y.%m.%d-%H.%M.%S
  gitzip () { zip -ruv "$(gdate).zip" $(git diff $@ --name-only); }
Produces a zip file of all files that changed since the commit you pass as the argument. Then I just transfer the resulting zip over, and unzip its contents to the root project folder. Haven't figured out how to deal with deleted files this way yet, fortunately that's not common.

--

And a pre-commit hook for linting PHP source code when I'm not in an IDE. Yes, this came around because of a few commits made without testing.

  #!/bin/sh
  exitStatus=0
  for i in $(git diff --name-only --staged HEAD); do
          [ "$VERBOSE" != "" ] && echo "Validating file $i"
          echo "$i"| grep -q '.php$'
          if [ $? -eq 0 ]; then
                  [ "$VERBOSE" != "" ] && echo "... seems to be PHP, running php lint"
                  php -n -l "$i"| grep -q 'Errors parsing'
                  valid=$?
                  if [ $valid -eq 0 ]; then
                          echo "File $i is invalid."
                          exitStatus=1
                  fi
          fi
  done
  exit $exitStatus

comment 16y ago · link · parent

Most of my weekend is spent playing, usually evenings too. But only part of that is playing for playing's sake. The major part is actually playtesting of my hobby project - patching new functionality into a certain game with asm/c++ (some more details in my profile). Wonder if that skillset is employable?

Productivity, yes, GTA VC/Urban Chaos/UT2k3 helps me unwind after work and in turn makes me more productive the next day. A few times I even solved some work problem that was bothering me, while ingame.

Oddly, I noticed that I fare better in GTA VC racing courses when I'm paying absolutely minimal attention to the actual game and focus on the music or some thinking problem instead.

comment 16y ago · link · parent

Aw, no assembler highlight. Even nano can do that...
1
1213141516