haroonawanofficial / XSSInspector-SecurityToolkit

XSSInspector can defeat any WAF in the world with its AI and 96 filter set. This open-source solution simplifies XSS vulnerability identification and mitigation, serving as a valuable asset for security experts and developers.
3 stars 2 forks source link

AttributeError: 'XSSScanner' object has no attribute 'store_vulnerabilities_in_sqlite' #1

Open Archurcl4w opened 1 month ago

Archurcl4w commented 1 month ago

Hello, I am testing xssinspector.py by cloning the repository and installing the required dependencies on Kali Linux 6.8.11-amd64 .After running a couple of minutes, it had errors such as

Traceback (most recent call last):
  File "/home/user/XSSInspector-SecurityToolkit/xssinspector.py", line 691, in <module>
    vulnerable_urls = scan.start()  # Start scanning for XSS vulnerabilities
                      ^^^^^^^^^^^^
  File "/home/user/XSSInspector-SecurityToolkit/xssinspector.py", line 616, in start
    self.store_vulnerabilities_in_sqlite()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'XSSScanner' object has no attribute 'store_vulnerabilities_in_sqlite'

It indicated that the XSScanner class does not have the method called store_vulnerabilities_in_sqlite, but the Python code attempted to call it otherwise. It could cause 1. Missing Method and 2. Code Inconsistency. When looking at the XSScanner class in the xssinspector.py script and checking whether there is a method named store_vulnerabilities_in_sqlite by the command

grep "def store_vulnerabilities_in_sqlite" ~/XSSInspector-SecurityToolkit/xssinspector.py     

The output of this command returns blank. It shows that the method is missing or not properly implemented, but the script is supposed to store results in an SQLite database anyway. The only workaround at the moment is to comment out them.

# self.store_vulnerabilities_in_sqlite()
# self.generate_report()

After that, xssinspector.py running without errors until finishing the scan. But it failed to generate any reports as it should be. The fix could be reimplemented the method store_vulnerabilities_in_sqlite and to work it properly. An example code of the missing method something like -

def store_vulnerabilities_in_sqlite(self):
        conn = sqlite3.connect('vulnerabilities.db')
        c = conn.cursor()
        c.execute('''
            CREATE TABLE IF NOT EXISTS vulnerabilities (
                id INTEGER PRIMARY KEY AUTOINCREMENT,
                url TEXT,
                payload TEXT,
                scan_time TEXT
            )
        ''')
        for url in self.vulnerable_urls:
            payload = 'xss_payload'
            start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
            c.execute('INSERT INTO vulnerabilities (url, payload, scan_time) VALUES (?, ?, ?)',
                      (url, payload, start_time))
        conn.commit()
        conn.close()
hendrafebriiiii commented 3 weeks ago

this works sir?

Halo, saya menguji xssinspector.py dengan mengkloning repositori dan menginstal dependensi yang diperlukan pada Kali Linux 6.8.11-amd64 . Setelah berjalan beberapa menit, muncul kesalahan seperti

Traceback (most recent call last):
  File "/home/user/XSSInspector-SecurityToolkit/xssinspector.py", line 691, in <module>
    vulnerable_urls = scan.start()  # Start scanning for XSS vulnerabilities
                      ^^^^^^^^^^^^
  File "/home/user/XSSInspector-SecurityToolkit/xssinspector.py", line 616, in start
    self.store_vulnerabilities_in_sqlite()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'XSSScanner' object has no attribute 'store_vulnerabilities_in_sqlite'

Hal ini menunjukkan bahwa kelas XSScanner tidak memiliki metode yang disebut store_vulnerabilities_in_sqlite, tetapi kode Python mencoba memanggilnya dengan cara lain. Hal ini dapat menyebabkan 1. Metode Hilang dan 2. Ketidakkonsistenan Kode. Saat melihat kelas XSScanner dalam skrip xssinspector.py dan memeriksa apakah ada metode bernama store_vulnerabilities_in_sqlite dengan perintah

grep "def store_vulnerabilities_in_sqlite" ~/XSSInspector-SecurityToolkit/xssinspector.py     

Output dari perintah ini mengembalikan kosong. Ini menunjukkan bahwa metode tersebut hilang atau tidak diterapkan dengan benar, tetapi skrip tersebut seharusnya menyimpan hasil dalam database SQLite. Satu-satunya solusi saat ini adalah mengomentarinya.

# self.store_vulnerabilities_in_sqlite()
# self.generate_report()

Setelah itu, xssinspector.py berjalan tanpa kesalahan hingga pemindaian selesai. Namun gagal menghasilkan laporan sebagaimana mestinya. Perbaikannya dapat dilakukan dengan mengimplementasikan kembali metode store_vulnerabilities_in_sqlite dan membuatnya berfungsi dengan baik. Contoh kode metode yang hilang seperti -

def store_vulnerabilities_in_sqlite(self):
        conn = sqlite3.connect('vulnerabilities.db')
        c = conn.cursor()
        c.execute('''
            CREATE TABLE IF NOT EXISTS vulnerabilities (
                id INTEGER PRIMARY KEY AUTOINCREMENT,
                url TEXT,
                payload TEXT,
                scan_time TEXT
            )
        ''')
        for url in self.vulnerable_urls:
            payload = 'xss_payload'
            start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
            c.execute('INSERT INTO vulnerabilities (url, payload, scan_time) VALUES (?, ?, ?)',
                      (url, payload, start_time))
        conn.commit()
        conn.close()
haroonawanofficial commented 1 day ago

I will update it within a day. Thank you for pointing that out. Both of you are absolutely correct, and it has been fixed. I am still testing it, though