aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2020-10-17 17:36:16 +0300
committerAleksey Veresov <aleksey@veresov.pro>2020-10-17 17:36:16 +0300
commita5a57f9386ce54d37c3b7de31db669b0f5236bf0 (patch)
treebc6adbd6a4e0f3eb8ad01ffb6cfed382dedea407
parent53ccfab6c1f2ddad977ceedbdbbfa54a05b81070 (diff)
downloadcryptrobber-a5a57f9386ce54d37c3b7de31db669b0f5236bf0.tar
cryptrobber-a5a57f9386ce54d37c3b7de31db669b0f5236bf0.tar.xz
cryptrobber-a5a57f9386ce54d37c3b7de31db669b0f5236bf0.zip
.
-rw-r--r--cipher.sts14
-rw-r--r--common/const.sts2
-rw-r--r--common/macro.sts4
-rw-r--r--main.sts45
4 files changed, 36 insertions, 29 deletions
diff --git a/cipher.sts b/cipher.sts
index d351397..cdcdc30 100644
--- a/cipher.sts
+++ b/cipher.sts
@@ -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
]
diff --git a/main.sts b/main.sts
index 93a9ed4..c99568c 100644
--- a/main.sts
+++ b/main.sts
@@ -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