|
Is it possible to detect if an app us running on our network? or VPN'd in? If so, how?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Is there a webserver running on the network? If not, grab a raspberry Pi and make one.
Try downloading a text-file from that webserver over the local LAN-address. If it works, you're either on your own network, or someone is trying to convince your app that it is.
Alternatively, you ask one of the network-admins for some help; I'll bet there's a lot of things that identify your network as yours when running netstat, ipconfig, whois and nslookup
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
That depends, and there are a few different approaches depending on your network configuration. It also depends on how much say you have in terms of how change is affected.
If you are using a Domain and the network is configured only to allow domain machines (via 802.1x or some other standard), then you can query WMI on windows machines on the domain using a privileged account, generally using powershell or a custom tool. You can mine running processes through WMI, and I would classify this as the "best" way to find out if a bit of software is running. Linux machines are easier, the BASH command ps-A will give you a running process list. You could do the same with local admin accounts, of course, but that approach really doesn't scale well.
Unfortunately, because of the pretty extreme strictures of Frame-level security, most networks do not have a domain lock on their network. You can run a port scan on a computer to try to determine what responsive applications are running, but that's not terribly consistent, especially with the number of applications that will use ephemeral ports, and can only determine applications that will handle in-bound connections.
You could require a connection client exist on computers before they get a DHCP lease; Cisco AnyConnect has modules that can do this, and I'm sure there's other pre-baked solutions for that. That connection client can have compliance portions that can do just about anything on the host, like process or file enumeration, as well as AV definition version checks, and so on. This is a medium-good solution, since anyone that can figure out how your switches are subnetted can just set a static IP.
Network traffic analysis will generally reveal applications that are communicating over the network with a fair degree of reliability. Best practices would say that you run a network proxy for hosts inside your domain, otherwise you'll have a bunch of encrypted traffic passing in and out of your network with no visibility into what that traffic is; not great for preventing intrusion or exfiltration. With un-encrypted traffic, a number of tools can fingerprint traffic automatically. From a pragmatic operational standpoint, this is generally the most feasible option for application fingerprinting.
Same answers apply to VPN, bearing in mind that the VPN address range should be subnetted differently than native internal systems.
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
|
|
|
|
|
This is a somewhat wide subject, so the QnA was inappropriate.
I am working on some games and apps, and they need to talk to some MySQL servers and/or Azure resources, and so I need some connection strings. Usually I've made internal tools, where having the connection strings in code or in a XML or Json -file, was unproblematic.
Now I'm having the issue that APK's are basically Zip-files, and .net executables are de-compilable.
My first solution is to setup an intermediary web service to keep the connection strings unavailable from the app.
But I can't help but think that I'm missing something here.
Also, an extra middle-man webserver, increase the possible bottle-necks and failure points
What are this community's thoughts on the subject?
Thanks for your time!
|
|
|
|
|
Frank R. Haugen wrote: This is a somewhat wide subject, so the QnA was inappropriate. Actually quite the opposite. More people would see this in Q&A, rather than just those who look at C# questions (which this is not).
|
|
|
|
|
Frank R. Haugen wrote: Now I'm having the issue that APK's are basically Zip-files, and .net executables are de-compilable. Does not seem an issue for Rimworld.
Frank R. Haugen wrote: What are this community's thoughts on the subject? If you can't afford the user in the database, don't give away the connectionstring. Simple as that. Third parties can't keep secrets on a computer that isn't theirs.
Who is going to be the "owner" of the data? You, or the user? Is the user going to be allowed to make changes? If no, simply give them a connection-string that's hooked to a user with limited (read) access.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hello there. I want to do an ftp server-client program with c #. I created free hostting for this, but this hostting does not give me ftp authorization, can you help me with this.
|
|
|
|
|
We can't add FTP authorization for you - you need to talk to your hosting service and see what they can do for you. It may be that your free plan does not include any FTP access and may well be blocked by their firewall (free plans are generally limited in some ways, and I don't bother with them at all any more as they have all been more hassle than they were worth) but that is something you will have to discuss with your provider.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Free hosting companies make their money by showing ads on the sites that you host there. Abusing their service to provide drive-functionality in the cloud would be probably in violation of their terms of use.
..but that's why they block FTP. It's a question that comes by a few times a year. If you want FTP, you will probably have to pay for the service.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
double a;
double da, fn, dfn_da;
da = 0.00;
double epsilon = 1.0e-10;
bool converged = true;
a = 10;
int n = 0;
do
{
for (int Ls = 10; Ls <= 30; Ls += 5)
{
for (double H = 0.5; H <= 2.5; H += 0.5)
{
n++;
fn = a * Math.Cosh(Ls / (2 * a)) - a - H;
dfn_da = -(Ls * Math.Sinh(Ls / (2 * a)) / (2 * a)) + Math.Cosh(Ls / (2 * a)) - H;
if (Math.Abs(dfn_da) < epsilon)
{
converged = false;
break;
}
else if (n == 200)
{
converged = false;
break;
}
da = -fn / dfn_da;
a += da;
}
while (Math.Abs(da) > epsilon)
{
if (converged)
Console.WriteLine("The root of the equation is: {0}", a);
}
}
}
}
}
|
|
|
|
|
What issue, all you have done is dump some code into the forum. Tell us what the problem is and where it occurs and you may get a better result.
Check the positioning of your do-while loop.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
The indentation shows you what the problem is!
Not only are you missing a close curly bracket, but your while is part of your outer for loop, rather than the do ...
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hi. There are 3 lists: List1, List2, List3;
List1: 1,2,3,... (can be empty)
List2: A,B,C,D,E,... (can be empty)
List3: a,b,c,... (can be empty)
I need to parse it into one List<obj> where OBJ{ data_list1, data_list2, data_list3}:
(1) 1,A,a
(2) 1,A,b
(3) 1,A,c
..
(..) 3,E,c
...
All variants of existing data form lists.
The list can be empty, and I need to use empty like a data. For example:
(1) empty, A,a
...
(2) empty,E,c
Could you advise the solution, please?
|
|
|
|
|
There is a Zip function which does some of what you want: Enumerable.Zip(IEnumerable<TFirst>, IEnumerable<TSecond>, Func<TFirst,TSecond,TResult>) Method (System.Linq) | Microsoft Docs[^]
List<int> list1 = new List<int>() { 1, 2, 3 };
List<string> list2 = new List<string>() { "A", "B", "C"};
List<string> list3 = new List<string>() { "a", "b", "c" };
var x = list1.Zip(list2, (a, b) => new { a, b }).Zip(list3, (a, c) => new { a.a, a.b, c }).ToList();
But ... the problem is that your lists are not necessarily the same length. I think that to get this to work in any practical way, you'd have to "pad" all three lists with NULL entries in order to use any standard methods. You would probably be better off writing your own class and providing a constructor that takes three lists and combines them the way you want.
What are you trying to do that you think this is a good idea? There may be better ways.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
This appears to me to require generating permutations/combinations. There are some excellent resources here for this in C#: I suggest you start here: [^].
And: [^] Here's a recent article that looks interesting: [^]
As OriginalGriff suggests, you need to get your data "normalized."
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
|
|
|
|
|
|
Since you've got a fixed number of lists, this should be fairly easy to do with a combination of SelectMany[^] and DefaultIfEmpty[^]:
var result = list1.DefaultIfEmpty().SelectMany(l1 => list2.DefaultIfEmpty().SelectMany(l2 => list3.DefaultIfEmpty().Select(l3 => new { l1, l2, l3 }))).ToList();
It's slightly cleaner using the query syntax:
var query = from l1 in list1.DefaultIfEmpty()
from l2 in list2.DefaultIfEmpty()
from l3 in list3.DefaultIfEmpty()
select new { l1, l2, l3 };
var result = query.ToList();
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have create a Win form app and create Polygons as follows:
private List<list<pointf>> Polygons = new List<list<pointf>>();
I store this polygons with Xml.Serialization, into a MySQL database as string and Deserialize it with my console app into a list of polygons again.
In my console app, which eventually is going to run from Raspberry Pi, I'm getting data from USB, which consist of floating X and floating Y coordinates.
Now I want to know how do I check if this point is within one of the polygons. I've tried it first with WinForms app and it works great.
public static bool IsPointInPolygon(IList<pointf> polygon, PointF testPoint)
{
try
{
bool result = false;
int j = polygon.Count() - 1;
for (int i = 0; i < polygon.Count(); i++)
{
if (polygon[i].Y < testPoint.Y && polygon[j].Y >= testPoint.Y || polygon[j].Y < testPoint.Y && polygon[i].Y >= testPoint.Y)
{
if (polygon[i].X + (testPoint.Y - polygon[i].Y) / (polygon[j].Y - polygon[i].Y) * (polygon[j].X - polygon[i].X) < testPoint.X)
{
result = !result;
}
}
j = i;
}
return result;
}
catch (Exception ex)
{
MessageBox.Show("error - " + ex.ToString());
return false;
}
I don't want to draw something, I know it's a console app, just getting a bool or int value back from the Test.
Any suggestions or help please?
|
|
|
|
|
What exactly is the problem? If the calculations work in a Windows Form app, then they will work in any other app.
|
|
|
|
|
I didn't add the drawing reference. Not my day. Thank you Richard. It works
modified 12-Nov-18 8:28am.
|
|
|
|
|
But the calculation is the same. Create a set of points which describe the polygon. Now do the comparisons with your test points.
|
|
|
|
|
Says who?
Of course you can! See the code I gave you in my reply - that code works just fine in a Console app!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
If you create a GraphicsPath object for the points, you can use that to check:
System.Drawing.Drawing2D.GraphicsPath poly = new System.Drawing.Drawing2D.GraphicsPath();
poly.AddLine(10, 10, 90, 10);
poly.AddLine(90, 10, 90, 90);
poly.AddLine(90, 90, 10, 90);
poly.AddLine(10, 90, 10, 10);
Point inPoly = new Point(50, 50);
Point outPoly = new Point(0, 0);
Console.WriteLine(poly.IsVisible(inPoly) ? "IN" : "OUT");
Console.WriteLine(poly.IsVisible(outPoly) ? "IN" : "OUT");
The beauty of that is that the poly can be extremely complex and the framework will sort it out. For example, an hourglass:
System.Drawing.Drawing2D.GraphicsPath poly = new System.Drawing.Drawing2D.GraphicsPath();
poly.AddLine(10, 10, 90, 90);
poly.AddLine(90, 90, 10, 90);
poly.AddLine(10, 90, 90, 10);
poly.AddLine(90, 10, 10, 10);
Point inPoly = new Point(50, 40);
Point outPoly = new Point(40, 50);
Console.WriteLine(poly.IsVisible(inPoly) ? "IN" : "OUT");
Console.WriteLine(poly.IsVisible(outPoly) ? "IN" : "OUT");
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
How to get the WIFI and LAN usage in C#.
Also my requirement is to get the usage between specified date range.
|
|
|
|
|
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
So stop trying to type as little as possible and explain what it is you are trying to do, what you have tired, where you are stuck, and what help you need!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|