forked from Stalin-143/Ai-Basic-programes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDecision-Making-Algorithm.asm
More file actions
130 lines (111 loc) · 2.8 KB
/
Decision-Making-Algorithm.asm
File metadata and controls
130 lines (111 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
section .data
prompt db "Enter your password: ", 0
weak_msg db "Weak password", 0
strong_msg db "Strong password", 0
buffer db 32
length equ $ - buffer
section .bss
password resb 32
section .text
global _start
_start:
; Prompt user for password
mov eax, 4 ; syscall: sys_write
mov ebx, 1 ; file descriptor: stdout
mov ecx, prompt ; message
mov edx, length ; message length
int 0x80 ; syscall interrupt
; Read input password
mov eax, 3 ; syscall: sys_read
mov ebx, 0 ; file descriptor: stdin
mov ecx, password ; buffer
mov edx, 32 ; buffer size
int 0x80 ; syscall interrupt
; Initialize counters
xor ebx, ebx ; has_upper
xor ecx, ecx ; has_lower
xor edx, edx ; has_digit
xor esi, esi ; has_special
xor edi, edi ; length
mov esi, password ; point to password buffer
check_char:
mov al, [esi] ; load character
cmp al, 0 ; end of string?
je evaluate ; if yes, jump to evaluation
inc edi ; increase length counter
; Check uppercase
cmp al, 'A'
jl check_lower
cmp al, 'Z'
jg check_lower
mov bl, 1 ; set has_upper = 1
jmp next_char
check_lower:
cmp al, 'a'
jl check_digit
cmp al, 'z'
jg check_digit
mov cl, 1 ; set has_lower = 1
jmp next_char
check_digit:
cmp al, '0'
jl check_special
cmp al, '9'
jg check_special
mov dl, 1 ; set has_digit = 1
jmp next_char
check_special:
; Check if character is a special symbol
cmp al, '!'
je set_special
cmp al, '@'
je set_special
cmp al, '#'
je set_special
cmp al, '$'
je set_special
cmp al, '%'
je set_special
cmp al, '^'
je set_special
cmp al, '&'
je set_special
cmp al, '*'
je set_special
jmp next_char
set_special:
mov esi, 1 ; set has_special = 1
next_char:
inc esi ; next character
jmp check_char
evaluate:
cmp edi, 8 ; length >= 8?
jl weak_password
; Check if all flags are set
test bl, bl ; has_upper?
jz weak_password
test cl, cl ; has_lower?
jz weak_password
test dl, dl ; has_digit?
jz weak_password
test esi, esi ; has_special?
jz weak_password
strong_password:
; Print "Strong password"
mov eax, 4
mov ebx, 1
mov ecx, strong_msg
mov edx, 14
int 0x80
jmp exit
weak_password:
; Print "Weak password"
mov eax, 4
mov ebx, 1
mov ecx, weak_msg
mov edx, 12
int 0x80
exit:
mov eax, 1 ; syscall: sys_exit
xor ebx, ebx ; exit code 0
int 0x80 ; syscall interrupt