📄 arcfour.asm
字号:
; Copyright (c) 2003 Samuel "Wolf on Air" Ljungkvist
;
; Redistribution and use of this software, in source code and binary forms,
; for any legal use, modified or unmodified, is permitted, provided that
; the following conditions are met:
;
; 1: Redistributions of SOURCE CODE must retain the above copyright notice,
; these conditions, and the following disclaimer.
;
; 2: Redistributions in BINARY FORM must reproduce the above copyright notice,
; these conditions, and the following disclaimer, in the documentation
; and/or other materials provided with the distribution.
;
; Disclaimer:
; This software is provided by the author "as is", and any express or implied
; warranties, including - but not limited to - the implied warranties of
; merchantability and fitness for a particular purpose, are DISCLAIMED.
;
; In no event shall the authors or contributors be liable for any direct,
; indirect, incidental, special, exemplary, or consequential damages
; (including, but not limited to, procurement of substitute goods or services;
; loss of use, data, or profits; or business interruption) however caused,
; and on any theory of liability, whether in contract, stict liability,
; or tort (including neglience or otherwise) arising in any way out of
; the use of this software, even if adviced of the possibility of such damage.
.equ code, 0x2000
.equ pm2_phex, 0x0034
.equ pm2_esc, 0x003E
.org code
.db 165, 229, 224, 165
.db 35, 255, 0, 0
.db 0, 0, 0, 0
.db 0, 0, 0, 0
.db 0, 0, 0, 0
.db 0, 0, 0, 0
.db 0, 0, 0, 0
.db 255, 255, 255, 255
.db "ArcFour",0
.org code+60
ajmp arcfour_set_key
ajmp arcfour
;-----
mov dptr, #code+0x100
acall arcfour_set_key
loop:
clr a
acall arcfour
lcall pm2_phex
lcall pm2_esc
jnc loop
ret
;-----
arcfour_set_key:
push acc
mov dpl, #0
inc dph
arcfour_reset_sbox_loop:
mov a, dpl
movx @dptr, a
inc dpl
clr a
cjne a, dpl, arcfour_reset_sbox_loop
dec dph
mov r6, #0
arcfour_rand_sbox_loop:
movx a, @dptr
add a, r6
mov r6, a
inc dph
movx a, @dptr
mov r7, a
add a, r6
mov r6, a
push dpl
mov dpl, r6
movx a, @dptr
xch a, r7
movx @dptr, a
pop dpl
mov a, r7
movx @dptr, a
dec dph
inc dpl
clr a
cjne a, dpl, arcfour_rand_sbox_loop
mov r6, #0
mov r7, #0
pop acc
ret
;-----
arcfour:
push b
push acc
inc dph
inc r6
mov dpl, r6
movx a, @dptr
mov b, a
add a, r7
mov r7, a
mov dpl, r7
movx a, @dptr
xch a, b
movx @dptr, a
mov dpl, r6
xch a, b
movx @dptr, a
add a, b
mov dpl, a
movx a, @dptr
pop b
xrl a, b
dec dph
pop b
ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -