forked from pyhoneybot/honeybot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
498355c
commit b011c7d
Showing
2 changed files
with
151 additions
and
59 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
[password_generator.py] | ||
Password Generator Plugin | ||
[Author] | ||
Nishant, JPMorgan Chase & Co. | ||
[About] | ||
sends different type of passwords | ||
[Commands] | ||
>>> .passgen <<length>> | ||
returns alphabetic password of specified length | ||
>>> .passgensecure <<length>> | ||
returns secure alphanumeric password of specified length | ||
>>> .passgenalphanum <<length>> | ||
returns alphanumeric password of specified length | ||
>>> .passgenspecialchar <<length>> | ||
returns universally accepted alphanumeric password with special characters of specified length where length >= 4 | ||
""" | ||
|
||
import string, random, secrets | ||
|
||
|
||
class Plugin: | ||
def __init__(self): | ||
pass | ||
|
||
def __passgen(self, password_length): | ||
letters = string.ascii_lowercase | ||
return ''.join(random.choice(letters) for i in range(password_length)) | ||
|
||
def __passgenalphanum(self, password_length): | ||
password_characters = string.ascii_letters + string.digits + string.punctuation | ||
return ''.join(random.choice(password_characters) for i in range(password_length)) | ||
|
||
def __passgensecure(self, password_length): | ||
password_characters = string.ascii_letters + string.digits + string.punctuation | ||
return ''.join(secrets.choice(password_characters) for i in range(password_length)) | ||
|
||
def __passgenspecialchar(self, password_length): | ||
randomSource = string.ascii_letters + string.digits + string.punctuation | ||
password = random.choice(string.ascii_lowercase) | ||
password += random.choice(string.ascii_uppercase) | ||
password += random.choice(string.digits) | ||
password += random.choice(string.punctuation) | ||
for i in range(password_length - 4): | ||
password += random.choice(randomSource) | ||
passwordList = list(password) | ||
random.SystemRandom().shuffle(passwordList) | ||
password = ''.join(passwordList) | ||
return password | ||
|
||
def run(self, incoming, methods, info): | ||
try: | ||
# if '!~' in info['prefix']: | ||
# print(info) | ||
msgs = info['args'][1:][0].split() | ||
if info['command'] == 'PRIVMSG': | ||
if len(msgs) > 1: | ||
if msgs[0] == '.passgen': | ||
length = msgs[1] | ||
methods['send'](info['address'], self.__passgen(length)) | ||
if msgs[0] == '.passgensecure': | ||
length = msgs[1] | ||
methods['send'](info['address'], self.__passgensecure(length)) | ||
if msgs[0] == '.passgenalphanum': | ||
length = msgs[1] | ||
methods['send'](info['address'], self.__passgenalphanum(length)) | ||
if msgs[0] == '.passgenspecialchar': | ||
length = msgs[1] | ||
if length >= 4: | ||
methods['send'](info['address'], self.__passgenspecialchar(length)) | ||
else: | ||
raise Exception('Length od password should be greater than 4.') | ||
except Exception as e: | ||
print('woops plug', e) |