اقتباس:
المشاركة الأصلية كتبت بواسطة CritYouDown
عفوا ,,, لايمكنك مشاهده الروابط لانك غير مسجل لدينا [ للتسجيل اضغط هنا ]
معلش انا كل ده مخدش بالى انك بتتكلم على ملفات MeGaMax 
لازم الباكيت تتبعت للـ Gateway معديش ليها حل تانى
كده كده ملفات MeGaMax ملهلش لزمه لو هتشتغل بالفيلتر
او انت بقا بلاش تشتغل بالـ PC limit
|
بما انت حضرتك رافض كل الكلام ... مش لازم الباكيت تتبعت .. وشرحلك و جربتها علي سورس سوبر ميك و نفعت ..
في GatewayContext.cs
انزل تحت خالص بعد ال #ResetPacketCount
كود:
// Reset packet count.
public void resetPackets(object e)
{
this.packetCount = 0;
}
void OnReceive_FromClient(IAsyncResult iar)
{
lock (m_Lock)
{
try
{
int nReceived = m_ClientSocket.EndReceive(iar);
if (nReceived != 0)
{
m_LocalSecurity.Recv(m_LocalBuffer, 0, nReceived);
List<Packet> ReceivedPackets = m_LocalSecurity.TransferIncoming();
if (ReceivedPackets != null)
{
foreach (Packet _pck in ReceivedPackets)
{
// Length of packet
this.length = _pck.GetBytes().Length;
// Packet count
this.packetCount++;
#region Packet protection
// Packet count
if (this.packetCount >= FilterMain.GATEWAY_COUNT)
{
// Ignore spam plis
if (FilterMain.ERROR_LOG.Equals("unknown") || FilterMain.ERROR_LOG.Equals("all") || FilterMain.ERROR_LOG.Equals("exploit"))
{
// Write to console log
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine("[" + DateTime.UtcNow + "][" + module_name + "] IP:{" + this.ip + "} User:{" + this.user_id + "} Opcode:{0x" + _pck.Opcode.ToString("X") + "} Bytes:{" + this.length + "} Packet_c{" + this.packetCount + "}");
Console.ResetColor();
}
// IF BAN IP?
if (FilterMain.PACKET_METHOD == "ban")
{
if (!FilterMain.ban_list.Contains(this.ip))
{
// Add ban
FilterMain.ban_list.Add(this.ip);
try
{
// File exist, write to it.
System.IO.StreamWriter file = new System.IO.StreamWriter("config/blacklist.txt", true);
if (this.ip.Length > 0)
{
file.WriteLine(this.ip + "\n");
}
file.Close();
// Ban log(For checking random bans)
System.IO.StreamWriter banlog = new System.IO.StreamWriter("logs/banlog.txt", true);
banlog.WriteLine("[" + DateTime.UtcNow + "] {" + module_name + "} Banned {" + this.ip + "} Reason: {HIGH PPS}\n");
banlog.Close();
}
catch { }
// Inform?
Console.ForegroundColor = ConsoleColor.DarkMagenta;
Console.WriteLine("[" + DateTime.UtcNow + "][" + module_name + "] IP:{" + this.ip + "} User:{" + this.user_id + "} Opcode:{0x" + _pck.Opcode.ToString("X") + "} Bytes:{" + this.length + "} Packet_c{" + this.packetCount + "}");
Console.ResetColor();
}
}
// Disconnect
this.DisconnectModuleSocket();
return;
}
#endregion
#region Logging system
// LEGIT OPCODES
if (FilterMain.ERROR_LOG.Equals("legit") || FilterMain.ERROR_LOG.Equals("all"))
{
if (FilterMain.Opcodes.ContainsKey(Convert.ToUInt16(_pck.Opcode)))
{
// ALLOWED OPCODE
string name = FilterMain.Opcodes[Convert.ToUInt16(_pck.Opcode)];
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("[" + DateTime.UtcNow + "][" + module_name + "] IP:{" + this.ip + "} User:{" + this.user_id + "} Opcode:{" + name + "} Bytes:{" + this.length + "} Packet_c{" + this.packetCount + "}");
Console.ResetColor();
}
}
// EXPLOIT OPCODES
else if (FilterMain.ERROR_LOG.Equals("exploit") || FilterMain.ERROR_LOG.Equals("all"))
{
if (FilterMain.BAD_Opcodes.ContainsKey(Convert.ToUInt16(_pck.Opcode)))
{
// SENT EXPLOITS
string name = FilterMain.BAD_Opcodes[Convert.ToUInt16(_pck.Opcode)];
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine("[" + DateTime.UtcNow + "][" + module_name + "] IP:{" + this.ip + "} User:{" + this.user_id + "} Opcode:{0x" + _pck.Opcode.ToString("X") + "} Bytes:{" + this.length + "} Packet_c{" + this.packetCount + "}");
Console.ResetColor();
}
}
// UNKNOWN OPCODES
else if (FilterMain.ERROR_LOG.Equals("unknown") || FilterMain.ERROR_LOG.Equals("all"))
{
if (!FilterMain.Opcodes.ContainsKey(Convert.ToUInt16(_pck.Opcode)) && !FilterMain.BAD_Opcodes.ContainsKey(Convert.ToUInt16(_pck.Opcode)))
{
// SENT UNKNOWN SHIT
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("[" + DateTime.UtcNow + "][" + module_name + "] IP:{" + this.ip + "} User:{" + this.user_id + "} Opcode:{0x" + _pck.Opcode.ToString("X") + "} Bytes:{" + this.length + "} Packet_c{" + this.packetCount + "}");
Console.ResetColor();
}
}
#endregion
#region Store system
// Store system
if (FilterMain.logging)
{
if (!FilterMain.Opcodes.ContainsKey(Convert.ToUInt16(_pck.Opcode)) && !FilterMain.BAD_Opcodes.ContainsKey(Convert.ToUInt16(_pck.Opcode)))
{
try
{
// Prevent opening errors.
//FilterMain.unknown_list.Add("0x" + _pck.Opcode.ToString("X"));
// Write/Create w/e
System.IO.StreamWriter file = new System.IO.StreamWriter("logs/unknown.txt", true);
file.WriteLine("[" + DateTime.UtcNow + "][" + module_name + "] IP:{" + this.ip + "} User:{" + this.user_id + "} Opcode:{0x" + _pck.Opcode.ToString("X") + "} Bytes:{" + this.length + "} Packet_c{" + this.packetCount + "}");
file.Close();
}
catch { }
// DISCONNECT
if (FilterMain.UNKNOWN_METHOD.Equals("disconnect"))
{
if (FilterMain.ERROR_LOG.Equals("unknown") || FilterMain.ERROR_LOG.Equals("all"))
{
// Inform?
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("[" + DateTime.UtcNow + "][" + module_name + "] IP:{" + this.ip + "} User:{" + this.user_id + "} Opcode:{0x" + _pck.Opcode.ToString("X") + "} Bytes:{" + this.length + "} Packet_c{" + this.packetCount + "}");
Console.ResetColor();
}
// Disconnect
this.DisconnectModuleSocket();
continue;
}
// BAN
else if (FilterMain.UNKNOWN_METHOD.Equals("ban"))
{
if (!FilterMain.ban_list.Contains(this.ip))
{
// Add ban
FilterMain.ban_list.Add(this.ip);
try {
// File exist, write to it.
System.IO.StreamWriter file = new System.IO.StreamWriter("config/blacklist.txt", true);
if (this.ip.Length > 0)
{
file.WriteLine(this.ip + "\n");
}
file.Close();
// Ban log(For checking random bans)
System.IO.StreamWriter banlog = new System.IO.StreamWriter("logs/banlog.txt", true);
banlog.WriteLine("[" + DateTime.UtcNow + "] {" + module_name + "} Banned {" + this.ip + "} Reason: {UNKNOWN PACKET}\n");
banlog.Close();
}
catch { }
// Inform?
Console.ForegroundColor = ConsoleColor.DarkMagenta;
Console.WriteLine("[" + DateTime.UtcNow + "][" + module_name + "] IP:{" + this.ip + "} User:{" + this.user_id + "} Opcode:{0x" + _pck.Opcode.ToString("X") + "} Bytes:{" + this.length + "} Packet_c{" + this.packetCount + "}");
Console.ResetColor();
// Disconnect
this.DisconnectModuleSocket();
return;
}
}
}
}
#endregion
#region Flood fix for 0x2001
// Filter against flood
if (_pck.Opcode == 0x2001)
{
// Recieve
this.DoRecvFromServer();
// K-guard
if (this.length != 12)
{
Console.WriteLine("Debug #3");
this.DisconnectModuleSocket();
return;
}
// Continue
continue;
}
#endregion
#region K-guard shits
if (_pck.Opcode == 0x2002)
{
if (this.length != 0)
{
Console.WriteLine("Debug #2");
this.DisconnectModuleSocket();
return;
}
}
#endregion
#region Fake playercount
// Server list
if (_pck.Opcode == 0x6101)
{
// Block server status tools? :3
if (FilterMain.block_status && this.patch_sent != 1)
{
// Inform
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine("[" + DateTime.UtcNow + "][" + module_name + "] IP:{" + this.ip + "} User:{" + this.user_id + "} Reason:{STATUS TOOL} Bytes:{" + this.length + "} Packet_c{" + this.packetCount + "}");
Console.ResetColor();
// Disconnect
this.DisconnectModuleSocket();
return;
}
// Register
this.sent_list = 1;
// K-guard shits
if (this.length != 0)
{
Console.WriteLine("Debug #1");
this.DisconnectModuleSocket();
return;
}
// Fake players
if (FilterMain.ENABLED && (FilterMain.FAKE_PLAYERS > 0))
{
// Current players
FilterMain.cur_players = (FilterMain.shard_players + FilterMain.FAKE_PLAYERS);
// Fancy fix for sro players :D
if (FilterMain.cur_players >= FilterMain.MAX_PLAYERS)
{
FilterMain.cur_players = FilterMain.MAX_PLAYERS;
}
FilterMain.max_players = FilterMain.MAX_PLAYERS;
FilterMain.status = 1;
Packet response1 = new Packet(0xA101, true);
response1.WriteUInt8(0x01); //flag
response1.WriteUInt8(0x14); //unk
response1.WriteAscii("SRO_Vietnam_TestLocal [F] 0");
response1.WriteUInt8(0x00); //flag
response1.WriteUInt8(0x01); //flag
response1.WriteUInt16(FilterMain.ShardID); //shardID
response1.WriteAscii(FilterMain.ServerName); //name
response1.WriteUInt16(FilterMain.cur_players); //online
response1.WriteUInt16(FilterMain.MAX_PLAYERS); //maxplayers
response1.WriteUInt8(0x01); //Status
response1.WriteUInt8(0x14); //unk
response1.WriteUInt8(0x00); //flag
// Send fake packet :3
m_LocalSecurity.Send(response1);
Send(false);
continue;
}
}
#endregion
#region ID RESPONSE // Exploit fix
if (_pck.Opcode == 0x6100)
{
this.sent_id = 1;
}
#endregion
#region Patch response // Exploit fix
if (_pck.Opcode == 0x6106)
{
this.patch_sent = 1;
}
#endregion
#region HARDWARE PACKET OPCODE
if (_pck.Opcode == 0x9001 && (FilterMain.PCLIMIT > 0))
{
// User HWID
this.hwid = regex.Replace(_pck.ReadAscii(), string.Empty);
}
#endregion
#region Login packet
// Login packet
if (_pck.Opcode == 0x6102)
{
// Check shit
byte locale = _pck.ReadUInt8();
this.user_id = _pck.ReadAscii().ToLower();
this.user_pw = _pck.ReadAscii();
ushort ServerID = _pck.ReadUInt16();
#region New anti exploit(gateway)
// Check news
if (this.sent_list != 1 || this.sent_id != 1 && !(FilterMain.USER_ID.Contains(this.user_id)))
{
// Logging
if (FilterMain.ERROR_LOG.Equals("unknown") || FilterMain.ERROR_LOG.Equals("all") || FilterMain.ERROR_LOG.Equals("exploit"))
{
// Inform
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine("[" + DateTime.UtcNow + "][" + module_name + "] IP:{" + this.ip + "} User:{" + this.user_id + "} Reason:{WEIRD BEHAVIOUR} Bytes:{" + this.length + "} Packet_c{" + this.packetCount + "}");
Console.ResetColor();
}
// Byebye
this.DisconnectModuleSocket();
return;
}
#endregion
#region Pioneer shit
// LOGIN LOG
if (FilterMain.PIONEER)
{
// Ban log(For checking random bans)
System.IO.StreamWriter userlog = new System.IO.StreamWriter("logs/login.txt", true);
userlog.WriteLine("[" + DateTime.UtcNow + "] StrUserID: {" + this.user_id + "} IP: {" + this.ip + "}\n");
userlog.Close();
}
#endregion
#region GM STUFF
// GM ONLY LOGIN
if (FilterMain.GM_LOGIN && !(FilterMain.GM_ACCOUNT.Contains(this.user_id)))
{
// Disconnect
this.DisconnectModuleSocket();
return;
}
// GM PRIV IP
if (FilterMain.PROXY.Contains(FilterMain.AGENT_IP) && FilterMain.GM_ACCOUNT.Contains(this.user_id))
{
// If not allowed ip.
if (FilterMain.PRIV_IP.Count() > 0)
{
if (!FilterMain.PRIV_IP.Contains(this.ip))
{
// Logging
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("[" + DateTime.UtcNow + "][" + module_name + "] IP:{" + this.ip + "} User:{" + this.user_id + "} Reason:{PRIV_IP} Bytes:{" + this.length + "} Packet_c{" + this.packetCount + "}");
Console.ResetColor();
// Disconnect
this.DisconnectModuleSocket();
return;
}
}
}
#endregion
#region IP LIMIT SHIT
// IP LIMIT ERROR MESSAGE
if ((FilterMain.IPLIMIT > 0) && !(FilterMain.LIMIT_BYPASS.Contains(this.user_id)))
{
if (FilterMain.CAFELIMIT > 0 && (FilterMain.cafe_list.Contains(this.ip)))
{
// COUNT +1 BECAUSE ALWAYS 1 LESS
if (ip_count(this.ip) > FilterMain.CAFELIMIT)
{
// Send client ERROR
Packet new_packet = new Packet(0xA102, false);
new_packet.WriteUInt8(0x02);
new_packet.WriteUInt8(8); // ip limit error
m_LocalSecurity.Send(new_packet);
Send(false);
// Disconnect
this.DisconnectModuleSocket();
// Continue
return;
}
}
else
{
// COUNT +1 BECAUSE ALWAYS 1 LESS
if (ip_count(this.ip) > FilterMain.IPLIMIT)
{
// Send client ERROR
Packet new_packet = new Packet(0xA102, false);
new_packet.WriteUInt8(0x02);
new_packet.WriteUInt8(8); // ip limit error
m_LocalSecurity.Send(new_packet);
Send(false);
// Disconnect
this.DisconnectModuleSocket();
// Continue
return;
}
}
}
#endregion
#region PC LIMIT SHIT
if (FilterMain.PCLIMIT > 0 &&!(FilterMain.LIMIT_BYPASS.Contains(this.user_id)))
{
// Check length and if not null.
if (this.hwid == null)
{
// Debug
Console.BackgroundColor = ConsoleColor.Red;
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine(module_name + " HWID was never sent from CLIENT->SUPERMIKE");
Console.ResetColor();
// Send client error
Packet new_packet = new Packet(0xA102, false);
new_packet.WriteUInt8(0x02);
new_packet.WriteUInt8(12); // PC LIMIT ERROR
m_LocalSecurity.Send(new_packet);
Send(false);
// Disconnect
this.DisconnectModuleSocket();
return;
}
// Check HWID LIMIT
if (hwid_count(this.hwid) > FilterMain.PCLIMIT)
{
// Send client error
Packet new_packet = new Packet(0xA102, false);
new_packet.WriteUInt8(0x02);
new_packet.WriteUInt8(10); // PC LIMIT ERROR
m_LocalSecurity.Send(new_packet);
Send(false);
// Disconnect
this.DisconnectModuleSocket();
return;
}
// Advanced system? :D
if (FilterMain.STORE_HWID && (FilterMain.DB))
{
try
{
SqlDataReader reader = sqlCon.Return("_HWIDCHECK", new SqlParameter("@StrUserID", Program.Plis(this.user_id)), new SqlParameter("@HWID", this.hwid));
reader.Read();
int value = reader.GetInt32(0);
// SQL result
if (value != 1)
{
// Send client error
Packet new_packet = new Packet(0xA102, false);
new_packet.WriteUInt8(0x02);
new_packet.WriteUInt8(11); // PC LIMIT ERROR
m_LocalSecurity.Send(new_packet);
Send(false);
// Close reader
reader.Close();
// Disconnect
this.DisconnectModuleSocket();
return;
}
}
catch {
// Debug
Console.BackgroundColor = ConsoleColor.Red;
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("SQL error, lel :D");
Console.ResetColor();
// Send client error
Packet new_packet = new Packet(0xA102, false);
new_packet.WriteUInt8(0x02);
new_packet.WriteUInt8(11); // PC LIMIT ERROR
m_LocalSecurity.Send(new_packet);
Send(false);
// Disconnect
this.DisconnectModuleSocket();
return;
}
}
// Avoid disconnects @gateway
try
{
// Add user to dictionary list, simple enough? :D
if (!FilterMain.hwid_user.ContainsKey(this.user_id))
{
FilterMain.hwid_user.Add(this.user_id, this.hwid);
}
else
{
FilterMain.hwid_user.Remove(this.user_id);
FilterMain.hwid_user.Add(this.user_id, this.hwid);
}
}
catch {
// Debug
Console.BackgroundColor = ConsoleColor.Red;
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Dictionary error, lel :D");
Console.ResetColor();
}
}
#endregion
#region ANTI BOT STUFF
// Anti bot stuff, nobody would understand.
if (locale == 51 && (FilterMain.BOT_DETECTION))
{
Packet login = new Packet(0x6102, true);
login.WriteUInt8(22);
login.WriteAscii(this.user_id);
login.WriteAscii(this.user_pw);
login.WriteUInt16(ServerID);
m_RemoteSecurity.Send(login);
Send(true);
continue;
}
#endregion
}
#endregion
#region BlockOPCODES and shit
// BLOCK OPCODES
if (FilterMain.BAD_Opcodes.ContainsKey(Convert.ToUInt16(_pck.Opcode)))
{
// Ban exploiters.
if (FilterMain.EXPLOIT_METHOD == "ban")
{
if (!FilterMain.ban_list.Contains(this.ip))
{
// Add ban
FilterMain.ban_list.Add(this.ip);
try
{
// File exist, write to it.
System.IO.StreamWriter file = new System.IO.StreamWriter("config/blacklist.txt", true);
if (this.ip.Length > 0)
{
file.WriteLine(this.ip + "\n");
}
file.Close();
// Ban log(For checking random bans)
System.IO.StreamWriter banlog = new System.IO.StreamWriter("logs/banlog.txt", true);
banlog.WriteLine("[" + DateTime.UtcNow + "] {" + module_name + "} Banned {" + this.ip + "} Reason: {EXPLOITING}\n");
banlog.Close();
}
catch { }
// Inform?
Console.ForegroundColor = ConsoleColor.DarkMagenta;
Console.WriteLine("[" + DateTime.UtcNow + "][" + module_name + "] IP:{" + this.ip + "} User:{" + this.user_id + "} Opcode:{0x" + _pck.Opcode.ToString("X") + "} Bytes:{" + this.length + "} Packet_c{" + this.packetCount + "}");
Console.ResetColor();
}
}
// Disconnect
this.DisconnectModuleSocket();
return;
}
#endregion
#region Ignore handshake
// Ignore handshake
if (_pck.Opcode == 0x5000 || _pck.Opcode == 0x9000)
{
Send(false);
continue;
}
#endregion
#region Clear logs
// Clear logs
if (m_LastPackets.Count > 100)
{
m_LastPackets.Clear();
}
#endregion
// No clue
Packet CopyOfPacket = _pck;
m_LastPackets.Enqueue(CopyOfPacket);
// Send packets
m_RemoteSecurity.Send(_pck);
Send(true);
}
}
}
لو واخد بالك تحت خالص موجود
كود:
// Send packets
m_RemoteSecurity.Send(_pck);
Send(true);
خليها
كود:
// Send packets
if (_pck.Opcode != 0x9001)
{
m_RemoteSecurity.Send(_pck);
Send(true);
}
طبعا 0x9001 دي hwid سوبرميك .. فحالت الJGuard حتبقي 0x8001
ويراب متعود تجادل و تقول لا علفاضي :D
و بما ان معيش السورس بتاعك فانا مش حعراف اعمل الحل ده علي JGuard.. نزلو انت في ال update الجي
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
انا صحيح مش مبرمج .. بس انا مش غبي .. فيريت نبطل نتعامل مع خلق الله علي انهم اغبيه و نستغل الجهل.. عشان دي بقت عاده فينا احنا كمصريين ..
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------