Skip to content

Instantly share code, notes, and snippets.

@steamraven
Last active August 29, 2015 13:57
Show Gist options
  • Save steamraven/9358204 to your computer and use it in GitHub Desktop.
Save steamraven/9358204 to your computer and use it in GitHub Desktop.
freerad admin password mask
--- 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