Skip to content

Instantly share code, notes, and snippets.

@andr-04
Created September 21, 2018 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andr-04/c5d5adc88f94eb629451cf1bff1e5123 to your computer and use it in GitHub Desktop.
Save andr-04/c5d5adc88f94eb629451cf1bff1e5123 to your computer and use it in GitHub Desktop.
Replace passwords in Yate
#!/usr/bin/env python
import asyncore
from libyate import Yate
def replace_passwords(params):
passwords = {
# 'user': 'pass'
}
user_n, pass_n = None, None
for n, pair in enumerate(params):
if pair[0] == 'username':
user_n = n
elif pair[0] == 'password':
pass_n = n
if user_n is not None and pass_n is not None:
username = params[user_n][1].lower()
if username in passwords:
params[pass_n][1] = passwords[username]
class YateApp:
def __init__(self):
self.app = Yate()
self.app.__Yatecall__ = self.retenv
self.app.si.connected = True # due to bug in libyate.py
def retenv(self, d):
if d == "incoming":
replace_passwords(self.app.params)
self.app.Acknowledge()
def main(self):
self.app.Install("user.login")
asyncore.loop()
self.app.Uninstall("user.login")
self.app.close()
if __name__ == '__main__':
a = YateApp()
a.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment