ASM validate user input

1055a5b2994f67781fa94a24ef91c581
0
fresh 101 Aug 25, 2004 at 11:15

Hey, I’m looking for a simple user input validation script coded in assembly, I am using TASM as a compiler, btw.. all the example needs to do is validate user input against a variable or whatever.. I have very little experience with assembly but I do know how to code in C++ and VB, so that’s a plus.. :)

any help is much appreciated.. thanks ;)

26 Replies

Please log in or register to post a reply.

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Aug 25, 2004 at 12:02

what do you mean by script ???
what do you mean by user input validation ?

1055a5b2994f67781fa94a24ef91c581
0
fresh 101 Aug 25, 2004 at 13:09

ok sorry, I mean example source.. and I am only assuming you can write a COM file via ASM, which can except user input and then validate it.. like a password protection scheme would in any other language.. is that even possible with assembly and if not, what good is ASM?? thanks :)

357c7b2935ccd2cb0913717186684394
0
JSoftware 101 Aug 25, 2004 at 13:15

i didn’t get what you wanted.. i would start out with some easier assembler programs.. i haven’t figured int 16 keyboard input all out yet!

you could load a string to the si register and make a loop og cmp’s and get some validations that way but try to tell a little more detailed what you need!

1055a5b2994f67781fa94a24ef91c581
0
fresh 101 Aug 25, 2004 at 13:23

I know what your saying.. but how to code it is were I am at a loss, what type of example would you say would be a good source to start with? I have already done the Hello World! LOL.. I’m looking to work on something more difficult, but something simple of course.. any suggestions or tutorials I can follow? Thanks and sorry about not fully explaining myself the first time ;)

357c7b2935ccd2cb0913717186684394
0
JSoftware 101 Aug 25, 2004 at 13:42
tmp DB 32 dup('?')
pass DB "Password"
succes DB "Access Granted!",0dh,0ah,"$"

getkeyin:
 MOV   AH,0CH
 MOV   AL,01H
 INT   21H
 CMP AL, 0DH
 JE process
 ADD tmp, AL
 JMP getkeyin
process:
 CMP tmp, pass
 jne exit
 
 mov dx, succes
 mov ah,09h
 int 21h
exit:
 mov ah, 00h
 int 21h

try this.. code made for nasm syntax. maybe you need to add some OFFSET’s some where or something.. i suppose it works B)

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Aug 25, 2004 at 14:25

oooh… now i get what you mean… i was confused by your terminology

1055a5b2994f67781fa94a24ef91c581
0
fresh 101 Aug 25, 2004 at 16:31

thank you very much, even though right now I don’t understand it, I now have a good reference to study from.. so thanks alot.. too bad it isn’t TASM ready.. because I tried to compile it but it said this:

errors:

Illegal memory reference
Operand types do not match
Unexpected end of file encountered

and this is my source:

.MODEL SMALL
.STACK
.CODE

    tmp DB 32 dup('?')
    pass DB "Password"
    succes DB "Access Granted!",0dh,0ah,"$"

getkeyin:
    MOV   AH,0CH
    MOV   AL,01H
    INT   21H
    CMP AL, 0DH
    JE process
    ADD tmp, AL
    JMP getkeyin
process:
    CMP tmp, pass
    jne exit

    mov dx, succes
    mov ah,09h
    int 21h
exit:
    mov ah, 00h
    int 21h

I mean I set that up right? Except for the fact that it isn’t made to compile in TASM.. other than that I set the source up correctly right? BTW.. I know what you mean by OFFSETS, but I haven’t found a understanding of them, any examples?? thanks :)

357c7b2935ccd2cb0913717186684394
0
JSoftware 101 Aug 25, 2004 at 17:21
tmp DB "??????????????????????????????"
pass DB "Password"
succes DB "Access Granted!",0dh,0ah,"$"

getkeyin:
MOV   AH,0CH
MOV   AL,01H
INT   21H
CMP AL, 0DH
JE process
OUT tmp, al
JMP getkeyin
process:
MOV si, tmp
CMP SI, pass
jne exit

mov dx, succes
mov ah,09h
int 21h
exit:
mov ah, 00h
int 21h

try this then

1055a5b2994f67781fa94a24ef91c581
0
fresh 101 Aug 25, 2004 at 17:26

nope, still no good, here is my errors:

Expecting scalar type
Operand types do not match
Operand types do not match
Operand types do not match
Unexpected end of file encountered

and of course the current attempt:

.MODEL SMALL
.STACK
.CODE

tmp DB "??????????????????????????????"
pass DB "Password"
succes DB "Access Granted!",0dh,0ah,"$"

getkeyin:
MOV   AH,0CH
MOV   AL,01H
INT   21H
CMP AL, 0DH
JE process
OUT tmp, al
JMP getkeyin
process:
MOV si, tmp
CMP SI, pass
jne exit

mov dx, succes
mov ah,09h
int 21h
exit:
mov ah, 00h
int 21h

BTW: I am using TASM.. thanks :)

357c7b2935ccd2cb0913717186684394
0
JSoftware 101 Aug 25, 2004 at 18:08

get nasm instead then :P

1055a5b2994f67781fa94a24ef91c581
0
fresh 101 Aug 25, 2004 at 18:18

haha ok.. is it free? and where can I get it… know nay links.. I’ll search google i guess, thanks man :)

alright, found one, how do I compile with it, I mean what is the syntax to compile and link? I am now using NASM.. ;)

2b97deded6213469bcd87b65cce5d014
0
Mihail121 102 Aug 25, 2004 at 19:05

Ok, i’ll said it only one time so be carefull - RTFM. It’s one of the most important programming rules and the abreviature stands for: Read The Fucking Manual.

In your case it means simply that you should simply check the docs that come with NASM. All lies there :)

6ad5f8c742f1e8ec61000e2b0900fc76
0
davepermen 101 Aug 25, 2004 at 19:16

it’s called Read The FRIENDLY Manual, Mihail.. at least….. in public area.. :D

357c7b2935ccd2cb0913717186684394
0
JSoftware 101 Aug 25, 2004 at 19:17

make a simple text document: tmp.txt or tmp.asm

then from dos write:
nasm tmp.txt

and you’ll get a nice file called: “tmp”
rename it to “tmp.com” or “tmp.exe”

viola!

(you could make some tricks so you don’t have to rename but wtf..

1055a5b2994f67781fa94a24ef91c581
0
fresh 101 Aug 26, 2004 at 04:31

well NASM didn’t come with a Fucking or Friendly manual.. LOL.. so I thought I’d ask.. Alright, I’ll try that, and see what happens.. thanks alot guys :)

OK. This code is just not going to work.. lol.. is it missing something?

File Name:dis
error: attempt to define a local label before any non-local labels
error: parser: instruction expected
error: attempt to define a local label before any non-local labels
error: attempt to define a local label before any non-local labels

.MODEL SMALL
.STACK
.CODE

 tmp DB "??????????????????????????????"
pass DB "Password"
succes DB "Access Granted!",0dh,0ah,"$"

getkeyin:
MOV   AH,0CH
MOV   AL,01H
INT   21H
CMP AL, 0DH
JE process
OUT tmp, al
JMP getkeyin
process:
MOV si, tmp
CMP SI, pass
jne exit

mov dx, succes
mov ah,09h
int 21h
exit:
mov ah, 00h
int 21h

thank you guys :)

P.s. what goes here:

tmp DB “??????????????????????????????”

I mean what goes in place of the ????????????????????? marks.. thanks

357c7b2935ccd2cb0913717186684394
0
JSoftware 101 Aug 26, 2004 at 12:13

nasm doen’st understand the DUP statement.. that’s why we have to declare some space for the incomming text to the tmp variable

and you should remove the first 3 lines.. they aren’t needed by the assembler linker

1055a5b2994f67781fa94a24ef91c581
0
fresh 101 Aug 27, 2004 at 01:46

hey I got the code compiled finally but how do I call the linker.. I looked threw the help file but it didn’t specify.. does it compile and link in all one step or is it like TASM, two different steps?

Syntax would be great.. :)

357c7b2935ccd2cb0913717186684394
0
JSoftware 101 Aug 27, 2004 at 04:23

c++ nerd i suppose.. :) NETWIDE assembler code isn’t compiled. it’s directly linked. you don’t have to output object code first

try typing: nasm -o output.exe input.asm

that should do the rename trick

1055a5b2994f67781fa94a24ef91c581
0
fresh 101 Aug 27, 2004 at 16:10

yeah can you tell.. lol

BTW: I compiled the code you gave me and for some reason it wont load, I did exactly what you said, but it just wont work, so I gave up on ASM, and went back to C++, atleast for something of this nature.. I still like ASM and want to learn the basics.. so thanks for giving me a head start man, I appreciate your help.. :)

357c7b2935ccd2cb0913717186684394
0
JSoftware 101 Aug 27, 2004 at 17:25

assembly nowadays.. (i haven’t been programming asm for a long time) … is mainly used for optimization. i don’t think there’s any reason for learning assembler if you are not a diehard optimization freak or microprocessor programmer. things like input from devices is just… a thing you could just as good do in a highlevel language. but methods handling simple math which you could perform faster using your own algo you could make better in assembler.

but i think i myself got a lot from learning assembler though it’s mainly for microprocessor developement :yes:

1055a5b2994f67781fa94a24ef91c581
0
fresh 101 Aug 30, 2004 at 06:49

hey sorry for the slow reply.. yeah I agree, I thought it would be cool to make a few crackme’s in ASM, but like you said it isn’t logical to do so, if you can just do it faster in C++ or VB.. I agree ASM is well worth learning, so I think I’ll continue to study it, but I don’t think I will be using it to code with any time soon.. lol ;)

Thanks for all your help man, I appreciate it alot :D

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Aug 30, 2004 at 12:24

getting into assembler is a great way of improving ones understanding of computers. you should continue to learn it…

357c7b2935ccd2cb0913717186684394
0
JSoftware 101 Aug 30, 2004 at 13:15

i nod with anubis.. assembler is a bit tough to start out with but after the hard working and reading you feel like being able to read matrix code :D Hehe

disclaimer: Experience may vary.. but.. do it! :)

1055a5b2994f67781fa94a24ef91c581
0
fresh 101 Aug 30, 2004 at 19:39

yeah absolutly, I still am learning how the stack works and all that good stuff, so it will take some time again before I attempt to code with it.. it’s rough to learn, but it’s logical, so I think it is possible to read.. just hard to understand.. thats my problem.. lol ;)

2b97deded6213469bcd87b65cce5d014
0
Mihail121 102 Aug 30, 2004 at 20:14

Not hard to learn, not hard to understand either if you have up the right stuff. Just two hours ago i found FreeDOS, which gives the answers to a lot of stuff in my coding life so here is what i can suggest to you:

  1. Get FreeDOS OS (1 diskette) and install it
  2. Get the best ASM book ever written - “Art of Assembly”, it’s free
  3. Get Privalov’s FlatASM

and enjoy the coding in it’s pureness! That’s what life’s all about!

1055a5b2994f67781fa94a24ef91c581
0
fresh 101 Sep 01, 2004 at 11:11

cool man, I’ll have to check those out :D