protal认证的稳定性测试脚本
来源:互联网 发布:邮箱大师mac版本下载 编辑:程序博客网 时间:2024/05/01 23:07
首先配置好环境,在控制台上进行设置:(1)设置保护区范围;(2)设置入网范围的ip,使其访问保护区时需要做相关认证;(3)设置例外管理,例外之内的机器无须做认证,直接到相关登录界面即可;(4)旁路开关打开,并打开网络接口和相应的端口(8080)
同时也需要对网络适配器上的网络端口进行对应的配置
需要相关技术:
伪装ip地址;
多线程运行;
打印debug日志
#!/usr/bin/python#coding:utf-8import os, sysimport reimport httplibimport time, threadingimport urllib2, random fail_num = 0fail_num_1 = 0thread_num = 0#filepath = 'C:\Users\zgc\Desktop\result.txt'import loggingdef initLogConf(): LOG_FILE = "debug.log" logging.basicConfig(filename=LOG_FILE,level=logging.DEBUG)def test_authentication(): ''' 伪造ip地址,测试是否出现认证界面 ''' global fail_num a = random.randint(1,255) b = random.randint(0,255) c = random.randint(0,255) d = random.randint(0,255) ipAddress = "%d.%d.%d.%d" % (a,b,c,d) #ipAddress = "76.27.131.228" #a = 172 #print ipAddress headers={"X-Forwarded-For":ipAddress,"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0"} conn = httplib.HTTPConnection("172.27.131.216:8080") conn.request("HEAD","/","",headers) time.sleep(5) res = conn.getresponse() #print res.getheaders() #print res.status,res.reason ''' if a < 172: print res.getheaders() result = res.getheaders() req = urllib2.Request("http://172.27.131.216:8080%s" %(result[5][1])) print result[5][1] response = urllib2.urlopen(req) html = response.read().decode('utf-8') xre = r'(<title>)(.+)(</title>)' auth = re.search(xre, html).group(2) print auth auth_word = u"360新天擎" if auth != auth_word: fail_num_1 += 1 else: continue response.close() else: ''' conn.close() result = res.getheaders() #print result if result[2][1] != "http://172.27.131.156:8080/nac/register/login?url=172.27.131.216:8080": fail_num += 1 else: print result[2][1] req = urllib2.Request(result[2][1]) response = urllib2.urlopen(req) html = response.read().decode('utf-8') xre = r'(<title>)(.+)(</title>)' auth = re.search(xre, html).group(2) #print auth auth_word = u"企业安全准入控制系统" #重定向不是预期效果 if auth != auth_word: fail_num += 1 response.close()def multi_threading(thread_num): thread_list = list(); #thread_num = 100 thread_num = random.randint(1,100) for i in range(0, thread_num): j = random.randint(1,10000) thread_name = "thread_%s" %j thread_list.append(threading.Thread(target = test_authentication, name = thread_name)) for thread in thread_list: thread.start() for thread in thread_list: thread.join()def run(interval): while True: try: time_remaining = interval-time.time()%interval time.sleep(time_remaining) multi_threading(thread_num) logging.info("[%s] fail_num: %d\n"%((time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())), fail_num)) except Exception, e: print eif __name__=="__main__": initLogConf() #间隔时间 interval = 30 #test_authentication() run(interval) #multi_threading(thread_num) #打印出总的失败次数 #print fail_num
0 0
- protal认证的稳定性测试脚本
- iosMonkey脚本测试iOS应用的稳定性测试
- 使用Ynm3k的iosMonkey脚本测试iOS应用的稳定性
- 利用UiAutomator写一个首页刷新的稳定性测试脚本
- [Android 测试] 压力稳定性测试之: Monkey 详解分析脚本
- 测试的那点事-稳定性测试
- 软件稳定性测试的测试点
- protal开发之前需要修改的文件
- 写稳定性测试程序的一些经验
- 如何测试硬件的稳定性和兼容性
- 控制Android自动化测试程序的稳定性
- Android稳定性测试工具Monkey的使用
- 图解测试之稳定性-了解稳定性测试
- Portlet && protal
- 关于protal
- 小议.....稳定性测试
- 服务器稳定性测试
- FTP服务器稳定性测试
- find命令之(-atime,-ctime,-mtime)
- powerpoint中的自动缩略图效果
- Hibernate 实体映射
- 埃氏筛法(筛选素数)
- dump文件的调试
- protal认证的稳定性测试脚本
- c++学习笔记(5)——关于三种内存分配方法
- 攻破JAVA NIO技术壁垒
- 补间动画
- poj2386
- java容器:Collection中的Iterator和Map中的entrySet对比学习
- 理解mipi协议
- HDU2604 Queuing(矩阵快速幂模板)
- Intellij Idea 使用Maven构建Java Web项目 + Tomcat集成