Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python error : X() takes exactly 1 argument (8 given)

Tags:

python

I'm trying to bulid an Anonymous FTP scanner , but i got an error about calling function X , i defined X to recieve ony 1 arguement which is the ip address , the same code works if i don't use the loop and send the IPs one by one .

The error is : X() takes exactly 1 argument (8 given)

from ftplib import FTP
import ipcalc
from threading import Thread


def X (ip):
    try:
        ftp = FTP(ip)
        x = ftp.login()
        if 'ogged' in  str(x):
            print '[+] Bingo ! we got a Anonymous FTP server IP: ' +ip
    except:
        return


def main ():
    global ip
    for ip in ipcalc.Network('10.0.2.0/24'):
        ip = str(ip)
        t =  Thread (target = X, args = ip)
        t.start()
main ()
like image 525
fooBar Avatar asked Mar 03 '13 18:03

fooBar


1 Answers

When constructing Thread objects, args should be a sequence of arguments, but you are passing in a string. This causes Python to iterate over the string and treat each character as an argument.

You can use a tuple containing one element:

t =  Thread (target = X, args = (ip,))

or a list:

t =  Thread (target = X, args = [ip])
like image 87
interjay Avatar answered Oct 23 '22 09:10

interjay