From 498355ce3827019fa316507f2e49aa0bea139443 Mon Sep 17 00:00:00 2001 From: Nishant Date: Tue, 12 Mar 2019 07:19:49 +0530 Subject: [PATCH 1/2] Update README.md Added Indian Flag into contributing countries --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 010a6b8..e5c2a2d 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Psst. since i learnt py through this bot, we decided to keep a new-comers friend ## 📌 Contributing Countries -🇲🇺 🇺🇸 🇨🇦 🇦🇷 +🇲🇺 🇺🇸 🇨🇦 🇦🇷 🇮🇳 ## ✂ Current Features * 🍬 OOP architecture From b011c7d833fab1bb48dd7818f502d04f019487c9 Mon Sep 17 00:00:00 2001 From: Nishant Date: Tue, 12 Mar 2019 08:53:44 +0530 Subject: [PATCH 2/2] Added Password Generator plugin --- .idea/workspace.xml | 129 ++++++++++++++----------- honeybot/plugins/password_generator.py | 81 ++++++++++++++++ 2 files changed, 151 insertions(+), 59 deletions(-) create mode 100644 honeybot/plugins/password_generator.py diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 85ea26c..0ad3a87 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,11 +2,8 @@ - - - + - @@ -30,15 +27,15 @@ - + - + - - + + @@ -61,11 +58,27 @@ + + + + + + + - - + + + + + + + + + + + @@ -88,17 +101,6 @@ - - - - - - - - - - - @@ -108,13 +110,6 @@ - - - - - - - @@ -140,6 +135,7 @@ @@ -160,6 +156,11 @@ + + + + + @@ -182,7 +183,7 @@ - + @@ -290,12 +291,12 @@ - - + - + @@ -303,7 +304,6 @@ - @@ -317,6 +317,7 @@ + @@ -400,29 +401,8 @@ - - - - - - - - - - - - - - - - - - - - - - + @@ -442,8 +422,8 @@ - - + + @@ -463,8 +443,39 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/honeybot/plugins/password_generator.py b/honeybot/plugins/password_generator.py new file mode 100644 index 0000000..ab2f9a8 --- /dev/null +++ b/honeybot/plugins/password_generator.py @@ -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 <> +returns alphabetic password of specified length + +>>> .passgensecure <> +returns secure alphanumeric password of specified length + +>>> .passgenalphanum <> +returns alphanumeric password of specified length + +>>> .passgenspecialchar <> +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)