aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2020-10-17 20:13:56 +0300
committerAleksey Veresov <aleksey@veresov.pro>2020-10-17 20:13:56 +0300
commitbb541944e4249cc30612056b64f15e593e58966c (patch)
tree729fd2ecd24d8b5d192decf54cf5383c5de4b888
parent7a8caa04bfdb807808636d094391c60fdef9dbbc (diff)
downloadcryptrobber-bb541944e4249cc30612056b64f15e593e58966c.tar
cryptrobber-bb541944e4249cc30612056b64f15e593e58966c.tar.xz
cryptrobber-bb541944e4249cc30612056b64f15e593e58966c.zip
.
-rw-r--r--main.sts51
1 files changed, 32 insertions, 19 deletions
diff --git a/main.sts b/main.sts
index 8613909..906cbbb 100644
--- a/main.sts
+++ b/main.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 -