in reply to Obfu spoiler: vladb's sig (was Re: Deobfuscation for fun and profit)
in thread Deobfuscation for fun and profit
Line 9 prints $\, which, umm, defaults to nothing; here it looks like it's being treated as a newline, though, doesn't it? I've gotta admit: I'm not sure where $\ gets set to \n...
It looks like it's being treated as a newline... but $\ isn't being set to \n in this code. So when we execute this code it prints out the empty string. Perhaps vladb has typoed this, because the resulting print out is a little confusing without the newlines.
You'd notice the uninitialised values if you ran the code with warnings turned on:[me]$ ls -a .sav* .saves-19639-~ .saves-19896-~ .saves-19896333-~ .saves-22-~ [me]$ perl tmp + ./.saves-22-~- ./.saves-19896333-~+ ./.saves-19639-~- ./.saves-19896 +-~[me]$
If, of course, you can see them through the other mess of warnings. Why are we getting these hash assignment warnings? Well, we can isolate the code that's causing them, it's the ternary operator:[me]$ perl -w tmp Useless use of single ref constructor in void context at tmp line 2. Odd number of elements in hash assignment at tmp line 2. Use of uninitialized value in print at tmp line 3. + ./.saves-22-~Odd number of elements in hash assignment at tmp line 2 +. - ./.saves-19896-~Use of uninitialized value in print at tmp line 3. Odd number of elements in hash assignment at tmp line 2. Use of uninitialized value in print at tmp line 3. + ./.saves-19639-~Odd number of elements in hash assignment at tmp lin +e 2. - ./.saves-19896333-~Use of uninitialized value in print at tmp line 3 +.
Perhaps Perl doesn't like blocks here? Or doesn't in my version of Perl (v5.6.1 built for i386-linux). We can't just remove them though, because if we do then we won't print out the file names that we delete.`@$_`?{print"+ $1"}:{print"- $1"}&&`rm $1`;
I can't explain the error messages but I can give an alternate line that doesn't create them:
although of course your replacement is much neater. When we run our changed versions with warnings we get a slightly cleaner result:`@$_`?print"+ $1":print("- $1")&&`rm $1`;
And then any of the following lines can remove the remaining warning:[me]$ perl -w tmp Use of uninitialized value in print at tmp line 3. + ./.saves-22-~- ./.saves-19896333-~Use of uninitialized value in prin +t at tmp line 3. + ./.saves-19639-~- ./.saves-19896-~Use of uninitialized value in prin +t at tmp line 3.
of course we could put the line $\=$/; somewhere before the for loop and then not even need this print$\; line at all.print$\; # cause of last warning #replacements print$/; print"\n"; print qq'\n'; #etc.
With it all cleaned up it works quite nicely
Anyway, thanks for a great obfu spoiler, it's fun.[me]$ perl tmp + ./.saves-22-~ - ./.saves-19896333-~ + ./.saves-19639-~ - ./.saves-19896-~ [@me]$
jarich
In Section
Meditations