-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchack.cpp
173 lines (126 loc) · 4.39 KB
/
chack.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
//Made By BioShot\\
#include <iostream>
#include <stdio.h>
#include <windows.h>
#include <fstream>
#include <conio.h>
#include <io.h>
#include <string>
#define _CRT_SECURE_NO_WARNINGS
#define cft int (char a){return sizeof(a) / sizeof(*a)}
using namespace std;
string convertBFToString(char* a, int size)
{
int i;
string s = "";
for (i = 0; i < size; i++) {
s = s + a[i];
}
return s;
}
BOOL isRunning(LPCWSTR pName) {
HWND hwnd;
hwnd = FindWindow(NULL, pName);
if (hwnd != 0) {
return true;
}
else {
return false;
}
}
INT main()
{
HANDLE hProcess;
HANDLE hThread;
STARTUPINFO si;
PROCESS_INFORMATION pi;
DWORD dwProcessId = 0;
DWORD dwThreadId = 0;
//Clear the values because i want to...\\
ZeroMemory( &si, sizeof(si) );
ZeroMemory(&pi, sizeof(pi));
BOOL bCreateProcess = NULL;
BOOL hadToMakeProcess = false;
BOOL bNpProcess = isRunning(L"notepad.exe");
if (bNpProcess != 0) {
//Create the process
hadToMakeProcess = true;
printf("(-) Atempting to run process notpad.exe with low prioity...\n");
bCreateProcess = CreateProcess(
L"C:\\Windows\\System32\\notepad.exe",
NULL,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi
);
}
else {
if (!bCreateProcess && hadToMakeProcess == true) {
printf("(-) Error creating the process! %ld",GetLastError());
}else{
ofstream ofstream_ob("notepad.exe.log",ios::out);
ofstream_ob << "Created Process Notepad.exe. Process Info: "<<endl;
ofstream_ob << "Process ID -> " << pi.dwProcessId << endl;
ofstream_ob << "Thread ID -> " << pi.dwThreadId << endl;
ofstream_ob << "GetProcessID -> " << GetProcessId(pi.hProcess) << endl;
ofstream_ob << "GetThreadID -> " << GetThreadId(pi.hThread) << endl;
cout << "(-) Created Process Notepad.exe. Process Info: " << endl;
cout << "(-) Process ID -> " << pi.dwProcessId << endl;
cout << "(-) Thread ID -> " << pi.dwThreadId << endl;
cout << "(-) GetProcessId _> " << GetProcessId(pi.hProcess) << endl;
cout << "(-) GetThreadID -> " << GetThreadId(pi.hThread) << endl;
for (;; ) {
int count = 0;
//Loop through the window parsing...\\
system("cls");
HWND hnd;
HWND edithnd;
CHAR* buf;
CHAR* checkStr;
hnd = FindWindow(L"Notepad", 0);
if (hnd == NULL)
printf("Handle not found");
edithnd = FindWindowEx(hnd, 0, L"Edit", 0);
buf = (char*)calloc(200, 1024);
//printf("%d", sizeof(buf));
SendMessage(edithnd, WM_GETTEXT, 10000, (LPARAM)buf);
checkStr = (char*)"chack::exit()";
if (buf == checkStr) {
exit(EXIT_SUCCESS);
}
else {
cout << "(-) [" << count << "]: Parsing input: " << buf << endl;
const size_t length = sizeof(buf) / sizeof(*buf);
ofstream_ob << "(-) [" << count << "]: Parsing input: ";
//cout << length;
char bufferA[length + 1];
char* buffer;
string sBuffer;
for (int i = 0; i <= length; i++) {
if (i == length) {
ofstream_ob << buf[i] << endl;
}
else {
ofstream_ob << buf[i];
}
//cout << bufferA[i];
}
count++;
// cout << buffer;
//ofstream_ob << "(-) Readss " << sBuffer << " on read-count " << count << endl;
// wprintf(L"%s", buf);
}
Sleep(500);
}
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hThread);
ofstream_ob.close();
}
}
return EXIT_SUCCESS;
}