Project

General

Profile

ThreatScript Web Client » History » Version 2

Version 1 (Luke Murphey, 05/19/2010 11:45 PM) → Version 2/3 (Luke Murphey, 05/19/2010 11:52 PM)

h1. ThreatScript Web Client

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):

* GetRequest
* PostRequest
* DeleteRequest
* PutRequest
* TraceRequest
* HeadRequest
* OptionsRequest

<pre>
<code class="Javascript">
/*
* Name: Test.Test.LinkCount Example.Test.WebRequest
* ID: 1200001
* Version: 1
* Message: Detects Get the number of websites linking to this page first 24 characters on a web-page
* Severity: Low
*/

importPackage(Packages.ThreatScript);
importPackage(Packages.HTTP);

function analyze( httpResponse, variables, environment ){
var get = new GetRequest("http://www.google.com/search?q=site+to+" + httpResponse.getLocation() ); GetRequest(httpResponse.getLocation());
var httpResponse = get.run();
var s = httpResponse.getResponseBodyAsString();

if( s == null ){
return new Result( true, "Could not get a response from Google.com"); "null");
}

var resultsCount = /About ([,0-9]+) results/;
var result = resultsCount.exec(s);

var linkcount = result[1];

return new Result( true, "Number "First 24 characters of sites that link to this page: page is: " + linkcount); s.substring(0,24));
}
</code>
</pre>