I need help to protect a very private tool that accepts followers on Instagram, I want to make the exe openable only if the user has logins credentials to prevent people from leaking it. I only have the .exe file and it's CMD line based, I wonder if we could like make an auth form in C# and then bind it to the .exe file Thanks
Asked
Active
Viewed 514 times
0
-
2Why not just specify the credentials as command-line arguments? – Nov 23 '18 at 14:41
-
The easiest way is to create a group account on the PC. The put users into the group account. You can then create a file on the PC with read credentials for the group account. So when the program runs only the users in the group account will be able to read file. With windows anybody can log into a computer and an account will be created. So just checking credentials will not prevent users from running program. – jdweng Nov 23 '18 at 14:51
-
Use the [process class](https://www.dotnetperls.com/process) to invoke the .exe – Kunal Mukherjee Nov 23 '18 at 14:57
-
If you pass on EXE file - accept that nothing in this file is secure. File can be decompiled, memory can be modified - just a matter of skill. Yes, some basic authentication will protect from naive user, but nothing will protect your code from competent hacker. – trailmax Nov 23 '18 at 14:57
-
You mean like how the game industry for years tried to stop people pirating their games with remarkable success rates (until they could force always online/server connected)? – Damien_The_Unbeliever Nov 23 '18 at 15:10
1 Answers
0
Hard coded info:
The most simple scenario is just asking about credentials when starting the tool -> i.e. hard-coded username and password.
Active directory (or local PC) data:
other more professional option is to read the data from active directory (I do not know the environment you are working in), for example check if this user belongs to a specific group, the code will look like this:
// set up domain context
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "DOMAINNAME");
// find a user
UserPrincipal user = UserPrincipal.FindByIdentity(ctx, "SomeUserName");
// find the group in question
GroupPrincipal group = GroupPrincipal.FindByIdentity(ctx, "YourGroupNameHere");
if(user != null)
{
// check if user is member of that group
if (user.IsMemberOf(group))
{
// do something.....
}
}
The code above is taken from this answer.

Mohammed Noureldin
- 14,913
- 17
- 70
- 99