SlideShare ist ein Scribd-Unternehmen logo
1 von 55
Downloaden Sie, um offline zu lesen
Hands-On Ethical
Hacking and
Network Defense

3
nd
edition
Chapter 7
Programming for Security Professionals
Last modified 1-11-17
2
Objectives
■ Explain basic programming concepts
■ Write a simple C program
■ Explain how Web pages are created with
HTML
■ Describe and create basic Perl programs
■ Explain basic object-oriented programming
concepts
3
Introduction to Computer
Programming
■ Computer programmers must understand
the rules of programming languages
■ Programmers deal with syntax errors
■ One minor mistake and the program will
not run
■ Or worse, it will produce unpredictable results
■ Being a good programmer takes time and
patience
4
Computer Programming
Fundamentals
■ Fundamental concepts
■ Branching, Looping, and Testing (BLT)
■ Documentation
■ Function
■ Mini program within a main program that
carries out a task
5
Branching, Looping, and Testing
(BLT)
■ Branching
■ Takes you from one area of the program to
another area
■ Looping
■ Act of performing a task over and over
■ Testing
■ Verifies some condition and returns true or
false
6
A C Program
■ Filename ends in .c
■ It's hard to read at first
■ A single missing semicolon can ruin a
program
7
Comments
■ Comments make code easier to read
8
Branching and Testing
main()
scanf()printf()
Diagram of branches
See links Ch 7b, 7c
9
Looping
10
Branching, Looping, and Testing
(BLT)
■ Algorithm
■ Defines steps for performing a task
■ Keep it as simple as possible
■ Bug
■ An error that causes unpredictable results
■ Pseudocode
■ English-like language used to create the
structure of a program
11
Pseudocode For Shopping
■ PurchaseIngredients Function
■ Call GetCar Function
■ Call DriveToStore Function
■ Purchase Bacon, Bread, Tomatoes,
Lettuce, and Mayonnaise
■ End PurchaseIngredients Function
12
Documentation
■ Documenting your work is essential
■ Add comments to your programs
■ Comments should explain what you are doing
■ Many programmers find it time consuming
and tedious
■ Helps others understand your work
13
Bugs
■ Industry standard
■ 20 to 30 bugs for every 1000 lines of code

(link Ch 7f)
■ Textbook claims a much smaller number without a source
■ Windows 2000 contains almost 50 million lines
■ And fewer than 60,000 bugs (about 1 per 1000 lines)
■ See link Ch 7e for comments in the leaked Win 2000
source code
■ Linux has 0.17 bugs per 1000 lines of code
■ (Link Ch 7f)
14
Learning the C Language
■ Developed by Dennis Ritchie at Bell
Laboratories in 1972
■ Powerful and concise language
■ UNIX was first written in assembly
language and later rewritten in C
■ C++ is an enhancement of the C language
■ C is powerful but dangerous
■ Bugs can crash computers, and it's easy to
leave security holes in the code
15
Assembly Language
■ The binary language hard-wired into the
processor is machine language
■ Assembly Language uses a combination of
hexadecimal numbers and expressions
■ Very powerful but hard to use (Link Ch 7g)
16
Compiling C in Ubuntu Linux
■ Compiler
■ Converts a text-based program (source code)
into executable or binary code
■ To prepare Ubuntu Linux for C
programming, use this command:
sudo apt-get install build-essential
■ Then you compile a file named "program.c"
with this command:
gcc program.c –o program
17
Anatomy of a C Program
■ The first computer program a C student
learns "Hello, World!"
18
Comments
■ Use /* and */ to comment large portions of
text
■ Use // for one-line comments
19
Include
■ #include statement
■ Loads libraries that hold the commands and
functions used in your program
20
Functions
■ A Function Name is always followed by
parentheses ( )
■ Curly Braces { } shows where a function
begins and ends
■ main() function
■ Every C program requires a main() function
■ main() is where processing starts
21
Functions
■ Functions can call other functions
■ Parameters or arguments are optional
■ n represents a line feed
22
Declaring Variables
■ A variable represents a numeric or string
value
■ You must declare a variable before using it
23
Variable Types in C
24
Mathematical Operators
■ The i++ in the example below adds one to
the variable i
25
Mathematical Operators
26
Logical Operators
■ The i<11 in the example below compares
the variable i to 11
27
Logical Operators
28
Demonstration: Buffer Overflow
Buffer Overflow Defenses
30
CANARY
Detecting stack smashing with a canary value
40
Understanding HTML Basics
■ HTML is a language used to create Web
pages
■ HTML files are text files
■ Security professionals often need to
examine Web pages
■ Be able to recognize when something looks
suspicious
41
Creating a Web Page Using HTML
■ Create HTML Web page in Notepad
■ View HTML Web page in a Web browser
■ HTML does not use branching, looping, or
testing
■ HTML is a static formatting language
■ Rather than a programming language
■ < and > symbols denote HTML tags
■ Each tag has a matching closing tag
■ <HTML> and </HTML>
42
43
44
45
Understanding Practical Extraction
and Report Language (Perl)
■ PERL
■ Powerful scripting language
■ Used to write scripts and programs for security
professionals
46
Background on Perl
■ Developed by Larry Wall in 1987
■ Can run on almost any platform
■ *NIX-base OSs already have Perl installed
■ Perl syntax is similar to C
■ Hackers use Perl to write malware
■ Security professionals use Perl to perform
repetitive tasks and conduct security
monitoring
47
48
Understanding the Basics of Perl
■ perl –h command
■ Gives you a list of parameters used with perl
49
50
Understanding the BLT of Perl
■ Some syntax rules
■ Keyword “sub” is used in front of function
names
■ Variables begin with the $ character
■ Comment lines begin with the # character
■ The & character is used when calling a
function
51
Branching in Perl
&speak;
■ Calls the subroutine
sub speak
■ Defines the subroutine
52
For Loop in Perl
■ For loop
53
Testing Conditions in Perl
54
Understanding Object-Oriented
Programming Concepts
■ New programming paradigm
■ There are several languages that support
object-oriented programming
■ C++
■ C#
■ Java
■ Perl 6.0
■ Object Cobol
55
Components of Object-Oriented
Programming
■ Classes
■ Structures that hold pieces of data and
functions
■ The :: symbol
■ Used to separate the name of a class from a
member function
■ Example:
■ Employee::GetEmp()
56
Example of a Class in C++
class Employee
{
public:
char firstname[25];
char lastname[25];
char PlaceOfBirth[30];
[code continues]
};
void GetEmp()
{
// Perform tasks to get employee info
[program code goes here]
}
Ruby Example
■ Metasploit is written in Ruby
■ See link Ch 7u
57
56
LOLCODE
Links Ch 7x, Ch 7y
53
56
Brainfuck
Link Ch 7z
56
"Hello, World!" in Brainfuck

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Security Vulnerabilities
Security VulnerabilitiesSecurity Vulnerabilities
Security Vulnerabilities
 
Ch 4: Footprinting and Social Engineering
Ch 4: Footprinting and Social EngineeringCh 4: Footprinting and Social Engineering
Ch 4: Footprinting and Social Engineering
 
Burp suite
Burp suiteBurp suite
Burp suite
 
Windowsforensics
WindowsforensicsWindowsforensics
Windowsforensics
 
Operating system security
Operating system securityOperating system security
Operating system security
 
Proxy servers
Proxy serversProxy servers
Proxy servers
 
Information Security Engineering
Information Security EngineeringInformation Security Engineering
Information Security Engineering
 
Dos attack
Dos attackDos attack
Dos attack
 
Microsoft Operating System Vulnerabilities
Microsoft Operating System VulnerabilitiesMicrosoft Operating System Vulnerabilities
Microsoft Operating System Vulnerabilities
 
Web application security: Threats & Countermeasures
Web application security: Threats & CountermeasuresWeb application security: Threats & Countermeasures
Web application security: Threats & Countermeasures
 
Web application security
Web application securityWeb application security
Web application security
 
Reconnaissance
ReconnaissanceReconnaissance
Reconnaissance
 
Hardware firewall
Hardware firewallHardware firewall
Hardware firewall
 
Footprinting and reconnaissance
Footprinting and reconnaissanceFootprinting and reconnaissance
Footprinting and reconnaissance
 
Windows privilege escalation by Dhruv Shah
Windows privilege escalation by Dhruv ShahWindows privilege escalation by Dhruv Shah
Windows privilege escalation by Dhruv Shah
 
Network Forensics
Network ForensicsNetwork Forensics
Network Forensics
 
TCP/IP and UDP protocols
TCP/IP and UDP protocolsTCP/IP and UDP protocols
TCP/IP and UDP protocols
 
Database Systems Security
Database Systems SecurityDatabase Systems Security
Database Systems Security
 
Linux security introduction
Linux security introduction Linux security introduction
Linux security introduction
 
PE File Format
PE File FormatPE File Format
PE File Format
 

Andere mochten auch

Ch 6: Enumeration
Ch 6: EnumerationCh 6: Enumeration
Ch 6: EnumerationSam Bowne
 
Ch 9: Embedded Operating Systems: The Hidden Threat
Ch 9: Embedded Operating Systems: The Hidden ThreatCh 9: Embedded Operating Systems: The Hidden Threat
Ch 9: Embedded Operating Systems: The Hidden ThreatSam Bowne
 
Ch 8: Desktop and Server OS Vulnerabilites
Ch 8: Desktop and Server OS VulnerabilitesCh 8: Desktop and Server OS Vulnerabilites
Ch 8: Desktop and Server OS VulnerabilitesSam Bowne
 
Ch 10: Hacking Web Servers
Ch 10: Hacking Web ServersCh 10: Hacking Web Servers
Ch 10: Hacking Web ServersSam Bowne
 
Ch 2: TCP/IP Concepts Review
Ch 2: TCP/IP Concepts ReviewCh 2: TCP/IP Concepts Review
Ch 2: TCP/IP Concepts ReviewSam Bowne
 
Is Your Mobile App Secure?
Is Your Mobile App Secure?Is Your Mobile App Secure?
Is Your Mobile App Secure?Sam Bowne
 
CNIT 123 Ch 1: Ethical Hacking Overview
CNIT 123 Ch 1: Ethical Hacking OverviewCNIT 123 Ch 1: Ethical Hacking Overview
CNIT 123 Ch 1: Ethical Hacking OverviewSam Bowne
 
CNIT 126 5: IDA Pro
CNIT 126 5: IDA Pro CNIT 126 5: IDA Pro
CNIT 126 5: IDA Pro Sam Bowne
 
Ch 3: Network and Computer Attacks
Ch 3: Network and Computer AttacksCh 3: Network and Computer Attacks
Ch 3: Network and Computer AttacksSam Bowne
 
Security Training at CCSF
Security Training at CCSFSecurity Training at CCSF
Security Training at CCSFSam Bowne
 
Ch 11: Hacking Wireless Networks
Ch 11: Hacking Wireless NetworksCh 11: Hacking Wireless Networks
Ch 11: Hacking Wireless NetworksSam Bowne
 
Ch 5: Port Scanning
Ch 5: Port ScanningCh 5: Port Scanning
Ch 5: Port ScanningSam Bowne
 
CNIT 128 5: Mobile malware
CNIT 128 5: Mobile malwareCNIT 128 5: Mobile malware
CNIT 128 5: Mobile malwareSam Bowne
 
CNIT 126 6: Recognizing C Code Constructs in Assembly
CNIT 126 6: Recognizing C Code Constructs in Assembly CNIT 126 6: Recognizing C Code Constructs in Assembly
CNIT 126 6: Recognizing C Code Constructs in Assembly Sam Bowne
 
CNIT 121: 4 Getting the Investigation Started on the Right Foot & 5 Initial D...
CNIT 121: 4 Getting the Investigation Started on the Right Foot & 5 Initial D...CNIT 121: 4 Getting the Investigation Started on the Right Foot & 5 Initial D...
CNIT 121: 4 Getting the Investigation Started on the Right Foot & 5 Initial D...Sam Bowne
 
CNIT 129S: Securing Web Applications Ch 1-2
CNIT 129S: Securing Web Applications Ch 1-2CNIT 129S: Securing Web Applications Ch 1-2
CNIT 129S: Securing Web Applications Ch 1-2Sam Bowne
 
CNIT 40: 6: DNSSEC and beyond
CNIT 40: 6: DNSSEC and beyondCNIT 40: 6: DNSSEC and beyond
CNIT 40: 6: DNSSEC and beyondSam Bowne
 
CNIT 129S: 9: Attacking Data Stores (Part 1 of 2)
CNIT 129S: 9: Attacking Data Stores (Part 1 of 2)CNIT 129S: 9: Attacking Data Stores (Part 1 of 2)
CNIT 129S: 9: Attacking Data Stores (Part 1 of 2)Sam Bowne
 
CNIT 129S: Ch 5: Bypassing Client-Side Controls
CNIT 129S: Ch 5: Bypassing Client-Side ControlsCNIT 129S: Ch 5: Bypassing Client-Side Controls
CNIT 129S: Ch 5: Bypassing Client-Side ControlsSam Bowne
 
CNIT 129S: 8: Attacking Access Controls
CNIT 129S: 8: Attacking Access ControlsCNIT 129S: 8: Attacking Access Controls
CNIT 129S: 8: Attacking Access ControlsSam Bowne
 

Andere mochten auch (20)

Ch 6: Enumeration
Ch 6: EnumerationCh 6: Enumeration
Ch 6: Enumeration
 
Ch 9: Embedded Operating Systems: The Hidden Threat
Ch 9: Embedded Operating Systems: The Hidden ThreatCh 9: Embedded Operating Systems: The Hidden Threat
Ch 9: Embedded Operating Systems: The Hidden Threat
 
Ch 8: Desktop and Server OS Vulnerabilites
Ch 8: Desktop and Server OS VulnerabilitesCh 8: Desktop and Server OS Vulnerabilites
Ch 8: Desktop and Server OS Vulnerabilites
 
Ch 10: Hacking Web Servers
Ch 10: Hacking Web ServersCh 10: Hacking Web Servers
Ch 10: Hacking Web Servers
 
Ch 2: TCP/IP Concepts Review
Ch 2: TCP/IP Concepts ReviewCh 2: TCP/IP Concepts Review
Ch 2: TCP/IP Concepts Review
 
Is Your Mobile App Secure?
Is Your Mobile App Secure?Is Your Mobile App Secure?
Is Your Mobile App Secure?
 
CNIT 123 Ch 1: Ethical Hacking Overview
CNIT 123 Ch 1: Ethical Hacking OverviewCNIT 123 Ch 1: Ethical Hacking Overview
CNIT 123 Ch 1: Ethical Hacking Overview
 
CNIT 126 5: IDA Pro
CNIT 126 5: IDA Pro CNIT 126 5: IDA Pro
CNIT 126 5: IDA Pro
 
Ch 3: Network and Computer Attacks
Ch 3: Network and Computer AttacksCh 3: Network and Computer Attacks
Ch 3: Network and Computer Attacks
 
Security Training at CCSF
Security Training at CCSFSecurity Training at CCSF
Security Training at CCSF
 
Ch 11: Hacking Wireless Networks
Ch 11: Hacking Wireless NetworksCh 11: Hacking Wireless Networks
Ch 11: Hacking Wireless Networks
 
Ch 5: Port Scanning
Ch 5: Port ScanningCh 5: Port Scanning
Ch 5: Port Scanning
 
CNIT 128 5: Mobile malware
CNIT 128 5: Mobile malwareCNIT 128 5: Mobile malware
CNIT 128 5: Mobile malware
 
CNIT 126 6: Recognizing C Code Constructs in Assembly
CNIT 126 6: Recognizing C Code Constructs in Assembly CNIT 126 6: Recognizing C Code Constructs in Assembly
CNIT 126 6: Recognizing C Code Constructs in Assembly
 
CNIT 121: 4 Getting the Investigation Started on the Right Foot & 5 Initial D...
CNIT 121: 4 Getting the Investigation Started on the Right Foot & 5 Initial D...CNIT 121: 4 Getting the Investigation Started on the Right Foot & 5 Initial D...
CNIT 121: 4 Getting the Investigation Started on the Right Foot & 5 Initial D...
 
CNIT 129S: Securing Web Applications Ch 1-2
CNIT 129S: Securing Web Applications Ch 1-2CNIT 129S: Securing Web Applications Ch 1-2
CNIT 129S: Securing Web Applications Ch 1-2
 
CNIT 40: 6: DNSSEC and beyond
CNIT 40: 6: DNSSEC and beyondCNIT 40: 6: DNSSEC and beyond
CNIT 40: 6: DNSSEC and beyond
 
CNIT 129S: 9: Attacking Data Stores (Part 1 of 2)
CNIT 129S: 9: Attacking Data Stores (Part 1 of 2)CNIT 129S: 9: Attacking Data Stores (Part 1 of 2)
CNIT 129S: 9: Attacking Data Stores (Part 1 of 2)
 
CNIT 129S: Ch 5: Bypassing Client-Side Controls
CNIT 129S: Ch 5: Bypassing Client-Side ControlsCNIT 129S: Ch 5: Bypassing Client-Side Controls
CNIT 129S: Ch 5: Bypassing Client-Side Controls
 
CNIT 129S: 8: Attacking Access Controls
CNIT 129S: 8: Attacking Access ControlsCNIT 129S: 8: Attacking Access Controls
CNIT 129S: 8: Attacking Access Controls
 

Ähnlich wie Ch 7: Programming for Security Professionals

Ch07 Programming for Security Professionals
Ch07 Programming for Security ProfessionalsCh07 Programming for Security Professionals
Ch07 Programming for Security Professionalsphanleson
 
The security professional's guide to programming - Eric Vanderburg
The security professional's guide to programming - Eric VanderburgThe security professional's guide to programming - Eric Vanderburg
The security professional's guide to programming - Eric VanderburgEric Vanderburg
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingManoj Tyagi
 
Basic C Structure and related terms with example
Basic C Structure and related terms with exampleBasic C Structure and related terms with example
Basic C Structure and related terms with examplesanjana mun
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programmingMalikaJoya
 
Compiler Construction Lecture One .pptx
Compiler Construction Lecture One  .pptxCompiler Construction Lecture One  .pptx
Compiler Construction Lecture One .pptxانشال عارف
 
Lecture-1&2.pdf Visual Programming C# .net framework
Lecture-1&2.pdf Visual Programming C# .net frameworkLecture-1&2.pdf Visual Programming C# .net framework
Lecture-1&2.pdf Visual Programming C# .net frameworkAbdullahNadeem78
 
Introduction
IntroductionIntroduction
IntroductionKamran
 
IP Lab Manual for Kerala University 3 Year UG Programme
IP Lab Manual for Kerala University 3 Year UG ProgrammeIP Lab Manual for Kerala University 3 Year UG Programme
IP Lab Manual for Kerala University 3 Year UG ProgrammeSAFAD ISMAIL
 
Introduction_to_Programming.pptx
Introduction_to_Programming.pptxIntroduction_to_Programming.pptx
Introduction_to_Programming.pptxPmarkNorcio
 

Ähnlich wie Ch 7: Programming for Security Professionals (20)

Ch07 Programming for Security Professionals
Ch07 Programming for Security ProfessionalsCh07 Programming for Security Professionals
Ch07 Programming for Security Professionals
 
The security professional's guide to programming - Eric Vanderburg
The security professional's guide to programming - Eric VanderburgThe security professional's guide to programming - Eric Vanderburg
The security professional's guide to programming - Eric Vanderburg
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
C session 1.pptx
C session 1.pptxC session 1.pptx
C session 1.pptx
 
Basic C Structure and related terms with example
Basic C Structure and related terms with exampleBasic C Structure and related terms with example
Basic C Structure and related terms with example
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
 
C language unit-1
C language unit-1C language unit-1
C language unit-1
 
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDYC LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
 
C languaGE UNIT-1
C languaGE UNIT-1C languaGE UNIT-1
C languaGE UNIT-1
 
Compiler Construction Lecture One .pptx
Compiler Construction Lecture One  .pptxCompiler Construction Lecture One  .pptx
Compiler Construction Lecture One .pptx
 
Lecture-1&2.pdf Visual Programming C# .net framework
Lecture-1&2.pdf Visual Programming C# .net frameworkLecture-1&2.pdf Visual Programming C# .net framework
Lecture-1&2.pdf Visual Programming C# .net framework
 
Mcs lec2
Mcs lec2Mcs lec2
Mcs lec2
 
Learn C Language
Learn C LanguageLearn C Language
Learn C Language
 
Introduction
IntroductionIntroduction
Introduction
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
 
C intro
C introC intro
C intro
 
IP Lab Manual for Kerala University 3 Year UG Programme
IP Lab Manual for Kerala University 3 Year UG ProgrammeIP Lab Manual for Kerala University 3 Year UG Programme
IP Lab Manual for Kerala University 3 Year UG Programme
 
C PROGRAMMING
C PROGRAMMINGC PROGRAMMING
C PROGRAMMING
 
Unit ii
Unit   iiUnit   ii
Unit ii
 
Introduction_to_Programming.pptx
Introduction_to_Programming.pptxIntroduction_to_Programming.pptx
Introduction_to_Programming.pptx
 

Mehr von Sam Bowne

3: DNS vulnerabilities
3: DNS vulnerabilities 3: DNS vulnerabilities
3: DNS vulnerabilities Sam Bowne
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development SecuritySam Bowne
 
4 Mapping the Application
4 Mapping the Application4 Mapping the Application
4 Mapping the ApplicationSam Bowne
 
3. Attacking iOS Applications (Part 2)
 3. Attacking iOS Applications (Part 2) 3. Attacking iOS Applications (Part 2)
3. Attacking iOS Applications (Part 2)Sam Bowne
 
12 Elliptic Curves
12 Elliptic Curves12 Elliptic Curves
12 Elliptic CurvesSam Bowne
 
11. Diffie-Hellman
11. Diffie-Hellman11. Diffie-Hellman
11. Diffie-HellmanSam Bowne
 
2a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 12a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 1Sam Bowne
 
9 Writing Secure Android Applications
9 Writing Secure Android Applications9 Writing Secure Android Applications
9 Writing Secure Android ApplicationsSam Bowne
 
12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)Sam Bowne
 
12 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 312 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 3Sam Bowne
 
9. Hard Problems
9. Hard Problems9. Hard Problems
9. Hard ProblemsSam Bowne
 
8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)Sam Bowne
 
11 Analysis Methodology
11 Analysis Methodology11 Analysis Methodology
11 Analysis MethodologySam Bowne
 
8. Authenticated Encryption
8. Authenticated Encryption8. Authenticated Encryption
8. Authenticated EncryptionSam Bowne
 
7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)Sam Bowne
 
7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)Sam Bowne
 
5. Stream Ciphers
5. Stream Ciphers5. Stream Ciphers
5. Stream CiphersSam Bowne
 
6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data CollectionSam Bowne
 

Mehr von Sam Bowne (20)

Cyberwar
CyberwarCyberwar
Cyberwar
 
3: DNS vulnerabilities
3: DNS vulnerabilities 3: DNS vulnerabilities
3: DNS vulnerabilities
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development Security
 
4 Mapping the Application
4 Mapping the Application4 Mapping the Application
4 Mapping the Application
 
3. Attacking iOS Applications (Part 2)
 3. Attacking iOS Applications (Part 2) 3. Attacking iOS Applications (Part 2)
3. Attacking iOS Applications (Part 2)
 
12 Elliptic Curves
12 Elliptic Curves12 Elliptic Curves
12 Elliptic Curves
 
11. Diffie-Hellman
11. Diffie-Hellman11. Diffie-Hellman
11. Diffie-Hellman
 
2a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 12a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 1
 
9 Writing Secure Android Applications
9 Writing Secure Android Applications9 Writing Secure Android Applications
9 Writing Secure Android Applications
 
12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)
 
10 RSA
10 RSA10 RSA
10 RSA
 
12 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 312 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 3
 
9. Hard Problems
9. Hard Problems9. Hard Problems
9. Hard Problems
 
8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)
 
11 Analysis Methodology
11 Analysis Methodology11 Analysis Methodology
11 Analysis Methodology
 
8. Authenticated Encryption
8. Authenticated Encryption8. Authenticated Encryption
8. Authenticated Encryption
 
7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)
 
7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)
 
5. Stream Ciphers
5. Stream Ciphers5. Stream Ciphers
5. Stream Ciphers
 
6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection
 

Kürzlich hochgeladen

Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 

Kürzlich hochgeladen (20)

Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 

Ch 7: Programming for Security Professionals

  • 1. Hands-On Ethical Hacking and Network Defense
 3 nd edition Chapter 7 Programming for Security Professionals Last modified 1-11-17
  • 2. 2 Objectives ■ Explain basic programming concepts ■ Write a simple C program ■ Explain how Web pages are created with HTML ■ Describe and create basic Perl programs ■ Explain basic object-oriented programming concepts
  • 3. 3 Introduction to Computer Programming ■ Computer programmers must understand the rules of programming languages ■ Programmers deal with syntax errors ■ One minor mistake and the program will not run ■ Or worse, it will produce unpredictable results ■ Being a good programmer takes time and patience
  • 4. 4 Computer Programming Fundamentals ■ Fundamental concepts ■ Branching, Looping, and Testing (BLT) ■ Documentation ■ Function ■ Mini program within a main program that carries out a task
  • 5. 5 Branching, Looping, and Testing (BLT) ■ Branching ■ Takes you from one area of the program to another area ■ Looping ■ Act of performing a task over and over ■ Testing ■ Verifies some condition and returns true or false
  • 6. 6 A C Program ■ Filename ends in .c ■ It's hard to read at first ■ A single missing semicolon can ruin a program
  • 7. 7 Comments ■ Comments make code easier to read
  • 10. 10 Branching, Looping, and Testing (BLT) ■ Algorithm ■ Defines steps for performing a task ■ Keep it as simple as possible ■ Bug ■ An error that causes unpredictable results ■ Pseudocode ■ English-like language used to create the structure of a program
  • 11. 11 Pseudocode For Shopping ■ PurchaseIngredients Function ■ Call GetCar Function ■ Call DriveToStore Function ■ Purchase Bacon, Bread, Tomatoes, Lettuce, and Mayonnaise ■ End PurchaseIngredients Function
  • 12. 12 Documentation ■ Documenting your work is essential ■ Add comments to your programs ■ Comments should explain what you are doing ■ Many programmers find it time consuming and tedious ■ Helps others understand your work
  • 13. 13 Bugs ■ Industry standard ■ 20 to 30 bugs for every 1000 lines of code
 (link Ch 7f) ■ Textbook claims a much smaller number without a source ■ Windows 2000 contains almost 50 million lines ■ And fewer than 60,000 bugs (about 1 per 1000 lines) ■ See link Ch 7e for comments in the leaked Win 2000 source code ■ Linux has 0.17 bugs per 1000 lines of code ■ (Link Ch 7f)
  • 14. 14 Learning the C Language ■ Developed by Dennis Ritchie at Bell Laboratories in 1972 ■ Powerful and concise language ■ UNIX was first written in assembly language and later rewritten in C ■ C++ is an enhancement of the C language ■ C is powerful but dangerous ■ Bugs can crash computers, and it's easy to leave security holes in the code
  • 15. 15 Assembly Language ■ The binary language hard-wired into the processor is machine language ■ Assembly Language uses a combination of hexadecimal numbers and expressions ■ Very powerful but hard to use (Link Ch 7g)
  • 16. 16 Compiling C in Ubuntu Linux ■ Compiler ■ Converts a text-based program (source code) into executable or binary code ■ To prepare Ubuntu Linux for C programming, use this command: sudo apt-get install build-essential ■ Then you compile a file named "program.c" with this command: gcc program.c –o program
  • 17. 17 Anatomy of a C Program ■ The first computer program a C student learns "Hello, World!"
  • 18. 18 Comments ■ Use /* and */ to comment large portions of text ■ Use // for one-line comments
  • 19. 19 Include ■ #include statement ■ Loads libraries that hold the commands and functions used in your program
  • 20. 20 Functions ■ A Function Name is always followed by parentheses ( ) ■ Curly Braces { } shows where a function begins and ends ■ main() function ■ Every C program requires a main() function ■ main() is where processing starts
  • 21. 21 Functions ■ Functions can call other functions ■ Parameters or arguments are optional ■ n represents a line feed
  • 22. 22 Declaring Variables ■ A variable represents a numeric or string value ■ You must declare a variable before using it
  • 24. 24 Mathematical Operators ■ The i++ in the example below adds one to the variable i
  • 26. 26 Logical Operators ■ The i<11 in the example below compares the variable i to 11
  • 29.
  • 31.
  • 32.
  • 33. CANARY Detecting stack smashing with a canary value
  • 34. 40 Understanding HTML Basics ■ HTML is a language used to create Web pages ■ HTML files are text files ■ Security professionals often need to examine Web pages ■ Be able to recognize when something looks suspicious
  • 35. 41 Creating a Web Page Using HTML ■ Create HTML Web page in Notepad ■ View HTML Web page in a Web browser ■ HTML does not use branching, looping, or testing ■ HTML is a static formatting language ■ Rather than a programming language ■ < and > symbols denote HTML tags ■ Each tag has a matching closing tag ■ <HTML> and </HTML>
  • 36. 42
  • 37. 43
  • 38. 44
  • 39. 45 Understanding Practical Extraction and Report Language (Perl) ■ PERL ■ Powerful scripting language ■ Used to write scripts and programs for security professionals
  • 40. 46 Background on Perl ■ Developed by Larry Wall in 1987 ■ Can run on almost any platform ■ *NIX-base OSs already have Perl installed ■ Perl syntax is similar to C ■ Hackers use Perl to write malware ■ Security professionals use Perl to perform repetitive tasks and conduct security monitoring
  • 41. 47
  • 42. 48 Understanding the Basics of Perl ■ perl –h command ■ Gives you a list of parameters used with perl
  • 43. 49
  • 44. 50 Understanding the BLT of Perl ■ Some syntax rules ■ Keyword “sub” is used in front of function names ■ Variables begin with the $ character ■ Comment lines begin with the # character ■ The & character is used when calling a function
  • 45. 51 Branching in Perl &speak; ■ Calls the subroutine sub speak ■ Defines the subroutine
  • 46. 52 For Loop in Perl ■ For loop
  • 48. 54 Understanding Object-Oriented Programming Concepts ■ New programming paradigm ■ There are several languages that support object-oriented programming ■ C++ ■ C# ■ Java ■ Perl 6.0 ■ Object Cobol
  • 49. 55 Components of Object-Oriented Programming ■ Classes ■ Structures that hold pieces of data and functions ■ The :: symbol ■ Used to separate the name of a class from a member function ■ Example: ■ Employee::GetEmp()
  • 50. 56 Example of a Class in C++ class Employee { public: char firstname[25]; char lastname[25]; char PlaceOfBirth[30]; [code continues] }; void GetEmp() { // Perform tasks to get employee info [program code goes here] }
  • 51. Ruby Example ■ Metasploit is written in Ruby ■ See link Ch 7u 57
  • 53. 53