7CCSMSEN: Security Engineering
Introduction
Lorenzo Cavallaro
http://s2lab.kcl.ac.uk
Systems Security Research Lab – Cybersecurity Research Group Department of Informatics, King’s College London
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 1 / 41
“Security Engineering is about building systems to remain dependable in the face of malice, error, or mischance.”
Security Engineering (2nd ed). Ross Anderson
Should we care?
(let me tell you a story…)
The Botnet Threat
A network of compromised devices (bots) controlled by a bot master
Responsible for (non-exhaustive list):
Large-scale network probing (i.e., scanning activities) Launching Distributed Denial of Service (DDoS) attacks Sending large-scale unsolicited emails (SPAM) Click-fraud campaign
Information theft (e.g., PII, financial, IP)
Shift from a for-fun activity towards a profit-oriented business
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 5 / 41
Torpig
Trojan horse
Distributed via the Mebroot “malware platform”
Injects itself into 29 different applications as DLL
Steals sensitive information (passwords, HTTP POST data) HTTP injection for phishing
Uses “encrypted” HTTP as C&C protocol
Uses domain flux to locate C&C server
Mebroot
Spreads via drive-by downloads
Sophisticated rootkit (overwrites master boot record)
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 6 / 41
The Torpig Botnet
Lorenzo Cavallaro (S2 Lab)
7CCSMSEN
7 / 41
Vulnerable web server
The Torpig Botnet
Phishing Page
Example: Wellsfargo
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 8 / 41
The Torpig Botnet
Phishing Page
Example: Bank of America
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 9 / 41
The Torpig Botnet
Torpig HTML Injection
Domains of interest (∼300) stored in configuration file When domain of interest visited
Torpig issues request to injection server
Server specifies a trigger page on target domain and a URL on injection server to be visited when user visits trigger page
When user visits the trigger page
Torpig requests injection URL from injection server
Torpig injects the returned content into the user’s browser
Content is HTML phishing form that asks for sensitive data Reproduces look and style of target web site
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 10 / 41
The Torpig Botnet
Botnet Resiliency: Domain Flux
Taking down a single bot has little effect on botmaster C&C servers are vulnerable to take down
If you use a static IP address, people will block or remove host
If you use a DNS name, people will block or remove domain name
Domain flux
Idea is to have bots periodically generate new C&C domain names
Often, use local date (system time) as input
Botmaster needs to register one of these domains and respond properly so that bots recognize valid C&C server
Defenders must register all domains to take down botnet
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 11 / 41
The Torpig Botnet
Torpig Domain Flux
Each bot has
Same domain generation algorithm (DGA) Three fixed domains to be used if all else fails
DGA generates
weekly domain name (wd) daily domain name (dd)
Every 20 minutes bot attempts to connect in order to wd.com, wd.net, wd.biz
If all three fail, then dd.com, dd.net, dd.biz If they also fail, then the three fixed domains
Criminals normally registered wd.com (and wd.net)
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 12 / 41
Sinkholing Torpig
Sinkholing Torpig C&C Overview
Reverse engineered DGA and C&C protocol
Observed domains for 01/25 – 02/15 unregistered Registered these domains ourselves
Unfortunately, Mebroot pushed new Torpig binary on 02/04 We controlled the botnet for ∼10 days
Data
8.7 GB Apache logs
69 GB pcap data (contains stolen information)
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 13 / 41
Sinkholing Torpig
Sinkholing Torpig C&C
Purchased hosting from two different hosting providers known to be unresponsive to complaints
Registered wd.com and wd.net with two different registrars
One was suspended 01/31 due to abuse complaint
Set up Apache web servers to receive bot requests
Recorded all network traffic
Automatically downloaded and removed data from our hosting providers
Enabled hosts a week early
Immediately received data from 359 infected machines
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 14 / 41
Sinkholing Torpig
Data Collection Principles
Principle 1: the sinkholed botnet should be operated so that any harm and/or damage to victims and targets of attacks would be minimized
Always responded with okn message Never sent new/blank configuration file
Principle 2: the sinkholed botnet should collect enough information to enable notification and remediation of affected parties
Worked with law enforcement (FBI and DoD Cybercrime units) Worked with bank security officers
Worked with ISPs
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 15 / 41
Sinkholing Torpig
Data Collection
Bot connects to Torpig C&C every 20 minutes via HTTP POST Sends a header
timestamp, IP address, proxy ports, OS version, locale, nid, Torpig build and version number nid
8 byte value, used for encrypting header and data
Derived from hard disk information or volume serial number Serves as a convenient, unique identifier
Allows one to detect VMware machines
Optional body data
Stolen information (accounts, browser data, . . . )
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 16 / 41
Sinkholing Torpig
Data Collection: Data Format
POST /A15078D49EBA4C4E/qxoT4B5uUFFqw6c35AKDYFpdZHdKLCNn…Qg6nIGA
Figure: Sample URL requested by a Torpig bot ts=1232724990&ip=192.168.0.1:&sport=8109&hport=8108&os=5.1.2600&
cn=United%20States&nid=A15078D49EBA4C4E&bld=gnh5&ver=229
Figure: Corresponding unencrypted submission header
[gnh5 229] [MSO2002-MSO2003:pop.smith.com:John Smith:
john@smith.com]
[pop3://john:smith@pop.smith.com:110]
[smtp://:@smtp.smith.com:25]
[gnh5 229]
POST /accounts/LoginAuth Host: www.google.com POST FORM: Email=test@gmail.com Passwd=test
Figure: Sample data sent by a Torpig bot
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 17 / 41
Sinkholing Torpig
Data Collection
Data Type
Mailbox account Email
Form data
HTTP account FTP account
POP account SMTP account Windows password
Data Items,(#)
54,090 1,258,862 11,966,532 411,039 12,307 415,206 100,472 1,235,122
Figure: Data items sent to our C&C server by Torpig bots.
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 18 / 41
Size Estimation I
Count number of infections
Usually based on unique IP addresses
Problematic: DHCP and NAT effects (we saw 1.2M unique IPs)
Our count based on header information:
180K hosts (nids) seen
16000
14000
12000
10000
8000
6000
4000
2000
16000
14000
12000
10000
8000
6000
4000
2000
New Torpig IPs Per Hour
New Torpig Encryption Keys Per Hour
00
Date
Figure: Average 4,690 new IPs Lorenzo Cavallaro (S2 Lab)
Botnet Size
New IPs
New Encryption Keys
01/21
01/23
01/25
01/27
01/29
01/31
02/02
02/04
02/06
01/21
01/23
01/25
01/27
01/29
01/31
02/02
02/04
02/06
7CCSMSEN
19 / 41
Date
Figure: Average 750 new nids
Size Estimation II
Cumulative number of infections Linear for unique IP addresses
Decayed quickly for unique nids
More than 75% of unique nids were observed in first 48 hours
Lorenzo Cavallaro
(S2 Lab)
7CCSMSEN
20 / 41
1.0
0.8
0.6
0.4
0.2
0.0
1.0
0.8
0.6
0.4
0.2
0.0
New Torpig IPs Per Hour
New Torpig Encryption Keys Per Hour
Date
Date
Botnet Size
New IPs
New Encryption Keys
01/21
01/23
01/25
01/27
01/29
01/31
02/02
02/04
02/06
01/21
01/23
01/25
01/27
01/29
01/31
02/02
02/04
02/06
Threats
Threats
Denial of Service
Proxy servers
Theft of financial information Privacy threats
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 21 / 41
Threats
Threats
Denial of Service
More than 60,000 active hosts at any given time Determine network speed from ip2location DB
Cable and DSL make up 65% of infected hosts
Used 435 kbps conservative upstream bandwidth
Yields greater than 17 GB per second just from DSL/cable Corporate networks make up 22% of infected hosts
Potential for a massive DDoS attack
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 22 / 41
Threats
Threats
Proxy Servers
Torpig opens SOCKS and HTTP proxy
20% of infected machines are publicly reachable Only 2.45% of those marked by Spamhaus blacklist Could be abused for spamming
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 23 / 41
A few insights. . .
Threats
Threats
Theft of Financial Information
8,310 unique accounts from 410 financial institutions
Top 5: PayPal (1,770), Poste Italiane, Capital One, E*Trade, Chase 38% of credentials stolen from browser’s password manager
1,660 credit cards
Top 3: Visa (1,056), Mastercard, American Express, Maestro, Discover
US (49%), Italy (12%), Spain (8%)
Typically, one CC per victim, but there are exceptions
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 25 / 41
Threats
Value of the Financial Information
In a 2008 report on the underground economy, Symantec estimates Credit card value at $.10 to $25.00
Bank account at $10.00 to $1,000.00
Using such values, 10 days of Torpig data valued at $83K to $8.3M
1400 1200 1000
800 600 400 200
0
01-21 01-23
01-25
01-27
01-29
Date
01-31
02-02
02-04
1e+07 1e+06 100000 10000 1000 100
10 02-06
New bank accounts and credit cards
Max value Min value
Lorenzo Cavallaro (S2 Lab)
7CCSMSEN
26 / 41
New bank accounts and credit cards (#)
Value ($)
Threats
Password Analysis
297,962 unique credentials used on 368,501 web sites (domains)
Mostly web mail (Google, live, Yahoo) and social networking sites (Facebook, MySpace,
netlog.com)
28% of the victims reused their password on multiple domains
Used John the Ripper to access the strength of the passwords 173,686 unique passwords
56,000 in ¡ 65 minutes using permutation, substitution, etc.
14,000 in next 10 minutes using large wordlist (i.e., 40% cracked in less than 75 minutes) Another 30,000 in next 24 hours
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 27 / 41
Threats
Threats
Privacy
Web mail, web chat, and forum messages
Focused on 6,542 messages in English that were 250 characters or longer Zeitgeist of the Torpig network
14% are about jobs/resumes
7% discuss money
6% are sports fans
5% prepare for exams and worry about grades 4% partners/sex online
Online security is a concern, but think they are clean 10% specifically mention security/malware
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 28 / 41
Lessons learned
Threats
Lessons Learned
In 7CCSMSCT – SecurityTesting
Week 1–4
1 Most security threats start from the web
2 A malicious web page leverages a defect in a program to gain arbitrary code execution
3 The exploit downloads and installs a malware sample, that infects the victim
In 7CCSMCFC – Computer Forensics and Cybercrime
Can we engineer secure systems?
5 Defenses: Memory Safety, Control Flow Integrity (Week 5)
6 By Design: Secure Software Dev. and Authentication & Authorization (Week 7, 11)
7 Analysis: Static & Dynamic Analysis, Symbolic Execution (Week 9, 10)
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 30 / 41
Threats
7CCSMSEN: Course Outline (Tentative)
In 7CCSMSCT – SecurityTesting
Week 1–4
1 Most security threats start from the web
2 A malicious web page leverages a defect in a program to gain arbitrary code execution
3 The exploit downloads and installs a malware sample, that infects the victim
In 7CCSMCFC – Computer Forensics and Cybercrime
Can we engineer secure systems?
5 Defenses: Memory Safety, Control Flow Integrity (Week 5)
6 By Design: Secure Software Dev. and Authentication & Authorization (Week 7, 11)
7 Analysis: Static & Dynamic Analysis, Symbolic Execution (Week 9, 10)
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 30 / 41
Threats
In 7CCSMSCT – SecurityTesting
Week 1–4
1 Most security threats start from the web
2 A malicious web page leverages a defect in a program to gain arbitrary code execution
3 The exploit downloads and installs a malware sample, that infects the victim
In 7CCSMCFC – Computer Forensics and Cybercrime
Can we engineer secure systems?
5 Defenses: Memory Safety, Control Flow Integrity (Week 5)
6 By Design: Secure Software Dev. and Authentication & Authorization (Week 7, 11)
7 Analysis: Static & Dynamic Analysis, Symbolic Execution (Week 9, 10)
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 30 / 41
Threats
In 7CCSMSCT – SecurityTesting
Week 1–4
1 Most security threats start from the web
2 A malicious web page leverages a defect in a program to gain arbitrary code execution
3 The exploit downloads and installs a malware sample, that infects the victim
In 7CCSMCFC – Computer Forensics and Cybercrime
Can we engineer secure systems?
5 Defenses: Memory Safety, Control Flow Integrity (Week 5)
6 By Design: Secure Software Dev. and Authentication & Authorization (Week 7, 11)
7 Analysis: Static & Dynamic Analysis, Symbolic Execution (Week 9, 10)
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 30 / 41
Threats
In 7CCSMSCT – SecurityTesting
Week 1–4
1 Most security threats start from the web
2 A malicious web page leverages a defect in a program to gain arbitrary code execution
3 The exploit downloads and installs a malware sample, that infects the victim
In 7CCSMCFC – Computer Forensics and Cybercrime
Can we engineer secure systems?
5 Defenses: Memory Safety, Control Flow Integrity (Week 5)
6 By Design: Secure Software Dev. and Authentication & Authorization (Week 7, 11)
7 Analysis: Static & Dynamic Analysis, Symbolic Execution (Week 9, 10)
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 30 / 41
Threats
In 7CCSMSCT – SecurityTesting
Week 1–4
1 Most security threats start from the web
2 A malicious web page leverages a defect in a program to gain arbitrary code execution
3 The exploit downloads and installs a malware sample, that infects the victim
In 7CCSMCFC – Computer Forensics and Cybercrime
Can we engineer secure systems?
5 Defenses: Memory Safety, Control Flow Integrity (Week 5)
6 By Design: Secure Software Dev. and Authentication & Authorization (Week 7, 11)
7 Analysis: Static & Dynamic Analysis, Symbolic Execution (Week 9, 10)
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 30 / 41
Administrivia
Threats
Aims and Learning Outcomes
Goals
This module focuses on how to design and develop secure systems. It also provides a detailed understanding of implementation errors and exploits, including mitigations techniques often built on static and dynamic analysis
Disclaimer & Adminstrivia
Vast topic; sometimes only pointers and overview Hacking-oriented lectures
Understanding how to break (i.e., attacks) is fundamental to devise novel and efficient mitigation techniques (i.e., protect)
Hacking-oriented hands-on challenges of increasing difficulties
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 32 / 41
Threats
Aims and Learning Outcomes
Goals
This module focuses on how to design and develop secure systems. It also provides a detailed understanding of implementation errors and exploits, including mitigations techniques often built on static and dynamic analysis
Disclaimer & Adminstrivia
Vast topic; sometimes only pointers and overview Hacking-oriented lectures
Understanding how to break (i.e., attacks) is fundamental to devise novel and efficient mitigation techniques (i.e., protect)
Hacking-oriented hands-on challenges of increasing difficulties
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 32 / 41
Threats
Administrivia
All course material available on KEATS (https://keats.kcl.ac.uk/course/view.php?id=67080)
Updated throughout the course
Do use the forum—I do encourage collaboration
Office hours: email for an appointment, Bush House (N)7.14 Anything, just contact me at
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 33 / 41
Threats
Administrivia (cont.)
No actual official textbook, just slides, and suggested readings, however:
Jon Erickson, “Hacking: the art of exploitation”, 2nd edition, No Starch Press
Steven Levy, “Hackers: heroes of the computer revolution”, O’Reilly
BBC Horizon—Defeating the Hackers, http://www.youtube.com/watch?v=_4NrrKTYmBI Module’s reading list: https://keats.kcl.ac.uk/mod/lti/view.php?id=2796038 Recommended reading on KEATS
Handbook 19/20: https://keats.kcl.ac.uk/course/view.php?id=68786 King’s Education Awards: https://www.kcl.ac.uk/academy/kea
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 34 / 41
Threats
Administrivia
Coursework & Exam
Coursework (aka practical assessments/challenges)
Announced likely on W5 (Oct 25, 2019) – until the end of the module
A number of per-topic hands-on and hacking-oriented CTF-like challenges You may be asked to explain how you have solved the challenges
Marks (over 100) contribute to 30% of the overall exam mark
Written exam
Open questions textbook-like and reasoning Contribute to 70% of overall exam mark
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 35 / 41
Threats
7CCSMSEN: Security Engineering Agenda (Tentative) I
2pm–5pm @ Bush House Lecture Theatre 1 BH(S)1.01 – 50’ slot + 10’ break
W1 Sep 27, 2019: Introduction (+ AppSec) W2 Oct 4, 2019: AppSec
Memory errors vulnerabilities x86 asm primer
Code injection attacks
W3 Oct 11, 2019: AppSec (cont.)
Code injection (cont.)
Other exploits
W4 Oct 18, 2019: AppSec (cont.)
Format string vulnerabilities Defenses against memory errors
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 36 / 41
Threats
7CCSMSEN: Security Engineering Agenda (Tentative) II
W5 Oct 25, 2019: AppSec (cont.)
Defenses against memory errors (cont.) Memory safety
Control flow integrity
W6 Nov 1, 2019: NO CLASS (Reading Week) W7 Nov 8, 2019: Secure Software Development
Threat modeling Security requirements Security principles Case study – qmail
W8 Nov 15, 2019: NO CLASS (Instructor @ CCS 2019)
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 37 / 41
Threats
7CCSMSEN: Security Engineering Agenda (Tentative) III
W9 Nov 22, 2019: Program Analysis
Static analysis
Dynamic analysis
W10 Nov 29, 2019: Program Analysis (cont.)
Taint analysis
Symbolic execution
W11 Dec 6, 2019: Authentication & Authorization
Authentication Authorization Security models
W12 Dec 13, 2019: Revision Q&A / catch up
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 38 / 41
Expectations of Behaviour
Threats
Expectations of Behaviour
Staff and students are expected to behave respectfully to one another—during lectures, outside of lectures and when communicating online or through email.
We won’t tolerate inappropriate or demeaning comments related to gender, gender identity and expression, sexual orientation, disability, physical appearance, race, religion, age, or any other personal characteristic.
If you witness or experience any behaviour you are concerned about, please speak to someone about it. This could be one of your lecturers, your personal tutor, a programme administrator, the diversity & inclusion lead (Elizabeth Black), a trained harassment advisor or any member of staff you feel comfortable talking about it to.
More info at: https://kcl.ac.uk/harassment
Lorenzo Cavallaro (S2 Lab) 7CCSMSEN 40 / 41
Wait! Who Am I?!