测试人生的小脚本。。。

发布新日志

  • TestNG安装

    2011-09-09 17:20:19

    開始備忘記:
    [1] 安裝 jdk 5
    [2] 安裝 Eclipse WTP
    [3] 安裝 TestNG eclipse plugin
    [4] 建立 Eclipse project

    [1] 安裝 jdk 5:
    下載 jdk-1_5_0_07-nb-5_0-win-ml.exe
    http://java.sun.com/j2se/1.5.0/download-netbeans.html
    安裝至 D:\jdk1.5.0_07
    新增環境變數 JAVA_HOME=D:\jdk1.5.0_07
    D:\jdk1.5.0_07\bin 加入至 PATH 中
    D:\jdk1.5.0_07\lib\dt.jar 及 D:\jdk1.5.0_07\lib\tools.jar 加入至 CLASSPATH 中
    執行 D:\>java -version
    輸出 java version "1.5.0_07" 即安裝成功.

    [2] 安裝 Eclipse WTP:
    下載 wtp-all-in-one-sdk-R-1.5.0-200606281455-win32.zip
    http://www.eclipse.org/webtools/
    http://www.eclipse.org/downloads/download.php?file=/webtools/downloads/drops/R-1.5.0-200606281455/wtp-all-in-one-sdk-R-1.5.0-200606281455-win32.zip
    解壓至 D:\eclipse_wtp

    [3] 安裝 TestNG eclipse plugin:
    Eclipse:Help -> Software Updates -> Find and Install -> Search for new features to install
    按 New Remote Site
    Name: TestNG
    URL: http://beust.com/eclipse
    然後安裝.

    [4] 建立 Eclipse project:
    Eclipse: File -> New -> Other -> Java Project
    Project Name: First_TestNG -> Finish

  • http error codes

    2011-06-22 16:55:49

    普遍的www服务器的网络连接,都用的是http协议,在这里我们如果对http状态字(http status)进行适当的了解有一定的帮助.

    http error codes

    400 invalid syntax. 语法问题
    401 access denied. 访问拒绝
    402 payment required. 必须完整
    403 request forbidden. 请求被禁止
    404 object not found. 对象没有找到
    405 method is not allowed. 方法不允许
    406 no resp acceptable to client found. 客户端没有响应
    407 proxy authentication required. 代理需要验证
    408 server timed out waiting for request. 等等请求时服务器断开连接
    409 user should resubmit with more info. 有冲突用户应该进行检查
    410 resource is no l available. 资源不可用
    411 server refused to accept request without a length. 服务器拒绝接受没有长度的请求
    412 prec given in request failed. 放弃请求失败的条件
    413 request entity was too large. 请求太大
    414 request uniform. resource identifier (uri) too long. 请求的uri 太长
    415 unsupported media type. 不支持media类型
    449 retry after doing the appropriate action. 在作了适当动作后重试
    500 internal server error. 服务器内部错误
    501 server does not support the functi required to fulfill the request. 服务器不支持请求的功能
    502 error resp received from gateway. 从网关收到错误应答
    503 temporarily overloaded. 过载
    504 timed out waiting for gateway. 等待网关时请求断开
    505 http version not supported. 不支持http的版本


    http status codes returned by servers on the internet.
    从internet返回的http status代码(http 状态字)
    http_status_continue (100)
    the request can be continued.
    请求不能被继续
    http_status_switch_protocols (101)
    the server has switched protocols in an upgrade header.
    通过新的header服务器的协议被转换了
    http_status_ok (200)
    the request completed successfully.
    请求成功的完成
    http_status_created (201)
    the request has been fulfilled and resulted in the creation of a new resource.
    通过新的资源请求已经被完成
    http_status_accepted (202)
    the request has been accepted for processing, but the processing has not been completed.
    请求已经被接受处理,但是处理还没有完成
    http_status_partial (203)
    the returned meta. information in the entity-header is not the definitive set available from the origin server.
    从服务器返回的在entity-header中的meta信息是无效的
    http_status_no_content (204)
    the server has fulfilled the request, but there is no new information to send back.
    服务器实现了请求,但是没有返回信息
    http_status_reset_content (205)
    the request has been completed, and the client program should reset the document view that caused the request to be sent to allow the user to easily initiate another input action.
    请求已经被完成,并且web程序(客户端程序浏览器程序)已经重置了文档视图目录(c
    http_status_partial_content (206)
    the server has fulfilled the partial get request for the resource.
    服务器已经为资源完成了部分get请求
    http_status_ambiguous (300)
    the server couldn't decide what to return.
    服务器不能判定返回什么
    http_status_moved (301)
    the requested resource has been assigned to a new permanent uri (uniform. resource identifier), and any future references to this resource should be d using of the returned uris.
    被请求的资源已经被分配给新的uri,并且以后引用时都使用这个uris资源。
    http_status_redirect (302)
    the requested resource resides temporarily under a different uri (uniform. resource identifier).
    请求的资源临时在不同的uri下
    http_status_redirect_method (303)
    the resp to the request can be found under a different uri (uniform. resource identifier) and should be retrieved using a get http verb on that resource.
    请求的资源不能在不同的uri下找到,并且从新使用get http在服务器上从新检索
    http_status_not_modified (304)
    the requested resource has not been modified.
    请求的资源没有被改变
    http_status_use_proxy (305)
    the requested resource must be accessed through the proxy given by the location field.
    请求的资源必须通过特定的代理获得
    http_status_redirect_keep_verb (307)
    the redirected request keeps the same http verb. http/1.1 behavīor.
    从定位请求,
    http_status_bad_request (400)
    the request could not be processed by the server due to invalid syntax.
    因为语法不能被服务器处理
    http_status_denied (401)
    the requested resource requires user authentication.
    请求资源命令必须被验证(拒绝访问)
    http_status_payment_req (402)
    not currently implemented in the http protocol.
    没有完全实现http协议
    http_status_forbidden (403)
    the server understood the request, but is refusing to fulfill it.
    服务器理解了请求,但是拒绝完成他
    http_status_not_found (404)
    the server has not found anything matching the requested uri (uniform. resource identifier).
    没有找到任何被指定的uri

    http_status_bad_method (405)
    the http verb used is not allowed.
    http动作不被允许
    http_status_none_acceptable (406)
    no resp acceptable to the client were found.
    应答没有被客户接受
    http_status_proxy_auth_req (407)
    proxy authentication required.
    代理必须被验证
    http_status_request_timeout (408)
    the server timed out waiting for the request.
    服务器在等待请求时中止了
    http_status_conflict (409)
    the request could not be completed due to a c with the current state of the resource. the user should resubmit with more information.
    请求不能被完成,问题是资源冲突。用户应该进行调整
    http_status_gone (410)
    the requested resource is no l available at the server, and no forwarding address is known.
    请求的资源在服务器上不再可用,而且没有转发地址
    http_status_length_required (411)
    the server refuses to accept the request without a defined c length.
    服务器拒绝接受没有定义目录大小的请求
    http_status_precond_failed (412)
    the prec given in or more of the request header fields evaluated to false when it was tested on the server.
    当在服务器上测试请求头文件放弃一个或者多个请求的条件
    http_status_request_too_large (413)
    the server is refusing to process a request because the request entity is larger than the server is willing or able to process.
    服务器拒绝处理请求,原因是请求的大小超过服务器能够处理的大小
    http_status_uri_too_long (414)
    the server is refusing to service the request because the request uri (uniform. resource identifier) is l than the server is willing to interpret.
    服务器拒绝服务,原因是请求的uri超过了服务器能够揭示的长度
    http_status_unsupported_media (415)
    the server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.
    服务器拒绝服务,原因是请求格式不被支持
    http_status_retry_with (449)
    the request should be retried after doing the appropriate action.
    在作了适当的动作后请求被重试
    http_status_server_error (500)
    the server encountered an unexpected c that prevented it from fulfilling the request.
    服务器遇到请求失败意外
    http_status_not_supported (501)
    the server does not support the functi required to fulfill the request.
    服务器不支持必须完成请求的功能
    http_status_bad_gateway (502)
    the server, while acting as a gateway or proxy, received an invalid resp from the upstream server it accessed in attempting to fulfill the request.
    服务器当作为网关或代理时,从上行服务器接受的响应请求失败
    http_status_service_unavail (503)
    the service is temporarily overloaded.
    服务器负载
    http_status_gateway_timeout (504)
    the request was timed out waiting for a gateway.
    等待网关时请求断开,没有响应
    http_status_version_not_sup (505)
    the server does not support, or refuses to support, the http protocol version that was used in the request message.
    服务器不支持或者拒绝支持正在使用请求的http协议的版本

  • IBM Rational AppScan 7.8 破解方法

    2011-06-03 17:10:44

    Web 应用安全利器:IBM Rational AppScan

    软件 注册机 自己百度

    破解文件有两个可执行文件patch.exe keygen.exe

    第一步:把以上两可执行文件拷到appscan安装路径下的 Rational appscan 目录下比如(C:\Program Files\IBM\Rational AppScan)

    第二步:运行patch.exe 可扏行文件

    第三步:运行Keygen.exe可扏行文件,会产生一个license.lic文件

    第四步:把运行产生的license.lic文件拷到 License 目录下(比如:C:\Program Files\IBM\Rational AppScan\License)

    第五步:运行appscan应用程序并升级更新

  • 安全性测试方法

    2011-06-03 16:37:45

    1. 功能验证

        功能验证是采用软件测试当中的黑盒测试方法,对涉及安全的软件功能,如:用户管理模块,权限管理模块,加密系统,认证系统等进行测试,主要验证上述功能是否有效,具体方法可使用黑盒测试方法。

    2. 漏洞扫描

        安全漏洞扫描通常都是借助于特定的漏洞扫描器完成的。漏洞扫描器是一种自动检测远程或本地主机安全性弱点的程序。通过使用漏洞扫描器,系统管理员能够发现所维护信息系统存在的安全漏洞,从而在信息系统网络安全保卫站中做到“有的放矢”,及时修补漏洞。按常规标准,可以将漏洞扫描分为两种类型:主机漏洞扫描器(Host Scanner)和网络漏洞扫描器(Net Scanner)。主机漏洞扫描器是指在系统本地运行检测系统漏洞的程序,如著名的COPSTripewireTiger等自由软件。网络漏洞扫描器是指基于网络远程检测目标网络和主机系统漏洞的程序,如SatanISS Internet Scanner等。

        安全漏洞扫描是可以用于日常安全防护,同时可以作为对软件产品或信息系统进行测试的手段,可以在安全漏洞造成严重危害前,发现漏洞并加以防范。

    3. 模拟攻击实验

        对于安全测试来说,模拟攻击测试是一组特殊的黑盒测试案例,我们以模拟攻击来验证软件或信息系统的安全防护能力,下面简要列举在数据处 理与数据通信环境中特别关心的几种攻击。在下列各项中,出现了“授权”和“非授权”两个术语。“授权”意指“授予权力”,包含两层意思:这里的权力是指进 行某种活动的权力(例如访问数据);这样的权力被授予某个实体、代理人或进程。于是,授权行为就是履行被授予权力(未被撤销)的那些活动

      l 冒充:就是意个实体假装成一个不同的实体。冒充常与某些别的主动攻击形式一起使用,特别是消息的重演与篡改。例如,截获鉴别序列,并在一个有效的鉴别序列使用过一次后再次使用。特权很少的实体为了得到额外的特权,可能使用冒充成具有这些特权的实体,举例如下。

              1)   口令猜测:一旦黑客识别了一台主机,而且发现了基于NetBIOSTelnetNFS服务的可利用的用户帐号,并成功地猜测出了口令,就能对机器进行控制。

              2)   缓冲区溢出:由于在很多地服务程序中大意的程序员使用类似于“strcpy()strcat()”不进行有效位检查函数,最终可能导致恶意用户编写一小段程序来进一步打开安全缺口,然后将该代码放在缓冲区有效载荷末尾,这样,当发生缓冲区溢出时,返回指针指向恶意代码,执行恶意指令,就可以得到系统的控制权。

      l 重演:当一个消息或部分消息为了产生非授权效果而被重复时,出现重演。例如,一个含有鉴别信息的有效消息可能被另一个实体所重演,目的是鉴别它自己(把它当作其他实体)。

      l 消息篡改:数据所传送的内容被改变而未被发觉,并导致非授权后果,如下所示。

              1)   DNS高速缓存污染:由于DNS服务器与其他名称服务器交换信息的时候并不进行身份验证,这就使得黑客可以加入不正确得信息,并把用户引向黑客自己的主机。

              2)   伪造电子邮件由于SMTP并不对邮件发送者的身份进行鉴定,因此黑客可以对内部客户伪造电子邮件,声称是来自某个客户认识并相信的人,并附上可安装的特洛伊木马程序,或者是一个指向恶意网站的链接。

      l 服务拒绝:当 溢个实体不能执行它的正常功能,或它的动作防碍了别的实体执行它们的正常功能的时候,便发生服务拒绝。这种攻击可能是一般性的,比如一个实体抑制所有的消 息,也可能是有具体目标的。例如,一个实体抑制所有流向某一特定目的端的消息,如安全审计服务。这种攻击可以是对通信业务流的抑制,或产生额外的通信业务 流。也可能制造出试图破坏网络操作的消息,特别是如果网络具有中继实体,这些中继实体根据从别的中继实体那里接收到的状态报告,来做出路由选择的决定。拒绝服务攻击种类很多,举例如下。

             1)   死亡之pingping of death):由于在早期的阶段,路由器对包的最大尺寸都有限制,许多操作系统对TCP/IP栈的实现在ICMP包上都规定为64KB,并且在读取包的标题后,要根据该标题头里包含的信息来为有效载荷生成缓冲区。当产生畸形的、声称自己的尺寸超过ICMP上限,也就是加载尺寸超过64K上限的包时,就会出现内存分配错误,导致TCP/IP堆栈崩溃,致使接受方宕机。
              2)   泪滴(Teardorop):泪滴攻击利用那些在TCP/IP堆栈实现中信任IP碎片中的包的标题头所包含的信息来实现自己的攻击。IP分段含有指示该分段所包含的是原包的哪一段的信息,某些TCP/IP(包括Service Pack 4 以前的NT)在收到含有重叠偏移的伪造分段时将崩溃。

               3)   UDP洪水(UDP Flood):  各种各样的假冒攻击利用简单的TCP/IP服务,如ChargenEcho 来传送毫无用处的数据以占满带宽。通过伪造与某一主机的Chargen服务之间的一次的UDP连接,回复地址指向开着Echo服务的一台主机,这样就生成在两台主机之间的足够多的无用数据流,如果数据流足够多,就会导致带宽的服务攻击。

               4)   SYN洪水(SYN Flood):一些TCP/IP栈的实现,只能等待从有限数量的计算机发来的ACK消息,因为它们只有有限的内存缓冲区用于创建连接,如果这一缓冲区充满了虚假连接的初始信息,该服务器就会对接下来的连接请求停止响应,直到缓冲区里的连接企图超时为止。在一些创建连接不受限制的实现里,SYN洪水也具有类似的影响。

               5)   Land攻击:Land攻击中,一个特别打造的SYN包的原地址和目标地址都被设置成某一个服务器地址,这将导致接受服务器向它自己的地址发送SYN-ACK消息,结果,这个地址又发回ACK消息并创建一个空连接,每一个这样的连接都将保留,直到超时。各种系统对Land攻击的反应不同,许多UNIX实现将崩溃,NT变得极其缓慢(大约持续5分钟)。

               6)   Smurf攻击:一个简单的Smurf攻击,通过使用将回复地址设置成受害网络的广播地址的ICMP应答请求(ping)数据包,来淹没受害主机的方式进行,最终导致该网络的所有主机都对此ICMP应答请求作出答复,导致网络阻塞,比“Ping of Death”洪水的流量高出一个或两个数量级。更加复杂的Smurf将源地址改为第三方的受害者,最终导致第三方雪崩。

               7)   Fraggle攻击:Fraggle攻击对Smurf攻击作了简单的修改,使用的是UDP应答消息,而非ICMP

               8)   电子邮件炸弹:电子邮件炸弹是最古老的匿名攻击之一,通过设置一台机器,不断大量地向同一地址发送电子邮件,攻击者能够耗尽接收者网络的带宽。

               9)   畸形消息攻击:各类操作系统上的许多服务都存在此类问题,由于这些服务在处理信息之前没有进行适当正确的错误校验,在收到畸形的信息时可能会崩溃。

      l 内部攻击:当 系统的合法用户以非故意或非授权方式进行动作时就成为内部攻击。多数已知的计算机犯罪都和使系统安全遭受损害的内部攻击有密切的关系。能用来防止内部攻击 的保护方法包括:所有管理数据流进行加密;利用包括使用强口令在内的多级控制机制和集中管理机制来加强系统的控制能力;为分布在不同场所的业务部门划分VLAN,将数据流隔离在特定部门;利用防火墙为进出网络的用户提供认证功能,提供访问控制保护;使用安全日志记录网络管理数据流等。

      l 外部攻击:外部攻击可以使用的方法有:搭线(主动的与被动的)、截取辐射、冒充为系统的授权用户、冒充为系统的组成部分、为鉴别或访问控制机制设置旁路等。

      l 陷阱门:当系统的实体受到改变,致使一个攻击者能对命令或对预定的事件或事件序列产生非授权的影响时,其结果就称为陷阱门。例如,口令的有效性可能被修改,使得除了其正常效力之外也使攻击者的口令生效。

      l 特洛伊木马:对系统而言的特洛伊木马,是指它不但具有自己的授权功能,而且还有非授权功能。一个向非授权信道拷贝消息的中继就是一个特洛伊木马。典型的特洛伊木马有NetBusBackOrificeBO2k 等。

    4.       侦听技术

    侦听技术实际上是在数据通信或数据交互过程,对数据进行截取分析的过程。目前最为流行的是网络数据包的捕获技术,通常我们称为 Capture,黑客可以利用该项技术实现数据的盗用,而测试人员同样可以利用该项技术实现安全测试。

    该项技术主要用于对网络加密的验证。

    功能验证      采用黑盒测试方法,对涉及安全的软件功能进行测试
    漏洞扫描      采用主机或系统漏洞扫描器自动检测远程或本机安全性弱点
    模拟攻击试验   采用冒充、重演、消息篡改、服务拒绝、内部攻击、外部攻击、陷阱门、特洛伊木马方法进行测试
    侦听技术      对数据进行截取分析的过程,主要用于对网络加密的验证


  • Selenium脚本实现

    2011-06-03 09:50:01

    1.从Selenium 官方站点下载:selenium-server-standalone-2.0b3.jar,selenium-java-2.0b3.zip,安装好jdk1.5或者jdk1.5以上。将selenium-java-2.0b3.zip解压压缩一个目录里。

    2.打开eclispe 3.5.0,然后点击new->java project创建一个java 项目,例如TestBaidu.右键点击TestBaidu项目,点new ->folder创建一个lib文件夹。点击lib文件件右键Build Path ->Config build path 在打开的窗体中选择Libraries后点击Add External JARs.选择加压的selenium-java-2.0b3.zip的所有的jar包,后点击ok按钮

    3.在TestBaidu中右键new->Junit Test case. 输入Name,例如testCase1,这里组要注意的是Name必须以test开头的字符。输入name后点击finish按钮。

    4.代码编写

    package com.autoScripts;
    import com.thoughtworks.selenium.*;


    //import java.util.regex.Pattern;

    @SuppressWarnings("deprecation")
    public class testCase1 extends SeleneseTestCase {
       
        public void setUp() throws Exception {
           
           
            setUp("http://www.baidu.com/", "*firefox D:/Program Files/Mozilla Firefox/firefox.exe");
        }
        public void testUntitled() throws Exception {
            selenium.open("/");
            selenium.click("kw");
            selenium.type("kw", "as");
            selenium.click("su");
            selenium.waitForPageToLoad("30000");
        }
    }

    5.运行Selenium server,进入到cmd ,cd 到selenium-server-standalone-2.0b3.jar所在的路径下面,在cmd内输入

    java -jar selenium-server-standalone-2.0b3.jar

    6.在eclipse中运行运行刚写的java测试脚本

    效果:约几秒钟后将先打开Selenium Remote Control 界面,然后再打开baidu搜索引擎,接着在文本框内输入as后点击按钮。

    注:

    1.*firefox D:/Program Files/Mozilla Firefox/firefox.exe"为firefox浏览器指定运行路径

    2.运行脚本时,CMD窗口不能关闭。

    3.脚本可用selenium IDE进行录制。

  • Windows server 2003 控制面板不能打开的解决方法

    2010-11-05 11:33:50

    运行regedit打开注册表
    找到 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\Locale下的两个项修改为
    "(Default)"="00000409"
    "00000804"="1"
    再打开控制面板就可以正常打开了
Open Toolbar