Skip to content
This repository has been archived by the owner on Sep 9, 2018. It is now read-only.

Commit

Permalink
Added 2FA token generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ne3tCode committed May 8, 2016
1 parent 6120e5c commit 438c58e
Show file tree
Hide file tree
Showing 12 changed files with 856 additions and 24 deletions.
2 changes: 1 addition & 1 deletion SteamItemDropIdler/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All this info available on: https://github.com/kokole/SteamItemDropIdler/wiki
* Features
- Works without Steam
- Steam Guard support
- Steam Mobile Authenticator support
- Steam Mobile Authenticator support + 2FA token generation
- Multiple instance support
- Auto add free game license (for games that you idle only)
- Auto reconnect if connection to Steam servers is lost
Expand Down
72 changes: 49 additions & 23 deletions SteamItemDropIdler/SteamItemDropIdler.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#include "stdafx.h"
#include "token_generator/token_generator.h"

CSteamAPILoader g_steamAPILoader;

void shutdown()
{
printf( "Press enter to exit...\n" );
getchar();
exit(0);
}

int main( int argc, char* argv[] )
//int CALLBACK WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
Expand Down Expand Up @@ -50,75 +58,75 @@ int main( int argc, char* argv[] )
}

char consoleTitle[256];
sprintf_s( consoleTitle, "Steam Item Drop Idler (%s)", steamAccountName );
sprintf_s( consoleTitle, sizeof(consoleTitle), "Steam Item Drop Idler (%s)", steamAccountName );
SetConsoleTitleA( consoleTitle );

// load steam stuff
CreateInterfaceFn steam3Factory = g_steamAPILoader.GetSteam3Factory();
if ( !steam3Factory ) {
printf( "GetSteam3Factory failed\n" );
goto funcEnd;
shutdown();
}

IClientEngine* clientEngine = (IClientEngine*)steam3Factory( CLIENTENGINE_INTERFACE_VERSION, NULL );
if ( !clientEngine ) {
printf( "clientEngine is null\n" );
goto funcEnd;
shutdown();
}

ISteamClient017* steamClient = (ISteamClient017*)steam3Factory( STEAMCLIENT_INTERFACE_VERSION_017, NULL );
if ( !steamClient ) {
printf( "steamClient is null\n" );
goto funcEnd;
shutdown();
}

HSteamPipe hSteamPipe;
HSteamUser hSteamUser = clientEngine->CreateLocalUser( &hSteamPipe, k_EAccountTypeIndividual );
if ( !hSteamPipe || !hSteamUser ) {
printf( "CreateLocalUser failed (1)\n" );
goto funcEnd;
shutdown();
}

IClientBilling* clientBilling = clientEngine->GetIClientBilling( hSteamUser, hSteamPipe, CLIENTBILLING_INTERFACE_VERSION );
if ( !clientBilling ) {
printf( "clientBilling is null\n" );
goto funcEnd;
shutdown();
}

IClientFriends* clientFriends = clientEngine->GetIClientFriends( hSteamUser, hSteamPipe, CLIENTFRIENDS_INTERFACE_VERSION );
if ( !clientFriends ) {
printf( "clientFriends is null\n" );
goto funcEnd;
shutdown();
}

IClientUser* clientUser = clientEngine->GetIClientUser( hSteamUser, hSteamPipe, CLIENTUSER_INTERFACE_VERSION );
if ( !clientUser ) {
printf( "clientUser is null\n" );
goto funcEnd;
shutdown();
}

IClientUtils* clientUtils = clientEngine->GetIClientUtils( hSteamPipe, CLIENTUTILS_INTERFACE_VERSION );
if ( !clientUtils ) {
printf( "clientUtils is null\n" );
goto funcEnd;
shutdown();
}

ISteamGameCoordinator001* steamGameCoordinator = (ISteamGameCoordinator001*)steamClient->GetISteamGenericInterface( hSteamUser, hSteamPipe, STEAMGAMECOORDINATOR_INTERFACE_VERSION_001 );
if ( !steamGameCoordinator ) {
printf( "steamGameCoordinator is null\n" );
goto funcEnd;
shutdown();
}

ISteamInventory001* steamInventory = (ISteamInventory001*)steamClient->GetISteamInventory( hSteamUser, hSteamPipe, "STEAMINVENTORY_INTERFACE_V001" );
if ( !steamInventory ) {
printf( "steamInventory is null\n" );
goto funcEnd;
shutdown();
}

ISteamUser017* steamUser = (ISteamUser017*)steamClient->GetISteamUser( hSteamUser, hSteamPipe, STEAMUSER_INTERFACE_VERSION_017 );
if ( !steamUser ) {
printf( "steamUser is null\n" );
goto funcEnd;
shutdown();
}

clientUser->LogOnWithPassword( false, steamAccountName, steamAccountPassword );
Expand Down Expand Up @@ -151,7 +159,7 @@ int main( int argc, char* argv[] )
RequestFreeLicenseResponse_t requestFreeLicenseResponse;
if ( !clientUtils->GetAPICallResult( hRequestFreeLicenseForApps, &requestFreeLicenseResponse, sizeof( RequestFreeLicenseResponse_t ), RequestFreeLicenseResponse_t::k_iCallback, &bFailed ) ) {
printf( "GetAPICallResult failed\n" );
goto funcEnd;
shutdown();
}
if ( requestFreeLicenseResponse.m_EResult == k_EResultOK && requestFreeLicenseResponse.m_nGrantedAppIds == 1 ) {
printf( "Added a free license\n" );
Expand All @@ -160,7 +168,7 @@ int main( int argc, char* argv[] )
}
else {
printf( "Failed to add a free license. You do not own this game\n" );
goto funcEnd;
shutdown();
}
}

Expand Down Expand Up @@ -192,9 +200,29 @@ int main( int argc, char* argv[] )
case k_EResultAccountLogonDeniedNeedTwoFactorCode:
{
char steamMobileAuthenticatorCode[33];
printf( "Enter the Steam Mobile Authenticator code: " );
scanf( "%32s", steamMobileAuthenticatorCode );
getchar();
uint8_t secret[20] = {0};
int ret = getSharedSecret(steamAccountName, secret);
switch (ret)
{
case 1:
printf("Secret file not found! Can not generate 2FA code.\n");
break;
case 2:
printf("Secret file is invalid. Can not generate 2FA code.\n");
break;
case 3:
printf("Secret is invalid. Can not generate 2FA code.\n");
break;
default:
get2FACode(secret, steamMobileAuthenticatorCode);
break;
}
if (ret > 0)
{
printf( "Enter the Steam Mobile Authenticator code: " );
scanf( "%32s", steamMobileAuthenticatorCode );
getchar();
}

(*(void( __thiscall** )(IClientUser*, const char*))(*(DWORD*)clientUser + 196))(clientUser, steamMobileAuthenticatorCode); // SetTwoFactorCode
clientUser->LogOnWithPassword( false, steamAccountName, steamAccountPassword );
Expand Down Expand Up @@ -277,13 +305,13 @@ int main( int argc, char* argv[] )
hSteamGameServerUser = steamClient->CreateLocalUser( &hSteamGameServerPipe, k_EAccountTypeGameServer );
if ( !hSteamGameServerPipe || !hSteamGameServerUser ) {
printf( "CreateLocalUser failed (2)\n" );
goto funcEnd;
shutdown();
}

steamGameServer = (ISteamGameServer012*)steamClient->GetISteamGameServer( hSteamGameServerUser, hSteamGameServerPipe, STEAMGAMESERVER_INTERFACE_VERSION_012 );
if ( !steamGameServer ) {
printf( "steamGameServer is null\n" );
goto funcEnd;
shutdown();
}

steamGameServer->InitGameServer( 0, 27015, MASTERSERVERUPDATERPORT_USEGAMESOCKETSHARE, k_unServerFlagSecure, 440, "3158168" );
Expand Down Expand Up @@ -368,8 +396,6 @@ int main( int argc, char* argv[] )
Sleep( 1000 );
}

funcEnd:
printf( "Press enter to exit...\n" );
getchar();
shutdown();
return 0;
}
}
6 changes: 6 additions & 0 deletions SteamItemDropIdler/SteamItemDropIdler.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,19 @@
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="token_generator\base64.h" />
<ClInclude Include="token_generator\sha1.h" />
<ClInclude Include="token_generator\token_generator.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="SteamItemDropIdler.cpp" />
<ClCompile Include="token_generator\base64.c" />
<ClCompile Include="token_generator\sha1.c" />
<ClCompile Include="token_generator\token_generator.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
18 changes: 18 additions & 0 deletions SteamItemDropIdler/SteamItemDropIdler.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="token_generator\base64.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="token_generator\sha1.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="token_generator\token_generator.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
Expand All @@ -32,5 +41,14 @@
<ClCompile Include="SteamItemDropIdler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="token_generator\base64.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="token_generator\sha1.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="token_generator\token_generator.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
Loading

9 comments on commit 438c58e

@Giza
Copy link

@Giza Giza commented on 438c58e Jan 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ничего. автор не поддерживает больше его

@titoncio
Copy link

@titoncio titoncio commented on 438c58e Jan 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@John677
Download the version 2.02 in Releases.
Or download the dev branch

@titoncio
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Download the dev branch, not the master.

@titoncio
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ne3tCode
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@John677 define __LITTLE_ENDIAN__

@blablabla156
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ne3tCode
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blablabla156
Copy link

@blablabla156 blablabla156 commented on 438c58e Jan 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The answer that I found related is this one (https://stackoverflow.com/questions/9928238/unresolved-external-symbol-in-object-files) but this goes back into endian.h but i did the

#define LITTLE_ENDIAN

and now im stuck at it. Am I forgetting any dll?

@blablabla156
Copy link

@blablabla156 blablabla156 commented on 438c58e Jan 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I had a problem that it didnt want to accept a precompiled header, so removed the precompile header but now I changed it back again to stdafx.h being the precompiled header. With this I don't have any link problems but I got this.

https://user-images.githubusercontent.com/34697260/35049846-6c61cc2a-fb88-11e7-939e-15b0ca0e24de.png

But when I include at the top of them it says "cannot open source file "stdafx.h", even though they are in the same folder.

Please sign in to comment.