-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathNessusGetHomeCode.py
executable file
·88 lines (74 loc) · 4.36 KB
/
NessusGetHomeCode.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/python3
r'''
Copyright 2025 Photubias(c)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File name GetNessusHomeCode.py
written by Photubias(c)
This script will use the Official Tenable website and generate legal
Nessus Essentials Registration Code.
Only requirement is an internet connection to tenable.com and mailinator.com
Of course: no warranty when either of them change their website :-)
'''
## The Banner
import sys
print(r'''
[*****************************************************************************]
--- Nessus Legal Home Key Registration ---
This script will use the Official Tenable website and generate & legal
Nessus Essentials Registration Code.
Only requirement is an internet connection to tenable.com and mailinator.com
NO WARRANTIES!
_______________________/-> Created By Photubias(c) <-\________________________
[*****************************************************************************]
''')
strNessusURL1 = r'https://www.tenable.com/products/nessus/nessus-essentials'
strNessusURL2 = r'https://www.tenable.com/evaluations/api/v1/nessus-essentials'
boolInteractive = True
if len(sys.argv) > 1: boolInteractive = False
## -- Create the cookies and receive CSRF token
print('--- Connecting to tenable.com')
#import urllib2, cookielib
import urllib.request, http.cookiejar
cookjar = http.cookiejar.CookieJar()
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cookjar))
opener.addheaders = [('User-Agent','Python')]
NessusPage = opener.open(strNessusURL1)
## -- Generate random email
print('--- Generating random e-mail')
import random, string
strRandomEmail = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(20))
print('[*] Using "' + strRandomEmail + '@mailinator.com"')
## -- Request code
print('--- Registering for a code')
import urllib.parse
postvalues = {"first_name":"Mister","last_name":"Student","email":strRandomEmail+"@mailinator.com","phone":"","code":"","country":"BE","region":"","zip":"3052","title":"","company":"","consentOptIn":"true","essentialsOptIn":"false","pid":"","utm_source":"","utm_campaign":"","utm_medium":"","utm_content":"","utm_promoter":"","utm_term":"","alert_email":"","_mkto_trk":"","mkt_tok":"","queryParameters":"utm_promoter=&utm_source=&utm_medium=&utm_campaign=&utm_content=&utm_term=&pid=&lookbook=&product_eval=essentials","referrer":"https://www.tenable.com/products/nessus/nessus-essentials?utm_promoter=&utm_source=&utm_medium=&utm_campaign=&utm_content=&utm_term=&pid=&lookbook=&product_eval=essentials","lookbook":"","apps":["essentials"],"companySize":"","preferredSiteId":"","tempProductInterest":"Nessus Essentials","partnerId":""}
postdata = urllib.parse.urlencode(postvalues).encode()
NessusRegister = opener.open(strNessusURL2, data = postdata)
bResult = NessusRegister.readlines()[0]
if bResult == b'{"message":"Success"}': print('[+] Registration success!')
else: print('[-] Registration error: ' + bResult.decode(errors='ignore'))
## -- Opening the mailinator website
print('--- Opening browser to mailinator')
import webbrowser
strMailinatorURL = r'https://www.mailinator.com/v4/public/inboxes.jsp?to={}'.format(strRandomEmail)
print(r'Success, opening the Mailinator webpage, please click the mail header')
print('Opening ' + strMailinatorURL)
webbrowser.open_new(strMailinatorURL)
print('')
print('--> The key should look something like AAAA-BBBB-CCCC-DDDD-EEEE')
print('Register Nessus with this key like this:')
print(r'/opt/nessus/sbin/nessuscli fetch --register <key>')
print('')
print('Manual Nessus update:')
print(r'/opt/nessus/sbin/nessuscli update --all')
if boolInteractive: input('When ready press [Enter] to exit')
exit(0)