Here is the JavaScript
function ChangeVol(id)
{
document.form.selectFS_devId.value = id;
document.form.selectFS_currentNameSpace.value = "";
document.form.submit();
}
function ChangeEvsVol(id, vNodeId)
{
document.form.selectFS_evsId.value = vNodeId;
document.form.selectFS_currentNameSpace.value = "";
ChangeVol(id);
}
document.form.selectFS_devId.value = "all"
document.form.selectFS_evsId.value = "2"
Here is the current C# code I’m using
Uri url = new Uri("https://mgr/app");
HttpWebRequest request = null;
ServicePointManager.ServerCertificateValidationCallback =
((sender, certificate, chain, sslPolicyErrors) => true);
CookieContainer cookieJar = new CookieContainer();
request = (HttpWebRequest)WebRequest.Create(url);
request.CookieContainer = cookieJar;
request.Method = "GET";
HttpStatusCode responseStatus;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
responseStatus = response.StatusCode;
url = request.Address;
}
if (responseStatus == HttpStatusCode.OK)
{
UriBuilder urlBuilder = new UriBuilder(url);
urlBuilder.Path =
urlBuilder.Path.Remove(urlBuilder.Path.LastIndexOf('/')) +
"/j_security_check";
request = (HttpWebRequest)WebRequest.Create(urlBuilder.ToString());
request.Referer = url.ToString();
request.CookieContainer = cookieJar;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
using (Stream requestStream = request.GetRequestStream())
using (StreamWriter requestWriter = new StreamWriter(requestStream, Encoding.ASCII))
{
string postData = "j_username=user&j_password=user&submit=Send";
requestWriter.Write(postData);
}
string responseContent = null;
string myTargetString = "https://mgr/app/action/storage.VivolAction/eventsubmit_dopreparevivollist/ignored/f5/true";
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream responseStream = response.GetResponseStream())
using (StreamReader responseReader = new StreamReader(responseStream))
{
responseContent = responseReader.ReadToEnd();
}
Console.WriteLine(responseContent);
request = (HttpWebRequest)WebRequest.Create(myTargetString);
request.Method = "GET";
request.CookieContainer = cookieJar;
using (HttpWebResponse responsedownload = (HttpWebResponse)request.GetResponse())
using (Stream responseStream = responsedownload.GetResponseStream())
using (StreamReader responseReader = new StreamReader(responseStream))
{
responseContent = responseReader.ReadToEnd();
}
Console.WriteLine(responseContent);
the problem is the string myTargetString doesn’t load the javascript params, if i could duplicate those params in the URL would be awesome, if not, what would I need to do to submit those in a post request like I do above in the StreamWriter?
using (StreamWriter requestWriter = new StreamWriter(requestStream, Encoding.ASCII))
{
string postData = "j_username=user&j_password=user&submit=Send";
requestWriter.Write(postData);
}
What I mean by in the url is perhaps something like:
https://mgr/app/action/storage.VivolAction/eventsubmit_dopreparevivollist/ignored?&evsId=1&devId=all¤tpagenumberbottom=1&filtername=¤tpagenumber=1"aactionlink=/mgr/app/action/storage.VivolQuotaAction&ascending=true¤tpagesize=20&ignoreErrorMessages=true&pageindex=1&sortby=name&filterpath=
Fiddler provided me with this
POST https://mgr/app/action/storage.SelectFileSystemAction/eventsubmit_doprocessselectfilesystem/ignored
Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/xaml+xml, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-xpsdocument, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer: https://mgr/app/action/storage.SelectFileSystemAction /eventsubmit_doprepareselectfilesystem/ignored
Accept-Language: en-us
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0)
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Host: arc
Content-Length: 378
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: jid=asdsad ; jsso = asdas2sa
op=&selectFS_devId=all&selectFS_previous_template=&selectFS_evsId=2&selectFS_currentNameSpace=&selectFS_action_class=storage.VivolAction&selectFS_action_method=doPreparevivollist&selectFS_uniqueId=13655b454e3951462f&selectFS_dont_alter_current=false&selectFS_disableReplicationTargets=true&selectFS_disableReadCache=true&selectFS_disableWorm=false&selectFS_disableUnmounted=true
I can see the electFS_devId=all and selectFS_evsId=2 in there, I need to change the EVSID but I’m not sure how to contruct the URL. Yes I changed the cookie id’s
Your javascript is just setting the form values for what are probably hidden fields on the form before performing the submit. You’ll need to do a POST request, the same way that you do for the login.
Look at the action value on the form tag in your HTML to determine where to submit the data and put the following form items into your postData:
You can use something like:
Looks like this will get involved, because it appears to be doing some form of session or transaction tracking using
selectFS_uniqueIdyou’ll likely have to do a GET operation first and then extract that value from the form. Also, notice that your submit location, just like with the prior j_security_check, isn’t going to the same location for the POST (doprocess) as the GET (doprepare) that retrieves the form.GET
https://mgr/app/action/storage.SelectFileSystemAction/eventsubmit_doprepareselectfilesystem/ignored
POST
https://mgr/app/action/storage.SelectFileSystemAction/eventsubmit_doprocessselectfilesystem/ignored
Take another look at your post values here too. Clearly there is a command being issued with a class (
selectFS_action_class) and method (selectFS_action_method) and likely nothing will be done if they aren’t specified.Rather than writing all this stuff to emulate a user doing operations through the web interface, have you checked with F5 to see if they have web services that you can call to do this?