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 | |
parent | 53ccfab6c1f2ddad977ceedbdbbfa54a05b81070 (diff) | |
download | cryptrobber-a5a57f9386ce54d37c3b7de31db669b0f5236bf0.tar cryptrobber-a5a57f9386ce54d37c3b7de31db669b0f5236bf0.tar.xz cryptrobber-a5a57f9386ce54d37c3b7de31db669b0f5236bf0.zip |
.
-rw-r--r-- | cipher.sts | 14 | ||||
-rw-r--r-- | common/const.sts | 2 | ||||
-rw-r--r-- | common/macro.sts | 4 | ||||
-rw-r--r-- | main.sts | 45 |
4 files changed, 36 insertions, 29 deletions
@@ -1,10 +1,10 @@ defword cipher - 3 ref as byte - 2 get as password - 1 get as plen - 0 get as pos - pos @ password + @ byte @ xor byte ! - pos @ 1 + pos ! - pos @ plen = if 0 pos ! fi + 3 ref as cipher.byte + 2 get as cipher.password + 1 get as cipher.len + 0 get as cipher.pos + cipher.pos @ cipher.password + @ cipher.byte @ xor cipher.byte ! + cipher.pos @ 1 + cipher.pos ! + cipher.pos @ cipher.len = if 0 cipher.pos ! fi drop drop drop exit diff --git a/common/const.sts b/common/const.sts index 7b20b4d..46b98e3 100644 --- a/common/const.sts +++ b/common/const.sts @@ -3,7 +3,7 @@ defconst '!' 21 defconst '"' 22 defconst '#' 23 defconst '$' 24 -; '%' (25) symbol is reserved by smack +defconst percent 25 ; '%' (25) symbol is reserved by smack defconst '&' 26 defconst ''' 27 defconst '(' 28 diff --git a/common/macro.sts b/common/macro.sts index f8620d5..162bf2f 100644 --- a/common/macro.sts +++ b/common/macro.sts @@ -3,7 +3,7 @@ ] [ change 0 - dup get - swap 2 get swap 2 + set + 1 + dup get + swap 2 get swap set swap drop ] @@ -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 |