Cyber Security Essentials Notes
Shellcode
Definition:
Shellcode is a small piece of code used as the payload in the exploitation of software
vulnerabilities. Originally designed to spawn a shell (command-line interface), modern
shellcode can perform a wide range of tasks such as downloading files, executing
commands, or injecting malware.
Key Concepts:
● Purpose of Shellcode: Execute arbitrary code within a target process and gain control
over a system after exploiting a vulnerability.
● How Shellcode Works: Written in assembly language, injected into a vulnerable process,
and executes with the same privileges as the compromised process.
● Platform Dependency: OS-specific due to differences in system calls (e.g., Linux uses INT
0x80, Windows uses kernel32.dll).
● Locating kernel32.dll in Windows: Via Process Environment Block (PEB), Structured
Error Handling (SEH), or scanning for magic bytes 'MZ'.
● Challenges: Avoid NULL bytes, make shellcode alphanumeric, and manage size
constraints.
● Optimization Techniques: Use XOR operations, encode shellcode, and use stage-loading.
Example: NULL-Free Instruction:
MOV EBX, 0x00000000 ; Contains NULLs
XOR EBX, EBX ; NULL-free alternative
Tools & Repositories: Metasploit Framework, ShellForge, Milw0rm.com (historical).
Detection & Prevention: IDS/IPS, antivirus, and emulation tools like libemu.
Summary:
Shellcode is a powerful tool used in cyber attacks to gain control over systems.
Understanding its structure and behavior is essential for defending against exploitation.
Integer Overflow Vulnerabilities
Definition:
An Integer Overflow occurs when an arithmetic operation attempts to create a numeric
value that exceeds the maximum limit of the data type used to store it.
Key Concepts:
● Types of Integers: Signed and Unsigned.
● Overflow Scenarios: Signed and Unsigned overflow behaviors.
● Two’s Complement Representation: Used for signed integers.
● Common Vulnerable Operations: Multiplication, addition, or subtraction without
bounds checking.
Examples:
Signed Overflow: 127 (01111111) + 1 → -128 (10000000)
Unsigned Overflow: 255 (11111111) + 1 → 0 (00000000)
Exploitation Risks: Denial of Service, Buffer Overflows, Privilege Escalation, Arbitrary Code
Execution.
Mitigation Strategies:
● Input Validation
● Strong Typing
● Safe Integer Libraries (e.g., SafeInt)
● Compiler Flags (e.g., -ftrapv)
Detection Techniques: Monitor for abnormal CPU usage or failed operations, use static
analysis tools.
Summary:
Integer overflows are subtle but dangerous vulnerabilities that arise from improper
handling of numeric data.