SSpoke
SSpoke

Reputation: 5836

Double check Inclusive OR Statements

Well I just made a question asking how to simply ~(i + -1) < -1 which turned out to be i > 1

Making a JAVA deobfuscator and here is what I have so far.. I just want people to tell me which ones I did wrong? if any just double checking.

~i > -1 is i < 0

~i < -1 is i > 0

~i > ~classA.var is i < classA.var

~i >= ~j is i <= j

~i <= ~b is i >= b

~i == -1 is i == 0

~classA.var < -1 is classA.var > 0

~classA.var > -1 is classA.var < 0

~classA.var == ~classB.var is classA.var == classB.var

~(-1 + i) < -1 is i > 1

~(i + -1) < -1 is i > 1

~(i & 0x22) != -1 is (i & 0x22) == 0 <- seems wrong..

Seems the correct answer by Eng.Fouad is

~(i & 0x22) != -1 is (i & 0x22) != 0 <- correct so far.

These are all the patterns my deobfuscator supports so far.. probably will find a bunch more.

(Any wrong ones?) I Fear the ones with == signs may be wrong.. i've tested them and they seem to work..

Thanks I appreciate the support, i'm a beginner to programming only programmed half a year and math isn't my strong point.

Upvotes: 2

Views: 309

Answers (1)

Eng.Fouad
Eng.Fouad

Reputation: 117589

Just replace each ~x with -x - 1:

  • ~i > -1 ==> -i - 1 > -1 ==> -i > 0 ==> i < 0
  • ~i < -1 ==> -i - 1 < -1 ==> -i < 0 ==> i > 0

and so on.

Upvotes: 1

Related Questions