Getting a helper in a standalone script

191 views
Skip to first unread message

Michael Courcy

unread,
Aug 11, 2015, 6:14:40 PM8/11/15
to OWASP ZAP User Group
Hi 

In an authenticate script you get a helper through the parameter of the authenticate function :  function authenticate(helper, paramsValues, credentials) { ...

I need to obtain this helper in a standalone script how can I do that ?

Thanks.

thc...@gmail.com

unread,
Aug 12, 2015, 3:32:37 AM8/12/15
to zaprox...@googlegroups.com
Hi.

It depends on what do you need from the "helper" object. Send requests?
Get the user?

Best regards.

On 11/08/15 23:14, Michael Courcy wrote:
> Hi
>
> In an authenticate script you get a helper through the parameter of the
> authenticate function : / function authenticate(*helper*, paramsValues,
> credentials) { .../
>
> I need to obtain this helper in a standalone script how can I do that ?
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google
> Groups "OWASP ZAP User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to zaproxy-user...@googlegroups.com
> <mailto:zaproxy-user...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Michael Courcy

unread,
Aug 12, 2015, 3:44:29 AM8/12/15
to zaprox...@googlegroups.com

Hi
I need to send request.
Thx


To unsubscribe from this group and stop receiving emails from it, send an email to zaproxy-user...@googlegroups.com.

thc...@gmail.com

unread,
Aug 12, 2015, 4:07:43 AM8/12/15
to zaprox...@googlegroups.com
OK, you can create the object to send the requests with:
sender =
org.parosproxy.paros.network.HttpSender(org.parosproxy.paros.model.Model.getSingleton().getOptionsParam().getConnectionParam(),
true, 6)

and do the request with:
sender.sendAndReceive(message)

and, if you do not want to follow redirects:
sender.sendAndReceive(message, false)


Best regards.

On 12/08/15 08:44, Michael Courcy wrote:
> Hi
> I need to send request.
> Thx
>
>
> Le mer. 12 août 2015 09:32, <thc...@gmail.com
> <mailto:thc...@gmail.com>> a écrit :
>
> Hi.
>
> It depends on what do you need from the "helper" object. Send requests?
> Get the user?
>
> Best regards.
>
> On 11/08/15 23:14, Michael Courcy wrote:
> > Hi
> >
> > In an authenticate script you get a helper through the parameter
> of the
> > authenticate function : / function authenticate(*helper*,
> paramsValues,
> > credentials) { .../
> >
> > I need to obtain this helper in a standalone script how can I do
> that ?
> >
> > Thanks.
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "OWASP ZAP User Group" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to zaproxy-user...@googlegroups.com
> <mailto:zaproxy-users%2Bunsu...@googlegroups.com>
> > <mailto:zaproxy-user...@googlegroups.com
> <mailto:zaproxy-users%2Bunsu...@googlegroups.com>>.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google
> Groups "OWASP ZAP User Group" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to zaproxy-user...@googlegroups.com
> <mailto:zaproxy-users%2Bunsu...@googlegroups.com>.

Michael Courcy

unread,
Aug 12, 2015, 7:28:40 AM8/12/15
to zaprox...@googlegroups.com

Ok, a last question how do you create the message object ?

If you don't have the time don't bother I can dig , I could watch the sendAndReceive method and find out the nature of the message object (especially its constructor) but if it's easy to explain can you share ?

Thanks anyway.


To unsubscribe from this group and stop receiving emails from it, send an email to zaproxy-user...@googlegroups.com.

thc...@gmail.com

unread,
Aug 12, 2015, 8:04:47 AM8/12/15
to zaprox...@googlegroups.com
Sure, following an example with main methods:
sender = new
org.parosproxy.paros.network.HttpSender(org.parosproxy.paros.model.Model.getSingleton().getOptionsParam().getConnectionParam(),
true, 6)

msg = new org.parosproxy.paros.network.HttpMessage(new
org.parosproxy.paros.network.HttpRequestHeader("GET / HTTP/1.1\r\nHost:
example.com"))
print(msg.getRequestHeader())

msg.getRequestHeader().setMessage("DELETE https://domain.example.com
HTTP/1.0")
print(msg.getRequestHeader())

msg.setRequestHeader(new
org.parosproxy.paros.network.HttpRequestHeader("PUT", new
org.apache.commons.httpclient.URI("https://domain.example.com", /* if
given uri is escaped */ true), "HTTP/1.1"))
msg.setRequestBody(new org.zaproxy.zap.network.HttpRequestBody("a=b&c=d"))
msg.getRequestHeader().setContentLength(msg.getRequestBody().length())

print(msg.getRequestHeader())
print(msg.getRequestBody())

msg.getRequestHeader().setURI(new
org.apache.commons.httpclient.URI("http://example.com", true))
print(msg.getRequestHeader().getURI())

msg.getRequestHeader().setMethod("GET")
print(msg.getRequestHeader().getMethod())

msg.getRequestBody().setBody("");
msg.getRequestHeader().setHeader("Content-Length", null);
msg.getRequestHeader().addHeader("X-Custom-Header", "Value");

print(msg.getRequestHeader())
print(msg.getRequestBody())

sender.sendAndReceive(msg)

print("====================================")
print("====================================")

print(msg.getResponseHeader())
print(msg.getResponseBody())



If you are using Rhino as the JavaScript engine (Java 7) you should
replace "print" with "println".

It was missing the "new" keyword in previous message to create the
HttpSender :/

Best regards.

On 12/08/15 12:28, Michael Courcy wrote:
> Ok, a last question how do you create the message object ?
>
> If you don't have the time don't bother I can dig , I could watch the
> sendAndReceive method and find out the nature of the message object
> (especially its constructor) but if it's easy to explain can you share ?
>
> Thanks anyway.
>
>
> Le mer. 12 août 2015 10:07, <thc...@gmail.com
> <mailto:thc...@gmail.com>> a écrit :
>
> OK, you can create the object to send the requests with:
> sender =
> org.parosproxy.paros.network.HttpSender(org.parosproxy.paros.model.Model.getSingleton().getOptionsParam().getConnectionParam(),
> true, 6)
>
> and do the request with:
> sender.sendAndReceive(message)
>
> and, if you do not want to follow redirects:
> sender.sendAndReceive(message, false)
>
>
> Best regards.
>
> On 12/08/15 08:44, Michael Courcy wrote:
> > Hi
> > I need to send request.
> > Thx
> >
> >
> > Le mer. 12 août 2015 09:32, <thc...@gmail.com
> <mailto:thc...@gmail.com>
> > <mailto:thc...@gmail.com <mailto:thc...@gmail.com>>> a écrit :
> > <mailto:zaproxy-users%2Bunsu...@googlegroups.com
> <mailto:zaproxy-users%252Buns...@googlegroups.com>>
> > > <mailto:zaproxy-user...@googlegroups.com
> <mailto:zaproxy-users%2Bunsu...@googlegroups.com>
> > <mailto:zaproxy-users%2Bunsu...@googlegroups.com
> <mailto:zaproxy-users%252Buns...@googlegroups.com>>>.
> > > For more options, visit https://groups.google.com/d/optout.
> >
> > --
> > You received this message because you are subscribed to the
> Google
> > Groups "OWASP ZAP User Group" group.
> > To unsubscribe from this group and stop receiving emails from it,
> > send an email to zaproxy-user...@googlegroups.com
> <mailto:zaproxy-users%2Bunsu...@googlegroups.com>
> > <mailto:zaproxy-users%2Bunsu...@googlegroups.com
> <mailto:zaproxy-users%252Buns...@googlegroups.com>>.

Michael Courcy

unread,
Aug 12, 2015, 8:55:00 AM8/12/15
to zaprox...@googlegroups.com
Fantastic ! Thank You.

To unsubscribe from this group and stop receiving emails from it, send an email to zaproxy-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Michael Courcy
06 68 41 87 71
Reply all
Reply to author
Forward
0 new messages