Change proxy server after Http Request using xNet (c#) - c#

I'm currently working on a C# Application that sends requests to a server. I am using proxies to change my IP to avoid Bans...
Issue: The only problem is it doesn't work how I want it to. I want the program to Automatically to change the username and proxy and also repeat this function (after button click:)
using xNet;
using (var request = new HttpRequest())
{
string proxy = "127.0.0.1:8888";
request["Accept"] = "*/*";
request.Proxy = Socks5ProxyClient.Parse(proxy);
var attempt = request.Post("https://fortnite-public-api.theapinetwork.com/prod09/users/id?username=" + TextBox1.Text).ToString();
}
My question for my code is: is it possible to repeat the function without using a timer? And also how can I make it so the proxy and username will automatically change after the server has responded?
How I want the code to work:
Basically, the user imports a list of usernames and proxies (IP:PORT,) after the user clicks on the start button it will send the server the first line of text and will set proxy form the imported Proxy.txt file. After the server responds, it will send the server the server the second line of text and will change the proxy to the second line of proxy form the imported Text file. So it starts form ProxyCount and UserNameCount 1 and then ++ it will keep sending until it has reached the last line of the username.

Related

Get all events from Asterisk 12

In my application I want to show a real time overview of all active calls on a asterisk server.
That's why I want to get all events (channel created/destroyed etc.) from Asterisk 12 server using the Asterisk 12 REST API (ARI).
When I connect to the websocket I only get events that are somehow targeted to my application that I specified in the initial call to "/ari/events" (in this case "hello").
$ wscat.py 'ws://localhost:8088/ari/events?app=hello&api_key=...'
How can I get all events (e.g. also information about new incoming calls)?
Or is there another possibility to get the desired information?
I am using AsterNET.ARI .NET Stasis Framework and the following code:
// Create a message client to receive events on
Client = new ARIClient(
new StasisEndpoint(Host, Port, Username, Password),
AppName
);
Client.Connect();
Client.OnChannelStateChangeEvent += Client_OnChannelStateChangeEvent;
The method Client_OnChannelStateChangeEvent is only called for calls that I have originated by my application using Client.Channels.Originate(...).
You can use AMI(manager interface)
http://www.voip-info.org/wiki/view/Asterisk+manager+API
http://www.voip-info.org/wiki/view/asterisk+manager+events

login to ajax web page from c# code

i'm trying to log in a site with username + password through a c# code.
i found out that it uses Ajax to authenticate...
how should i implement such login ?
the elements in the web page doesn't seem to have an "id"...
i tried to implement it using HtmlAgilityPack but i don't think this is the correct direction...
i can't simulate a click button since i don't find "id" for the button.
if (tableNode.Attributes["class"].Value == "loginTable")
{
var userInputNode =
tableNode.SelectSingleNode("//input[#data-logon-popup-form-user-name-input='true']");
var passwordInputNode =
tableNode.SelectSingleNode("//input[#data-logon-popup-form-password-input='true']");
userInputNode.SetAttributeValue("value", "myemail#gmail.com");
passwordInputNode.SetAttributeValue("value", "mypassword");
var loginButton = tableNode.SelectSingleNode("//div[#data-logon-popup-form-submit-btn='true']");
}
This question is quite broad but I'll help you in the general direction:
Use Chrome DevTools (F12) => Network tab => Check the "Preserve Log". An alternative could be Fiddler2
Login manually and look at the request the AJAX sends. Save the endpoint (the URL) and save the Body of the request (the Json data that's in the request with username and password)
Do the post directly in your C# code and forget about HtmlAgilityPack unless you need to actually get some dynamic data from the page, but that's rarely the case
Login with something like this code snippet: POSTing JSON to URL via WebClient in C#
Now you're logged in. You usually receive some data from the server when you're logging in, so save it and use it for whatever you want to do next. I'm guessing it might have some SessionId or some authentication token that your future requests will need as a parameter to prove that you're actually logged in.

SignalR not adding server callbacks

When every I attempt to add a new server callback function I cannot seem to get the callback to show up in the $.connection server callback list.
What do I need to do to refresh the javascript that SignalR produces and sends to the client with the latest list of server callbacks.
I would think that I should be able to just add a server callback for the client to call and rebuild my app and fire up a new instance of Google Chrome and the newly added server callback would be in the list of available callbacks on the client.
For example here is exactly what I've done.
1.) A client joins a group and everyone is notified.
public override Task OnConnected()
{
string pid = this.Context.QueryString["pid"],
uid = this.Context.QueryString["uid"],
ispro = this.Context.QueryString["ispro"];
Groups.Add(this.Context.ConnectionId, pid);
return Clients.Group(pid).joined(new cmsg(Context.ConnectionId, UtilCommon.GetUserMini(new Guid(uid), bool.Parse(ispro))));
}
2.) On the client the joined function is called from the server
this.collaborateHub.client.joined = function (cmsg) {
//
that.chatBox.addAttendee(cmsg);
//let the new attendee know about you
if (cmsg.cnnid !== that.chatBox.getMeAttendee().cnnid) {
that.chatBox.getMeAttendee().newbieid = cmsg.cnnid;
debugger
this.server.addMeNewbie(that.chatBox.getMeAttendee());
};
};
3.) Now, if someone joined and it was not the user of the currently opened window, that means the someone how just joined is someone other than myself, so I need to call the server back and notify the newly joined user to add me to their user list. I stead of having to keep up with the currently signed on users to the given group in a database, I am just using every signed on client of the group as a distributed database and let them manage their own info.
So, I need to call the server callback named addMeNewbie; however, this callback function is not available in the list.
public Task addMeNewbie(cmsg cmsg) {
return Clients.Client(cmsg.newbieid).addCurrAttendee(cmsg);
}
Here is a snapshot of the client side in debug mode
4.) And finally here is the client side callback that i need the server to call so that the newly joined group member can update their list of current group members.
this.collaborateHub.client.addCurrAttendee = function (cmsg) {
debugger
that.chatBox.addAttendee(cmsg);
};
I would think that I should be able to add as many server callbacks as I want and they should show up on the next build and restart of a new instance of Google Chrome; however, this is not the case. What do I need to do to get newly added server callbacks to show up in the available server callbacks on the client side?
This doesn't make since to me, but I am thinking maybe this is a cashing issue or something?
The only callback that is available is the one shown in the snapshot provided. At this time I've only got two callbacks, the one that you see in the snapshot and the one that is not visible.
Somewhere along the way I created a signalr-hubs.js file from the generated JavaScript file that can be retrieved by http://localhost:3250/signalr/hubs and was adding new server functions to my hub but not updating the signalr-hugs.js file.
At this point every time I add a new server callback I retrieve the newly generated proxy by placing this url http://localhost:3250/signalr/hubs into the browser, coping the code, and then updating my signalr-hubs.js file.

Silverlight: Preventing authentication window / login prompt while connecting SharePoint with different credentials using DataContext (REST)

I'm programming a Silverlight client to consume a list in Sharepoint 2010 using REST. It's supposed to work as a gadget on users Windows desktop.
My requirement is, logging into Sharepoint with specific credentials instead of current logged user. It works fine with the source code I pasted down and I'm able to fetch the list content as expected, however, everytime I run the software, Windows shows a login box - authentication window to user before estabilishing a connection to Sharepoint.
If user skips it by clicking "cancel" the rest of software works normally.
So I need to prevent this login box.
ObservableCollection<ShoutBoxItem> allItems = new ObservableCollection<ShoutBoxItem>();
ShoutsProxy.TwitterDataContext context = new TwitterDataContext(new Uri(webServiceUrl));
context.HttpStack = HttpStack.ClientHttp;
context.Credentials = new System.Net.NetworkCredential(username, password, domain);
context.UseDefaultCredentials = false;
DataServiceQuery<ShoutBoxItem> query = DataServiceQuery<ShoutBoxItem>)context.ShoutBox;
query.BeginExecute(onGetShoutBoxItemsComplete, query);
So at exactly "query.beginexecute" line, a login box comes up immediately.
Any suggestions?
Greetings from Duisburg,
Alper Barkmaz
Well, I have found a workaround for this.
Instead of filling out a NetworkCredential object with login information, I post username and password at web service URL, http://username:password#domain.com/service.svc
And voila, there's no authentication prompt. The point was, my silverlight application was hosted in local html file with address starting with file://, thus transferring network credentials to target domain was having problems. So in this case, instead of dealing this inside Silverlight, I directly modified the URL and the result was brilliant.
Security: I believe httpclient breaks in, does authentication and removes the login information from URL, so the login information is not transferred over network as plain text. However, double checking this is better.
The new form of solution is,
ObservableCollection<ShoutBoxItem> allItems = new ObservableCollection<ShoutBoxItem>();
ShoutsProxy.TwitterDataContext context = new TwitterDataContext(new Uri("http://username:password#domain.com/service.svc"));
context.HttpStack = HttpStack.ClientHttp;
context.Credentials = new System.Net.NetworkCredential();
context.UseDefaultCredentials = false;
DataServiceQuery<ShoutBoxItem> query = DataServiceQuery<ShoutBoxItem>)context.ShoutBox;
query.BeginExecute(onGetShoutBoxItemsComplete, query);

RDPSession ConnectToClient Terminating Unexpectedly

I have successfully created a desktop sharing solution where an RDPViewer connects to an RDPSession. That's all working beautifully. Now, however, I'm trying to get the opposite to work: using the RDPViewer's StartReverseConnectListener method, and RDPSession's ConnectToClient method (where the session side would connect to the viewer side to work around NAT/Firewall issues). I've followed the steps outlined at http://msdn.microsoft.com/en-us/library/windows/desktop/aa373359%28v=vs.85%29.aspx, mainly:
The viewer obtains its connection string by calling the
StartReverseConnectListener method, passing NULL for the
bstrConnectionString, bstrUserName, and bstrPassword parameters.
The viewer initiates a reverse connect listener by calling the
StartReverseConnectListener method, passing NULL for the
pbstrReverseConnectString parameter and valid values for the
bstrConnectionString, bstrUserName, and bstrPassword parameters.
The viewer sends the connection string obtained in step 1 to the
sharer.
Using C# 2010, I've done the following on the RDPSession side:
RDPSession session = new RDPSession();
session.Open();
session.Invitations.CreateInvitation(null, "test", "12345", 1);
Then, on the RDPViewer side, I've done:
string reverseConnectString = axRDPViewer1.StartReverseConnectListener(null, null, null);
(step 1, above)
axRDPViewer1.StartReverseConnectListener(reverseConnectString, "test", "12345");
(step 2, above)
Then, back on the RDPSession side, I attempt to make the connection using the reverseConnectString I obtained from the viewer (I actually saved the string to a file, and then loaded it on the RDPSession side):
session.ConnectToClient(reverseConnectString);
(step 3, above)
As soon as I execute this method, the RDPViewer side disconnects with an error of 1798, which, according to http://msdn.microsoft.com/en-us/library/aa373802%28VS.85%29.aspx, means:
ServerCertificateUnpackErr 1798
Failed to unpack server certificate.
I feel like I'm missing something obvious, but I can't figure out what.
Any suggestions?
Thanks!
The Microsoft documentation is all wrong regarding reverse connections. Here's what you need to do (adapted from your code above):
RDP Session Side:
RDPSession session = new RDPSession();
session.Open();
string hostConnString = session.Invitations.CreateInvitation(null, "My Group Name", "12345", 1);
RDPViewer side (note that hostConnString should be the same value as retrieved on the session side):
string viewerConnString = axRDPViewer1.StartReverseConnectListener(hostConnString, "My Name", "12345");
Now back to the RDP session side (note that the viewerConnString should be the same value as retrieved from the viewer side):
session.ConnectToClient(viewerConnString);
And that should do it. A couple of things to note. The group name specified in CreateInvitation does not need to match anything anywhere else. I think it's just for reference should your program need to enumerate the invitations started by the host. The user name passed to StartReverseConnectListener can also be anything you want. This can be interrogated and used on the host side by looking at the RemoteName property in the IRDPSRAPIAttendee interface.

Categories