Jump to content
  • 0

ANTI WPE AND RPE SCRIPT.


justeyngonzales

Question


  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.01
  • Content Count:  72
  • Reputation:   0
  • Joined:  04/30/13
  • Last Seen:  

Is it possible ?

Link to comment
Share on other sites

9 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  815
  • Reputation:   86
  • Joined:  10/26/12
  • Last Seen:  

No. but some src code can

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  1125
  • Reputation:   236
  • Joined:  07/30/12
  • Last Seen:  

Saw this one in eAthena, I do not know if this is compatible with rAthena. I suggest you to use Harmony, but here's the code.

trunk/src/common/socket.c

Index: socket.c
===================================================================
--- socket.c	(revision 13725)
+++ socket.c	(working copy)
@@ -16,6 +16,7 @@
 
 #ifdef WIN32
 	#include <winsock2.h>
+	#include <time.h>
 	#include <io.h>
 #else
 	#include <errno.h>
@@ -112,7 +113,54 @@
 		sock_arr_len = fd+1;
 	return fd;
 }
+ 
+#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
+  #define DELTA_EPOCH_IN_MICROSECS  11644473600000000Ui64
+#else
+  #define DELTA_EPOCH_IN_MICROSECS  11644473600000000ULL
+#endif
 
+struct timezone 
+{
+  int  tz_minuteswest; /* minutes W of Greenwich */
+  int  tz_dsttime;     /* type of dst correction */
+};
+ 
+int gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+  FILETIME ft;
+  unsigned __int64 tmpres = 0;
+  static int tzflag;
+ 
+  if (NULL != tv)
+  {
+    GetSystemTimeAsFileTime(&ft);
+ 
+    tmpres |= ft.dwHighDateTime;
+    tmpres <<= 32;
+    tmpres |= ft.dwLowDateTime;
+ 
+    /*converting file time to unix epoch*/
+    tmpres /= 10;  /*convert into microseconds*/
+    tmpres -= DELTA_EPOCH_IN_MICROSECS; 
+    tv->tv_sec = (long)(tmpres / 1000000UL);
+    tv->tv_usec = (long)(tmpres % 1000000UL);
+  }
+ 
+  if (NULL != tz)
+  {
+    if (!tzflag)
+    {
+      _tzset();
+      tzflag++;
+    }
+    tz->tz_minuteswest = _timezone / 60;
+    tz->tz_dsttime = _daylight;
+  }
+ 
+  return 0;
+}
+
 int sAccept(int fd, struct sockaddr* addr, int* addrlen)
 {
 	SOCKET s;
@@ -196,6 +244,9 @@
 time_t last_tick;
 time_t stall_time = 60;
 
+uint32 max_frequency_warning = 12; //Max number of packets user can have that are within a certain interval of each other before the program kicks
+int diff_tolerance = 7000; //In microseconds
+
 uint32 addr_[16];   // ip addresses of local host (host byte order)
 int naddr_ = 0;   // # of ip addresses
 
@@ -317,9 +368,37 @@
 		set_eof(fd);
 		return 0;
 	}
-
 	session[fd]->rdata_size += len;
 	session[fd]->rdata_tick = last_tick;
+	
+	// Anti-WPE script by Zohan
+    if(!session[fd]->flag.server && (RFIFOW(fd,0) == 0x0438 || RFIFOW(fd,0) == 0x0116))
+    {
+       session[fd]->lastDiff = session[fd]->thisDiff;
+       session[fd]->lastPacket.tv_sec = session[fd]->thisPacket.tv_sec;
+       session[fd]->lastPacket.tv_usec = session[fd]->thisPacket.tv_usec;
+       gettimeofday(&session[fd]->thisPacket, NULL);
+       session[fd]->thisDiff = (((session[fd]->thisPacket.tv_sec - session[fd]->lastPacket.tv_sec) * 1000000) + session[fd]->thisPacket.tv_usec) - session[fd]->lastPacket.tv_usec;
+       if(abs(session[fd]->thisDiff - session[fd]->lastDiff) < diff_tolerance)
+       {
+          session[fd]->warning_number++;
+          if(session[fd]->warning_number > max_frequency_warning)
+          {
+            set_eof(fd);
+          }
+       }
+       else if(session[fd]->thisPacket.tv_sec - session[fd]->lastPacket.tv_sec > 10)
+       {
+            session[fd]->warning_number = 0;
+       }
+       else
+       {
+           if(session[fd]->warning_number > 0)
+           {
+             session[fd]->warning_number--;
+           }
+       }
+    }
 	return 0;
 }

 

trunk/src/common/socket.h

Index: socket.h
===================================================================
--- socket.h	(revision 13725)
+++ socket.h	(working copy)
@@ -83,6 +83,13 @@
 	size_t rdata_pos;
 	time_t rdata_tick; // time of last recv (for detecting timeouts); zero when timeout is disabled
 
+    //Anti-WPE
+    struct timeval thisPacket;
+    struct timeval lastPacket;
+    int thisDiff;
+    int lastDiff;
+    uint32 warning_number; 
+    
 	RecvFunc func_recv;
 	SendFunc func_send;
 	ParseFunc func_parse;
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  145
  • Topics Per Day:  0.03
  • Content Count:  455
  • Reputation:   3
  • Joined:  06/19/12
  • Last Seen:  

I hope we could have something like this from Hercules http://hercules.ws/board/topic/1105-hercules-wpe-free-june-14th-patch/

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  341
  • Reputation:   43
  • Joined:  01/10/12
  • Last Seen:  

-	script	AntiWPEandRPE	-1,{
OnPCLoginEvent:
	dispbottom "Do not use WPE/RPE.";
	end;
}

Sadly, you can't do it with script.

  • Upvote 3
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  



-	script	AntiWPEandRPE	-1,{
OnPCLoginEvent:
	dispbottom "Do not use WPE/RPE.";
	end;
}

Sadly, you can't do it with script.

/heh

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  112
  • Topics Per Day:  0.03
  • Content Count:  388
  • Reputation:   4
  • Joined:  05/01/12
  • Last Seen:  

Posted · Hidden by Capuche, August 31, 2013 - No reason given
Hidden by Capuche, August 31, 2013 - No reason given
-	script	AntiWPEandRPE	-1,{
OnPCLoginEvent:
	dispbottom "Do not use WPE/RPE.";
	end;
}

Sadly, you can't do it with script.

LOL trolling wkkwkw

Link to comment

  • Group:  Members
  • Topic Count:  65
  • Topics Per Day:  0.02
  • Content Count:  181
  • Reputation:   0
  • Joined:  08/07/13
  • Last Seen:  

Posted · Hidden by Capuche, August 31, 2013 - Trolling
Hidden by Capuche, August 31, 2013 - Trolling

use @cleanmap at commands

Link to comment

  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  400
  • Reputation:   5
  • Joined:  12/05/11
  • Last Seen:  

Saw this one in eAthena, I do not know if this is compatible with rAthena. I suggest you to use Harmony, but here's the code.

trunk/src/common/socket.c

Index: socket.c
===================================================================
--- socket.c	(revision 13725)
+++ socket.c	(working copy)
@@ -16,6 +16,7 @@
 
 #ifdef WIN32
 	#include <winsock2.h>
+	#include <time.h>
 	#include <io.h>
 #else
 	#include <errno.h>
@@ -112,7 +113,54 @@
 		sock_arr_len = fd+1;
 	return fd;
 }
+ 
+#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
+  #define DELTA_EPOCH_IN_MICROSECS  11644473600000000Ui64
+#else
+  #define DELTA_EPOCH_IN_MICROSECS  11644473600000000ULL
+#endif
 
+struct timezone 
+{
+  int  tz_minuteswest; /* minutes W of Greenwich */
+  int  tz_dsttime;     /* type of dst correction */
+};
+ 
+int gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+  FILETIME ft;
+  unsigned __int64 tmpres = 0;
+  static int tzflag;
+ 
+  if (NULL != tv)
+  {
+    GetSystemTimeAsFileTime(&ft);
+ 
+    tmpres |= ft.dwHighDateTime;
+    tmpres <<= 32;
+    tmpres |= ft.dwLowDateTime;
+ 
+    /*converting file time to unix epoch*/
+    tmpres /= 10;  /*convert into microseconds*/
+    tmpres -= DELTA_EPOCH_IN_MICROSECS; 
+    tv->tv_sec = (long)(tmpres / 1000000UL);
+    tv->tv_usec = (long)(tmpres % 1000000UL);
+  }
+ 
+  if (NULL != tz)
+  {
+    if (!tzflag)
+    {
+      _tzset();
+      tzflag++;
+    }
+    tz->tz_minuteswest = _timezone / 60;
+    tz->tz_dsttime = _daylight;
+  }
+ 
+  return 0;
+}
+
 int sAccept(int fd, struct sockaddr* addr, int* addrlen)
 {
 	SOCKET s;
@@ -196,6 +244,9 @@
 time_t last_tick;
 time_t stall_time = 60;
 
+uint32 max_frequency_warning = 12; //Max number of packets user can have that are within a certain interval of each other before the program kicks
+int diff_tolerance = 7000; //In microseconds
+
 uint32 addr_[16];   // ip addresses of local host (host byte order)
 int naddr_ = 0;   // # of ip addresses
 
@@ -317,9 +368,37 @@
 		set_eof(fd);
 		return 0;
 	}
-
 	session[fd]->rdata_size += len;
 	session[fd]->rdata_tick = last_tick;
+	
+	// Anti-WPE script by Zohan
+    if(!session[fd]->flag.server && (RFIFOW(fd,0) == 0x0438 || RFIFOW(fd,0) == 0x0116))
+    {
+       session[fd]->lastDiff = session[fd]->thisDiff;
+       session[fd]->lastPacket.tv_sec = session[fd]->thisPacket.tv_sec;
+       session[fd]->lastPacket.tv_usec = session[fd]->thisPacket.tv_usec;
+       gettimeofday(&session[fd]->thisPacket, NULL);
+       session[fd]->thisDiff = (((session[fd]->thisPacket.tv_sec - session[fd]->lastPacket.tv_sec) * 1000000) + session[fd]->thisPacket.tv_usec) - session[fd]->lastPacket.tv_usec;
+       if(abs(session[fd]->thisDiff - session[fd]->lastDiff) < diff_tolerance)
+       {
+          session[fd]->warning_number++;
+          if(session[fd]->warning_number > max_frequency_warning)
+          {
+            set_eof(fd);
+          }
+       }
+       else if(session[fd]->thisPacket.tv_sec - session[fd]->lastPacket.tv_sec > 10)
+       {
+            session[fd]->warning_number = 0;
+       }
+       else
+       {
+           if(session[fd]->warning_number > 0)
+           {
+             session[fd]->warning_number--;
+           }
+       }
+    }
 	return 0;
 }

 

trunk/src/common/socket.h

Index: socket.h
===================================================================
--- socket.h	(revision 13725)
+++ socket.h	(working copy)
@@ -83,6 +83,13 @@
 	size_t rdata_pos;
 	time_t rdata_tick; // time of last recv (for detecting timeouts); zero when timeout is disabled
 
+    //Anti-WPE
+    struct timeval thisPacket;
+    struct timeval lastPacket;
+    int thisDiff;
+    int lastDiff;
+    uint32 warning_number; 
+    
 	RecvFunc func_recv;
 	SendFunc func_send;
 	ParseFunc func_parse;

 

Anyone had tried this at rAthena?

 

-	script	AntiWPEandRPE	-1,{
OnPCLoginEvent:
	dispbottom "Do not use WPE/RPE.";
	end;
}

Sadly, you can't do it with script.

 

Haha. Very sad! /wah

 

 

 

                    Posted 30 August 2013 - 05:59 PM

                              

 I hope we could have something like this from Hercules http://hercules.ws/b...une-14th-patch/

 

 

Posted 15 June 2013 - 05:33 PM

either request at rAthena to convert it, or change to using Hercules

 

Hercules devs will not create this for rAthena o_O

 

Dem~

Edited by uDe
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  308
  • Reputation:   24
  • Joined:  11/26/12
  • Last Seen:  

i will try this "Anakid" ^_^

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...