Hello guys, I'm trying to build a simple port scanner, but I constantly got this error : ''str' object is not callable"
I really don't know why I'm getting it, I did not assign a var as str, e.g : str= 'hello'. I tried to review my script quite few times now, I looked the problem up on the web, still nothing. Thank you for your help. (P.S : just had to create a brand new account, cuz the forum moved and I wasn't able to login anymore, or recuperate my password)
I really don't know why I'm getting it, I did not assign a var as str, e.g : str= 'hello'. I tried to review my script quite few times now, I looked the problem up on the web, still nothing. Thank you for your help. (P.S : just had to create a brand new account, cuz the forum moved and I wasn't able to login anymore, or recuperate my password)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
from socket import * def port_scanner(host,port): socket = ' ' try : socket = socket(AF_INET,SOCK_STREAM) socket.connect(host, int (port)) # tried to double the parentheses here, still did not work result = '[>]' + host + ' :is opened on:' + str (port) print result except Exception,e: print e print '[!]' + host + ' is not opened on' + str (port) def main(): totalchars = 0 totalpoints = 0 listofports = [ '80' , '21' , '22' ] host = gethostbyname( 'www.xxxx.com' ) for char in host: totalchars = 1 + totalchars if char = = '.' : totalpoints = 1 + totalpoints if totalpoints = = 3 : hostfixed = host[:totalchars] for num in range ( 1 , 255 ): num1 = str (num) host1 = hostfixed + num1 #I've also tried ...+str(num) and it does not work. for port in listofports: port_scanner(host1,port) main() |