Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Top Posters

Who's Online (2)

Powered by Vanilla. Made with Bootstrap.
Python Syntax Error Please Help
  • Xin
    Posts: 3,251
    ## pyScope 0.1
    ## Xinapse's Shodan, Exploit_DB, Metasploit Search Tool
    from shodan import WebAPI

    SHODAN_API_KEY = \"key\"

    api = WebAPI(SHODAN_API_KEY)
    print 'pyScope by Xinapse'
    print '1) Host Scan (Scan just one Server)'
    print '2) Service Scan (Search for all servers running a service'
    print '3) Search ExploitDB for a particular version'

    choice = int(raw_input('What Scan would you like? '))
    ## Choice which scan

    if choice == 1: ## Host Scan
    print '1'
    target = raw_input('Enter the target: ')
    host = api.host(target)

    print \"\"\"
    IP: %s
    Country: %s
    City: %s
    \"\"\" % (host['ip'], host.get('country', None), host.get('city', None))

    # Print all banners
    for item in host['data']:
    print \"\"\"
    Port: %s
    Banner: %s

    \"\"\" % (item['port'], item['banner'])


    elif choice == 2: ## Service Scan
    keyword = raw_input('Enter keyword: ')
    try:
    print (\"Searching...\")
    results = api.search(keyword)

    print results[\"total\"]
    for result in results[\"matches\"]:
    print result[\"ip\"]
    print result[\"data\"]
    print ''
    except Exception, e:
    print 'Error: %s' % e







    elif choice == 3:
    search = int(raw_input('Enter Keyword: '))
    results = api.exploitdb.search(search)
    print 'Results found: '
    print results['total']
    for exploit in results['matches']:
    print '%s: %s' % (exploit['id'], exploit['description'])
    print ' '

    sploitnumber = int(raw_input('Enter ID of the Exploit to Download: ')

    file = api.exploitdb.download(exploit[sploitnumber])


    print 'Filename: %s' % file['filename']
    print 'Content-type: %s' % file['content-type']
    print file['data']




    else:
    print 'Invalid Option'


    file = api.exploitdb.download(exploit[sploitnumber])

    Is getting a syntax error and im pretty new to python can anyone help? Thanks
    Xin
  • Sh3llc0d3
    Posts: 1,910
    Probably won't be much help but what's the syntax error? Any info on what line etc?
  • sangf
    Posts: 203
    you missed an ending bracket on the previous line, just a silly mistake :P

    sploitnumber = int(raw_input('Enter ID of the Exploit to Download: ')


    sploitnumber = int(raw_input('Enter ID of the Exploit to Download: '))

    usually when you get a syntax error on a line that looks fine it's because of the previous code as it falls through and starts parsing whatever comes next out of line.
  • undead
    Posts: 822
    Write it like that so you won't forget it:
    sploitnumber = int()
    and then put raw_input('Enter ID of the Exploit to Download: ') inside int()
  • Xin
    Posts: 3,251
    Bursihido fixed it for me on IRC Thanks guys :) it was the missing bracket.
    Xin
This discussion has been closed.
All Discussions