日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python以下导入包的格式错误的是_ICMP python上的错误数据包

發布時間:2023/12/10 python 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python以下导入包的格式错误的是_ICMP python上的错误数据包 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

如何創建幀icmp

我在python上標記格式錯誤的包導入套接字,結構,uuid,子進程,fcntl,time,random

列表項

from binascii import hexlify,unexlify from datetime導入datetime

tarRed=原始輸入('Ingrese nombre de Tarjeta de Red Utilizada:')

subprocess.call(['ifconfig',tarRed,'promisc'])pt=0x0800秒=

插座.插座(socket.AF_包, SOCK峎生, 插座.htons(鉑))

s、 綁定(柏油,pt)

#GETCheck def getchecksum(ip_頭,大小):cksum=0 pointer=0,而size>1:cksum+=int((str(“%02x”%(ip_header[pointer],))

+str(“%02x”%(ip_頭[pointer+1],)),16)size-=2 pointer+=2#如果size:#這說明了頭是奇數的情況

#cksum+=int(ip_頭[指針])cksum=(cksum>>16)+

(cksum&0xffff)cksum+=(cksum>>16)返回(~cksum)&

0xFFFF def_checksum(data):#計算標題和

ip_header_sum=總和(解包結構(“6H”,數據))#添加進位

ip_header_sum=(ip_header_sum&0xFFFF)+(ip_header_sum>>8&

0xFFFF)ip_header_sum=~ip_header_sum&0xFFFF return

ip_header_sum def i_checksum(checksum_packet):總計=0個單詞

=len(checksum_packet)/2,用于塊輸入解包結構("!%sH“%num_words,checksum_packet[0:num_words*2]):total+=chunk if

len(校驗和數據包)%2:總計+=ord(校驗和數據包[-1])<<8

total+=total>>16返回(~total+0xffff&0xffff)def checksum(source_string): sum = 0 countTo =

(len(source_string)/2)*2 count = 0 while count

thisVal = ord(source_string[count + 1])*256 + ord(source_string[count]) sum = sum + thisVal sum = sum &

0xffffffff

count = count + 2 if countTo

0xffffffff sum = (sum >> 16) + (sum & 0xffff) sum = sum + (sum

>> 16) answer = ~sum answer = answer & 0xffff #answer = answer >> 8 | (answer << 8 & 0xff00) return answer def

checksuma(source_string): sum = 0 countTo =

(len(source_string)/2)*2 count = 0 while count

thisVal = ord(source_string[count + 1])*256 + ord(source_string[count]) sum = sum + thisVal sum = sum &

0xffffffff

count = count + 2 if countTo

0xffffffff sum = (sum >> 16) + (sum & 0xffff) sum = sum + (sum

>> 16) answer = ~sum answer = answer & 0xffff answer = answer >> 8 | (answer << 8 & 0xff00) return answer def ultimo(str):

csum = 0

countTo = (len(str) / 2) * 2

count = 0

while count < countTo:

thisVal = ord(str[count+1]) * 256 + ord(str[count])

csum = csum + thisVal

csum = csum & 0xffffffff

count = count + 2

if countTo < len(str):

csum = csum + ord(str[len(str) - 1])

csum = csum & 0xffffffff

csum = (csum >> 16) + (csum & 0xffff)

csum = csum + (csum >> 16)

answer = ~csum

answer = answer & 0xffff

answer = answer >> 8 | (answer << 8 & 0xff00)

return answer

#GETCheck

#MACs adst='ffffffffffff' mac_destino = unhexlify(adst) ma = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) info =

fcntl.ioctl(ma.fileno(), 0x8927, struct.pack('256s', tarRed[:15]))

asrc = ''.join(['%02x:' % ord(char) for char in info[18:24]])[:-1]

sd = asrc.split(':') asrc = sd[0]+sd[1]+sd[2]+sd[3]+sd[4]+sd[5]

mac_origen = unhexlify(asrc)

#MACs cabEther = struct.pack('!6s6sh',mac_destino,mac_origen,pt)

#datosIP

#version = '4'

#IHL = '5' tipoServicio = unhexlify('00') longitudT = struct.pack('!BB',00,24) identificador = struct.pack('!BB',00,01)

flag_Pos = 0x4000 tiempoVida = 05 ptIP = unhexlify('01') SCC = 0

#IPs ip = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) ipO= str( socket.inet_ntoa(fcntl.ioctl(ip.fileno(),0x8915,struct.pack('256s',

tarRed[:15]))[20:24])) ipO1 = ipO.split('.') ipOr =

struct.pack("!BBBB",int(ipO1[0]),int(ipO1[1]),int(ipO1[2]),int(ipO1[3]))

ipD = raw_input('Ingrese la direccion IP destino: ') ipD1 =

ipD.split('.') ipDest =

struct.pack("!BBBB",int(ipD1[0]),int(ipD1[1]),int(ipD1[2]),int(ipD1[3]))

#IPs

#datosIP cabIP = struct.pack('!1s1s2s2shB1sH4s4s',unhexlify('45'),tipoServicio,longitudT,identificador,flag_Pos,tiempoVida,ptIP,SCC,ipOr,ipDest)

SCC = checksum(cabIP) cabIP =

struct.pack('!1s1s2s2shB1sH4s4s',unhexlify('45'),tipoServicio,longitudT,identificador,flag_Pos,tiempoVida,ptIP,socket.htons(SCC),ipOr,ipDest)

#datosIcmp tipo = 8 codigo = 0x00 check = 0x0000 identificador = int((id(1) * random.random()) % 65535) secuencia = 0x0000

#datos = 'qwertyasdfghzxcvbn0102030405060708091011121314151617181920' datos =

1 * 'Q'

#datosIcmp cabIcmp = struct.pack('!bbHHh',tipo,0,0,identificador,1) my_checksum = ultimo(cabIcmp + datos) cabIcmp =

struct.pack('!bbHHh',tipo,0,socket.htons(my_checksum),identificador,1)

cabIcmp = cabIcmp + datos tiempo = datetime.now() print tiempo for i

in range(15): s.send(cabEther + cabIP + cabIcmp,0)

總結

以上是生活随笔為你收集整理的python以下导入包的格式错误的是_ICMP python上的错误数据包的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。