Oct-31-2019, 09:45 PM
(This post was last modified: Oct-31-2019, 10:05 PM by ichabod801.)
I am doing an online course and when i run the program, i get an error message of:
And the other program, named vulnerability_scanner is here:
(The url is apart of metaslpoitable, a vulnerable operating system by design)
Running the program is the conventional vulnerability_scanner.py and sure enough, I get the error message.
Any and all help, along with formatting my code to whatever you guys ask would be great.
Output:Traceback (most recent call last):
File "vulnerability_scanner.py", line 9, in <module>
vuln_scanner.session.post("http://10.0.2.4/dvwa/login", data=data_dic)
AttributeError: Scanner instance has no attribute 'session'
root@kali:~/PycharmProjects/vulnerability_scanner#
Here is a copy of my code..now, im using pycharm so I have two different programs that i have separately coded that work in tandem, if you will so the scanner is here: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 |
#!/usr/bin/env python import requests import re import urlparse class Scanner: def __init__( self , url): self .target_url = url self .target_links = [] self .session = requests.Session() def extract_links_from( self , url): response = self .session.get(url) return re.findall( '(?:href=")(.*?)"' , response.content.decode( 'utf-8' , 'ignore' )) def crawl( self , url = None ): if url is None : url = self .target_url href_links = self .extract_links_from(url) for link in href_links: link = urlparse.urljoin(url, link) if "#" in link: link = link.split( "#" )[ 0 ] if self .target_url in link and link not in self .target_links: self .target_links.append(link) print (link) self .crawl(link) |
1 2 3 4 5 6 7 8 9 10 11 |
#!/usr/bin/env python import scanner data_dic = { "username" : "admin" , "password" : "password" , "Login" : "submit" } vuln_scanner = scanner.Scanner(target_url) vuln_scanner.crawl() |
Running the program is the conventional vulnerability_scanner.py and sure enough, I get the error message.
Any and all help, along with formatting my code to whatever you guys ask would be great.