Reversing algebraic equation with bitwise-XOR
up vote
2
down vote
favorite
I'm trying to reverse an encryption scheme, but I seem to have fallen into a pit when it comes to reversal using algebra.
The encryption scheme is as follows for a single char (using registers and constants):
encrypted_char= (original_char XOR dl) + al
where:
eax = eax.previous * c1 +c2
edx = (eax >> c3)
eax.0 is a known seeded constant.
I want to solve this equation algebraically for original_char, but I'm running into a few problems, namely with order of operations for getting original char on it's own. Thinking about wraparound for negative numbers is also giving me a headache.
If anyone had any pointers for how to solve for the original_char, it would be appreciated. My first thoughts are to just subtract al and then xor with dl, but I'm starting to feel confused at this point.
assembly encryption reverse-engineering
add a comment |
up vote
2
down vote
favorite
I'm trying to reverse an encryption scheme, but I seem to have fallen into a pit when it comes to reversal using algebra.
The encryption scheme is as follows for a single char (using registers and constants):
encrypted_char= (original_char XOR dl) + al
where:
eax = eax.previous * c1 +c2
edx = (eax >> c3)
eax.0 is a known seeded constant.
I want to solve this equation algebraically for original_char, but I'm running into a few problems, namely with order of operations for getting original char on it's own. Thinking about wraparound for negative numbers is also giving me a headache.
If anyone had any pointers for how to solve for the original_char, it would be appreciated. My first thoughts are to just subtract al and then xor with dl, but I'm starting to feel confused at this point.
assembly encryption reverse-engineering
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I'm trying to reverse an encryption scheme, but I seem to have fallen into a pit when it comes to reversal using algebra.
The encryption scheme is as follows for a single char (using registers and constants):
encrypted_char= (original_char XOR dl) + al
where:
eax = eax.previous * c1 +c2
edx = (eax >> c3)
eax.0 is a known seeded constant.
I want to solve this equation algebraically for original_char, but I'm running into a few problems, namely with order of operations for getting original char on it's own. Thinking about wraparound for negative numbers is also giving me a headache.
If anyone had any pointers for how to solve for the original_char, it would be appreciated. My first thoughts are to just subtract al and then xor with dl, but I'm starting to feel confused at this point.
assembly encryption reverse-engineering
I'm trying to reverse an encryption scheme, but I seem to have fallen into a pit when it comes to reversal using algebra.
The encryption scheme is as follows for a single char (using registers and constants):
encrypted_char= (original_char XOR dl) + al
where:
eax = eax.previous * c1 +c2
edx = (eax >> c3)
eax.0 is a known seeded constant.
I want to solve this equation algebraically for original_char, but I'm running into a few problems, namely with order of operations for getting original char on it's own. Thinking about wraparound for negative numbers is also giving me a headache.
If anyone had any pointers for how to solve for the original_char, it would be appreciated. My first thoughts are to just subtract al and then xor with dl, but I'm starting to feel confused at this point.
assembly encryption reverse-engineering
assembly encryption reverse-engineering
asked Nov 7 at 21:51
comp.sci.intern
356
356
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
I played with a toy example before posting and my answer is as follows:
bitwise xor has the same precedence as multiplication, I just flip it over. I already knew that XOR was the inverse of XOR, but I thought I should state it here.
The resulting formula is as follows:
(encrypted_char - al) XOR dl = al
What goes into the larger registers doesn't need to be toyed with to arrive at the correct solution.
I will solve the wraparound using the modulus operation with the correct size for my variables.
Using the above methods I was able to reverse the code.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
I played with a toy example before posting and my answer is as follows:
bitwise xor has the same precedence as multiplication, I just flip it over. I already knew that XOR was the inverse of XOR, but I thought I should state it here.
The resulting formula is as follows:
(encrypted_char - al) XOR dl = al
What goes into the larger registers doesn't need to be toyed with to arrive at the correct solution.
I will solve the wraparound using the modulus operation with the correct size for my variables.
Using the above methods I was able to reverse the code.
add a comment |
up vote
1
down vote
I played with a toy example before posting and my answer is as follows:
bitwise xor has the same precedence as multiplication, I just flip it over. I already knew that XOR was the inverse of XOR, but I thought I should state it here.
The resulting formula is as follows:
(encrypted_char - al) XOR dl = al
What goes into the larger registers doesn't need to be toyed with to arrive at the correct solution.
I will solve the wraparound using the modulus operation with the correct size for my variables.
Using the above methods I was able to reverse the code.
add a comment |
up vote
1
down vote
up vote
1
down vote
I played with a toy example before posting and my answer is as follows:
bitwise xor has the same precedence as multiplication, I just flip it over. I already knew that XOR was the inverse of XOR, but I thought I should state it here.
The resulting formula is as follows:
(encrypted_char - al) XOR dl = al
What goes into the larger registers doesn't need to be toyed with to arrive at the correct solution.
I will solve the wraparound using the modulus operation with the correct size for my variables.
Using the above methods I was able to reverse the code.
I played with a toy example before posting and my answer is as follows:
bitwise xor has the same precedence as multiplication, I just flip it over. I already knew that XOR was the inverse of XOR, but I thought I should state it here.
The resulting formula is as follows:
(encrypted_char - al) XOR dl = al
What goes into the larger registers doesn't need to be toyed with to arrive at the correct solution.
I will solve the wraparound using the modulus operation with the correct size for my variables.
Using the above methods I was able to reverse the code.
answered Nov 7 at 21:51
comp.sci.intern
356
356
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53198391%2freversing-algebraic-equation-with-bitwise-xor%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown