Information Security System Design Foundation third Week Experiment report

Source: Internet
Author: User

Chapter II Representation and processing of information three most important digital representations

Unsigned: Based on traditional binary notation, greater than or equal to 0

Complement: Signed integer

Floating-point numbers: A binary-based version of the scientific notation for real numbers

Buffer Overflow Vulnerability:

The representation of a computer is to use a finite number of bits to correspond to a number encoding, and overflow occurs when the result is too large to be represented. An artificial overflow is an attempt by an attacker to write a string that is longer than the buffer length, which may result in two types of results: one is that the long string overwrites the adjacent storage unit, causing the program to fail, causing the system to crash seriously, and the other result is to exploit the vulnerability to execute arbitrary instructions. You can even get the system root privilege.

2.1

For program objects that span multiple bytes, you must establish two rules:

What is the address of the object?

How these bytes are arranged in memory

Multibyte objects are stored as contiguous sequence of bytes, with the address of the object being the smallest address in the bytes used

The big-endian & Small-end method : the least significant byte in the first way is called the small-end method, the most effective byte in the first way is called the big-endian method. Byte order is the basis of network programming, the small end is "high-to-high, low-to-low", the big-endian opposite.

There are three scenarios in which the byte order is visible:

Network application code must follow established rules on byte order when writing

Disassembler Display (tool that determines the sequence of instructions represented by the executable file)

When writing programs that circumvent a normal type system, you can use coercion type conversions to allow a data type to reference an object

Boolean algebra

Use 0, 1 to express true and false, to study the basic principles of logical reasoning.

There are: ~=not;&=and;|=or;^= XOR

Bit-level operations in C: the C language supports bitwise Boolean operations. With or non, XOR, or common usage is to implement a mask operation.

Logical operations in the C language: logical operators && and | | Bit-level operations that correspond to them & and | The second important difference between the two is if the first

Parameter evaluation can determine the result of an expression, then the logical operator does not evaluate the second parameter.

Shift operations in C: the C language standard does not explicitly define which type of right shift should be used

2.2

Shaping data types

The C language supports multiple shaping data types-integers representing a limited range.

To use the "long Long" type in C99, compiling is to use the Gcc-std=c99

Complement code:最高位有效位也称符号位,权重为-2^w-1。符号位为1是负为0是正。补码的范围不对称,是因为:一半的数的整数一半是负数,而0是非负

数。最大的无符号数值刚好比补码的最大值的两倍大一点。

There are two standard ways to represent signed numbers:

Anti-code: In addition to the most effective bit of the right is-(2w-1-1) rather than -2w-1, it is the same as the complement.

The original code: the most significant bit is the sign bit, used to determine whether the rest of the bit should take negative or positive right.

The C language allows for coercion of type conversions between different numeric data types. Converting negative numbers to unsigned numbers can get 0. If the converted unsigned number is too large to exceed the range that the complement can represent, you may get Tmax.

The C language allows the conversion between signed and unsigned numbers, and the principle of conversion is that the underlying bit representation remains the same

2.3

1. unsigned addition: unsigned addition is equivalent to computation and modulo 2w. This value can be calculated by simply discarding the highest bit represented by the W + 1 bits of x + Y. Can be considered as a form of modulo operation, which is equivalent to calculation and modulus 2^w.

Overflow: Full integer result cannot be placed into the word length limit of the data type

2. Complement addition: negative overflow results are larger than integers and large 16, and positive overflow results are 16 smaller than integers.

3. Complement of non-

4. The formula is calculated without symbolic multiplication.

5. Complement multiplication: Two bit vectors for a given length, the bit-level representation of the unsigned product is the same as that of the complement product, indicating that the machine can use a multiplication instruction to multiply the signed and unsigned numbers.

6. Multiply constants: In order to shorten the computational time, many C-language compilers try to replace multiplication by multiplying constants with a combination of shift, addition, and subtraction operations.

7. The power of dividing by 2: the Power of dividing by 2 can be achieved by logical or arithmetic right shift.

8. The final thought on integer arithmetic: The computer performs the "integer" operation is actually a form of modulo operation. A finite word length that represents a number limits the possible range of values, and the result can overflow. The complement provides a flexible way for skills to represent positive numbers and to represent negative numbers, while using the same bit-level implementation as the execution of unsigned arithmetic.

2.4

The IEEE floating-point standard represents a number in the form of V = ( -1) ^sxmx2^e:

    • Symbol: s Determines whether the number is negative (S=1) or positive (s=0), while the symbolic bit interpretation for the value 0 is handled as a special case.
    • Mantissa: M is a binary decimal, and its range is 1~2-ε, or 0~1-ε.
    • Order code: The role of E is weighted to the floating-point number, which is 2 of the power of the E (may be negative).

Divide the bit representation of a floating-point number into three fields and encode the values:

    • A separate sign bit s directly encodes the symbol S.
    • The Order field of K-bit exp = EK-1...E1E0 encoded Order E.
    • N-bit decimal field frac = FN-1...F1 F0 encoded mantissa m, but the encoded value also depends on whether the value of the Order field equals 0.
    • The IEEE standard specifies a simple rule that is used to determine the results of arithmetic operations such as addition and multiplication. The floating-point values X and Y are considered real, and an operation ⊙ is defined on the real number, and the calculation produces round (x⊙y), which is the result of rounding the exact result of the actual operation. When one of the parameters is a special value (such as-0,-∞, or Nan), the IEEE standard defines some rules that make it more reasonable. For example, defining 1/-0 will produce-∞, and defining 1/+0 will produce +∞.

      • Floating-point addition does not have a binding, which is the most important group attribute that is missing.
      • Floating-point addition satisfies the monotonicity attribute: If a≥b, then for any value of a, B, and X, except Nan, there is x + a≥x + B. unsigned or complement addition does not have the attribute of this real (and integer) addition.

Information Security System Design Foundation third Week Experiment report

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.