accountmanagementengine

accountmanagementengine Commit Details


Date:2013-01-26 16:36:00 (11 years 10 months ago)
Author:Natalie Adams
Branch:default
Commit:1bbff175f8dd
Message:Adding account management code

Changes:
AAccountManagementConsole/AccountManagementConsole.csproj (full)
AAccountManagementConsole/AccountManagementConsole.sln (full)
AAccountManagementConsole/Program.cs (full)
AAccountManagementConsole/Properties/AssemblyInfo.cs (full)
AAccountManagementEngine/AccountManagementEngine.cs (full)
AAccountManagementEngine/AccountManagementEngine.csproj (full)
AAccountManagementEngine/AccountManagementEngine.sln (full)
AAccountManagementEngine/CookieAwareWebClient.cs (full)
AAccountManagementEngine/Engines/FacebookEngine.cs (full)
AAccountManagementEngine/Engines/SMFEngine.cs (full)
AAccountManagementEngine/Engines/TwitterEngine.cs (full)
AAccountManagementEngine/Engines/WindowsEngine.cs (full)
AAccountManagementEngine/IEngine.cs (full)
AAccountManagementEngine/Properties/AssemblyInfo.cs (full)
AAccountManagementEngine/Properties/Resources.Designer.cs (full)
AAccountManagementEngine/Properties/Resources.resx (full)
AAccountManagementEngine/Resources/facebook_login.txt (full)
AAccountManagementEngine/Resources/facebook_passgate.txt (full)
AAccountManagementEngine/Resources/smf_login.txt (full)
AAccountManagementEngine/Resources/smf_passgate.txt (full)
AAccountManagementEngine/Resources/twitter_login.txt (full)
AAccountManagementEngine/Resources/twitter_passgate.txt (full)
AAccountManagementEngine/WebEngine.cs (full)

File differences

AccountManagementConsole/AccountManagementConsole.csproj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{756440DE-D000-4CD0-8735-30AAB282FD13}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AccountManagementConsole</RootNamespace>
<AssemblyName>AccountManagementConsole</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="AccountManagementEngine">
<HintPath>.\AccountManagementEngine.dll</HintPath>
</Reference>
<Reference Include="OTPNet">
<HintPath>.\OTPNet.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
AccountManagementConsole/AccountManagementConsole.sln
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccountManagementConsole", "AccountManagementConsole.csproj", "{756440DE-D000-4CD0-8735-30AAB282FD13}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{756440DE-D000-4CD0-8735-30AAB282FD13}.Debug|x86.ActiveCfg = Debug|x86
{756440DE-D000-4CD0-8735-30AAB282FD13}.Debug|x86.Build.0 = Debug|x86
{756440DE-D000-4CD0-8735-30AAB282FD13}.Release|x86.ActiveCfg = Release|x86
{756440DE-D000-4CD0-8735-30AAB282FD13}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
AccountManagementConsole/Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AccountManagement;
using OTPNet;
using System.Timers;
using System.IO;
namespace AccountManagementConsole
{
class Program
{
static void Main(string[] args)
{
//Timer tim;
Dictionary<string, string> options = new Dictionary<string,string>();
if (args[0] == "-f")
{
StreamReader filestream = new StreamReader(args[1]);
string filecont = filestream.ReadToEnd();
filestream.Close();
string[] parts = filecont.Split(' ');
if (parts.Length == 6)
options = parseOpts(parts[5]);
string newpass = ExecuteOptions(parts[0], parts[1], parts[2], parts[3], parts[4], options);
StreamWriter filewrite = new StreamWriter(args[1]);
filecont = filecont.Replace(parts[3], newpass);
filewrite.Write(filecont);
filewrite.Flush();
filewrite.Close();
}
else
{
if (args.Length == 6)
options = parseOpts(args[5]);
ExecuteOptions(args[0], args[1], args[2], args[3], args[4], options);
}
}
static string ExecuteOptions(string engine, string key, string user, string oldpass, string newpassbase, Dictionary<string, string> options)
{
Engine eng = Engine.NONE;
string newpass;
switch (engine)
{
case "fb":
eng = Engine.FACEBOOK;
break;
case "smf":
eng = Engine.SMF;
break;
case "win":
eng = Engine.WINDOWS;
break;
case "twitter":
eng = Engine.TWITTER;
break;
}
TOTP t = new TOTP(key);
using (AccountManagementEngine aeng = new AccountManagementEngine())
{
foreach (KeyValuePair<string, string> opt in options)
{
aeng.AddData(opt.Key, opt.Value);
}
newpass = newpassbase + t.now().ToString("D6");
aeng.ChangePassword(eng, user, oldpass, newpass);
}
return newpass;
}
static Dictionary<string, string> parseOpts(string arg)
{
Dictionary<string, string> ret = new Dictionary<string,string>();
string[] sections = arg.Split('&');
string[] pieces;
foreach(string s in sections)
{
pieces = s.Split('=');
ret[pieces[0]] = pieces[1];
}
return ret;
}
}
}
AccountManagementConsole/Properties/AssemblyInfo.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("AccountManagementConsole")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AccountManagementConsole")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3860ac52-6cfd-4dfa-b6a9-3ad3cc504701")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
AccountManagementEngine/AccountManagementEngine.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Text.RegularExpressions;
using AccountManagement.Engines;
namespace AccountManagement
{
public enum Engine
{
FACEBOOK,
SMF,
TWITTER,
WINDOWS,
NONE
}
public class AccountManagementEngine : IDisposable
{
public Dictionary<string, string> options = new Dictionary<string,string>();
public void AddData(string key, string val)
{
this.options[key] = val;
}
public bool ChangePassword(Engine engine, string username, string oldpass, string newpass)
{
bool retval = true;
IEngine eng = null;
switch (engine)
{
case Engine.FACEBOOK:
eng = new FacebookEngine();
break;
case Engine.TWITTER:
eng = new TwitterEngine();
break;
case Engine.SMF:
// Options:
// Required:
// URL
eng = new SMFEngine(options);
break;
case Engine.WINDOWS:
// Options:
// Required:
// location { local | domain }
// if location == domain
// domain -> domain of AD
// ads -> path of AD ie dc=microsoft,dc=com
eng = new WindowsEngine(options);
break;
}
if (eng != null)
eng.ChangePassword(username, oldpass, newpass);
return retval;
}
public void Dispose()
{
}
}
}
AccountManagementEngine/AccountManagementEngine.csproj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{89ED6745-E9F4-42A3-8795-D1C213956084}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AccountManagement</RootNamespace>
<AssemblyName>AccountManagementEngine</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.DirectoryServices.AccountManagement" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AccountManagementEngine.cs" />
<Compile Include="CookieAwareWebClient.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Engines\FacebookEngine.cs" />
<Compile Include="Engines\SMFEngine.cs" />
<Compile Include="Engines\TwitterEngine.cs" />
<Compile Include="Engines\WindowsEngine.cs" />
<Compile Include="IEngine.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="WebEngine.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="Resources\facebook_login.txt" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\facebook_passgate.txt" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\twitter_login.txt" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\twitter_passgate.txt" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\smf_login.txt" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\smf_passgate.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
AccountManagementEngine/AccountManagementEngine.sln
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccountManagementEngine", "AccountManagementEngine.csproj", "{89ED6745-E9F4-42A3-8795-D1C213956084}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{89ED6745-E9F4-42A3-8795-D1C213956084}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{89ED6745-E9F4-42A3-8795-D1C213956084}.Debug|Any CPU.Build.0 = Debug|Any CPU
{89ED6745-E9F4-42A3-8795-D1C213956084}.Release|Any CPU.ActiveCfg = Release|Any CPU
{89ED6745-E9F4-42A3-8795-D1C213956084}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
AccountManagementEngine/CookieAwareWebClient.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
namespace AccountManagement
{
//copied from http://rockycode.com/blog/creating-cookie-aware-webclient/
internal class CookieAwareWebClient : WebClient
{
public CookieContainer CookieContainer { get; set; }
public Uri Uri { get; set; }
public CookieAwareWebClient()
: this(new CookieContainer())
{
}
public CookieAwareWebClient(CookieContainer cookies)
{
this.CookieContainer = cookies;
}
protected override WebRequest GetWebRequest(Uri address)
{
WebRequest request = base.GetWebRequest(address);
if (request is HttpWebRequest)
{
(request as HttpWebRequest).CookieContainer = this.CookieContainer;
}
HttpWebRequest httpRequest = (HttpWebRequest)request;
httpRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
return httpRequest;
}
protected override WebResponse GetWebResponse(WebRequest request)
{
WebResponse response = base.GetWebResponse(request);
String setCookieHeader = response.Headers[HttpResponseHeader.SetCookie];
if (setCookieHeader != null)
{
this.CookieContainer.SetCookies(response.ResponseUri, setCookieHeader);
}
return response;
}
}
}
AccountManagementEngine/Engines/FacebookEngine.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace AccountManagement.Engines
{
internal class FacebookEngine : IEngine, IDisposable
{
private WebEngine web;
public bool ChangePassword(string username, string oldpass, string newpass)
{
web = new WebEngine("Nokia 7110/1.0");
this.Login(username, oldpass);
this.ChangePass(oldpass, newpass);
return true;
}
private void Login(string username, string password)
{
Dictionary<string, string> postdatadct = new Dictionary<string, string>();
postdatadct.Add("{{username}}", username);
postdatadct.Add("{{password}}", password);
string[] scriptarr = Regex.Split(Properties.Resources.facebook_login, Environment.NewLine);
this.web.PostData(scriptarr[0], scriptarr.Skip(1).ToArray(), postdatadct);
}
private void ChangePass(string oldpass, string newpass)
{
Dictionary<string, string> postdatadct = new Dictionary<string, string>();
postdatadct.Add("{{oldpassword}}", oldpass);
postdatadct.Add("{{newpassword}}", newpass);
string passpage = this.web.DownloadString("https://m.facebook.com/settings/account/?password&refid=70");
Regex r = new Regex(@"""hidden"" name=""fb_dtsg"" value=""(.*)"" autocomplete=""off"" />");
Match m = r.Match(passpage);
List<string> scriptarr = Regex.Split(Properties.Resources.facebook_passgate, Environment.NewLine).ToList();
scriptarr.Add("fb_dtsg=" + m.Groups[1].ToString());
this.web.PostData(scriptarr[0], scriptarr.Skip(1).ToArray(), postdatadct);
}
public void Dispose()
{
}
}
}
AccountManagementEngine/Engines/SMFEngine.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace AccountManagement.Engines
{
class SMFEngine : IDisposable, IEngine
{
private WebEngine web;
private Dictionary<string, string> options;
public SMFEngine(Dictionary<string, string> options)
{
this.web = new WebEngine();
this.options = options;
}
public bool ChangePassword(string username, string oldpass, string newpass)
{
this.Login(username, oldpass);
this.ChangePass(oldpass, newpass);
return true;
}
private void Login(string username, string password)
{
Dictionary<string, string> postdatadct = new Dictionary<string, string>();
postdatadct.Add("{{username}}", username);
postdatadct.Add("{{password}}", password);
postdatadct.Add("{{url}}", this.options["url"]);
string[] scriptarr = Regex.Split(Properties.Resources.smf_login, Environment.NewLine);
this.web.PostData(scriptarr[0], scriptarr.Skip(1).ToArray(), postdatadct);
}
private void ChangePass(string oldpass, string newpass)
{
Dictionary<string, string> postdatadct = new Dictionary<string, string>();
postdatadct.Add("{{oldpassword}}", oldpass);
postdatadct.Add("{{newpassword}}", newpass);
postdatadct.Add("{{url}}", this.options["url"]);
string[] scriptarr = Regex.Split(Properties.Resources.smf_passgate, Environment.NewLine);
this.web.PostData(scriptarr[0], scriptarr.Skip(1).ToArray(), postdatadct);
}
public void Dispose()
{
}
}
}
AccountManagementEngine/Engines/TwitterEngine.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace AccountManagement.Engines
{
class TwitterEngine : IEngine, IDisposable
{
private WebEngine web;
public TwitterEngine()
{
}
public void Dispose()
{
}
public bool ChangePassword(string username, string oldpass, string newpass)
{
web = new WebEngine("Nokia 7110/1.0");
this.Login(username, oldpass);
this.ChangePass(oldpass, newpass);
return true;
}
private void Login(string username, string password)
{
string page = this.web.DownloadString("https://mobile.twitter.com/session/new");
Regex r = new Regex("input name=\"authenticity_token\" type=\"hidden\" value=\"(.*)\" /></div>");
Match m = r.Match(page);
Dictionary<string, string> postdatadct = new Dictionary<string, string>();
postdatadct.Add("{{username}}", username);
postdatadct.Add("{{password}}", password);
postdatadct.Add("{{token}}", m.Groups[1].ToString());
string[] scriptarr = Regex.Split(Properties.Resources.twitter_login, Environment.NewLine);
string ret = this.web.PostData(scriptarr[0], scriptarr.Skip(1).ToArray(), postdatadct);
//Console.WriteLine(ret);
}
private void ChangePass(string oldpass, string newpass)
{
String page = this.web.DownloadString("https://mobile.twitter.com/settings/password");
Regex r = new Regex("input name=\"authenticity_token\" type=\"hidden\" value=\"(.*)\" /></div>");
Match m = r.Match(page);
Dictionary<string, string> postdatadct = new Dictionary<string, string>();
postdatadct.Add("{{oldpassword}}", oldpass);
postdatadct.Add("{{newpassword}}", newpass);
postdatadct.Add("{{token}}", m.Groups[1].ToString());
List<string> scriptarr = Regex.Split(Properties.Resources.twitter_passgate, Environment.NewLine).ToList();
string ret = this.web.PostData(scriptarr[0], scriptarr.Skip(1).ToArray(), postdatadct);
}
}
}
AccountManagementEngine/Engines/WindowsEngine.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.DirectoryServices.AccountManagement;
namespace AccountManagement.Engines
{
class WindowsEngine : IDisposable, IEngine
{
private Dictionary<string, string> options;
public WindowsEngine(Dictionary<string, string> options)
{
this.options = options;
}
// Adapted from http://www.snippetdirectory.com/csharp/changing-password-of-a-local-or-domain-user/
public bool ChangePassword(string username, string oldpass, string newpass)
{
PrincipalContext insPrincipalContext = null;
if (this.options.Keys.Contains("location") && this.options["location"] == "local")
{
insPrincipalContext = new PrincipalContext(ContextType.Machine);//Connecting to local computer.
}
else if (this.options.Keys.Contains("location") && this.options["location"] == "domain")
{
insPrincipalContext = new PrincipalContext(ContextType.Domain, this.options["domain"], this.options["ads"]);//Connecting to Active Directory
}
UserPrincipal insUserPrincipal = new UserPrincipal(insPrincipalContext);
insUserPrincipal.Name = username;
PrincipalSearcher insPrincipalSearcher = new PrincipalSearcher();
insUserPrincipal = insPrincipalSearcher.FindOne() as UserPrincipal;
insUserPrincipal.SetPassword(newpass);
insUserPrincipal.Save();
insUserPrincipal.Dispose();
return true;
}
public void Dispose()
{
}
}
}
AccountManagementEngine/IEngine.cs
1
2
3
4
5
6
7
8
9
10
11
12
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AccountManagement
{
internal interface IEngine
{
bool ChangePassword(string username, string oldpass, string newpass);
}
}
AccountManagementEngine/Properties/AssemblyInfo.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("AccountManagementEngine")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AccountManagementEngine")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("8a14255b-6392-45b9-ab71-c8864453b8ce")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
AccountManagementEngine/Properties/Resources.Designer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.17929
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AccountManagement.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AccountManagement.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to https://m.facebook.com/login.php?refsrc=http%3A%2F%2Fm.facebook.com%2Findex.php&amp;refid=8
///email={{username}}
///pass={{password}}
///lsd=AVrMdhYE
///charset_test=€,´,€,´,水,Д,Є
///version=1
///ajax=1
///width=1920
///pxr=1
///gps=1
///m_ts=1358832742
///li=ZiT-UIWK8L6q0qNMGoz6tT7I
///signup_layout=layout|lower_subdued_button||s_btn|special||l_btn|confirm||signupinstr||logininstr
///laststage=first
///login=Log In.
/// </summary>
internal static string facebook_login {
get {
return ResourceManager.GetString("facebook_login", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to https://m.facebook.com/login.php?refsrc=https%3A%2F%2Fm.facebook.com%2Fsettings%2Faccount%2F&amp;refid=70
///old_password={{oldpassword}}
///new_password={{newpassword}}
///confirm_password={{newpassword}}
///change_password=
///save=Change Password
///charset_test=€,´,€,´,水,Д,Є.
/// </summary>
internal static string facebook_passgate {
get {
return ResourceManager.GetString("facebook_passgate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {{url}}/login2/
///user={{username}}
///passwrd={{password}}.
/// </summary>
internal static string smf_login {
get {
return ResourceManager.GetString("smf_login", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {{url}}/profile/?area=account;u=1;save
///passwrd1={{newpassword}}
///passwrd2={{newpassword}}
///oldpasswrd={{oldpassword}}.
/// </summary>
internal static string smf_passgate {
get {
return ResourceManager.GetString("smf_passgate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to https://mobile.twitter.com/session
///username={{username}}
///password={{password}}.
/// </summary>
internal static string twitter_login {
get {
return ResourceManager.GetString("twitter_login", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to https://mobile.twitter.com/settings/password
///settings[current_password]={{oldpassword}}
///settings[password]={{newpassword}}
///settings[password_confirmation]={{newpassword}}.
/// </summary>
internal static string twitter_passgate {
get {
return ResourceManager.GetString("twitter_passgate", resourceCulture);
}
}
}
}
AccountManagementEngine/Properties/Resources.resx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="facebook_login" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\facebook_login.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="facebook_passgate" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\facebook_passgate.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="smf_login" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\smf_login.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="smf_passgate" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\smf_passgate.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="twitter_login" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\twitter_login.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="twitter_passgate" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\twitter_passgate.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
</root>
AccountManagementEngine/Resources/facebook_login.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
https://m.facebook.com/login.php?refsrc=http%3A%2F%2Fm.facebook.com%2Findex.php&refid=8
email={{username}}
pass={{password}}
lsd=AVrMdhYE
charset_test=€,´,€,´,水,Д,Є
version=1
ajax=1
width=1920
pxr=1
gps=1
m_ts=1358832742
li=ZiT-UIWK8L6q0qNMGoz6tT7I
signup_layout=layout|lower_subdued_button||s_btn|special||l_btn|confirm||signupinstr||logininstr
laststage=first
login=Log In
AccountManagementEngine/Resources/facebook_passgate.txt
1
2
3
4
5
6
7
https://m.facebook.com/login.php?refsrc=https%3A%2F%2Fm.facebook.com%2Fsettings%2Faccount%2F&refid=70
old_password={{oldpassword}}
new_password={{newpassword}}
confirm_password={{newpassword}}
change_password=
save=Change Password
charset_test=€,´,€,´,水,Д,Є
AccountManagementEngine/Resources/smf_login.txt
1
2
3
{{url}}/login2/
user={{username}}
passwrd={{password}}
AccountManagementEngine/Resources/smf_passgate.txt
1
2
3
4
{{url}}/profile/?area=account;u=1;save
passwrd1={{newpassword}}
passwrd2={{newpassword}}
oldpasswrd={{oldpassword}}
AccountManagementEngine/Resources/twitter_login.txt
1
2
3
4
5
https://mobile.twitter.com/session
username={{username}}
password={{password}}
authenticity_token={{token}}
commit=Sign in
AccountManagementEngine/Resources/twitter_passgate.txt
1
2
3
4
5
6
https://mobile.twitter.com/settings/password
settings[current_password]={{oldpassword}}
settings[password]={{newpassword}}
settings[password_confirmation]={{newpassword}}
authenticity_token={{token}}
commit=Save
AccountManagementEngine/WebEngine.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using AccountManagement.Engines;
namespace AccountManagement
{
internal class WebEngine : IDisposable
{
private CookieAwareWebClient cli;
private string useragent = "";
public void AddHeader(string header, string val)
{
this.cli.Headers.Add(header, val);
}
public WebEngine()
{
this.cli = new CookieAwareWebClient();
}
public WebEngine(string ua)
{
this.useragent = ua;
this.cli = new CookieAwareWebClient();
}
private void SetHeaders()
{
this.cli.Headers.Add("user-agent", this.useragent);
}
public string DownloadString(string url)
{
this.SetHeaders();
return this.cli.DownloadString(url);
}
public string PostData(string url, string[] postarr, Dictionary<string, string> replace)
{
return this.post(url, BuildPostData(postarr, replace));
}
public string PostData(string url, string[] postarr)
{
return this.post(url, String.Join("&", postarr));
}
private string post(string url, string postdata)
{
this.SetHeaders();
this.cli.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
return this.cli.UploadString(url, "POST", postdata);
}
private string BuildPostData(string[] postdata, Dictionary<string, string> replace)
{
string ret;
ret = String.Join("&", postdata);
foreach (KeyValuePair<string, string> entry in replace)
{
ret = ret.Replace(entry.Key, entry.Value);
}
return ret;
}
public void Dispose()
{
}
}
}

Archive Download the corresponding diff file

Branches

Tags

Page rendered in 0.50266s using 14 queries.