ThreatScript Web Client » History » Version 2
Luke Murphey, 05/19/2010 11:52 PM
1 | 1 | Luke Murphey | h1. ThreatScript Web Client |
---|---|---|---|
2 | 1 | Luke Murphey | |
3 | 1 | Luke Murphey | ThreatScript definitions can actively access and gather information from websites using one of the HTTP request classes. The following classes are available (each corresponding to the associated HTTP verb): |
4 | 1 | Luke Murphey | |
5 | 1 | Luke Murphey | * GetRequest |
6 | 1 | Luke Murphey | * PostRequest |
7 | 1 | Luke Murphey | * DeleteRequest |
8 | 1 | Luke Murphey | * PutRequest |
9 | 1 | Luke Murphey | * TraceRequest |
10 | 1 | Luke Murphey | * HeadRequest |
11 | 1 | Luke Murphey | * OptionsRequest |
12 | 1 | Luke Murphey | |
13 | 1 | Luke Murphey | <pre> |
14 | 1 | Luke Murphey | <code class="Javascript"> |
15 | 1 | Luke Murphey | /* |
16 | 2 | Luke Murphey | * Name: Test.Test.LinkCount |
17 | 1 | Luke Murphey | * ID: 1200001 |
18 | 1 | Luke Murphey | * Version: 1 |
19 | 2 | Luke Murphey | * Message: Detects the number of websites linking to this page |
20 | 1 | Luke Murphey | * Severity: Low |
21 | 1 | Luke Murphey | */ |
22 | 1 | Luke Murphey | |
23 | 1 | Luke Murphey | importPackage(Packages.ThreatScript); |
24 | 1 | Luke Murphey | importPackage(Packages.HTTP); |
25 | 1 | Luke Murphey | |
26 | 1 | Luke Murphey | function analyze( httpResponse, variables, environment ){ |
27 | 2 | Luke Murphey | var get = new GetRequest("http://www.google.com/search?q=site+to+" + httpResponse.getLocation() ); |
28 | 1 | Luke Murphey | var httpResponse = get.run(); |
29 | 1 | Luke Murphey | var s = httpResponse.getResponseBodyAsString(); |
30 | 1 | Luke Murphey | |
31 | 1 | Luke Murphey | if( s == null ){ |
32 | 2 | Luke Murphey | return new Result( true, "Could not get a response from Google.com"); |
33 | 1 | Luke Murphey | } |
34 | 1 | Luke Murphey | |
35 | 2 | Luke Murphey | var resultsCount = /About ([,0-9]+) results/; |
36 | 2 | Luke Murphey | var result = resultsCount.exec(s); |
37 | 2 | Luke Murphey | |
38 | 2 | Luke Murphey | var linkcount = result[1]; |
39 | 2 | Luke Murphey | |
40 | 2 | Luke Murphey | return new Result( true, "Number of sites that link to this page: " + linkcount); |
41 | 1 | Luke Murphey | } |
42 | 1 | Luke Murphey | </code> |
43 | 1 | Luke Murphey | </pre> |