Browse Source

PyNessus Generate Activation Code Updated

Umar Farook 5 years ago
parent
commit
1ee70b08e4
6 changed files with 207 additions and 95 deletions
  1. 0 32
      NessusReg.py
  2. 70 0
      Nessus_Activation_Code.py
  3. 21 14
      README.md
  4. 0 49
      TempMailServer.py
  5. 97 0
      Tempmail/tempmail.py
  6. 19 0
      setup.py

+ 0 - 32
NessusReg.py

@@ -1,32 +0,0 @@
-#!/usr/bin/python3
-print("==================================================================")
-print("  Welcome !  to  ! Nessus Home  activation code Generation ! Service ! ")
-print("       Don't misuse this script other then for pentesting purpose      ")
-print("                This script written  on Python 3 modules                  ")
-print("                          Author:anonmech                                   ")
-print("==================================================================")
-
-
-from urllib.request import urlopen
-from bs4 import BeautifulSoup
-import requests
-ht=urlopen("https://www.tenable.com/products/nessus-home")
-bs=BeautifulSoup(ht,'html.parser')
-for link in bs.findAll("input",{"name":"token"}):
- if 'name' in link.attrs:
-   tkn=link.attrs['value']
- else:
-   print("not found")
-fname=input("First Name:")
-lname=input("Last Name:")
-email=input("Email:")
-params={"first_name":fname,"last_name":lname,"email":email,"country":"IN","Accept":"Agree","robot":"human","type":"homefeed","token":tkn,"submit":"Register"}
-r = requests.post("https://www.tenable.com/products/nessus-home", data=params)
-bs=BeautifulSoup(r.text,'html.parser')
-for link in bs.findAll("meta",{"content":"Thank you for registering for Nessus Home. An email containing your activation code has been sent to you at the email address you provided."}):
- if 'content' in link.attrs:
-    print(link.attrs['content'])
- else:
-    print("something went wrong")
-
-

+ 70 - 0
Nessus_Activation_Code.py

@@ -0,0 +1,70 @@
+from bs4 import BeautifulSoup
+import requests
+import time
+import re
+from tempmail import TempMail
+import os
+import sys
+
+def banner():
+	print("==================================================================")
+	print("            Generate Multiple Nessus Activation code                       ")
+	print("   Don't misuse this script other then for Pentesting purpose              ")
+	print("                      \033[1;31;10mBy:Fools of Security :)\033[1;31;0m     ")
+	print("==================================================================")
+
+
+def nessus_activation():
+	tmp = TempMail()
+	email = tmp.get_email_address()  
+	print("Your Temp mail address is successfully created!")
+	print ("Email Address: "+ email)
+	# print tmp.get_mailbox(email)  
+	#Nessus Registeration Form
+	print ("\033[1;32;10mNessus Registeration Form \033[1;32;0m")
+	ht=requests.get("https://www.tenable.com/products/nessus-home")
+	bs=BeautifulSoup(ht.text,'html.parser')
+	for link in bs.findAll("input",{"name":"token"}):
+	 if 'name' in link.attrs:
+	   tkn=link.attrs['value']
+	 else:
+	   print("not found")
+	fname=raw_input("First Name:")
+	lname=raw_input("Last Name:")
+	# nes_email=raw_input("Email:")
+	params={"first_name":fname,"last_name":lname,"email":email,"country":"IN","Accept":"Agree","robot":"human","type":"homefeed","token":tkn,"submit":"Register"}
+	r = requests.post("https://www.tenable.com/products/nessus-home", data=params)
+	if r.status_code == 200:
+		bs=BeautifulSoup(r.text,'html.parser')
+		keyword=bs.find("title").get_text()
+		success=keyword.split('|')
+		if str(success[0][:-1]) == 'Thank You for Registering for Nessus Home!':
+			print('\033[1;32;10m'+str(success[0][:-1])+'\033[1;32;0m')
+			while  True:
+				if tmp.get_mailbox(email):
+					for emails in tmp.get_mailbox(email):
+						if emails['mail_subject'] == 'Tenable Nessus Home Activation Code':
+							message=emails['mail_text']
+							receive=raw_input("To check for Nessus Activation Code in Inbox, press enter")
+							regex = r"\w{4}(?:-\w{4}){4}"
+							activation_code=re.search(regex,message)
+							print('\033[1;32;10mNessus Activation Code is:\033[1;32;0m'+activation_code.group())
+							sys.exit()
+				else:
+					print ('There are no emails yet....')
+
+		elif bs.find('span',{"style":"color:#FF0000;"}).get_text():
+			os.system('clear')
+			# print('\033[1;31;10m'+bs.find('span',{"style":"color:#FF0000;"}).get_text()+'\033[1;31;0m')
+			print('\033[1;31;10m Sorry, This Email Address is already Registered for Nessus Activation Code\033[1;31;0m')
+			print("Wait..Regenerating new Temp email address")
+			nessus_activation()
+	else:
+		print("something went wrong with the request")
+		sys.exit()
+
+
+if __name__ == "__main__":
+	banner()
+	nessus_activation()
+

+ 21 - 14
README.md

@@ -1,25 +1,32 @@
-# Nessus-Home-Activation-Key-Generation
+## Nessus Activation Code:
+ Generate Multiple Nessus Activation Code for Home Version using Temp Mail Service.
 
-Nessus Home Activation Key Generation without visiting a Nessus website by python script
+### Dependencies:
+* Python 2.7+
+* requests module
 
-NessusReg.py/TempMailServer.py:
-Usage:
+### How to install and generate Multiple Nessus Activation Code:
+1. Install the Temp Mail Python Package.<br>
 
-Run Nessusreg.py script to register a new Nessus account to receive activation code to ur mail.
+   ``Python setup.py install``
+2. Run the Nessus_activation_code.py script.
 
-Enter ur first name and last name,then i know u need a mail id to receive so i create a TempMailServer.py script to get a temporary mail service to recieve a nessus activation code.
+3. It will a new Temp Email and Prompt to enter First name and Last name for Nessus Registeration Form.
 
-Then run TempMailServer.py and enter ur random id and domain name to get new mail id.
+4. Press Enter to check the Inbox to get Nessus Activation code.
+   
+### Updates
+If you want new features, create an issue report and label it as enhancement Or start a pull request on our repositories.
 
-you will see the message mail was sucessfully created and then wait for a moment before pressing enter go to other terminal where you run NessusReg.py script and enter ur mail id and press enter.
 
-Move to TempMailServer.py terminal now press enter to recieve your aactivation code.
+### Credits:
+* FOS Team : [Fools of Security](https://www.youtube.com/channel/UCEBHO0kD1WFvIhf9wBCU-VQ)
 
-you can use this script for many times to create  temporary mail id to get nessus activation code after the IP limit exceeds in Nessus Vulnerability Scanner in Home version.
-
-Next  my  Python script is to  get activation code for Nessus Professional Version..
-
-Thank You......
+### Support !
+ Email address: pingus@foolsofsecurity.com for more details. <br>
+ Youtube: [Fool of Security](https://www.youtube.com/channel/UCEBHO0kD1WFvIhf9wBCU-VQ) <br>
+ Official Website: [Fools of security](http://foolsofsecurity.com/) <br>
+ Blog: [Fools of security](https://fosecurity.blogspot.com) 
 
 
 

+ 0 - 49
TempMailServer.py

@@ -1,49 +0,0 @@
-#!/usr/bin/python3
-print("==================================================================")
-print("            Welcome !  to  ! Temp Mail ! Service ! ")
-print("   Don't misuse this script other then for pentesting purpose  ")
-print("            This script written  on Python 3 modules                  ")
-print("                      Author:anonmech                             ")
-print("==================================================================")
-from urllib.request import urlopen
-from bs4 import BeautifulSoup
-import requests
-session = requests.Session()
-ht=session.get("https://temp-mail.org/en/option/change")
-bs=BeautifulSoup(ht.text,'html.parser')
-#print("Cookie is set to:")
-#print(ht.cookies.get_dict())
-for  link in bs.findAll("input",{"name":"csrf"}):
-  if 'name' in link.attrs:
-   token=link.attrs['value']
-   print("Csrf token is ",token)
-  else:
-   print("somethings went wrong")
-mail_id=input("Choose Your Mail ID:")
-print("@polyfaust.com\n@cartelera.org")
-domain_name=input("Choose Your Mail Domain:")
-params={"csrf":token,"mail":mail_id,"domain":domain_name}
-r=session.post("https://temp-mail.org/en/option/change",params)
-bs=BeautifulSoup(r.text,'html.parser')
-for link in bs.findAll("button",{"data-dismiss":"alert"}):
-  if 'data-dismiss' in link.attrs:
-     print("The mail address is successfully created!")
-     print("your mail id is" +mail_id+domain_name)
-  else:
-     print("somethings went wrong")
-receive=input("if you read to recieve mail then press enter")
-ht=session.get("https://temp-mail.org/en/")
-bs=BeautifulSoup(ht.text,'html.parser')
-for link in bs.findAll("a",{"title":"Tenable Nessus Home Activation Code"}):
-  if 'title' in link.attrs:
-     url=link.attrs['href']
-     print(url)
-  else:
-      print("somethings went wrong")
-url1=str(url)
-ht=session.get(url1)
-bs=BeautifulSoup(ht.text,'html.parser')
-message=bs.findAll("div",{"data-x-div-type":"body"})
-for msg in message:
-     print(msg.get_text())
-

+ 97 - 0
Tempmail/tempmail.py

@@ -0,0 +1,97 @@
+import string
+import random
+from hashlib import md5
+
+import requests
+
+
+class TempMail(object):
+    """
+    API Wrapper for service which provides temporary email address.
+
+    :param login: (optional) login for email address.
+    :param domain: (optional) domain (from current available)
+    for email address.
+    :param api_domain: (optional) domain for temp-mail api.
+    Default value is ``api.temp-mail.ru``.
+    """
+
+    def __init__(self, login=None, domain=None, api_domain='api.temp-mail.ru'):
+        self.login = login
+        self.domain = domain
+        self.api_domain = api_domain
+
+    def __repr__(self):
+        return u'<TempMail [{0}]>'.format(self.get_email_address())
+
+    @property
+    def available_domains(self):
+        """
+        Return list of available domains for use in email address.
+        """
+        if not hasattr(self, '_available_domains'):
+            url = 'http://{0}/request/domains/format/json/'.format(
+                self.api_domain)
+            req = requests.get(url)
+            domains = req.json()
+            setattr(self, '_available_domains', domains)
+        return self._available_domains
+
+    def generate_login(self, min_length=6, max_length=10, digits=True):
+        """
+        Generate string for email address login with defined length and
+        alphabet.
+
+        :param min_length: (optional) min login length.
+        Default value is ``6``.
+        :param max_length: (optional) max login length.
+        Default value is ``10``.
+        :param digits: (optional) use digits in login generation.
+        Default value is ``True``.
+        """
+        chars = string.ascii_lowercase
+        if digits:
+            chars += string.digits
+        length = random.randint(min_length, max_length)
+        return ''.join(random.choice(chars) for x in range(length))
+
+    def get_email_address(self):
+        """
+        Return full email address from login and domain from params in class
+        initialization or generate new.
+        """
+        if self.login is None:
+            self.login = self.generate_login()
+
+        available_domains = self.available_domains
+        if self.domain is None:
+            self.domain = random.choice(available_domains)
+        elif self.domain not in available_domains:
+            raise ValueError('Domain not found in available domains!')
+        return u'{0}{1}'.format(self.login, self.domain)
+
+    def get_hash(self, email):
+        """
+        Return md5 hash for given email address.
+
+        :param email: email address for generate md5 hash.
+        """
+        return md5(email).hexdigest()
+
+    def get_mailbox(self, email=None, email_hash=None):
+        """
+        Return list of emails in given email address
+        or dict with `error` key if mail box is empty.
+
+        :param email: (optional) email address.
+        :param email_hash: (optional) md5 hash from email address.
+        """
+        if email is None:
+            email = self.get_email_address()
+        if email_hash is None:
+            email_hash = self.get_hash(email)
+
+        url = 'http://{0}/request/mail/id/{1}/format/json/'.format(
+            self.api_domain, email_hash)
+        req = requests.get(url)
+        return req.json()

+ 19 - 0
setup.py

@@ -0,0 +1,19 @@
+from distutils.core import setup
+
+install_dependencies = (
+    'requests == 2.8.14',
+    'bs4 == 0.0.1'
+)
+
+
+setup(
+    name='Tempmail',
+    version='0.1',
+    packages=[''],
+    package_dir={'': 'Tempmail'},
+    url='',
+    license='MIT License',
+    author='Umar Farook',
+    author_email='Twitter: @umarfarook882',
+    description='Generate Temporary Email Address  to register and get Nessus Activation Code'
+)