예제 #1
0
def main(avgr):
	usage = '''%prog  --lang en|tw  --online|--new'''

	parser = OptionParser(usage=usage)
	parser.add_option("--lang",action="store",type="choice",choices=("tw","en","tl"),dest="lang",help="指定语言:tl,tw,en",metavar="tl|tw|en")
	parser.add_option("--time",action="store",type="str",dest="mtime",help="时间 2015-09-06 23:57:00",metavar="2015-09-06 23:57:00")	
	parser.add_option("--online",action="store_true",dest="online",help="线上")
	parser.add_option("--new",action="store_true",dest="new",help="最新")
	parser.add_option('--nowtime',action="store_true",dest="nowtime",help="获取机器当前时间")

	option,args = parser.parse_args()


	if option.online and option.new:
		parser.error("--online 与 --new 不能同时使用")

	port = 22

	if option.lang == 'en':
		ip="52.76.92.169"
		sshconnect=ssh(host=ip,port=port)
		if option.online:
			server="en_s998"
			m_time(ip,port,server,option.mtime)
		if option.new:
			server="en_s999"
			m_time(ip,port,server,option.mtime)

		if option.nowtime:
			getnowtime(ip,port)

	if option.lang == 'tw':
		ip="113.196.57.220"
		sshconnect=ssh(host=ip,port=port)
		if option.online:
			server="tw_s3"
			m_time(ip,port,server,option.mtime)
		if option.new:
			server="tw_s2"
			m_time(ip,port,server,option.mtime)
	
		if option.nowtime:
			getnowtime(ip,port)

	if option.lang == 'tl':
		ip="203.151.82.219"
		sshconnect=ssh(host=ip,port=port)
		if option.online:
			server="tl_s998"
			m_time(ip,port,server,option.mtime)
		if option.new:
			server="tl_s999"
			m_time(ip,port,server,option.mtime)
	
		if option.nowtime:
			getnowtime(ip,port)
예제 #2
0
파일: BHPsec.py 프로젝트: apumax-1/BHPsec
def menu():
    print('''\033[1m
    TOOLS::

    [1] Hostscan            [5] DNS Enum
    [2] Portscan            [6] Dir Scan
    [3] Pass Sniffer        [0] Exit
    [4] SSH Client          
    \033[m''')

    option = int(input('\033[1;31m>\033[m '))

    if option == 1:

        print('\n\033[1;31m[#] =-=NETWORK HOST SCANNER=-=\n\033[m')
        hostscan()
        menu()

    elif option == 2:

        print('\n\033[1;31m[#] =-=TCP PORTSCANNER=-=\n\033[m')
        portscan()
        menu()

    elif option == 3:

        print('\n\033[1;31m[#] =-=Password Sniffer=-=\n\033[m')
        sniffer()
        menu()

    elif option == 4:

        print('\n\033[1;31m[#] =-=SSH Client=-=\n\033[m')
        ssh()
        menu()

    elif option == 5:

        print('\n\033[1;31m[#] =-=DNS Enumerator=-=\n\033[m')
        dnsenum()
        menu()

    elif option == 6:

        print('\n\033[1;31m[#] =-=Dir Scanner=-=\n\033[m')
        dirscan()
        menu()

    elif option == 0:

        sys.exit(0)

    else:

        print('\nInvalid Option \nTry Again')
        menu()
예제 #3
0
def m_time(ip,port,server,mtime):
	stop_cmd="""'cd /data/server/%s && ./gamectl sync_stop -q'"""%server
	mtime_cmd="""'date -s "%s" && echo -e "\033[1;32m-------------------\033[0m" && echo `date +"%%Y-%%m-%%d %%H:%%M:%%S"` && echo -e "\033[1;32m-------------------\033[0m"'"""%mtime
	start_cmd="""'cd /data/server/%s && ./gamectl start'"""%server
	try:
		sshconnect=ssh(host=ip,port=port)

		print "\033[1;33m开始停服: %s\033[0m"%server
		stdout,stderr,returncode = sshconnect.run(stop_cmd,drop_socket=False)
		print stdout.strip("\n")
		if returncode != 0:
			print "停服失败!!! %s,%s"%(stdout,stderr)

		print "\033[1;33m\n开始修改机器时间: %s\033[0m"%ip
		stdout,stderr,returncode = sshconnect.run(mtime_cmd,drop_socket=False)
		print stdout.strip("\n")
		if returncode != 0:
			print "修改时间失败!!! %s,%s"%(stdout,stderr)

		print "\033[1;33m\n开始开启服: %s\033[0m"%server
		stdout,stderr,returncode = sshconnect.run(start_cmd,drop_socket=False)
		print stdout.strip("\n")
		if returncode != 0:
			print "开启游戏服失败!!! %s,%s"%(stdout,stderr)

	except Exception,err:
		message = '"fail",sshconnect失败,信息:%s'%(err)
		raise Exception(message)		
def main(args):
    global cf,rsync_conf    
    cf = ConfigParser.ConfigParser()    
    ABSPATH=os.path.abspath(sys.argv[0])
    #conf 路径
    rsync_conf=os.path.dirname(ABSPATH)+"/rsync.conf"
    cf.read(rsync_conf)
    ############变量区域###########    
    #当前时间格式2016-01-06_13-36
    nowtime = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M")
    #参数解析
    option,args = parser_command()    
    #备份路径
    backup_path = "/data/backup/%s/%s/%s"%(option.platform,option.os,nowtime)
    #创建备份目录
    mkdir_p(backup_path)

    test_port = cf.getint("test","port")
    test_ip  = cf.get("test","server")
    #update存放在测试服上的位置
    client_dir = cf.get("test","client_dir") 
    #rsync信息
    cdn_server =  cf.get(option.platform,"server")
    cdn_user = cf.get(option.platform,"user")
    #test_passfile 是代表测试服务器存在pass的路径,后续与163进行统一存放
    cdn_pass_file = cf.get(option.platform,"passfile")
    cdn_dir = cf.get(option.platform,"dir")
    cdn_url = cf.get(option.platform,"url")
    lang = cf.get(option.platform,"lang")
    #需要备份的update url
    back_update = cf.get(option.platform,"back_channel_%s"%option.os)
    if not back_update:back_update="update_%s_%s.xml"%(lang,option.os)
    back_update_url = cdn_url + "/" + option.os +"/" + back_update
    #备份
    down_xml(backup_path,back_update_url,verbose=option.verbose)
    #连接测试服
    try:
        SSH = ssh(host=test_ip,port=test_port)
        if option.platform == "qq":
            update_xml = "update_000028.xml update_000184.xml"
            local_file_path = client_dir + update_xml
            #存放cdn 目录
            Rsync_file(cdn_pass_file,cdn_user,cdn_dir,cdn_server,local_file_path,option.os,sshconnect=SSH,verbose=option.verbose)
        elif option.single_file: 
            local_file_path = client_dir + option.single_file
            Rsync_file(cdn_pass_file,cdn_user,cdn_dir,cdn_server,local_file_path,option.os,sshconnect=SSH,verbose=option.verbose)
        else:
            #排除一些文件
            local_file_path = client_dir + "*"
            #如果要排除一些文件,使用下面的格式,exclue_file=excule_xml
            excule_xml =[ e for e in cf.get(option.platform,"exclude_update").split(",")]
            if len(excule_xml) == 0 or excule_xml[0] == "":
                excule_xml=None
            Rsync_file(cdn_pass_file,cdn_user,cdn_dir,cdn_server,local_file_path,option.os,sshconnect=SSH,exclue_file=excule_xml,verbose=option.verbose)
 
    except KeyboardInterrupt:
        warn("程序被强行停止!!") 
    except Exception,err:
        error(err) 
예제 #5
0
def getnowtime(ip,port):
	cmd = """'echo `date +"%Y-%m-%d %H:%M:%S"`'"""
	try:
		sshconnect=ssh(host=ip,port=port)
		stdout,stderr,returncode = sshconnect.run(cmd,drop_socket=False)
		if returncode != 0:
			print "获取机器当前时间失败!!!,请联系运维处理... %s,%s"%(stdout,stderr)	
		else:
			print stdout.strip("\n")		
	except Exception,err:
		message = '"fail",sshconnect失败,信息:%s'%(err)
		raise Exception(message)
예제 #6
0
 def __init__(self, host, usr, passwd):
     self.host = host
     self.usr = usr
     self.passwd = passwd
     self.session = ssh(self.host, self.usr, self.passwd)