$\require{cancel}$
String Input
- Our goal for the day.
- Input is done as raw strings. Yipeee!
- System Call 0, SYS_READ
- See Jorgensen, page 328
- rax contains 0, (SYS_READ)
- rsi is the address of where to store the characters.
- This needs to be the size given (later) or larger
- This is probably in the .bss segment
- rdx contains the maximum Length.
- If fewer characters are input, the remaining buffer will be ignored.
- If more characters are input, only the given number will be read.
- rax will contain the number of characters read, up to and including the newline.
- This will be -1 if there is a problem.
- Back to bad old days of C style arrays, guess the size.
- This is the primary source for buffer overflow attacks.
- The code
- Jorgensen describes setting up data in the data section
- Page 34
-
variable_name dataType initial_value
- dd - 8 bit variable.
- dw - 16 bit variable.
- dd - 32 bit
- dq - 64 bit varaiable
- ddq - 128 bit integer
- dt - 128 bit float
- These are discussed in full detail here in the manual
- Apparently a ? can be use for initialized storage, but that should go in the bss segment.
- Multiple values can be listed.
- We saw the constant format types before.
- This was in Chapter 3.4 of the NASM assembly manual.
- Strings, which will be useful soon, are in the next section
- Escapes must be in back quotes ` (up by escape)
- we have seen it is possible to hard code ascii values
I think we looked at the res? statements before
- But to be sure, they are covered here in the manual.
- We will be back for this, I am getting too far from our code.
By the way, we can examine memory with x
- Named memory is accessed with &label
- Ie
&phrase
in this case.
-
x /nfu memory
- f is a format
- s: interpret as a string
- i: interpret as a machine instruction
- x: default, show as hex
-
- u is a unit size
- b for bytes
- h for two bytes
- w for four bytes
- g for eight bytes
- n is an optional count
- x /s &phrase
- x /10b &phrase
- x /i $rip