diff options
author | Aleksey Veresov <aleksey@veresov.pro> | 2020-10-17 17:36:16 +0300 |
---|---|---|
committer | Aleksey Veresov <aleksey@veresov.pro> | 2020-10-17 17:36:16 +0300 |
commit | a5a57f9386ce54d37c3b7de31db669b0f5236bf0 (patch) | |
tree | bc6adbd6a4e0f3eb8ad01ffb6cfed382dedea407 /main.sts | |
parent | 53ccfab6c1f2ddad977ceedbdbbfa54a05b81070 (diff) | |
download | cryptrobber-a5a57f9386ce54d37c3b7de31db669b0f5236bf0.tar cryptrobber-a5a57f9386ce54d37c3b7de31db669b0f5236bf0.tar.xz cryptrobber-a5a57f9386ce54d37c3b7de31db669b0f5236bf0.zip |
.
Diffstat (limited to 'main.sts')
-rw-r--r-- | main.sts | 45 |
1 files changed, 26 insertions, 19 deletions
@@ -1,30 +1,37 @@ module ia32/elf/begin.sts module cipher.sts -defarr bigbad 64000 ; max size of input is 64 000 chars -defarr bigbadres 64000 ; max size of output is 64 000 chars -defarr passwd 3 - set_entry - 31 passwd ! - 32 passwd 1 + ! - 33 passwd 2 + ! + ; read file into stack + 0 do sys_read 0 = until + swap 1 + + od as length + local ciphertext - 0 local bigbadlen - do sys_read 0 = until - over bigbad + ! - 1 + - od + ; -= MAIN LOOP BEGIN =- ; + ; place password ontop of stack + 33 32 31 local password + 3 as passlen - 0 local cipherpos - 0 do dup bigbadlen @ = until - dup bigbad + @ passwd 3 cipherpos cipher - over bigbadres + ! + ; decipher text (length is the same as for ciphertext) + 0 0 do dup length = until + as pos local cipos + pos ciphertext + @ + password + passlen + cipos + cipher + swap pos 1 + od drop drop + local plaintext - 0 do dup bigbadlen @ = until - dup bigbadres + @ sys_write - 1 + od drop drop + ; todo: check deciphering attempt, exit if Ok + ; -= MAIN LOOP END =- ; + + ; output text (todo: and language) + 0 do dup length = until + dup plaintext + @ sys_write + 1 + od sys_exit module ia32/elf/end.sts |