From 187f0de25af5f511eed76c7623195eb0259a8d57 Mon Sep 17 00:00:00 2001 From: BreakWa11 Date: Fri, 24 Jun 2016 19:37:25 +0800 Subject: [PATCH] generate random password remove default users in mudb.json --- mudb.json | 24 ------------------------ mujson_mgr.py | 7 ++++++- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/mudb.json b/mudb.json index 22fad21..0d4f101 100644 --- a/mudb.json +++ b/mudb.json @@ -1,26 +1,2 @@ [ - { - "user": "admin", - "port": 443, - "u": 0, - "d": 0, - "transfer_enable": 1125899906842624, - "passwd": "admin", - "method": "aes-128-cfb", - "protocol": "auth_sha1_v2_compatible", - "obfs": "tls1.2_ticket_auth_compatible", - "enable": true - }, - { - "user": "user001", - "port": 10001, - "u": 0, - "d": 0, - "transfer_enable": 1099511627776, - "passwd": "abc123", - "method": "rc4-md5", - "protocol": "auth_sha1_v2_compatible", - "obfs": "http_post_compatible", - "enable": true - } ] diff --git a/mujson_mgr.py b/mujson_mgr.py index 092baf8..4518c6f 100644 --- a/mujson_mgr.py +++ b/mujson_mgr.py @@ -4,6 +4,7 @@ import traceback from shadowsocks import common, shell from configloader import load_config, get_config +import random import getopt import sys import json @@ -48,11 +49,15 @@ class MuMgr(object): ret += " %s : %s" % (key, user[key]) return ret + def rand_pass(self): + return b''.join([random.choice(b'''ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~-_=+(){}[]^&%$@''') for i in range(8)]) + def add(self, user): - up = {'enable': True, 'u': 0, 'd': 0, 'passwd': "m", 'method': "aes-128-cfb", + up = {'enable': True, 'u': 0, 'd': 0, 'method': "aes-128-cfb", 'protocol': "auth_sha1_v2_compatible", 'obfs': "tls1.2_ticket_auth_compatible", 'transfer_enable': 1125899906842624} + up['passwd'] = self.rand_pass() up.update(user) self.data.load(self.config_path)