pls help me with this code

pls help me with this code

Postby chronos » Sat Nov 02, 2013 3:26 pm

Code: Select all
import socket
def retBanner(ip, port):
        s = socket.socket()
        s.connect((ip, port))
        banner = s.recv(1024)
        return banner
    def main():
        ip1 = ''
        ip2 = ''
        port = 22
        banner1 = retBanner(ip1, port)
if banner1:
    print '[+] ' + ip1 + ': ' + banner1
        banner2 = retBanner(ip2, port)
if banner2:
    print '[+] ' + ip2 + ': ' + banner2
if __name__ == '__main__':

the error code is: ip1 is not defined.
Last edited by Yoriz on Sat Nov 02, 2013 4:02 pm, edited 1 time in total.
Reason: First post lock, Added code tags
Posts: 1
Joined: Sat Nov 02, 2013 3:09 pm

Re: pls help me with this code

Postby Yoriz » Sat Nov 02, 2013 4:05 pm

Hi, welcome to the forum.
Please read the 'new users read this' link in my signature.
I added code tags to your code please use them as stated in the link otherwise the indentation of your code is not shown.

Your if banner1 and if banner2 are not indented to be inside your main function, hence ip1 is local to main function and throws the error, also main def indentation is wrong.
Due to the reasons discussed here we will be moving to on October 1 2016
This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
User avatar
Posts: 1672
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Return to Networking

Who is online

Users browsing this forum: No registered users and 4 guests