diff options
author | exegete <nikitf-97@mail.ru> | 2020-10-17 21:07:31 +0300 |
---|---|---|
committer | exegete <nikitf-97@mail.ru> | 2020-10-17 21:07:31 +0300 |
commit | 59b7d405aeeb0ac8fea048d5d336bae62932f0c6 (patch) | |
tree | 52365832103ba901f27fb40ecd440a0ea609ec2b | |
parent | be953c23a9ee9c328d186e0afd7fbc0855eefd3a (diff) | |
parent | bb541944e4249cc30612056b64f15e593e58966c (diff) | |
download | cryptrobber-59b7d405aeeb0ac8fea048d5d336bae62932f0c6.tar cryptrobber-59b7d405aeeb0ac8fea048d5d336bae62932f0c6.tar.xz cryptrobber-59b7d405aeeb0ac8fea048d5d336bae62932f0c6.zip |
Merge remote-tracking branch 'aversey/master' into master
-rw-r--r-- | encrypt.sts | 19 | ||||
-rw-r--r-- | main.sts | 51 |
2 files changed, 38 insertions, 32 deletions
diff --git a/encrypt.sts b/encrypt.sts index a472e57..7762b3a 100644 --- a/encrypt.sts +++ b/encrypt.sts @@ -1,20 +1,13 @@ module ia32/elf/begin.sts module cipher.sts -defarr passwd 3 - -defword encrypt - top as pos - do sys_read 0 = until - passwd 3 pos cipher sys_write - od drop -exit - set_entry - 31 passwd ! - 32 passwd 1 + ! - 33 passwd 2 + ! - 0 encrypt drop + 31 32 33 local password + 3 as passlen + passlen 1 - local pos + do sys_read 0 = until + password passlen pos cipher sys_write + od sys_exit module ia32/elf/end.sts @@ -1,6 +1,14 @@ module ia32/elf/begin.sts module cipher.sts +defword checktext + 1 +exit + +defword keygen + drop 31 32 33 3 +exit + set_entry ; read file into stack 0 do sys_read 0 = until @@ -8,25 +16,30 @@ set_entry od drop as length local ciphertext - ; -= MAIN LOOP BEGIN =- ; - ; place password ontop of stack - 31 32 33 local password - 3 as passlen - - ; decipher text (length is the same as for ciphertext) - passlen 1 - length do 1 - - as pos local cipos - pos word_size mul ciphertext + @ - password - passlen - cipos - cipher - swap pos - dup 0 = untilod drop drop - local plaintext - - ; todo: check deciphering attempt, exit if Ok - ; -= MAIN LOOP END =- ; + 0 ; initial key is empty + do + ; generate next key to try + keygen as keylen local key + + ; decipher text (length is the same as for ciphertext) + keylen 1 - length do 1 - + as textpos local pos + textpos word_size mul ciphertext + @ + key + keylen + pos + cipher + swap textpos + dup 0 = untilod drop drop + local plaintext + + ; check deciphering attempt, exit if Ok + length checktext until + ; else remove the text from stack and place keylen back + 0 do dup length = until + swap drop 1 + + od drop keylen + od ; output text (todo: and language) length do 1 - |