diff options
author | Aleksey Veresov <aleksey@veresov.pro> | 2020-10-16 22:38:45 +0300 |
---|---|---|
committer | Aleksey Veresov <aleksey@veresov.pro> | 2020-10-16 22:38:45 +0300 |
commit | a5ada20d77f6fcf7bf54e49402e55d3b1c56df5e (patch) | |
tree | b6f9a205a4da8c00c58b5da66c74b99874f4f620 | |
parent | ce9e52469d0b12b3231ccc199e1b19bb924f54cd (diff) | |
download | cryptrobber-a5ada20d77f6fcf7bf54e49402e55d3b1c56df5e.tar cryptrobber-a5ada20d77f6fcf7bf54e49402e55d3b1c56df5e.tar.xz cryptrobber-a5ada20d77f6fcf7bf54e49402e55d3b1c56df5e.zip |
Meh.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | cipher.sts | 24 | ||||
-rw-r--r-- | encrypt.sts | 21 | ||||
-rw-r--r-- | ia32/macro.sts | 20 | ||||
-rw-r--r-- | ia32/math.sts | 16 | ||||
-rw-r--r-- | main.sts | 27 |
6 files changed, 68 insertions, 42 deletions
@@ -20,4 +20,4 @@ strans: strans.c gcc $< -o $@ clean: - rm -f smack strans cryptrobber encrypt + rm -f smack strans cryptrobber encrypt test @@ -1,18 +1,10 @@ -; cipher is password string (pointer to start and length) and position in it - -defword ciphernew - 0 -exit - -defword mod - swap / drop -exit - -defword cipher ; ... passwd plen ppos key - 3 get 2 get + @ xor ; key = key ^ passwd[ppos] - over 1 + 3 get mod 2 set ; ppos = (ppos + 1) % plen -exit - -defword cipherdel +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 drop drop drop exit diff --git a/encrypt.sts b/encrypt.sts index 29424a2..a472e57 100644 --- a/encrypt.sts +++ b/encrypt.sts @@ -1,29 +1,20 @@ module ia32/elf/begin.sts module cipher.sts -defword encbyte - sys_read dup if - drop - cipher sys_write - 1 1 - fi 0 = if - drop 0 - fi -exit +defarr passwd 3 defword encrypt - encbyte if encrypt fi + top as pos + do sys_read 0 = until + passwd 3 pos cipher sys_write + od drop exit -defarr passwd 3 - set_entry 31 passwd ! 32 passwd 1 + ! 33 passwd 2 + ! - passwd 3 ciphernew - encrypt - cipherdel + 0 encrypt drop sys_exit module ia32/elf/end.sts diff --git a/ia32/macro.sts b/ia32/macro.sts index 5aa3b35..34c3a9d 100644 --- a/ia32/macro.sts +++ b/ia32/macro.sts @@ -40,13 +40,21 @@ [ as 1 _data_segment ?choose - defword %1% - lit ?$ # 0 ?. - exit + defword %1% + lit ?$ # 0 ?. + exit _code_segment ?choose lit ?. ! ] +[ local 1 + top as %1% +] + +[ ref 0 + top + 1 + +] + [ literal 0 lit # %1% ?. ] @@ -84,3 +92,9 @@ branch ?swap ?. ?$ ?swap ?! ] + +[ change 0 + dup get + swap 2 get swap 2 + set + swap drop +] diff --git a/ia32/math.sts b/ia32/math.sts index 1864a93..95ca5f7 100644 --- a/ia32/math.sts +++ b/ia32/math.sts @@ -17,6 +17,22 @@ defasm / # 50 ?' ; push eax next +defasm mod + # 5b ?' ; pop ebx + # 58 ?' ; pop eax + # 31 ?' # d2 ?' ; xor edx, edx + # f7 ?' # f3 ?' ; div ebx + # 52 ?' ; push edx +next + +defasm div + # 5b ?' ; pop ebx + # 58 ?' ; pop eax + # 31 ?' # d2 ?' ; xor edx, edx + # f7 ?' # f3 ?' ; div ebx + # 50 ?' ; push eax +next + defasm = # 5b ?' ; pop ebx # 58 ?' ; pop eax @@ -1,17 +1,30 @@ module ia32/elf/begin.sts +module cipher.sts -defarr bigbad 65536 ; max size of input is 64KB +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 ; reversed echo - 0 ; bigbad index +set_entry + 31 passwd ! + 32 passwd 1 + ! + 33 passwd 2 + ! + + 0 local bigbadlen do sys_read 0 = until over bigbad + ! 1 + - od ; bigbad length will be on top of stack + od + + 0 local cipherpos + 0 do dup bigbadlen @ = until + dup bigbad + @ passwd 3 cipherpos cipher + over bigbadres + ! + 1 + od drop drop - do - 1 - dup bigbad + @ sys_write - dup 0 = untilod drop + 0 do dup bigbadlen @ = until + dup bigbadres + @ sys_write + 1 + od drop drop sys_exit module ia32/elf/end.sts |