AdvancedHacker101 / android-c-sharp-rat-server

This is a plugin for the c# R.A.T server providing extension to android based phone systems
Other
21 stars 18 forks source link

App Crash on Client Re-connection #3

Closed doomed2020 closed 6 years ago

doomed2020 commented 6 years ago

Hi,

Getting a sudden app crash when android client is connected after the server is restarted. 1st connection attempt is fine, but the 2nd attempt right after I close the server and re-open it to Listen on a Port, the app crashes without any error. Found some details of the crash in the Event Viewer:

Log Name:      Application
Source:        .NET Runtime
Date:          2/19/2018 9:37:55 PM
Event ID:      1026
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      Doom-PC
Description:
Application: TutServer.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.FormatException
   at System.Convert.FromBase64_ComputeResultLength(Char*, Int32)
   at System.Convert.FromBase64CharPtr(Char*, Int32)
   at System.Convert.FromBase64String(System.String)
   at AndroidExtension.Class1.ReadCallback(System.IAsyncResult)
   at System.Net.LazyAsyncResult.Complete(IntPtr)
   at System.Net.ContextAwareResult.CompleteCallback(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Net.ContextAwareResult.Complete(IntPtr)
   at System.Net.LazyAsyncResult.ProtectedInvokeCallback(System.Object, IntPtr)
   at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
Log Name:      Application
Source:        Application Error
Date:          2/19/2018 9:37:55 PM
Event ID:      1000
Task Category: (100)
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      Doom-PC
Description:
Faulting application name: TutServer.exe, version: 1.0.0.0, time stamp: 0x5a887e4d
Faulting module name: KERNELBASE.dll, version: 6.1.7601.18015, time stamp: 0x50b83c8a
Exception code: 0xe0434352
Fault offset: 0x0000c41f
Faulting process id: 0xd40
Faulting application start time: 0x01d3a99fe650c216
Faulting application path: C:\Users\Doom\Downloads\C-Sharp-R.A.T-Server-master\C-Sharp-R.A.T-Server-master\TutServer\bin\Debug\TutServer.exe
Faulting module path: C:\Windows\syswow64\KERNELBASE.dll
Report Id: 3bc1b143-1593-11e8-83ea-c01885fdcec0
AdvancedHacker101 commented 6 years ago

Wierd. Seems like the server is expecting a Base64 String and for some reason, it recives non-Base64 data. I will have to investigate this further to come up with a solution.
Thank you for pointing out this issue.

doomed2020 commented 6 years ago

I made few changes in the androidextension.dll code:

public void PluginMain() { . . . . serverSocket.Listen(500); // Changed it to 500 from 5 }

Also in the android app, increased the socket timeout to "50000" from "5000". The App does not crash instantly on reconnect now, I am not sure if it is the right solution. I think it was caused due to app making too many connection attempts to the server, which is unable to handle all connection attempts at the same time(my theory).

AdvancedHacker101 commented 6 years ago

Hi!
I just pushed a version with the changed pending limit, and I see how this was an issue!
You can check out the changed version here:
97f7d61a61dda780e96bdbf344827744402012a0