JEFF HOWELL
  • Home
  • About
  • Cyber Security Fundementals
    • Threats and Vulnerabilities
    • Reference Monitor
    • Links to Additional Resources
  • Cryptography
    • Block Ciphers
    • Hash Functions
    • Message Authentication Codes (MAC's)
    • Kerberos Key Management (Single sign-on)
    • Public Key Infrastructure (PKI)
    • Links to Additional Resources
  • Secure Architecture
    • Architecture Strategy
    • Contextual Security Architecture
    • Conceptual Security Architecture
    • Logical Security Architecture
    • Physical Security Architecture
    • Component Security Architecture
    • Operations
    • Supporting Materials
  • Reference Link Library
    • Industry Websites
    • Government Resources
    • Cyber Security News
    • Certification and Training
    • Books
    • Cyber Security Tools
  • Risk Management
    • Supporting Materials
  • Operational Policy
    • Laws and Regualations
    • Data Classification
    • Policy Implementation and Enforcement
    • Supporting Materials
  • Management and Cyber Security
    • Contingency Planning
    • ROI of Cyber Security
    • Staffing Models
    • Links to Additional Resources
  • Secure Software Design and Development
    • Heartbleed Details
    • Mobile Device Vulnerabilities
    • Links to Additional Resources
  • Network Visualization and Vulnerability Detection
    • Visualizing the Network
    • Protecting the Perimeter
    • Vulnerability Detection
    • Sniffing Wireless Networks
    • Links to Additional Resources
  • Cyber Threat Intelligence
    • Links to Additional Resources
  • Incident Response and Computer Network Forensics
    • Links to Additional Resources

DoS Attack Simulation using Python

Server code ….<scroll-down for the client code>
​#!/usr/bin/python
#the threading function allows us to enable multi-threading so we can have simultaneous connecitons on the server
from socket import *
from threading import Thread
#open a list to read clients
clients = [] 
#funciton to manage client sockets
def clientHandler(c, addr):    
    global clients
    print(addr, "is Connected")
   
#Loop to validate sockets, terminates at EoF.
    try:
        while True:
            data = c.recv(1024)
            if not data:
                break
            for client in clients:
                if addr != client:
                    c.send(data, client)
    except:
        print("Error. Data not sent to all clients.")
#defines port server will listen to on host machine
HOST = '' #localhost
PORT = 8000
#creates port and listens to up to five a socket that used as an internet standard and specifically as IPV4.
#Socket is created an will listen to up to 5 clients simultaneously
s = socket(AF_INET, SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(5)
#notifies the user the server is running
print("Server is running on "+ str(PORT))
trds = []
for i in range(5):
    c, addr = s.accept()
    clients.append(addr)
    t = Thread(target=clientHandler, args = (c, addr))
    trds.append(t)
    t.start()
for t in trds:
    t.join()
Client
​#!/usr/bin/python
from socket import *
s = socket()
s.connect(('', 8000))
s.send('I am client 1')
s.close()

from socket import *
s = socket()
s.connect(('', 8000))
s.send('I am client 2')
s.close()

from socket import *
s = socket()
s.connect(('', 8000))
s.send('I am client 3')
s.close()

from socket import *
s = socket()
s.connect(('', 8000))
s.send('I am client 4')
s.close()
​
from socket import *
s = socket()
s.connect(('', 8000))
s.send('I am client 5')
s.close()
Jeff Howell  -  San Carlos, CA  -  Privacy Statement - email Jeff
  • Home
  • About
  • Cyber Security Fundementals
    • Threats and Vulnerabilities
    • Reference Monitor
    • Links to Additional Resources
  • Cryptography
    • Block Ciphers
    • Hash Functions
    • Message Authentication Codes (MAC's)
    • Kerberos Key Management (Single sign-on)
    • Public Key Infrastructure (PKI)
    • Links to Additional Resources
  • Secure Architecture
    • Architecture Strategy
    • Contextual Security Architecture
    • Conceptual Security Architecture
    • Logical Security Architecture
    • Physical Security Architecture
    • Component Security Architecture
    • Operations
    • Supporting Materials
  • Reference Link Library
    • Industry Websites
    • Government Resources
    • Cyber Security News
    • Certification and Training
    • Books
    • Cyber Security Tools
  • Risk Management
    • Supporting Materials
  • Operational Policy
    • Laws and Regualations
    • Data Classification
    • Policy Implementation and Enforcement
    • Supporting Materials
  • Management and Cyber Security
    • Contingency Planning
    • ROI of Cyber Security
    • Staffing Models
    • Links to Additional Resources
  • Secure Software Design and Development
    • Heartbleed Details
    • Mobile Device Vulnerabilities
    • Links to Additional Resources
  • Network Visualization and Vulnerability Detection
    • Visualizing the Network
    • Protecting the Perimeter
    • Vulnerability Detection
    • Sniffing Wireless Networks
    • Links to Additional Resources
  • Cyber Threat Intelligence
    • Links to Additional Resources
  • Incident Response and Computer Network Forensics
    • Links to Additional Resources