Last active
August 29, 2015 13:57
-
-
Save steamraven/9358204 to your computer and use it in GitHub Desktop.
freerad admin password mask
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
--- yubiadmin/apps/freerad.py 2014-03-04 16:36:11.468515179 -0700 | |
+++ ~/freerad.py 2014-03-04 16:39:01.224515159 -0700 | |
@@ -31,7 +31,7 @@ | |
from yubiadmin.util.config import parse_block | |
from yubiadmin.apps.dashboard import panel | |
from wtforms import Form | |
-from wtforms.fields import TextField | |
+from wtforms.fields import TextField,PasswordField | |
import os | |
import re | |
@@ -57,7 +57,7 @@ | |
""" | |
client_secret = TextField('Client Secret', default='testing123') | |
username = TextField('Username') | |
- password = TextField('Password') | |
+ password = PasswordField('Password') | |
class FreeRadius(App): | |
@@ -97,11 +97,14 @@ | |
password = form.password.data | |
secret = form.client_secret.data | |
+ masked_cmd = 'radtest %s ***** localhost 0 %s' % (username, secret) | |
status, output = run(cmd) | |
- alert = {'title': 'Command: %s' % cmd} | |
+ masked_output = re.sub('User-Password = ".*?"', "User-Password = *****", output) | |
+ alert = {'title': 'Command: %s' % masked_cmd} | |
alert['message'] = '<pre style="white-space: pre-wrap;">%s</pre>' \ | |
- % output | |
+ % masked_output | |
if status == 0: | |
alert['type'] = 'success' | |
elif status == 1: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment