Created
February 10, 2009 00:58
-
-
Save nikolasco/61132 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; pertinent MASM disassembly excerpt | |
loc_417925: ; CODE XREF: sub_417900:loc_417A5Dj | |
cmp [ebp+var_18], 1 | |
jnz loc_417A62 | |
push offset aPleaseEnterAPa ; "Please Enter a password " | |
call sub_4114AB | |
add esp, 4 | |
push offset off_428B40 | |
push 7 | |
lea eax, [ebp+var_C] | |
push eax | |
call sub_41104B | |
add esp, 0Ch | |
movsx eax, byte ptr [ebp+var_C] | |
add eax, 79h | |
cdq | |
sub eax, edx | |
sar eax, 1 | |
mov byte ptr [ebp+var_C], al | |
movsx eax, byte ptr [ebp+var_C+1] | |
movsx ecx, byte ptr [ebp+var_C] | |
add eax, ecx | |
shl eax, 1 | |
cdq | |
mov ecx, 3 | |
idiv ecx | |
sub eax, 1Eh | |
mov byte ptr [ebp+var_C+1], al | |
mov byte ptr [ebp+var_C+2], 65h | |
movsx eax, byte ptr [ebp+var_C+3] | |
movsx ecx, byte ptr [ebp+var_C+1] | |
lea eax, [eax+ecx+1] | |
cdq | |
sub eax, edx | |
sar eax, 1 | |
mov byte ptr [ebp+var_C+3], al | |
movsx eax, [ebp+var_8] | |
movsx ecx, byte ptr [ebp+var_C+3] | |
add eax, ecx | |
movsx edx, byte ptr [ebp+var_C] | |
lea eax, [eax+edx+2] | |
cdq | |
mov ecx, 3 | |
idiv ecx | |
mov [ebp+var_8], al | |
movsx eax, [ebp+var_7] | |
movsx ecx, [ebp+var_8] | |
add eax, ecx | |
cdq | |
sub eax, edx | |
sar eax, 1 | |
mov [ebp+var_7], al | |
movsx eax, byte ptr [ebp+var_C] | |
cmp eax, 76h | |
jnz short loc_417A0B | |
movsx eax, byte ptr [ebp+var_C+1] | |
cmp eax, 74h | |
jnz short loc_417A0B | |
movsx eax, byte ptr [ebp+var_C+2] | |
cmp eax, 65h | |
jnz short loc_417A0B | |
movsx eax, byte ptr [ebp+var_C+3] | |
cmp eax, 73h | |
jnz short loc_417A0B | |
movsx eax, [ebp+var_8] | |
cmp eax, 70h | |
jnz short loc_417A0B | |
movsx eax, [ebp+var_7] | |
cmp eax, 72h | |
jnz short loc_417A0B | |
push offset aGoodJob ; "good job" | |
call sub_4114AB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# reimplementation in Ruby | |
s = ARGV[0].dup | |
s[0] = ((s[0] + 0x79) >> 1) | |
s[1] = (((s[1] + s[0]) << 1)/3)-0x1e | |
s[2] = 0x65 | |
s[3] = (s[3] + s[1] + 1) >> 1 | |
s[4] = ((s[4] + s[3] + s[0] + 2)/3) | |
s[5] = (s[4] + s[5]) >> 1 | |
puts s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# generate the lexigraphically first solution (aprox.) | |
t = "vtespr" | |
s = "a"*6 | |
s[0] = (t[0] << 1) - 0x79 | |
s[1] = (((t[1] + 0x1e)*3)>>1)-t[0] | |
s[2] = 0x65 | |
s[3] = ((t[3] << 1) - 1 - t[1]) | |
s[4] = t[4]*3 - 2 - t[3] - t[0] | |
s[5] = (t[5] << 1) - t[4] | |
puts s | |
# n.b. not originally stated, but they wanted an English word as a solution |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment