1

我正在研究这本书:实用安全自动化和测试。在第 [124] 页上,有一个使用 RIDE 和 SSHLibrary 的脚本。

但我使用的是 Eclipse,所以我尝试安装它。

点安装轮

pip install --upgrade robotframework-sshlibrary

成功了,现在您可以开始编辑 .robot 脚本了。

我做到了这一点:(所以它与书不同,但这适用于 Eclipse)

*** Settings ***
Library  SSHLibrary
*** Variables ***
${HOST_URL}  http://demo.testfire.net
${output}=  Execute Command  python sqlmap.py -u ${HOST_URL} --batch --banner

*** Test Cases ***
SQL Injection Testing
  Should Not Contain  ${output}  vulnerable

现在的问题是:它说“通过”,但是当我更改 host_url 时我确信它应该失败,它也说“通过”。换句话说:它似乎没有检查或做任何事情。

我不知道我在这里做错了什么。需要帮忙。

4

2 回答 2

3

您根本没有执行命令 - 不能在变量部分调用关键字。这条线在这里

*** Variables ***
${HOST_URL}  http://demo.testfire.net
${output}=  Execute Command  python sqlmap.py -u ${HOST_URL} --batch --banner

只会使用该内容创建一个字符串变量。将其移动到案例中(或在它自己的关键字中)

*** Test Cases ***
SQL Injection Testing
    ${output}=  Execute Command  python sqlmap.py -u ${HOST_URL} --batch --banner
    Should Not Contain  ${output}  vulnerable
于 2020-07-30T05:21:00.123 回答
0

我混合了第 124 页和第 126 页的内容(书:实用安全自动化和测试)

第 126 页有一个错误。骑行图像上的代码实际上是 RBFW 的代码。

这就是它没有错误的方式:

*** Settings ***
Library  SSHLibrary
Library  Collections
Library  String
Library  RequestsLibrary
Library  OperatingSystem

*** Variables ***
${HOST_URL}  http://demo.testfire.net
${url}  http://demo.testfire.net
${SpiderScan}  http://localhost:8090/JSON/spider/action/scan/?zapapiformat=JSON&formatMethod=GETurl=${url}&maxChildren=&recurse=&ontextName=&subtreeOnly=

*** Test Cases ***
SQL Injection Testing
  Get Connection    host=http://demo.testfire.net
  ${output}=  Execute Command  python sqlmap.py -u ${HOST_URL} --batch --banner
  Should Not Contain  ${output}  vulnerable
  

ZAP Spider Scan
  [Tags]  get skip
  Create session   ZAP  ${SpiderScan}
  ${resp}=    Get Request     ZAP   /
  Should Be Equal As Strings    ${resp.status_code}    200
于 2020-07-30T17:05:52.923 回答