Skip to content
This repository has been archived by the owner on Jun 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #50 from steam-account-creator/dev-no-CI
Browse files Browse the repository at this point in the history
Update 2.1.1
  • Loading branch information
EarsKilla authored Oct 4, 2019
2 parents 6f53b77 + da89ef1 commit 3114d10
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 37 deletions.
28 changes: 21 additions & 7 deletions SteamAccCreator/Gui/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions SteamAccCreator/Models/RuCaptchaConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ public class RuCaptchaConfig
{
public string ApiKey { get; set; } = "";
public bool ReportBad { get; set; } = false;

public bool TransferProxy { get; set; } = true;
}
}
5 changes: 5 additions & 0 deletions SteamAccCreator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ static void Main()
(m) => true,
Web.Steam.SteamWebClient.DisableLegitDelay);

Web.Account.SkipSteamGuardDisable = Utility.GetStartOption(@"-skip(Steam)?Guard",
(m) => true,
Web.Account.SkipSteamGuardDisable);

var noStylesOpt = Utility.HasStartOption("-nostyles");
if (!noStylesOpt)
{
Expand All @@ -142,6 +146,7 @@ static void Main()
$"Count of mail checks in hand mode: {Web.Mail.MailHandler.CheckUserMailVerifyCount}\n" +
$"Count of mail checks in auto mode: {Web.Mail.MailHandler.CheckRandomMailVerifyCount}\n" +
$"Disable \"legit\" delays between Steam requests: {(Web.Steam.SteamWebClient.DisableLegitDelay ? "Yes" : "No")}\n" +
$"Skip disabling Steam guard: {(Web.Account.SkipSteamGuardDisable ? "Yes" : "No")}\n" +
$"NoStyles: {(noStylesOpt ? "Yes" : "No")}\n" +
$"Default text render: {(defTextRenderOpt ? "Yes" : "No")}\n" +
"######################################");
Expand Down
115 changes: 87 additions & 28 deletions SteamAccCreator/Web/Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class Account
RegexOptions.IgnoreCase);
public static int ConfirmMailLoopMax = 5; // max. of tries to confirm mail
public static Regex SteamMailConfirmed = new Regex("class=\\\"newaccount_email_verified_text\\\"", RegexOptions.IgnoreCase);
public static bool SkipSteamGuardDisable = false;
public static Regex SteamGuardDisabled = new Regex("class=\\\"(email_verified_text\\serror|error\\semail_verified_text)\\\"", RegexOptions.IgnoreCase); // it will not match!
public static Regex SteamGroupLink = new Regex(@"https?:\/\/steamcommunity\.com\/groups\/([^?#]+)", RegexOptions.IgnoreCase);

Expand Down Expand Up @@ -73,7 +74,8 @@ public Account(AccountCreateOptions options)
HttpClient = new RestClient("https://127.0.0.1/") // cuz this ask base even if you put full link in request object
{
CookieContainer = new CookieContainer(),
UserAgent = userAgent
UserAgent = userAgent,
FollowRedirects = true, // we will...
};

Steam = new Steam.SteamWebClient(HttpClient);
Expand Down Expand Up @@ -772,15 +774,21 @@ async Task<bool> checkPasswordFn()

await Task.Delay(3000);

var disableGuard = await DisableSteamGuard();
if (!disableGuard.Success)
var isGuardDisabled = false;
if (!SkipSteamGuardDisable)
{
if (disableGuard.IsFatal)
var disableGuard = await DisableSteamGuard();
if (!disableGuard.Success)
{
SwitchState(State.GuardLeavedOn);
Warn(ErrorMessages.Account.FAILED_TO_CREATE_FATAL);
return;
if (disableGuard.IsFatal)
{
SwitchState(State.Failed);
Warn(ErrorMessages.Account.FAILED_TO_CREATE_FATAL);
return;
}
}
else
isGuardDisabled = true;
}

var activatedLicenses = 0;
Expand All @@ -796,29 +804,50 @@ async Task<bool> checkPasswordFn()

await Task.Delay(3000);

if (!(await UpdateProfileInformation()))
var isProfileUpdated = false;
var setProfilePhotoState = ProfilePhotoState.FileNotSet;
if ((Config?.Profile?.Enabled ?? false))
{
Warn(ErrorMessages.Account.FAILED_TO_CREATE_FATAL);
return;
}
isProfileUpdated = await UpdateProfileInformation();

await Task.Run(Steam.LegitDelay);
await Task.Run(Steam.LegitDelay);

await SetProfilePhoto();

await Task.Run(Steam.LegitDelay);
setProfilePhotoState = await SetProfilePhoto();
}

var groupsJoined = 0;
var doGroupsJoin = Config.Profile.DoJoinToGroups && (Config?.Profile?.GroupsToJoin?.Count() ?? 0) > 0;
if (doGroupsJoin)
{
await Task.Run(Steam.LegitDelay);
groupsJoined = await JoinToGroups();
}

var _lastState = SaveAccount();

var actionsDone = new Dictionary<string, string>
var actionsDone = new Dictionary<string, string>();

if (!SkipSteamGuardDisable)
actionsDone.Add("Guard", (isGuardDisabled) ? "Off" : "ON!");
if ((Config?.Profile?.Enabled ?? false))
{
{ "Guard", (disableGuard.Success) ? "Off" : "ON!" }
};
actionsDone.Add("Profile", (isProfileUpdated) ? "OK" : "Fail!");
switch (setProfilePhotoState)
{
case ProfilePhotoState.Success:
actionsDone.Add("Photo", "OK");
break;
case ProfilePhotoState.FileNotFound:
actionsDone.Add("Profile", "Lost file!");
break;
case ProfilePhotoState.RequestError:
actionsDone.Add("Profile", "Fail!");
break;
case ProfilePhotoState.FileNotSet:
default:
break;
}
}
if (doGroupsJoin)
actionsDone.Add("Groups", $"{groupsJoined}/{Config?.Profile?.GroupsToJoin?.Count() ?? 0}");
if (doLicensesActivation)
Expand All @@ -835,7 +864,7 @@ async Task<bool> checkPasswordFn()
break;
}

UpdateStatus($"{completeStatus} [{string.Join(";", actionsDone.Select(x=> $"{x.Key}={x.Value}"))}]", _lastState);
UpdateStatus($"{completeStatus} [{string.Join(";", actionsDone.Select(x => $"{x.Key}={x.Value}"))}]", _lastState);
}

private State SaveAccount()
Expand Down Expand Up @@ -938,24 +967,24 @@ private async Task<bool> UpdateProfileInformation()

return false;
}
private async Task SetProfilePhoto()
private async Task<ProfilePhotoState> SetProfilePhoto()
{
if (string.IsNullOrEmpty(Config?.Profile?.Image))
{
Info("No profile photo is set!");
return;
return ProfilePhotoState.FileNotSet;
}
if (!System.IO.File.Exists(Config?.Profile?.Image))
{
Warn($"Cannot find profile image at '{Config?.Profile?.Image ?? "..."}'!");
return;
return ProfilePhotoState.FileNotFound;
}

UpdateStatus("Uploading profile photo...", State.Processing);

var response = await Task.Run(() => Steam.Account.UploadAvatar(Config.Profile.Image));
if (response.IsSuccess)
return;
return ProfilePhotoState.Success;

if (response.Exception == null)
{
Expand All @@ -967,6 +996,8 @@ private async Task SetProfilePhoto()
Error(ErrorMessages.Account.AVATAR_UPLOAD_FAILED_FATAL, response.Exception);
UpdateStatus(ErrorMessages.Account.AVATAR_UPLOAD_FAILED_FATAL, State.Failed);
}

return ProfilePhotoState.RequestError;
}

private async Task<int> ActivateLicenses()
Expand Down Expand Up @@ -1017,12 +1048,30 @@ private async Task<int> ActivateLicenses()

private async Task<(bool Success, bool IsFatal)> DisableSteamGuard()
{
UpdateStatus("Enabling Steam guard...", State.Processing);

var tfEnableResponse = await Task.Run(() => Steam.TwoFactor.TurnOnByMail());
if (!tfEnableResponse.IsSuccess)
{
if (tfEnableResponse.Exception == null)
{
Warn(ErrorMessages.Account.TF_FAILED_TO_ENABLE);
UpdateStatus(ErrorMessages.Account.TF_FAILED_TO_ENABLE, State.Failed);
}
else
{
Error(ErrorMessages.Account.TF_FAILED_TO_ENABLE_FATAL, tfEnableResponse.Exception);
UpdateStatus(ErrorMessages.Account.TF_FAILED_TO_ENABLE_FATAL, State.Failed);
}
return (false, true);
}

UpdateStatus("Disabling Steam guard...", State.Processing);

var response = await Task.Run(() => Steam.TwoFactor.TurnOff());
if (!response.IsSuccess)
var tfDisableResponse = await Task.Run(() => Steam.TwoFactor.TurnOff());
if (!tfDisableResponse.IsSuccess)
{
if (response.Exception == null)
if (tfDisableResponse.Exception == null)
{
Warn(ErrorMessages.Account.TF_FAILED_TO_DISABLE);
UpdateStatus(ErrorMessages.Account.TF_FAILED_TO_DISABLE, State.Failed);
Expand All @@ -1035,14 +1084,16 @@ private async Task<int> ActivateLicenses()
return (false, true);
}

var tfDisable = response.HttpResponses.Last();
var tfDisable = tfDisableResponse.HttpResponses.Last();
if (!Regex.IsMatch(tfDisable?.Content ?? "", @"phone_box", RegexOptions.IgnoreCase))
return (false, true);
return (false, false); //thonk... old: (false, true)

var _status = (MailBoxResponse == null)
? "Waiting for your confirmation..."
: "Waiting for mail...";

await Task.Delay(TimeSpan.FromSeconds(5)); // wait 5s. we will wait for mail to be delivered

for (int i = 0; i < MailVerifyMaxRetry; i++)
{
UpdateStatus($"[Disabling guard | Try {i + 1}/{ConfirmMailLoopMax}]: {_status}", State.Processing);
Expand Down Expand Up @@ -1244,5 +1295,13 @@ private enum State
GuardLeavedOn,
Failed,
}

private enum ProfilePhotoState
{
Success,
FileNotFound,
FileNotSet,
RequestError
}
}
}
3 changes: 3 additions & 0 deletions SteamAccCreator/Web/Captcha/Handlers/RuCaptchaHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ private void AddProxy(IRestRequest request, Proxy proxy)
if (proxy == null)
return;

if (!Config.TransferProxy)
return;

request.AddParameter("proxy", $"{proxy.Host}:{proxy.Port}");
request.AddParameter("proxytype", (proxy.Type == ProxyType.Unknown) ? "HTTP" : proxy.Type.ToString().ToUpper());
}
Expand Down
2 changes: 2 additions & 0 deletions SteamAccCreator/Web/ErrorMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public class Account

public const string TF_FAILED_TO_DISABLE = "Failed to disable SteamGuard!";
public const string TF_FAILED_TO_DISABLE_FATAL = "Cannot disable SteamGuard!";
public const string TF_FAILED_TO_ENABLE = "Failed to enable SteamGuard!";
public const string TF_FAILED_TO_ENABLE_FATAL = "Cannot enable SteamGuard!";
public const string TF_LOAD_LINK_FAILED = "|Steam guard| Failed to load data from confirmation link!";
public const string TF_LOAD_LINK_FAILED_FATAL = "|Steam guard| Something went wrong while loading data from link!";
public const string TF_SEARCH_MESSAGE_ERROR = "|Steam guard| Something went wrong while searching message from Steam...";
Expand Down
6 changes: 4 additions & 2 deletions SteamAccCreator/Web/ProxyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public async Task CheckProxies(Action onDisabled,
Action onGood,
Action onDone)
{
const int MAX_THREADS = 200;

var proxies = Proxies.ToList();

var threadEndCb = new Action<Thread>((t) =>
Expand Down Expand Up @@ -183,12 +185,12 @@ public async Task CheckProxies(Action onDisabled,

await Task.Factory.StartNew(async () =>
{
var thrs = new List<Thread>(10);
var thrs = new List<Thread>(MAX_THREADS);
while (CheckThreads.Count > 0)
{
lock (ThreadsSync)
{
var _thrs = CheckThreads.Take(10 - thrs.Count);
var _thrs = CheckThreads.Take(MAX_THREADS - thrs.Count);
thrs.AddRange(_thrs);

for (int i = thrs.Count - 1; i > -1; i--)
Expand Down
Loading

0 comments on commit 3114d10

Please sign in to comment.