Skip to content

Instantly share code, notes, and snippets.

@andr-04 andr-04/pass.py
Created Sep 21, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.