|
||||||||||
|
|
||||||||||
NavigationMy posts on Twitter
|
Using the WebScarab bean shell to modify requests/responsesDescription of WebScarab taken from the OWASP WebScarab project website: import org.owasp.webscarab.model.Request;
import org.owasp.webscarab.model.Response;
import org.owasp.webscarab.httpclient.HTTPClient;
import org.owasp.webscarab.model.HttpUrl;
import java.io.IOException;
public Response fetchResponse(HTTPClient nextPlugin, Request request) throws IOException {
String url = request.getURL().toString();
url = url.replace("www.google.be", "www.google.com");
httpurl = new HttpUrl(url);
request.setURL(httpurl);
return nextPlugin.fetchResponse(request);
}
The following code will go through all headers received in the response and will delete the 'Set-Cookie' headers for cookie-names starting with __utm. The purpose is to not cache the __utma and the __utmz cookies in the browser.
import org.owasp.webscarab.model.Request;
import org.owasp.webscarab.model.Response;
import org.owasp.webscarab.httpclient.HTTPClient;
import org.owasp.webscarab.model.HttpUrl;
import org.owasp.webscarab.model.NamedValue;
import java.io.IOException;
public Response fetchResponse(HTTPClient nextPlugin, Request request) throws IOException {
response = nextPlugin.fetchResponse(request);
String nvName;
String nvValue;
int counter=0;
NamedValue[] nv = response.getHeaders();
NamedValue[] newNV = new NamedValue[nv.length];
for(int i=0; i < nv.length; i++)
{
nvName = (nv[i]).getName();
nvValue = (nv[i]).getValue();
if (!(nvName.startsWith("Set-Cookie") && nvValue.startsWith("st8id")))
{
newNV[counter]=new NamedValue(nvName, nvValue);
counter++;
}
}
NamedValue[] responseHeaders = new NamedValue[counter];
for(int i = 0; i < counter; i++)
responseHeaders[i] = newNV[i];
response.setHeaders(responseHeaders);
return response;
}
Request and Response methodsRequest methods that you may use are:
Response methods that you may use are:
The following methods are common to both the Request and Response objects:
References |
|
||||||||
| © Copyleft 2005-2011 - Lode Vanstechelman - Login | ||||||||||