#!/usr/bin/python3
import os
import requests
from cyberonix.main.tools import banner,colors,template
from bs4 import BeautifulSoup

def main():
    while True:
        os.system("clear")
        banner.main()
        banner.attack("Vulnerability Analysis")
        list_attacks=["Wpscan","Wireshark","Wapiti","Nmap","Legion","Nikto","go back"]
        for i in range(len(list_attacks)):
                print(colors.options,f"{i}) {list_attacks[i]}".title(),colors.reset)
        try:
            option = input(f"\n {colors.select}Select An Option ->{colors.reset}  ")
        except KeyboardInterrupt:
            template.exit_program()
        if option=="0":
            print("\n[+] Wpscan")
            os.system("clear")
            github = "WPScan is a security scanner designed for testing the security of websites built using WordPress. WPScan was developed using the Ruby programming language and then released in the first version in 2019. The WPScan security scanner is primarily intended to be used by WordPress administrators and security teams to assess the security status of their WordPress installations. It is used to scan WordPress websites for known vulnerabilities both in WordPress and commonly used WordPress plugins and themes. The code base for WPScan is licensed under GPLv3"
            template.template("wpscan","wpscan -h",github.strip(),{'WPScan Intro: How to Scan for WordPress Vulnerabilities':'https://blog.sucuri.net/2021/05/wpscan-how-to-scan-for-wordpress-vulnerabilities.html/','WPScan:WordPress Pentesting Framework':'https://www.hackingarticles.in/wpscanwordpress-pentesting-framework/','How To Use WPScan to Test for Vulnerable Plugins and Themes in Wordpress':"https://www.digitalocean.com/community/tutorials/how-to-use-wpscan-to-test-for-vulnerable-plugins-and-themes-in-wordpress","How to Use wpscan tool in Kali Linux":"https://www.geeksforgeeks.org/how-to-use-wpscan-tool-in-kali-linux/","WPScan Usage Example [Enumeration + Exploit]":"https://www.cyberpunk.rs/wpscan-usage-example"})
        elif option=="1":
            print("\n[+] Wireshark")
            os.system("clear")
            github=github_getting_text("https://github.com/wireshark/wireshark",'p[dir="auto"]',0)
            template.template("wireshark","wireshark",github.strip(),{'How To Install & Use Wireshark On Kali Linux':'https://infosecscout.com/wireshark-on-kali-linux/','Wireshark Tool Documentation':'https://www.kali.org/tools/wireshark/','Wireshark Training':'https://www.wireshark.org/docs/','Wireshark – Resources':'https://blog.inf.ed.ac.uk/atate/2023/01/14/wireshark-resources/','Kerberos Wireshark Captures: A Windows Login Example':'https://medium.com/@robert.broeckelmann/kerberos-wireshark-captures-a-windows-login-example-151fabf3375a','Wireshark – Packet Capturing and Analyzing':'https://www.geeksforgeeks.org/wireshark-packet-capturing-and-analyzing/','https://unit42.paloaltonetworks.com/wireshark-tutorial-decrypting-https-traffic/':'https://unit42.paloaltonetworks.com/wireshark-tutorial-decrypting-https-traffic/'})
        elif option=="2":
            print("\n[+] Wapiti")
            os.system("clear")
            github=github_getting_text("https://github.com/wapiti-scanner/wapiti",'p[dir="auto"]',6)
            template.template("wapiti","wapiti",github.strip(),{"wapiti free web application vulnerability scanner":"https://pentestit.medium.com/wapiti-free-web-application-vulnerability-scanner-ce7712adf644","Official docs":"https://github.com/wapiti-scanner/wapiti","wapiti tutorial":"https://www.kalilinux.in/2021/01/wapiti-tutorial.html","complete guide to using wapiti web vulnerability scanner to keep your web applications websites secure":"https://linuxsecurity.com/features/complete-guide-to-using-wapiti-web-vulnerability-scanner-to-keep-your-web-applications-websites-secure"})
        elif option=="3":
            print("\n[+] Nmap")
            os.system("clear")
            github = "Nmap (Network Mapper) is a network scanner created by Gordon Lyon (also known by his pseudonym Fyodor Vaskovich). Nmap is used to discover hosts and services on a computer network by sending packets and analyzing the responses."
            template.template("nmap","nmap -h",github.strip(),{"Nmap Cheat-Sheet":"https://www.stationx.net/nmap-cheat-sheet/","Official website":"https://nmap.org/ ","Other resources":"https://linux.die.net/man/1/nmap"})            
        elif option=="4":
            print("\n[+] Legion")
            os.system("clear")
            github=github_getting_text("https://github.com/GoVanguard/legion",'p[class="f4 my-3"]',0)
            template.template("legion","legion",github.strip(),{'Legion Tool in Kali Linux':'https://www.geeksforgeeks.org/legion-tool-in-kali-linux','Legion -- Test Web Application Vulnerability Automatically':'https://www.kalilinux.in/2020/09/legion-kali-linux.html','How to use Legion application in Kali Linux | Information Gathering':'https://www.youtube.com/watch?v=5UAfXbP5Y0k'})
        elif option=="5":
            print("\n[+] Nikto")
            os.system("clear")
            github=github_getting_text("https://en.wikipedia.org/wiki/Nikto_(vulnerability_scanner)",'p',1)
            template.template("nikto","nikto -h",github.strip(),{'What is Nikto and it’s usages ?':'https://www.geeksforgeeks.org/what-is-nikto-and-its-usages/','Nikto: A Practical Website Vulnerability Scanner':'https://securitytrails.com/blog/nikto-website-vulnerability-scanner','Nikto Official Docs':'https://github.com/sullo/nikto/wiki'})
        else:
            return

def github_getting_text(link,selector,indexvalue):
    print("Please Wait....\r",end="")
    URL = link
    try:
        r = requests.get(URL)
        soup = BeautifulSoup(r.content, 'html.parser')
        paras = soup.select(selector)
        #check index value from test file
        return paras[indexvalue].text
    except:
        return f"{colors.red}NotLloaded Because No Internet Connection{colors.reset}"

def tool_writeups():
    print(f"{colors.options}1) TOOL(About,Installation)")
    print(f"2) Write Ups")
    print(f"3) Go Back..")
    try:
        ask=input(f"\n {colors.select}Select An Option ->{colors.reset}  ")
    except KeyboardInterrupt:
        template.exit_program()
    return ask

if __name__=='__main__':
    main()
