[Openvas-discuss] Creating a lot of targets

Juan José Pavlik Salles jjpavlik at gmail.com
Wed Nov 9 03:18:34 CET 2011


YESSS!!! you were right!!!

        cadena="<create_target><name>Webserver
$counter</name><hosts>$i</hosts></create_target>"
        omp -X "$cadena" --config-file=$CONFIG

Changed those lines and just added 203 new targets in a minute!!!!! Thanks
Brandon!!!

El 8 de noviembre de 2011 23:16, Brandon Perry
<bperry.volatile at gmail.com>escribió:

> Also, omp -X "$cadena"
>
> 2011/11/8 Brandon Perry <bperry.volatile at gmail.com>:
> >        cadena="'<create_target><name>Webserver
> > $counter</name><hosts>$i</hosts></create_target>'"
> >
> > should be (I think)
> >
> >        cadena="<create_target><name>Webserver
> > $counter</name><hosts>$i</hosts></create_target>"
> >
> > Here is some (albeit C#) code that may help you.
> >
> >                        string command = "<create_target>";
> >
> >                        command = command + "<name>" + name + "</name>";
> >                        command = command + "<comment>" + comment +
> "</comment>";
> >                        command = command + "<hosts>" + hosts +
> "</hosts>";
> >
> >                        if (!string.IsNullOrEmpty(smbCredentialsID))
> >                                command = command +
> "<smb_lsc_credential>" + smbCredentialsID+
> > "</smb_lsc_credential>";
> >
> >                        if (!string.IsNullOrEmpty(sshCredentialsID))
> >                                command = command +
> "<ssh_lsc_credential>" + sshCredentialsID +
> > "</ssh_lsc_credential>";
> >
> >                        command = command + "<port_range>" + portRange +
> "</port_range>";
> >
> >                        command = command + "</create_target>";
> >
> >                        XmlDocument doc = new XmlDocument();
> >                        doc.LoadXml(command);
> >
> >                        XmlDocument response =
> _session.ExecuteCommand(doc);
> >
> >                        return response;
> >
> > 2011/11/8 Juan José Pavlik Salles <jjpavlik at gmail.com>:
> >> This is the context:
> >>
> >> root at openvas:~/pruebas# netstat -natp|grep openvas
> >> tcp        0      0 127.0.0.1:9390          0.0.0.0:*
> >> ESCUCHAR    1665/openvasmd
> >> tcp        0      0 127.0.0.1:9391          0.0.0.0:*
> >> ESCUCHAR    12661/openvassd: wa
> >> tcp        0      0 127.0.0.1:9393          0.0.0.0:*
> >> ESCUCHAR    16805/openvasad
> >>
> >> root at openvas:~/pruebas# cat config
> >> [Connection]
> >> host=localhost
> >> port=9390
> >> username=admin
> >> password=admin
> >>
> >> root at openvas:~/pruebas# omp -X '<create_target><name>Webserver
> >> 0</name><hosts>200.16.30.227</hosts></create_target>'
> --config-file=config
> >> <create_target_response status="201"
> >> id="3e7e1451-979a-4f4e-b57a-1b7b21197f8f" status_text="OK, resource
> >> created"></create_target_response>
> >>
> >> root at openvas:~/pruebas# ./crear_targets.sh
> >> Failed to read response.
> >> ^C
> >> root at openvas:~/pruebas#
> >>
> >> crear_targets.sh is the file script i pasted in the first mail.
> >>
> >> I have no clue... must be some stupid mistake, but it's killing me.
> >>
> >> El 8 de noviembre de 2011 22:56, Brandon Perry <
> bperry.volatile at gmail.com>
> >> escribió:
> >>>
> >>> is openvasmd listening on the correct IP Address/Port? (using the -a
> >>> argument)
> >>>
> >>> 2011/11/8 Juan José Pavlik Salles <jjpavlik at gmail.com>:
> >>> > I guess i am. I also tried passing the user and password parameters
> in
> >>> > the
> >>> > script with -u and -w, but there's no difference, still getting
> "Failed
> >>> > to
> >>> > read response."
> >>> >
> >>> > El 8 de noviembre de 2011 22:27, Brandon Perry
> >>> > <bperry.volatile at gmail.com>
> >>> > escribió:
> >>> >>
> >>> >> Are you authenticating properly with openvassmd?
> >>> >>
> >>> >> 2011/11/8 Juan José Pavlik Salles <jjpavlik at gmail.com>:
> >>> >> > Hi! it's me again. I tried creating targets with
> >>> >> >
> >>> >> > omp -X '<create_target><name>xxx</name><hosts>paste hosts
> >>> >> > here</hosts></create_target>' -u username -w password
> >>> >> >
> >>> >> > and i worked great, but... i have 203 web servers to create... so
> >>> >> > this
> >>> >> > is
> >>> >> > not a good way. I thought about repeating that line in a bash
> script
> >>> >> > for
> >>> >> > all
> >>> >> > my servers, like this:
> >>> >> >
> >>> >> > #!/bin/bash
> >>> >> > TARGETS="/root/pruebas/web_limpio"
> >>> >> > CONFIG="/root/pruebas/config"
> >>> >> >
> >>> >> > if [ ! -e $TARGETS ]; then
> >>> >> >         echo "$TARGETS doesn't exist"
> >>> >> >         exit -1
> >>> >> > fi
> >>> >> >
> >>> >> > counter=0
> >>> >> > for i in `cat $TARGETS`;do
> >>> >> >         cadena="'<create_target><name>Webserver
> >>> >> > $counter</name><hosts>$i</hosts></create_target>'"
> >>> >> >         omp -X $cadena --config-file=$CONFIG
> >>> >> >         counter=$(($counter+1))
> >>> >> > done
> >>> >> >
> >>> >> > But it does not work, i get "Failed to read response." for every
> >>> >> > webserver.
> >>> >> > Any clue???
> >>> >> >
> >>> >> > --
> >>> >> > Pavlik Juan José
> >>> >> >
> >>> >> > _______________________________________________
> >>> >> > Openvas-discuss mailing list
> >>> >> > Openvas-discuss at wald.intevation.org
> >>> >> > http://lists.wald.intevation.org/mailman/listinfo/openvas-discuss
> >>> >> >
> >>> >> >
> >>> >>
> >>> >>
> >>> >>
> >>> >> --
> >>> >> http://volatile-minds.blogspot.com -- blog
> >>> >> http://www.volatileminds.net -- website
> >>> >
> >>> >
> >>> >
> >>> > --
> >>> > Pavlik Juan José
> >>> >
> >>>
> >>>
> >>>
> >>> --
> >>> http://volatile-minds.blogspot.com -- blog
> >>> http://www.volatileminds.net -- website
> >>
> >>
> >>
> >> --
> >> Pavlik Juan José
> >>
> >
> >
> >
> > --
> > http://volatile-minds.blogspot.com -- blog
> > http://www.volatileminds.net -- website
> >
>
>
>
> --
> http://volatile-minds.blogspot.com -- blog
> http://www.volatileminds.net -- website
>



-- 
Pavlik Juan José
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wald.intevation.org/pipermail/openvas-discuss/attachments/20111108/333613a9/attachment.html>


More information about the Openvas-discuss mailing list