Created
September 21, 2018 21:12
-
-
Save andr-04/c5d5adc88f94eb629451cf1bff1e5123 to your computer and use it in GitHub Desktop.
Replace passwords in Yate
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
#!/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