 |
Server Help Community forums for Subgame, ASSS, and bots
|
Author |
Message |
fatrolls Novice
Age:35 Gender: Joined: Jul 25 2013 Posts: 35 Offline
|
Posted: Sun Apr 06, 2014 9:19 am Post subject: |
 |
|
|
|
yes SpaceHiker your issue is pretty simple I also had the same problem..
The person who ported this into linux did a very poor job he had a mindset like this
This works on 32bit cpu I need to port it to 64bit cpu and Linux what should do I? Okay first let me replace all the int's with long's lol
That's why when you connect nothing happens. Now we are at a problem not knowing what was really a long before and what was really a int before.
Going crazy changing all the long's back into int's is worse you might break something.
But changing some common mistakes there is only 6 to fix it.
Biggest mistakes are with the packet readers
long GetLong(BYTE * Message, const SHORT Offset)
{ // Get a long from a char *
return *(long*)&(Message[Offset]);
}
|
should be
Uint32 GetLong(BYTE * Message, const SHORT Offset)
{ // Get a long from a char *
return *(Uint32*)&(Message[Offset]);
}
|
Second one looks like this
Uint32 GetLong(char * Message, const SHORT Offset)
{ // Get a long from a char *
return *(Uint32*)&(Message[Offset]);
}
|
it should only read 4 bytes from packet stream not 8 even though it's called GetLong it really means get unsigned int
Now all those possible error messages will now also use this GetLong so the linkedlist will have errors now because it doesn't support unsigned int
So the final 3 errors will involve adding code to linkedlist (although it never probably uses the long version in linkedlist and you could just rename it to Uint32/DWORD still safer to just create a new ones).
Under
void operator=(const int); // l-string = r-int;
|
add
void operator=(const unsigned int); // l-string = r-uint;
|
Under
void operator+=(const int); // l-string += r-int;
|
add
void operator+=(const unsigned int); // l-string += r-uint;
|
Under
_string operator+(const int); // l-string + r-int;
|
add
_string operator+(const unsigned int); // l-string + r-uint;
|
Now comes filling in the codes just copy/paste the int version right under it and change to unsigned int
Like so
void _string::operator=(const unsigned int Number)
{
char Message[50];
itoa(Number, Message, 10);
delete Text;
Text = new char[ (Length = strlen(Message)) + 1 ];
memcpy(Text, Message, Length + 1);
}
|
void _string::operator+=(const unsigned int Number)
{
char Message[50];
itoa(Number, Message, 10);
char * new_pointer;
new_pointer = new char[ (Length + strlen(Message)) + 1 ];
memcpy(new_pointer, Text, Length);
memcpy(&new_pointer[Length], Message, strlen(Message) + 1);
delete Text;
Text = new_pointer;
Length += strlen(Message);
}
|
_string _string::operator+(const unsigned int Number)
{
char Message[50];
itoa(Number, Message, 10);
_string S;
S.Text = new char[ (S.Length = Length + strlen(Message)) + 1 ];
memcpy(S.Text, Text, Length);
memcpy(&S.Text[Length], Message, strlen(Message) + 1);
return S;
}
|
That's it now it should work.. I would change all the long's that should be uint32 or just int32 and it would probably make the biller take twice as less memory.
But hey it works good enough for me.. plus changing all those long's to uint32's will corrupt the saved user entries database not like it's compatible with SCOREMAN anymore.
Another fix to fix negative ports (this is only for GUI display it will work without this fix).
Replace all short Port with SHORT Port
since typedef unsigned short SHORT; it would make it unsigned too.
This is okay for now, But I recommend porting catid's ssbilling2 again to linux without making any of these find/replace mistakes would fix more issues which are unknown right now.
Another fix I just added to support more users which SSBilling2 considers illegal/invalid clients.
bool InvalidMachineID(long MachineID)
{
/*if (MachineID == 101) return false;
if (MachineID < 0) return true;
if (MachineID < 2000) return true;
*/
return false;
}
|
|
|
Back to top |
|
 |
fatrolls Novice
Age:35 Gender: Joined: Jul 25 2013 Posts: 35 Offline
|
Posted: Mon Apr 07, 2014 7:07 am Post subject: |
 |
|
|
|
Converted the ASM in the ssbilling2-linux into C code, now Comms:EncryptMode=1 works without any problems.
Here is the code if anyone is interested.
#ifndef ENCRYPTION_H
#define ENCRYPTION_H
#endif
// Packet encryption
void Host::InitializeEncryption(unsigned int Key)
{
if (SentKey == Key)
{
SSEncrTable.SSKey = 0;
return;
}
SSEncrTable.SSKey = Key;
// Do the ASM thing (Assembly rips provided by Coconut Emulator)
// Initialize calculations
//It's a regular pseudo-random number with +123 extra -fatrolls
int SKey = (int)Key;
int counter = 0;
int remaining = 260; //sizeof(SSBuf) = 520 / 2 = 260.
do
{
SKey = 16807 * (SKey % 127773) - 2836 * (SKey / 127773) + 123;
if ( SKey <= 0 )
SKey += 2147483647;
SSEncrTable.SSBuf[counter] = (SKey & 0xFF);
SSEncrTable.SSBuf[counter+1] = (SKey >> 8) & 0xFF;
counter += 2;
--remaining;
}
while (remaining);
}
void Host::Encrypt(char * Message, unsigned short Length)
{
if (SSEncrTable.SSKey == 0) return;
unsigned int IV = SSEncrTable.SSKey;
char buffer[520];
memset(buffer, 0, 520);
if (Message[0] == 0)
memcpy(buffer, &Message[2], Length - 2);
else
memcpy(buffer, &Message[1], Length - 1);
for (unsigned short Counter = 0; Counter < 520; Counter += 4)
{
IV = GetLong(buffer, Counter) ^ GetLong(SSEncrTable.SSBuf, Counter) ^ IV;
*(unsigned int*)&buffer[Counter] = IV;
}
if (Message[0] == 0)
memcpy(&Message[2], buffer, Length - 2);
else
memcpy(&Message[1], buffer, Length - 1);
}
void Host::Decrypt(char * Message, unsigned short Length)
{
if (SSEncrTable.SSKey == 0) return;
unsigned int IV = SSEncrTable.SSKey;
unsigned int ESI;
unsigned int EDX;
char buffer[520];
memset(buffer, 0, 520);
if (Message[0] == 0)
memcpy(buffer, &Message[2], Length - 2);
else
memcpy(buffer, &Message[1], Length - 1);
for (unsigned short Counter = 0; Counter < 520; Counter += 4)
{
EDX = GetLong(buffer, Counter);
ESI = GetLong(SSEncrTable.SSBuf, Counter) ^ IV ^ EDX;
IV = EDX;
*(unsigned int*)&buffer[Counter] = ESI;
}
if (Message[0] == 0)
memcpy(&Message[2], buffer, Length - 2);
else
memcpy(&Message[1], buffer, Length - 1);
}
// One-way encryption algorithms
void HashPassword(char * Password)
{
size_t StrLen = strlen((char*)Password);
unsigned short Factor = 0;
char Char;
size_t L = 0;
for (L = 0; L < StrLen; L++)
Factor ^= Password[L];
for (L = 0; L < StrLen; L++)
{
Char = (Password[L] ^= Factor);
Factor = (Factor ^ (Char << (Char & 3))) & 255;
if (Password[L] == 0)
Password[L] = 0xED;
}
}
unsigned long HashModemInfo(char * Info)
{
unsigned long h = 0, g;
for (short i = 0; i < 608; i++)
{
h = ( h << 4 ) + *Info++;
if ( g = h & 0xF0000000 )
h ^= g >> 24;
h &= ~g;
}
return h;
}
|
|
|
Back to top |
|
 |
Doc Flabby Server Help Squatter

Joined: Feb 26 2006 Posts: 636 Offline
|
Posted: Mon Apr 07, 2014 2:16 pm Post subject: |
 |
|
|
|
Nice to see someone has taken an interest in this Sorry for all the bugs I don't think i was worried too much abut 64-bit in 2007  _________________ Rediscover online gaming. Get Subspace | STF The future...prehaps
|
|
Back to top |
|
 |
fatrolls Novice
Age:35 Gender: Joined: Jul 25 2013 Posts: 35 Offline
|
|
Back to top |
|
 |
SpaceHiker Newbie
Joined: Apr 05 2014 Posts: 3 Offline
|
Posted: Sun Apr 13, 2014 5:37 pm Post subject: |
 |
|
|
|
This is awesome, thanks!
|
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Sun Apr 13, 2014 7:15 pm Post subject: |
 |
|
|
|
For those interested, I've posted ssbilling from Confess (2.0c) to bitbucket.
https://bitbucket.org/cypherjf/ssbilling-server/overview
I'm planning to add in my future tweaks to it - but it may be helpful to start merging some of this together? _________________ Performance is often the art of cheating carefully. - James Gosling
|
|
Back to top |
|
 |
SpaceHiker Newbie
Joined: Apr 05 2014 Posts: 3 Offline
|
Posted: Thu Apr 17, 2014 11:36 pm Post subject: |
 |
|
|
|
fatrolls, can you tell me your gcc --version and your g++ --version?
Thanks
|
|
Back to top |
|
 |
Cheese Wow Cheese is so helpful!

Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Fri Apr 18, 2014 3:25 am Post subject: |
 |
|
|
|
ive been making a modular client in the exact same style as asss, and i intend to make a biller and directory as well, and all 4 will be available on bitbucket for anyone to update
if you can write a module for one you can make a module for any
gonna call them SSCS SSCC SSCD SSCB
still deciding whether im going to put them all in the same bitbucket or 4 separate ones
each will have a major.minor.version versioning system
gonna keep directory and biller at major version 0 until they first successfully connect to a subgame zone/client
my intent is to make a centralized thing that will be the standardized thing that everyone uses, and ideally id like to have it be completely open sourced to where people cant recompile cheating versions because the public open source security module is good enough to keep things clean
i dont like this "security through obscurity" bullshit
i want it to be unbreakable, and i want people to know why its unbreakable
ive also had some ideas about periodically changing memory values and shuffling around pointers to prevent/detect memory hacks
i have been planning to have all the cores written from may-july, which sucks because the ddos made ssc zone owners switch many months earlier than i had the biller written
something else ive been deciding on is if i want biller to save to dat files or a mysql database, but i suppose i could write 2 modules that are interchangeable
also going to carry over groupdef to biller, so same concepts will apply instead of the level0-4 thing
once i finally get the time to get this shit done the game will be forever liberated from priits stranglehold on the game, effectively enabling the game to pretty much be immortal
downside is that its a shit ton of work and once i make it all open source theres a very good chance that literally noone else will bother working on it because i was 10 years late to the party
also cypher can you keep that bitbucket up for at least half a year?
also it would probably be good if you remove the dsp/dsw/vcproj/sln compiler specific cruft
the above is a collection of thoughts saved for later _________________ SSC Distension Owner
SSCU Trench Wars Developer
|
|
Back to top |
|
 |
fatrolls Novice
Age:35 Gender: Joined: Jul 25 2013 Posts: 35 Offline
|
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
Software by php BB © php BB Group Server Load: 13 page(s) served in previous 5 minutes.
|